From patchwork Thu Nov 16 15:32:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Woods, Brian" X-Patchwork-Id: 10061405 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DE1FE601AE for ; Thu, 16 Nov 2017 15:35:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE9D52A6C6 for ; Thu, 16 Nov 2017 15:35:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C31EF2A74B; Thu, 16 Nov 2017 15:35:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 29BEC2A6C6 for ; Thu, 16 Nov 2017 15:35:05 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFM9r-00024f-CQ; Thu, 16 Nov 2017 15:32:51 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFM9p-00024F-SR for xen-devel@lists.xen.org; Thu, 16 Nov 2017 15:32:49 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id F2/49-09576-1AFAD0A5; Thu, 16 Nov 2017 15:32:49 +0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-Ref: server-15.tower-21.messagelabs.com!1510846367!82164877!1 X-Originating-IP: [104.47.38.82] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 11478 invoked from network); 16 Nov 2017 15:32:48 -0000 Received: from mail-bl2nam02on0082.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) (104.47.38.82) by server-15.tower-21.messagelabs.com with AES256-SHA256 encrypted SMTP; 16 Nov 2017 15:32:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=f8/s9JJQln6rlJcy/yt4KcUwSrGc0a/aQsAzYnPAjoI=; b=4iKmcbgewpD3t0rntyyim7EvIC1IOZe46ZgmzuXhc7luKhStg8rMY1K1YObRZK2YTUSEjYb6UFSPYk0DvSzwNYPFS9DzLrnxkYxZ6w7e+QokDolaSHJZZC7ISHFXICN7fnG6w3iBRazefgAZoRbOo+DplqfzB1Rp9FglbCj7xt8= Received: from nikka.amd.com (165.204.78.1) by MWHPR12MB1839.namprd12.prod.outlook.com (10.175.55.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.239.5; Thu, 16 Nov 2017 15:32:45 +0000 From: Brian Woods To: xen-devel@lists.xen.org Date: Thu, 16 Nov 2017 09:32:03 -0600 Message-Id: <20171116153203.71358-3-brian.woods@amd.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171116153203.71358-1-brian.woods@amd.com> References: <20171116153203.71358-1-brian.woods@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: MWHPR08CA0056.namprd08.prod.outlook.com (10.173.236.30) To MWHPR12MB1839.namprd12.prod.outlook.com (10.175.55.150) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e2c10694-d7b2-4d17-3b8f-08d52d074974 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603199); SRVR:MWHPR12MB1839; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1839; 3:vNay+DqFZERYNCzh4W24nFshRBo9i1lOOVEGZ/Uc/crqyxPdpG1yssCSdDjbjxrpOHMPARqd+a0L+3ksRO14RJSZpSlG7qNYwer8O3Bb8FsTsjpO+uIdY1uCVKHlNhKfCXV5TYhcRAb7c0m2cpvq6BOZeHx/2tDm0nLrt//JGAy3J4uYpbE9p5FhinXEFlwN7pB/4Sf4tE0DQKZChULFc/WLpO/KRhZXqwzrsdiuVyzueEgJvQ0OPyd7jchkFKX4; 25:hD5cH3b5r6FWzBkRgdZi8j5MSOEqotMquwi2TaPtTOvxUEiZYnzYjukd8C9CdsD+1aqeGpYaTYWUUjqwZSzBXeB8B9AlUkVNLSkPXEQ0SF1Roa8rdMnVjodmVKJo9JkeWvmJLPKB6/oWbOnw33c7WgRWn69uV5H+rixeH3BWQ2kIKKsRY3eL5NBcx2h/ED5PmhL0HCirDKKf0X2TtOUe2Gkop2oYHiaWPla7ukzGLMNVr3W2I3OpBAFojUxZ2+pFfi293VLIzpKfylsJR+XlkabJFuy16wxFsPAFtRwHrjgmFRLsnV/ikoVEVxl+eiGc3Mou7jTbFGZIkGu0rSLBsQ==; 31:fu0SpM2OEYXa9bmadMSrVG0/WuXERCwI0SafK+P1UioXYNBbxDX+GzOVSWpehusZQiqJaYNPTRMLWHtnkUqThnSwNaTVfltKgss8lK72WrJtmBmpGG0xtCTCeAUNSbTmEEHLqO02Q0tchtPcxkvmYLdt6cmZN93aBwT0f2yiYMu+Lv53IPYns7UZbZ1GANCQ3LTEImcV9nzs1KCgZJfZ1qwmMgvRCgva9fMxB5rI79I= X-MS-TrafficTypeDiagnostic: MWHPR12MB1839: X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1839; 20:yuEXhNY7YzdoPdG2TPrX4uiryccbNGX8nlkVNTm2zpilI7vaGPOFWlkiuUM93XzrsKxUPMWQqr6my9bfPH++7MhIgfLkm6iGJJ/TYbXONbVLLThiiJH9dnXmUSwFmhWdH7UDDzNmJEG5EKvSYhw+LSKkCd6BY2CTeIVF23C0UMKo4lXZS9ZcfInukV6+XyrzxrD8uW4BN60FtVpBg9G30HtsgK44yT5g3H0x+gWDO0ANEOO7Trp5vW1zRWfOSlbJwFK2xsfor1XbpbMpkhZPTEg00lB/dQbLqYFgZEUssxikZ4jkgjWHRNsjqc73AOtSIWUUXZG7mn1SFH3p/zFqsLQby01nSdB5Zp+seErxvVMFRMcMpNjYaTlxawzpMniKAHW5Mq6oSDjRF91zsfZAHaLqhUoMVfEupuYhM2Mjgzj18R1k2SZ+HrrJltZeCxZ1/mkFiuA8C/13YjptglS2xh49zCa9EdqeB2xjsazyC8tD3/86VULjV7IT6SlD1oGm; 4:ZvhyDvQK2esVSJRWT0bcte24Gjlilcf7xlIF6QIQ5tfAMeuhtgu4+/Z1m7rrQ4WyUooqs+0nniGGia5WeJsfUF2jXFdKQEkbPIcyd93OfL/j2kRcAeKrdfXTUQBiL1Xp7J7M1u8PLcMD0rYAlUfD1Q5TdVV1W6KQwMvUs6npgxxf/BdZLmlNQ1uBBn6KrmSwcAGHHo69leRxPNWJosliKcp+ksWY61BmZtcNkgCzNpgBBHBAjfGmm8mWPNEBDhoCm7QdkXBkJQ81NFRUWiIq0Es0SsHMlWtEMY/9Vaosf+0KhT1F5Wr3m1/1YLAZMDpf X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(3231022)(10201501046)(3002001)(100000703101)(100105400095)(93006095)(93001095)(6055026)(6041248)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR12MB1839; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR12MB1839; X-Forefront-PRVS: 0493852DA9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(376002)(39860400002)(346002)(199003)(189002)(6666003)(2950100002)(6916009)(106356001)(6486002)(86362001)(2351001)(2361001)(48376002)(36756003)(68736007)(53416004)(25786009)(54906003)(8666007)(105586002)(16586007)(33646002)(50466002)(316002)(189998001)(8936002)(50226002)(5660300001)(7736002)(53936002)(5003940100001)(4326008)(97736004)(101416001)(478600001)(47776003)(2906002)(16526018)(72206003)(66066001)(81156014)(50986999)(8676002)(3846002)(76176999)(81166006)(6116002)(305945005)(1076002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1839; H:nikka.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR12MB1839; 23:iG0HISyYLq4AW+AGzq2xjxJa2id53uIGbjYPwAso6?= =?us-ascii?Q?4E7taw8G3i9lBOUd5KNrBrjCI0O0GM+tZEN6bRmUoMnFyowdDuMNHUFNz8qn?= =?us-ascii?Q?vLAjMy+dKLqc1TFKxuv9sJnqa37t11KLAz+qDoZWwEvGDUx39e7YWGR1QFfK?= =?us-ascii?Q?OT2JDpmwIuCKd8jwTbM7JntOy/I47+bxy2rudEsDbpcfI/0SgDBMwSdem0n6?= =?us-ascii?Q?7qJavdWQQlrA0Rq5F2oLq17sUBZxhb9u4IuWrJ7hC/T9Rdkwi4wfSIv2MTaw?= =?us-ascii?Q?9O0PxsxFmPWPAMYkRGpQGtaUH2fsVMtEJshqixMghd4ZVva8ng+3iFV9eibu?= =?us-ascii?Q?NhBrs9bYmKMndj+I21zxG95+jiEfJfEht/Ztt9owmgharXp2sL+2zba5qPVB?= =?us-ascii?Q?H5CivfBGerM3Mx8aJGzURFXxAX2d6EfrIy57sBzttvnRKj//n5gwutw2E3kH?= =?us-ascii?Q?0IFHqKoa5I3bzDTajND54QPHz7MjxY7TyHUUH+qGfgkW5mDaOOyqskqABUGJ?= =?us-ascii?Q?rkUrg3bAtEgGqUktTxlETELGloYRqwKgZyOqplvpVr2LIGu2jExybztCl+X0?= =?us-ascii?Q?YwyXyvqBQEmGrvKktoegsU53ws94vm6+PLyFQjucBNceZwT6oPkg8nkwU8qU?= =?us-ascii?Q?zOKkHQ3KZV5uHQzSBQ9RYMUPMZpLstMJcIhFbtGKQlhBFJ7eq6jUuZ5yJNmB?= =?us-ascii?Q?dXEAWM8RFH8HeWKeB5T1gWeoLabSj5tECNoSXR+DRxEaGHQe1guk/oQiJaq1?= =?us-ascii?Q?Af5CNcBTv2cMOBSBXVXSeKBGQXCnKLRs9UXunOAwyQFiHbKiiZXnDQiT2RPh?= =?us-ascii?Q?ATv61W20HmngXQng+UJOWUncTWwniZEqDLb9yang74ZKpRPXq6Zr2bibOFxP?= =?us-ascii?Q?YqPK2zfd9FNhuol9VgUiaVzL3JnqILsem+9pz41Of4E3ES6oFoo0KyGSK4wE?= =?us-ascii?Q?jl2kFQ3dqqJArcMISctm+CnyEwIrtFctGkfLavT7Wvl1TgqfBGjULw3CiOX0?= =?us-ascii?Q?eGJONepSlh0KbEyELLrbhtq/JpvKjpRTo/rAAWqvkCNt7MgJwsUdrhJmAElG?= =?us-ascii?Q?IHSUZaTfl3qo2uBO/hhv3e/tlcPzZWUgRK45kcHV01GcQ8Kkwceovr12Gkk2?= =?us-ascii?Q?bTFYURRmm2gc3CG8VyRrnjn01aEnGEW4vgvN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change-Diagnostics: 1; MWHPR12MB1839; 20:zudblEswFYhQY8QdPcIMf6wvYuFC2X2I8nOEIJIDTIXK4xoE4Jn7+Yv95eZU8DbCOvHIT7Ppd3ZGj/Cw70xJDah8SNHdx2M9nqQz0daQWyvWMGtWftrE9q4sVM62skYGMz9NLkPrXAAScSEhsvzUXm8oP0DdF1ZHT3JPYAa99RJKIrQDMjk7tX9+olTYGRuxw2b/KnzbsoEL4DljHk/C5o/8HDAI3xSIra3BCjF/kh5xusGCRMMSGV1A7VfDA1Ru X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2017 15:32:45.6918 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2c10694-d7b2-4d17-3b8f-08d52d074974 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1839 Cc: Andrew Cooper , Boris Ostrovsky , Brian Woods , Jan Beulich , Suravee Suthikulpanit Subject: [Xen-devel] [PATCH 2/2] x86/svm: Add virtual GIF support X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch detects and enables Virtual GIF if available. This allows a nested hypervisor to perform STGIs and CLGIs without having to be intercepted by host hypervisor. Signed-off-by: Brian Woods --- xen/arch/x86/hvm/svm/nestedsvm.c | 7 ++++++- xen/arch/x86/hvm/svm/svm.c | 1 + xen/arch/x86/hvm/svm/vmcb.c | 9 +++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c index 1de896e456..de5d022815 100644 --- a/xen/arch/x86/hvm/svm/nestedsvm.c +++ b/xen/arch/x86/hvm/svm/nestedsvm.c @@ -1597,8 +1597,13 @@ bool_t nestedsvm_gif_isset(struct vcpu *v) { struct nestedsvm *svm = &vcpu_nestedsvm(v); + struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb; - return (!!svm->ns_gif); + /* get the vmcb gif value if using vgif */ + if ( cpu_has_svm_vgif ) + return (!!vmcb->_vintr.fields.vgif); + else + return (!!svm->ns_gif); } void svm_vmexit_do_stgi(struct cpu_user_regs *regs, struct vcpu *v) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index b9cf423fd9..6b7a462fcb 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1669,6 +1669,7 @@ const struct hvm_function_table * __init start_svm(void) P(cpu_has_svm_nrips, "Next-RIP Saved on #VMEXIT"); P(cpu_has_svm_cleanbits, "VMCB Clean Bits"); P(cpu_has_svm_decode, "DecodeAssists"); + P(cpu_has_svm_vgif, "Virtual GIF"); P(cpu_has_pause_filter, "Pause-Intercept Filter"); P(cpu_has_tsc_ratio, "TSC Rate MSR"); #undef P diff --git a/xen/arch/x86/hvm/svm/vmcb.c b/xen/arch/x86/hvm/svm/vmcb.c index 997e7597e0..5a714be8f2 100644 --- a/xen/arch/x86/hvm/svm/vmcb.c +++ b/xen/arch/x86/hvm/svm/vmcb.c @@ -206,6 +206,15 @@ static int construct_vmcb(struct vcpu *v) vmcb->_exception_intercepts |= (1U << TRAP_page_fault); } + /* if available, enable and configure virtual gif */ + if ( cpu_has_svm_vgif ) + { + vmcb->_vintr.fields.vgif = 1; + vmcb->_vintr.fields.vgif_enable = 1; + vmcb->_general2_intercepts &= ~GENERAL2_INTERCEPT_STGI; + vmcb->_general2_intercepts &= ~GENERAL2_INTERCEPT_CLGI; + } + if ( cpu_has_pause_filter ) { vmcb->_pause_filter_count = SVM_PAUSEFILTER_INIT;