public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2] KVM: when entering real mode align segment base to 16 bytes
@ 2010-12-27 15:25 Gleb Natapov
  2010-12-27 15:30 ` Avi Kivity
  0 siblings, 1 reply; 2+ messages in thread
From: Gleb Natapov @ 2010-12-27 15:25 UTC (permalink / raw)
  To: avi, mtosatti; +Cc: kvm

VMX checks that base is equal segment shifted 4 bites left. Otherwise
guest entry fails.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---

v1->v2
 add printk_once.

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 2260783..e1eecf0 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1736,9 +1736,11 @@ static void fix_rmode_seg(int seg, struct kvm_save_segment *save)
 	save->limit = vmcs_read32(sf->limit);
 	save->ar = vmcs_read32(sf->ar_bytes);
 	vmcs_write16(sf->selector, save->base >> 4);
-	vmcs_write32(sf->base, save->base & 0xfffff);
+	vmcs_write32(sf->base, save->base & 0xffff0);
 	vmcs_write32(sf->limit, 0xffff);
 	vmcs_write32(sf->ar_bytes, 0xf3);
+	if (save->base & 0xf)
+		printk_once(KERN_WARNING"kvm: segment base is not 16 bit aligned when entering protected mode (seg=%d)", seg);
 }
 
 static void enter_rmode(struct kvm_vcpu *vcpu)
--
			Gleb.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-12-27 15:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-27 15:25 [PATCHv2] KVM: when entering real mode align segment base to 16 bytes Gleb Natapov
2010-12-27 15:30 ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox