From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: [PATCHv2] KVM: when entering real mode align segment base to 16 bytes Date: Mon, 27 Dec 2010 17:25:04 +0200 Message-ID: <20101227152504.GP2231@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: avi@redhat.com, mtosatti@redhat.com Return-path: Received: from mx1.redhat.com ([209.132.183.28]:46561 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754056Ab0L0PZH (ORCPT ); Mon, 27 Dec 2010 10:25:07 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oBRFP6Bg031110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 27 Dec 2010 10:25:06 -0500 Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: VMX checks that base is equal segment shifted 4 bites left. Otherwise guest entry fails. Signed-off-by: Gleb Natapov --- 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.