From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751136AbcGNMYU (ORCPT ); Thu, 14 Jul 2016 08:24:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57311 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750966AbcGNMYR (ORCPT ); Thu, 14 Jul 2016 08:24:17 -0400 Date: Thu, 14 Jul 2016 14:24:13 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [RFC PATCH 3/4] KVM: x86: add support for emulating UMIP 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 14 Jul 2016 12:24:16 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2016-07-14 09:00+0200, Paolo Bonzini: > On 13/07/2016 22:03, Radim Krčmář 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) >>> >>> static int em_smsw(struct x86_emulate_ctxt *ctxt) >>> { >>> + if ((ctxt->ops->get_cr(ctxt, 4) & X86_CR4_UMIP) && >>> + ctxt->ops->cpl(ctxt) > 0) >> >> UMIP should #GP(0) in virtual-8086 mode too (for SMSW, SIDT, and SGDT), >> but cpl() returns 0 in vm86. > > No, it returns 3. > > 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=3 for all segments, and CPL=SS.DPL. Right, thanks.