Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752529AbdHPWEY (ORCPT ); Wed, 16 Aug 2017 18:04:24 -0400 Received: from mail-cys01nam02on0077.outbound.protection.outlook.com ([104.47.37.77]:5504 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752262AbdHPWEW (ORCPT ); Wed, 16 Aug 2017 18:04:22 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Janakarajan.Natarajan@amd.com; Subject: Re: [PATCH 2/2] KVM: SVM: Enable Virtual GIF feature To: Radim Krcmar References: <34f2f25e05496f4212c622ecce999dabb0bd2357.1502896608.git.Janakarajan.Natarajan@amd.com> <20170816195312.GB32542@flask> 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" , "Ghannam, Yazen" From: "Natarajan, Janakarajan" Message-ID: <968101a9-a5de-7090-2ea5-b61b24f21e83@amd.com> Date: Wed, 16 Aug 2017 17:04:10 -0500 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170816195312.GB32542@flask> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: MWHPR2001CA0015.namprd20.prod.outlook.com (10.172.58.153) To BN6PR12MB1665.namprd12.prod.outlook.com (10.172.19.16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0bdf98ec-c950-4dee-f691-08d4e4f2bdec X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BN6PR12MB1665; X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1665;3:XeAKsoK4sv427v2AwjE0FqJue3QXD+uKJkgORoNuEz4UVrP0E/gOENOJnTypKjnFHOR5RDeGL2xTGv7km5HrEXb3c+1rSG1+aIjrHCI8khndK1U4pcnWl08m8dc7zb9ecBVY0fHc6HPKYWeEQTPmUQRmn34HyLcWOL4LCjhAdOKJvnLKgYADJYNJFdV1Hyy5+d9tEB7Xkxx4ccncRfDkOYVD2oItgyKu4StQo63ULxB/2Qilt1srzI/noeHLLMXe;25:i/oj5m/dlwnziSbBB7pFmc0fNO46ECHlw+WiQvPcTzPbk4YmxUIifz5p7BwVZx49kVK0xF1nyrVNtEX6HKKRfh0tUOHJOp2l2J2Rx58hW9jqyK16Lp9HAhKRbuRh3MhgQnAChkpaIJ0P3KYmoQM4o47RYzoJh79809Szx4Z1XLVrDFvJvDdZO7vojNWMkNDU16q6+bMPn7BFt5ERMURSy05LRkUnLuQ4oXbYsSAw4lzEjyEd9ZO62P0Xk7fIS/qwr0DHxKhPMpbxAjLulXZZVUvdmE5Eq4CcqNsz8tV4+370JYp6E0OcdMlgi0PnLvAQjndlHqH4X3thAnN5WY7VRg==;31:sKt6Gx3yujSKkVT/8qoeeu3nvLuJxRdZPC7j/hm1mebbZ9qTWU9dw8GM2FVNE97ItnY6wLmXZkZZ2e3ksL/m8D1OT7qX0VeM9FRLdQGkuxjDQGkMi8kF643UjL659LpH+c2dgmN7Wh0KCSw4iY/PyOvHyEg9g4PzkyZyF6Ut5cn8s/IZ0a0tj8w91hX/+kULcssQqJx0eNzG12RaUCivzS8FapzvSJ0it7DXXM3PX+A= X-MS-TrafficTypeDiagnostic: BN6PR12MB1665: X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1665;20:CvwBM1OlkxFF/1ObGybJHklqdHMRFgFlyP6GBFe9nzIPJliSsTyzYTqj85q/LFjcqthPCaEs5zj3P2YFGyCmAfsgP69dd+YjGRTnDuHflT2WJGY1mo4cXo8NAjzwU7GG/3ySPOaRpm67dAz3MAT9oaToo9+K4Zb2Q6YUhOGuOJtgtqwGe7MIBsvw58WY3OEf0prG8Hyz5JYnvWPDlUIFMheW8xZ8/J0Ne947D/uY1bW87aWrNPCf1yaRWmQ5O4CThaBeGRez83BfSIplFZqL818gcMVxNNphocP9zFb6D/4fvafSOLkKPmVgAOVYFnAvTAT4KW3OqAa3yFmt1Moer6eB93WzloR6ZUiD7vePaIcxLb9rrl4L10RwulSCa3DLEuRbfl+152zF8JamfW2pySEWEwfIIPuiOQ6UKjnKxr1ecO2poIYFgovM+/KDpRRBqQzJtFrTmhlXPo+MAfBvWbAWZ3WN4rjlnO976AieblbMzOaULPuBiX4AZEp0gRTh;4:bt7S1zFvhxITnTekLhuzY9XaQ577Tpbi9mg+Uz1I7g3pbG2qiwfsDxLp/LlnPcus3sdzluIeYInAiX4RTXIO9THw+Vh2GZPgU5TYew5aeD9TA0Ch0/m0pkEe6GevlxNQOeLntXaxyyJyiMRcKOCSARAYcbjEtYFpSamW8oXkImsWbSoPhkjKA2spzEdOGlN8ju3ULUIOL+mR/Kimw1oLyhVPyAfJWqC1d8aeulGzvG59WAGUZuHvoERoMUQuEH5eR/cdbGuArd6ATzorfSei+PXlGtPf4/VjgGTLcrz1zlY= X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6055026)(6041248)(20161123562025)(20161123558100)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BN6PR12MB1665;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BN6PR12MB1665; X-Forefront-PRVS: 0401647B7F X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(7370300001)(4630300001)(6049001)(6009001)(377454003)(377424004)(189002)(199003)(24454002)(31696002)(2906002)(7350300001)(66066001)(101416001)(65806001)(65956001)(4326008)(25786009)(86362001)(54906002)(50986999)(76176999)(54356999)(47776003)(229853002)(2950100002)(7416002)(6916009)(36756003)(64126003)(4001350100001)(23746002)(42186005)(6666003)(6486002)(77096006)(33646002)(189998001)(90366009)(106356001)(50466002)(110136004)(72206003)(83506001)(105586002)(97736004)(6246003)(68736007)(7736002)(6116002)(5660300001)(81156014)(81166006)(53546010)(8676002)(31686004)(3846002)(65826007)(305945005)(230700001)(53936002)(478600001);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR12MB1665;H:[10.236.68.193];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;BN6PR12MB1665;23:d17l9X1VtpAr4cAznZ/XCcxIRg5oAl086F+2P?= =?Windows-1252?Q?3FT09PySsjd4U7D7J0qqnPfuMkstnn2EtQTufUmRw72PfiUX7w4E1cOw?= =?Windows-1252?Q?WPS5Is6kJaiKaaKxWs3CuKvn0rWiHQgOwwDQr9S8XX6SmcJEcZ8+EtHm?= =?Windows-1252?Q?YiCa+qpdlWPg2gjc7LEX3Nvnb2EHayy1ZQPmbkYGjm4cjoJyI/NQxJ5+?= =?Windows-1252?Q?LXykyfmepUPe7G0LpK6twUG+p3OufEiX67+1eRteabJIz2dxWnhPUSyU?= =?Windows-1252?Q?n4+sy4laWg1HDA7XOhEV7OXRDJWXbeO3MAgRyMs3J4aS8IsadKAbVT/D?= =?Windows-1252?Q?Pxo2Ls1jwOw1hC1vo1/ZVfCiRuAFKMnxi5Q+OUTUHN+3xvDgFQ3yk3Pu?= =?Windows-1252?Q?2m5gmamNfPZh3Pdx6M3tp65eGK+p7lxGtZ4TlvydRDOsT3OdhkbtwDB8?= =?Windows-1252?Q?xPhpmCaPlVJn8FMO/Jd+JM3tSixmX84fwjrVM1BVVqMkxmqpV7MgIUj6?= =?Windows-1252?Q?PBDmwaYODdcUx+fR4/cRYEvJm3wMjN7pDgEIknYOoVmmpTTSSlmu/6nm?= =?Windows-1252?Q?f5V9N3+C4YIju3yOYNgipEH0Z87Hl5Xbr3xuNCUEfWJb9rA4vPHjCbwu?= =?Windows-1252?Q?nsYcD7xv32Fnp4Yf2Ez3EEe2Ofa28eSmqe3WdDlSHynWBPAyVsuStJHg?= =?Windows-1252?Q?BmNZBakyaHGohqp/VoSavX0/0FhlSETVSFM+kiU9Tj/ObXCiQw/72Dgy?= =?Windows-1252?Q?WdHO1lBG8rH/wvB0SNX9vau8gMdHjlBy1htqQwJV96hGsCGW/pc4Ey5j?= =?Windows-1252?Q?lCEfvx716rQsq43sUzle3ICuYiFofrjyi4pnpBemYzsgr3PhskD9GGnA?= =?Windows-1252?Q?jxJDFNhlAm2NAwevc/6AkPPw1mvLd5Pbx6dAjZETJofQqjAl0/C9rtOi?= =?Windows-1252?Q?TnFaOd3vIMXnmDQHQHDvAqiYNZoEtXgrHUSMfow+v1ZXLaBii6w9S/qe?= =?Windows-1252?Q?/qS2aZ29FrtfykjnszF+LPoAOcU+id9DpzoIDFjJhOkoF54/spxryINZ?= =?Windows-1252?Q?qSR43RB3Eh/4coioaE5s5XHAeLIrJFcTpcV5npUi6bqo/cozmSSoUjwU?= =?Windows-1252?Q?y2Y/t/FgI4LvGzvHRMD1DptNO1/zK1SiGZt/1kYo7yoaXKcBu2qyOg+S?= =?Windows-1252?Q?KaYPAO2mk6+AUH0UuESMI9h5t+1ofQ53hxleRQQuideNGYP9jEZUHMzz?= =?Windows-1252?Q?EUxwoCr0P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cyJdgKhPXuTuRVDfopy5Iyi8ziZ1vvzDKOXNv2dX2wnhUKnwtuAZgZdX50LbEmRKs9xLvCJxVJPnap6o/1SEiNseNs6gVqJ6wDGbEFgIU8FP781iIuLQytDWOFnmlAnfU+Shbm1JXHQicmYdBi2AZ8ZwudEfuB0DEaFocSYzJOZxkMRRmizxYFfzql/W4I= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1665;20:rBrn2vrYVtbC0Bijb94whq9DNCo5YXfGFdfzEsTZHMg2YXHPUD734VA6p3BbitM5m/inJQRQKlAlxiqAZnwvfaT62vKxOKPavUf1xze0WQMIOS5mrBDSHwJ5n8pa4JVzQUEOntOejPTIRMwsWwLfPCtenx1j34oFzWmCFpbPuqmAWlIgWNlCbuUiDV0Pbea5o97NiuSMFuHMwe8TmjFYZkp1TZK56LgB+p+YJto9rzzJmoOaaaaLwTc5wzO8xO4C X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2017 22:04:16.3776 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1665 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1585 Lines: 38 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. > > Thanks.