From patchwork Thu Nov 16 22:11:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Woods, Brian" X-Patchwork-Id: 10062149 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 8E5BC6023A for ; Thu, 16 Nov 2017 22:14:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 803082AC0F for ; Thu, 16 Nov 2017 22:14:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 752072AC10; Thu, 16 Nov 2017 22:14:09 +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 09E332AB20 for ; Thu, 16 Nov 2017 22:14:09 +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 1eFSNh-00023H-Lz; Thu, 16 Nov 2017 22:11:33 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFSNh-00022p-5o for xen-devel@lists.xen.org; Thu, 16 Nov 2017 22:11:33 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id 40/A0-14794-41D0E0A5; Thu, 16 Nov 2017 22:11:32 +0000 X-Bright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206.messagelabs.com!1510870288!71280992!3 X-Originating-IP: [104.47.37.66] 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 60225 invoked from network); 16 Nov 2017 22:11:31 -0000 Received: from mail-cys01nam02on0066.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) (104.47.37.66) by server-12.tower-206.messagelabs.com with AES256-SHA256 encrypted SMTP; 16 Nov 2017 22:11:31 -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=flphfpPbDhj79Gg+IEvVQO7//eic9ytlo9TiF5AX3rg=; b=KBnpXAZkCxCX6VAsDGoB5JBir2OiOpB47FRb346AaiWlENXoAU83vxuv4iFp9TxyHuO0sTCagxNygc2V6BbA02cAivmgY5AtRK3+WQYL95ajH+45Cu2CoRnt7nb8lJ91avjdvsIGsA8YCh9DqBj+QQHc6vlb2FpbeOcCy+sZxc4= Received: from nikka.amd.com (165.204.78.1) by CY4PR12MB1830.namprd12.prod.outlook.com (10.175.81.148) 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 22:11:28 +0000 From: Brian Woods To: xen-devel@lists.xen.org Date: Thu, 16 Nov 2017 16:11:15 -0600 Message-Id: <20171116221115.98954-3-brian.woods@amd.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171116221115.98954-1-brian.woods@amd.com> References: <20171116221115.98954-1-brian.woods@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.78.1] X-ClientProxiedBy: MWHPR12CA0045.namprd12.prod.outlook.com (10.172.49.31) To CY4PR12MB1830.namprd12.prod.outlook.com (10.175.81.148) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7b53c1d7-1eec-4d2d-5fc1-08d52d3efcd2 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199); SRVR:CY4PR12MB1830; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1830; 3:V5e1md+Gg1n1uYqxIeIShhYQfpo+cax3eMiryOckQsxt+kksuOD3mQk/OTuZJ9A0io4zUD7A+URL5gxsQoJA3258ePSA/8Y4tdRfRgzgsBApakc5R8eUrvEWSCr5v8fE2598eA9BuDfrEAw1zECVwtJfqw/5fAxdGqZ6IiSFIYxjvuwKOPI5VZmvxc6yeTb4YbaBToxrZdbv1VqFtpyFfg/pBc18vO3i9sVC5wxsaS6j3Ll22QID5469jH47B/RN; 25:Y4C3q8lLQYhPq0u8MADWMmDTXsaobsZO7x1wU3c2tMeEK4B3R/3SgL0SlNvFEyt76w1GirWoB1ehhRzjGjQuWmmv+q6eWczLFCzLMk225Sr3hOm0MZT2lor/kXd7rshznk4KHhSvCL3mNc1IA8097mM4YIizNGPBQexX0XP3Dml6jsVmIghj73H530xxoKuYENIeAFC4nFwILzbrssJERachPW3RSjsI7IiHdOvyrC6R+eC0UKTkog0yrNVJDrhdvQh0MOMfohSY8WHHVcctUCU6W27Uc62LCRkwzsmhK/hxIHywjyoscx/Eq4VewUxw8SpypY/DGm9/DDmEnbArGQ==; 31:0PIanAkfGU/ojUm1raJpiPzsIO1oZicEjTzFhM22yLH4w89jjPJRm4rLFwkHKxN+x8FzqTcoSF3bbwCQh1XVtxJdwuKcDzErvTW+rlb0mfULDAEk/c6qPBdNbjHumNOUka10ZtLz1LStX070HJbCMcQE96qyPn5IR4nKULAo6DtWuoBXKfCMPKOZw87o8NWSHPGzFlGvFy/k/epq9ygfDzYGit/oBbyUfF9TmXfMThg= X-MS-TrafficTypeDiagnostic: CY4PR12MB1830: X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1830; 20:r4g0qyIypODMRSLSKQX0j9JPAhCW77g5VODkWkGcu5/hbOPTsjI6BDTSrjZt5tvFm8DpJGm8ew6X0GK82s/e/nmQ0jmWlv8diwLESLbOpJq8/BbAGz3QukkX6rQBbNNpO2nlP2yxN0y9XY8rMUxqv0V+Upb2G+7ApiNgAPT94qbKcugfGQVe3zdi7IzbwY7mdWjqFC9Uf4qMXCZNQaPcJY2gXz1adpQKkjkrNeSevMJLfufvOJ4v4NlKsuDbWHeTNKR+G6dipcwwFWdEDuxZ/FD03l8VTdFnhhGyU7CVymvCFoON4oVb7V/hGUx3Pz2eXeoCfGrWfjwruQ5yzWvTCQZNm7SJa8Q7YaxrZcevOjVKOHiL5OtwV5ttPTcwpnBvIZrLTvU406/quIO/finbQ18ceeLj8H3h4rRgphVEK0j3krUI1OLaMDe2IfULHgjSFzzH7cw3MaLppYk3n4HjSw1xV0YitNHKEqOz9GQAlE9zXuLe2uBgoyym8kqPCV3B; 4:cagIFw788h3klExOh1aAFvLcBn1i2jRbs05Bi/sxuhEuRzPoO3Qbb/tZP7VeqFQVuM7GrmJdik2v+CgpcDlVdMSiWmL/A/lMtymZFfIkO2mBQyBU96qzrLSY0pATuZOBbXz9+Kf0EAs8v7J+QBdFhNDKPfPsHI1usghf6tnPEPyw5/2WDrB6MrT1vXjuTpy1BVOte3ENaQ8HelBxK9jPGjbxhO+/DBHZEhhpFe+6EY/4QJyrXbAsF4ElhyVmKVXRFW2LflXuGsE0PsXQyF44CJpwPXQrEZBgkQ+Sl3p76ZOtsgzMoU9+ZA257dwB9TAn 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)(100000703101)(100105400095)(93006095)(93001095)(3002001)(10201501046)(3231022)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123558100)(20161123562025)(20161123560025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY4PR12MB1830; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY4PR12MB1830; X-Forefront-PRVS: 0493852DA9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(346002)(376002)(189002)(199003)(3846002)(6486002)(53416004)(72206003)(53936002)(2906002)(6116002)(76176999)(50986999)(1076002)(25786009)(101416001)(8936002)(36756003)(5660300001)(6666003)(2950100002)(478600001)(6916009)(4326008)(48376002)(8676002)(50466002)(54906003)(189998001)(8666007)(66066001)(47776003)(16586007)(305945005)(16526018)(81156014)(97736004)(81166006)(316002)(50226002)(7736002)(105586002)(5003940100001)(2361001)(106356001)(33646002)(68736007)(2351001)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1830; H:nikka.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; CY4PR12MB1830; 23:TeHd0KmFlqm+MilirwRIsI137YP0742xT2YWG3jN1?= =?us-ascii?Q?aZNpey0sHqv5JMXDhjYk+OXg6i28GGOmwScifVDGc8nyVFnnNiZsp3/uCLAy?= =?us-ascii?Q?mfwCA/uc2s6CtcOvBvp5oI2cWqRIhErVjnLD47bVCdQOZ2tq2hJAPHXijBwK?= =?us-ascii?Q?q0F+2RWW3kFoY0ZPHeHpMgXfdgor4/BidzgrwmAzQdq9ZwEDBPevNFRpQGtx?= =?us-ascii?Q?E80TSSmIyYOTs1ejLN44G1iUp5AymUb/Q7vtckAR14LxkD3xgnNAjG+35DvS?= =?us-ascii?Q?QyBlVCsak4ZNUZj+Nwc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o1wn6b0+H+FQMZbs6bZGCXE3QqGWfPasn54XQ5j7RE+0zleWcIT9UpTdJhsarRCY5i5S5833baalTZt4TmT+siHJxl9seNeYMNDjOJJpyHGGGALoR8pm9RwewU0AKQSVFVcE/UVuJW2mS+AVMdWBDiX9DKQZe+NqmD3FE/1gHlUTbhH2n5SHA2GtGIycJ55TqHhmmr6dg9Je0kF8VWJdw5KII4+c1hPjcfTPb2Ai1WSV+/87ChHA2 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2017 22:11:28.7535 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7b53c1d7-1eec-4d2d-5fc1-08d52d3efcd2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1830 Cc: Andrew Cooper , Boris Ostrovsky , Brian Woods , Jan Beulich , Suravee Suthikulpanit Subject: [Xen-devel] [PATCH v3 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..0705cf9cb8 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 ( vmcb->_vintr.fields.vgif_enable ) + 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;