Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752614AbdHPWH7 (ORCPT ); Wed, 16 Aug 2017 18:07:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53112 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752262AbdHPWH5 (ORCPT ); Wed, 16 Aug 2017 18:07:57 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1347BC058EBE Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pbonzini@redhat.com Date: Wed, 16 Aug 2017 18:07:56 -0400 (EDT) From: Paolo Bonzini To: Janakarajan Natarajan Cc: Radim Krcmar , kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel , Andy Lutomirski , Tony Luck , Borislav Petkov , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Yazen Ghannam Message-ID: <751264091.1124859.1502921276661.JavaMail.zimbra@redhat.com> In-Reply-To: <968101a9-a5de-7090-2ea5-b61b24f21e83@amd.com> References: <34f2f25e05496f4212c622ecce999dabb0bd2357.1502896608.git.Janakarajan.Natarajan@amd.com> <20170816195312.GB32542@flask> <968101a9-a5de-7090-2ea5-b61b24f21e83@amd.com> Subject: Re: [PATCH 2/2] KVM: SVM: Enable Virtual GIF feature MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [94.39.192.75, 10.4.196.3, 10.4.195.16] Thread-Topic: Enable Virtual GIF feature Thread-Index: PTM2do8VUqjxAjgLJV9QRLEfGoyUtg== X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 16 Aug 2017 22:07:57 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2527 Lines: 54 ----- Original Message ----- > From: "Janakarajan Natarajan" > To: "Radim Krcmar" > Cc: kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, "Paolo Bonzini" , "Joerg > Roedel" , "Andy Lutomirski" , "Tony Luck" , "Borislav Petkov" > , "Thomas Gleixner" , "Ingo Molnar" , "H . Peter Anvin" > , "Yazen Ghannam" > Sent: Thursday, August 17, 2017 12:04:10 AM > Subject: Re: [PATCH 2/2] KVM: SVM: Enable Virtual GIF feature > > On 8/16/2017 2:53 PM, Radim Krcmar wrote: > > 2017-08-16 10:54-0500, Janakarajan Natarajan: > >> Enable the Virtual GIF feature. This is done by setting bit 25 at position > >> 60h in the vmcb. > >> > >> With this feature enabled, the processor uses bit 9 at position 60h as the > >> virtual GIF when executing STGI/CLGI instructions. > >> > >> Since the execution of STGI by the L1 hypervisor does not cause a return > >> to > >> the outermost (L0) hypervisor, the enable_irq_window and enable_nmi_window > >> are modified. > >> > >> The IRQ and NMI windows will be opened even if GIF is not set, under the > >> assumption that on resuming the L1 hypervisor the IRQ and NMI will be > >> held pending until the processor executes the STGI instruction. > >> > >> Signed-off-by: Janakarajan Natarajan > >> --- > >> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > >> @@ -4702,8 +4735,8 @@ static void enable_nmi_window(struct kvm_vcpu *vcpu) > >> == HF_NMI_MASK) > >> return; /* IRET will cause a vm exit */ > >> > >> - if ((svm->vcpu.arch.hflags & HF_GIF_MASK) == 0) > >> - return; /* STGI will cause a vm exit */ > >> + if (!vgif_enabled(svm) && !gif_set(svm)) > >> + return; /* STGI will cause a vm exit or HW will set VGIF*/ > > Why don't we enable STGI interception to get notified that the window > > has opened? (I doubt that single stepping would be faster ...) > > It would defeat the purpose of having vGIF - execute STGI/CLGI and not > have a world-switch. Plus it would be like implementing the vGIF feature > halfway, allowing only CLGI to take advantage of the hardware. No, only enable the STGI intercept to enable the NMI window. Normally you'd still run with free STGI. This is because if you do not return here, you enter singlestepping mode where each instruction causes a world switch. Paolo