From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH RESEND] KVM: when entering real mode align segment base to 16 bytes Date: Mon, 27 Dec 2010 16:37:27 +0200 Message-ID: <20101227143727.GN2231@redhat.com> References: <20101227130110.GK2231@redhat.com> <4D18A101.90407@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: mtosatti@redhat.com, kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:2648 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753772Ab0L0Oh3 (ORCPT ); Mon, 27 Dec 2010 09:37:29 -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 oBREbSML013789 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 27 Dec 2010 09:37:29 -0500 Content-Disposition: inline In-Reply-To: <4D18A101.90407@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Dec 27, 2010 at 04:21:53PM +0200, Avi Kivity wrote: > On 12/27/2010 03:01 PM, Gleb Natapov wrote: > >VMX checks that base is equal segment shifted 4 bites left. Otherwise > >guest entry fails. > > > >Signed-off-by: Gleb Natapov > >-- > >Same as previous one but with correct (I hope) To: header. > > > >diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > >index 2260783..45014ba 100644 > >--- a/arch/x86/kvm/vmx.c > >+++ b/arch/x86/kvm/vmx.c > >@@ -1736,7 +1736,7 @@ 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); > > } > > This looks okay, but I'm curious what happened here. If the guest > will use the segment it will fail on an incorrect address. > Not much we can do about it. Either do what patch does, or exit to userspace with more meaningful message then: kvm: unhandled exit 80000021 kvm_run returned -22 > What's the scenario here? And what segment is involved? if it's fs > or gs, or maybe ss, I can see it working out, but hardly otherwise. > The scenario is older Seabios that lefts DS segment unaligned during switch to real mode in int1587 function (copy extended memory). -- Gleb.