* [PATCH] Fix migration of real mode guests from host with unrestricted guest to a host without it.
@ 2012-05-31 11:13 Orit Wasserman
2012-05-31 11:23 ` Avi Kivity
0 siblings, 1 reply; 2+ messages in thread
From: Orit Wasserman @ 2012-05-31 11:13 UTC (permalink / raw)
To: kvm; +Cc: avi, gleb, Orit Wasserman, Orit Wasserman
For example migration between Westmere and Nehelem hosts.
The patch fixes the guest segments similar to enter_rmode function.
Signed-off-by: Orit Wasserman <owasserm@rehdat.com>
---
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, 0xffff);
+ if (vmcs_readl(GUEST_CS_BASE) == 0xffff0000)
+ vmcs_writel(GUEST_CS_BASE, 0xf0000);
+ 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, 0xffff);
+ 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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix migration of real mode guests from host with unrestricted guest to a host without it.
2012-05-31 11:13 [PATCH] Fix migration of real mode guests from host with unrestricted guest to a host without it Orit Wasserman
@ 2012-05-31 11:23 ` Avi Kivity
0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2012-05-31 11:23 UTC (permalink / raw)
To: Orit Wasserman; +Cc: kvm, gleb, Orit Wasserman
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 <owasserm@rehdat.com>
> ---
> 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, 0xffff);
> + if (vmcs_readl(GUEST_CS_BASE) == 0xffff0000)
> + vmcs_writel(GUEST_CS_BASE, 0xf0000);
> + 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, 0xffff);
> + 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-05-31 12:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-31 11:13 [PATCH] Fix migration of real mode guests from host with unrestricted guest to a host without it Orit Wasserman
2012-05-31 11:23 ` Avi Kivity
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox