From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [RFC PATCH 3/4] KVM: x86: add support for emulating UMIP Date: Thu, 14 Jul 2016 14:24:13 +0200 Message-ID: <20160714122413.GG21976@potion> References: <1468351223-3250-1-git-send-email-pbonzini@redhat.com> <1468351223-3250-4-git-send-email-pbonzini@redhat.com> <20160713200321.GA16130@potion> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org To: Paolo Bonzini Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org 2016-07-14 09:00+0200, Paolo Bonzini: > On 13/07/2016 22:03, Radim Kr=C4=8Dm=C3=A1=C5=99 wrote: >> 2016-07-12 21:20+0200, Paolo Bonzini: >>> Signed-off-by: Paolo Bonzini >>> --- >>> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c >>> @@ -3738,6 +3747,10 @@ static int em_lidt(struct x86_emulate_ctxt *= ctxt) >>> =20 >>> static int em_smsw(struct x86_emulate_ctxt *ctxt) >>> { >>> + if ((ctxt->ops->get_cr(ctxt, 4) & X86_CR4_UMIP) && >>> + ctxt->ops->cpl(ctxt) > 0) >>=20 >> UMIP should #GP(0) in virtual-8086 mode too (for SMSW, SIDT, and SGD= T), >> but cpl() returns 0 in vm86. >=20 > No, it returns 3. >=20 > vmx->rmode.vm86_active means "there is no unrestricted guest support, > and we're using VM86 mode to emulate real mode". The special case in > vmx_get_cpl is needed exactly because real mode CPL is 0 but VM86 has > CPL 3. In fact fix_rmode_seg sets DPL=3D3 for all segments, and CPL=3D= SS.DPL. Right, thanks.