Re: [PATCH] Fix migration of real mode guests from host with unrestricted guest to a host without it.
On 05/31/2012 02:13 PM, Orit Wasserman wrote: > For example migration between Westmere and Nehelem hosts. > The patch fixes the guest segments similar to enter_rmode function. > > Signed-off-by: Orit Wasserman > --- > arch/x86/kvm/vmx.c | 38 ++ > 1 files changed, 38 insertions(+), 0 deletions(-) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 32eb588..2eca18f 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -3229,6 +3229,44 @@ static void vmx_set_segment(struct kvm_vcpu *vcpu, > > vmcs_write32(sf->ar_bytes, ar); > __clear_bit(VCPU_EXREG_CPL, (ulong *)&vcpu->arch.regs_avail); > + > + /* > + * Fix segments for real mode guest in hosts that don't have > + * "unrestricted_mode" or it was disabled. > + * This is done to allow migration of the guests from hosts with > + * unrestricted guest like Westmere to older host that don't have > + * unrestricted guest like Nehelem. > + */ > + if (!enable_unrestricted_guest && vmx->rmode.vm86_active) { > + switch (seg) { > + case VCPU_SREG_CS: > + vmcs_write32(GUEST_CS_AR_BYTES, 0xf3); > + vmcs_write32(GUEST_CS_LIMIT, 0x); > + if (vmcs_readl(GUEST_CS_BASE) == 0x) > + vmcs_writel(GUEST_CS_BASE, 0xf); > + vmcs_write16(GUEST_CS_SELECTOR, > + vmcs_readl(GUEST_CS_BASE) >> 4); > + break; > + case VCPU_SREG_ES: > + fix_rmode_seg(VCPU_SREG_ES, &vmx->rmode.es); > + break; > + case VCPU_SREG_DS: > + fix_rmode_seg(VCPU_SREG_DS, &vmx->rmode.ds); > + break; > + case VCPU_SREG_GS: > + fix_rmode_seg(VCPU_SREG_GS, &vmx->rmode.gs); > + break; > + case VCPU_SREG_FS: > + fix_rmode_seg(VCPU_SREG_FS, &vmx->rmode.fs); > + break; > + case VCPU_SREG_SS: > + vmcs_write16(GUEST_SS_SELECTOR, > + vmcs_readl(GUEST_SS_BASE) >> 4); > + vmcs_write32(GUEST_SS_LIMIT, 0x); > + vmcs_write32(GUEST_SS_AR_BYTES, 0xf3); > + break; > + } > + } > } > This duplicates the code in enter_rmode(). Please change enter_rmode() to vmx_set_segment(vmx_get_segment()) to avoid duplication. -- error compiling committee.c: too many arguments to function -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Fix migration of real mode guests from host with unrestricted guest to a host without it.
For example migration between Westmere and Nehelem hosts. The patch fixes the guest segments similar to enter_rmode function. Signed-off-by: Orit Wasserman --- arch/x86/kvm/vmx.c | 38 ++ 1 files changed, 38 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 32eb588..2eca18f 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3229,6 +3229,44 @@ static void vmx_set_segment(struct kvm_vcpu *vcpu, vmcs_write32(sf->ar_bytes, ar); __clear_bit(VCPU_EXREG_CPL, (ulong *)&vcpu->arch.regs_avail); + + /* +* Fix segments for real mode guest in hosts that don't have +* "unrestricted_mode" or it was disabled. +* This is done to allow migration of the guests from hosts with +* unrestricted guest like Westmere to older host that don't have +* unrestricted guest like Nehelem. +*/ + if (!enable_unrestricted_guest && vmx->rmode.vm86_active) { + switch (seg) { + case VCPU_SREG_CS: + vmcs_write32(GUEST_CS_AR_BYTES, 0xf3); + vmcs_write32(GUEST_CS_LIMIT, 0x); + if (vmcs_readl(GUEST_CS_BASE) == 0x) + vmcs_writel(GUEST_CS_BASE, 0xf); + vmcs_write16(GUEST_CS_SELECTOR, +vmcs_readl(GUEST_CS_BASE) >> 4); + break; + case VCPU_SREG_ES: + fix_rmode_seg(VCPU_SREG_ES, &vmx->rmode.es); + break; + case VCPU_SREG_DS: + fix_rmode_seg(VCPU_SREG_DS, &vmx->rmode.ds); + break; + case VCPU_SREG_GS: + fix_rmode_seg(VCPU_SREG_GS, &vmx->rmode.gs); + break; + case VCPU_SREG_FS: + fix_rmode_seg(VCPU_SREG_FS, &vmx->rmode.fs); + break; + case VCPU_SREG_SS: + vmcs_write16(GUEST_SS_SELECTOR, +vmcs_readl(GUEST_SS_BASE) >> 4); + vmcs_write32(GUEST_SS_LIMIT, 0x); + vmcs_write32(GUEST_SS_AR_BYTES, 0xf3); + break; + } + } } static void vmx_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l) -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html