From patchwork Mon Aug 22 23:24:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brijesh Singh X-Patchwork-Id: 9294837 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 4A75A608A7 for ; Tue, 23 Aug 2016 00:07:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A26728B39 for ; Tue, 23 Aug 2016 00:07:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E66028B2E; Tue, 23 Aug 2016 00:07:21 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4A0328B28 for ; Tue, 23 Aug 2016 00:07:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933129AbcHWAHA (ORCPT ); Mon, 22 Aug 2016 20:07:00 -0400 Received: from mail-bl2nam02on0076.outbound.protection.outlook.com ([104.47.38.76]:60235 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932973AbcHWAG5 (ORCPT ); Mon, 22 Aug 2016 20:06:57 -0400 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=HqDNoCeeagbmeL206+XBIolIXqSP0+IVxm7glcAPLcw=; b=t2wioa3TNVSDVPwNJwlA/wB2U058dqJY42SyM7yDP7E9pPhLSeU6DjqIeTV7ECG4TgShIvpehabh6b4hyFGU62l+ukdv1p6I9RCsP7ikhjvWl+Y9K1Lt58QH3lvObUn33Wg0S3xamo+iatIf/UHqZnvx4uohUZIqBKNVR/TH8sw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=brijesh.singh@amd.com; Received: from [127.0.1.1] (165.204.77.1) by BY2PR12MB0663.namprd12.prod.outlook.com (10.163.113.152) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.557.21; Mon, 22 Aug 2016 23:24:35 +0000 Subject: [RFC PATCH v1 05/28] KVM: SVM: prepare for new bit definition in nested_ctl From: Brijesh Singh To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Date: Mon, 22 Aug 2016 19:24:32 -0400 Message-ID: <147190827232.9523.18200019204059963746.stgit@brijesh-build-machine> In-Reply-To: <147190820782.9523.4967724730957229273.stgit@brijesh-build-machine> References: <147190820782.9523.4967724730957229273.stgit@brijesh-build-machine> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BN6PR17CA0029.namprd17.prod.outlook.com (10.175.189.15) To BY2PR12MB0663.namprd12.prod.outlook.com (10.163.113.152) X-MS-Office365-Filtering-Correlation-Id: e2b453ce-2d7d-4912-f0c2-08d3cae37dd7 X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0663; 2:9DZMJGVURlVz2rwyotG6IWz/fI2CauWMgemiT1AmbK0uiTyxNPYm1+0QJ+r2betpNqnDSrfDQnSGrDeH/nc4QyxYpYc62nZvOLejWhwvdc0SX5r2BXHWW/nszk+7n7WKoPX4D0CLNqZrPOp3xlGZDmzyWm01z263RngNih9xvU3P0xX+7La5oobwT+VZ3SJ1; 3:KdSj4ZO6YY+3d26i726NixnayDSsi5u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TrQPH6i2FfN/0kQrKeLrH8OGpUOcpVWLV1C00jvMLNikVLY1f4vr5vR3VqMTCgT9YW8BgcNC0rUiPk+nosZpHKuzPeIHoMFBMCNbUNrjGoQYawMEVNGK4PtcYaw1sarM26oONV3inabEWtRBpsuCXeqdemGwA7OEen5MPqCo/PDBPOLRGp1/f9kq1b3CuJ7v8wkw+IN+h4+mBOtJXoiV4W/U4WTyKcAvDzUekZ6NpIQTx/NlDN5zA9HtHm5iBYvt5X6pODQKtSEOM18mbRAkwDK8twmX7vPplaVZsVjcsLOp X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:BY2PR12MB0663; BCL:0; PCL:0; RULEID:; SRVR:BY2PR12MB0663; X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0663; 4:wHafsN9Tke7QKE133Wz4CHOG8t02VNT+ZCEDVE7xqzjHq4bduxD+Kf9VwLO2LXdg/N9UpBFKOVmTShlfI4GgtUG3478MBmjOZCXezXZrko7IJhP6x02nq/he6RfxRZmgpq22t132/GBhiTQ0xq4CAl5ISHtux3OOoy78+b4AwHJ2nG5a37EAESZeDxFUNL0wYT9eDyABQSuECJRmeAVF1uKnGD7E+IsWC54wBWgdVqoNvH5f+Mi6yw2OWows+OGnpM1F9zdWuYTP74l3XGX/QG6zwAB8fDlJ5M9kqcSQZtxQTGzqlBHq4g0+jAp1Rd/ArgyikbhEkxEgPzy4HIG7ddZgjiFjgDgflhdLUM2mVwl2iwBnAX0pOYw/aDzBLQduSGJAbsGhMjGRzGNNRxIXifNBc9BCU6xb2Iz1XHrREhbaBFLJpEdEPFrjscOQlFx4 X-Forefront-PRVS: 00429279BA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6049001)(7916002)(189002)(199003)(33646002)(7416002)(92566002)(50466002)(77096005)(42186005)(7406005)(230700001)(19580395003)(101416001)(83506001)(19580405001)(2950100001)(9686002)(76176999)(54356999)(81156014)(4001350100001)(586003)(106356001)(50986999)(86362001)(47776003)(81166006)(305945005)(105586002)(97736004)(5001770100001)(7846002)(229853001)(23676002)(189998001)(8676002)(2906002)(7736002)(3846002)(2201001)(6116002)(33716001)(66066001)(103116003)(107886002)(68736007)(5660300001)(921003)(217873001)(83996005)(2101003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR12MB0663; H:[127.0.1.1]; 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: =?utf-8?B?MTtCWTJQUjEyTUIwNjYzOzIzOi8vZ0J1bndZbFcxTDdaeGI1SkRFUTcvREU4?= =?utf-8?B?QXhGTEEwMXV6cXdGUGExcXhaQjRBL0pXcHVKUjVmbmMxeEhuelVQVVRxaEgr?= =?utf-8?B?dC9oMGFScFFzeC9CQmJPaFJPWmIyR2pUdTltQms4QVFGby9NMWhRY3RDVyt6?= =?utf-8?B?dytCeS9xN0FyZGlZNHJUeDJUQnpJYXMvUWt2MGd6Z3lsYWlaWkFuVnowQkRI?= =?utf-8?B?ejNzRVhYdnhqTm9jMlpnUFpLaWk4ZGhZdWxGb0ExQUZ1WFRtR3B0emdrUWNi?= =?utf-8?B?RHU2M3BEcE9xV2RLMnhYRXZGM1FuWUV5cHJrMjA4YlVoR2MreUFHbXB5MDFk?= =?utf-8?B?VWxkYkZEY09kR1dRaUYwamR6WDJqUjByQi93dy9xVWNzU3drRVU0eVNJajU2?= =?utf-8?B?WTJ4MU5NSllQaHlaK0JKSVJGaUpDTzVRQVFGWEdoTTNyZ2R6Qll6UkI0SG5s?= =?utf-8?B?WjhRN3RhSUNVVjdZdnZEYVJxdytWMkRObDMva01QYk5NVkIxemNERUE3TGJY?= =?utf-8?B?VXBKZnZadWcwWVExN2JON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PQDlCm/bIT24o4FZJwjR7K82g=; 7:uAy+LSXCdsaOSCBNKL/1jO7vk2fN1xYz0lwJgnpyKgy7R79+5E88Qtr+LNLILzKq4ac0fTMz+uAbt0+WM2Icq+y26HoN/YiAW4jdmSH0ZYJPH4x2dswTSw9wKWZw/rfSY1ZIOWcxk7i3PP8H7V4bEdrZb/vbt2gzLt31aGgrVzZJF6q+dSOUbqIXxVxbJ2o8lvKLc8fplK+tfcuCuMR7zdd5FCnKag+tqehn4lOoufkRz2sfVNNpEQ+Z7kiwfhyz SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR12MB0663; 20:z2U9YhrLc6/Cvh/LnrKFTFhd1CAx70ikaig0T+/7R5eBDZouNa7iSGKDP1Wk0RSyI2/tDKWDVF0GAwaF05OK36dd4NM0c1ts+eo1Kx9fF4SnUnx8cA4somjFvm25Ef8z2VveBRpkqdaEolPD9WJu8u1P7W0kosuKLhfXXk5ASe2dXH7mBp4EzOMsZQxdrsloPaTQ5EqYgwSGzXPWMAL3xbS/v9DOPP2ri84sZOt/0o9Qs0YIE6xiPsdROh9TTU7I; 23:ib6uvLg2/twdnsj4dPp4uCiu/HVLS5OE1r9Wycadpe1Wh1Cy2epxDL5TVmIzerzpPyLG+LZjVZ+FZDtTEO1aF8m6MLapZY04YMePFFOB0u9qiTo0kK5pcP0f4E8uN9JFL+cOrO7IIOD8Hk/7fxK9x0ZafZm8rfxvcI+L11w4Bo6r+a0xsMlXv0zG1KwLKDF9 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2016 23:24:35.9604 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR12MB0663 X-OriginatorOrg: amd.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tom Lendacky Currently the nested_ctl variable in the vmcb_control_area structure is used to indicate nested paging support. The nested paging support field is actually defined as bit 0 of the this field. In order to support a new feature flag the usage of the nested_ctl and nested paging support must be converted to operate on a single bit. Signed-off-by: Tom Lendacky Reviewed-by: Borislav Petkov --- arch/x86/include/asm/svm.h | 2 ++ arch/x86/kvm/svm.c | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index 14824fc..2aca535 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -136,6 +136,8 @@ struct __attribute__ ((__packed__)) vmcb_control_area { #define SVM_VM_CR_SVM_LOCK_MASK 0x0008ULL #define SVM_VM_CR_SVM_DIS_MASK 0x0010ULL +#define SVM_NESTED_CTL_NP_ENABLE BIT(0) + struct __attribute__ ((__packed__)) vmcb_seg { u16 selector; u16 attrib; diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 9b2de7c..9b59260 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1177,7 +1177,7 @@ static void init_vmcb(struct vcpu_svm *svm) if (npt_enabled) { /* Setup VMCB for Nested Paging */ - control->nested_ctl = 1; + control->nested_ctl |= SVM_NESTED_CTL_NP_ENABLE; clr_intercept(svm, INTERCEPT_INVLPG); clr_exception_intercept(svm, PF_VECTOR); clr_cr_intercept(svm, INTERCEPT_CR3_READ); @@ -2701,7 +2701,8 @@ static bool nested_vmcb_checks(struct vmcb *vmcb) if (vmcb->control.asid == 0) return false; - if (vmcb->control.nested_ctl && !npt_enabled) + if ((vmcb->control.nested_ctl & SVM_NESTED_CTL_NP_ENABLE) && + !npt_enabled) return false; return true; @@ -2776,7 +2777,7 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm) else svm->vcpu.arch.hflags &= ~HF_HIF_MASK; - if (nested_vmcb->control.nested_ctl) { + if (nested_vmcb->control.nested_ctl & SVM_NESTED_CTL_NP_ENABLE) { kvm_mmu_unload(&svm->vcpu); svm->nested.nested_cr3 = nested_vmcb->control.nested_cr3; nested_svm_init_mmu_context(&svm->vcpu);