Message ID | 20230612042559.375660-28-michael.roth@amd.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 470B5C7EE37 for <linux-mm@archiver.kernel.org>; Mon, 12 Jun 2023 04:38:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7F538E0002; Mon, 12 Jun 2023 00:38:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D56716B0074; Mon, 12 Jun 2023 00:38:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C1EA98E0002; Mon, 12 Jun 2023 00:38:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B4D8E6B0072 for <linux-mm@kvack.org>; Mon, 12 Jun 2023 00:38:01 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8C4C5AF3B8 for <linux-mm@kvack.org>; Mon, 12 Jun 2023 04:38:01 +0000 (UTC) X-FDA: 80892838362.09.31EE1A8 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2050.outbound.protection.outlook.com [40.107.93.50]) by imf14.hostedemail.com (Postfix) with ESMTP id 84F4F100008 for <linux-mm@kvack.org>; Mon, 12 Jun 2023 04:37:57 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=1g1eaNBG; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf14.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.93.50 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686544677; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pOpw3KzGxdOjwJ/TkrcnFihbFz41wbR17m9Hf+7f9aQ=; b=S0/i5vapRWYki2rYQUhPStBp+e0+7zcrOuYZzqOzLeJWEUH5w9Fe/jT901Fh4fT+xxbsRe 3DAzn2W8SGIyCIJCBq+WdPBZGzRf/0DzAAsK3pkca1/dBX9dswjdJpCG879zlguEr3pDyi hx08gqc7d6ZkICJ+1+q6P3U/C1Jh/vk= ARC-Authentication-Results: i=2; imf14.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=1g1eaNBG; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf14.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.93.50 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1686544677; a=rsa-sha256; cv=pass; b=j4S96OF4ac1aNduOqH612msVdjEZVSMLfga1ln/O2TfHIFMpbp39ZgW6S7tEjB0AtdrI5e dq0p52WnK1rmYUAm/mEP+0ikXzQ4uvNLmoc02Nz/Iz5GrcCcRU90746SgnLZe9qvtUGI4+ IXnwdNjRg44rzzVkCDjSHyepSMTY7+Y= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lfJ4DMH5UeL4MLfR70vtA0ZBekZIPM9Vtivv1eQTZrVm2G1KNpXlh+Hpqbhc3wou4StxEiJFjpJtUCiyLDV0QUHmBlRLpmVHoCxrTkXFF0npzq7lrF8yS7eQG34y3JtYTDXqcBax/L8ji+P2K9JSyASNTmhEbfZ22t29Gpbdqg2xUsCEY7oHIUrV42eAesnTxRTuHKs7TXve8qdb+v3ownwMbE/WqUZqFOgBiG/S6/C09yYF0TbQfzpDgsJ3Otohl4Kmm42I09ourWftwPYGRP9Amvoie0pUZyy2whCQI4Pfxpycp8+3kW08Gy3o+I66j6RQ4CRDN4wAcFiB93+xSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pOpw3KzGxdOjwJ/TkrcnFihbFz41wbR17m9Hf+7f9aQ=; b=kw9r0XvrmMdG+rFbrGD2NOq4pmQXK0/ozB/oM+UBe2+rg7L/Rp72lRPhL8RSDpSYCVGE9Ps0uWE6sQhlBLSVqr/MG552tp9TryYd4I3ZChIaREQb1NUc7w1zpzHGj/VNUMq/eczCU2iSX97fQKbMG3mWkLMh2fqPw4U+y3tqK0JV1gK1ywlbCVHnhQ7F9U+9y/9Ljs+BcxdtwgViHIYYYSKGShkLTZlKNHlgVOqcVnpyFOVwNnmuxCOq3gVw0hTkzLJ2HYxG2a7gse6VdDhgif66FrUJZU8D2ymSh8zSpL8YmSBkYsxQBPjAZoXyGPl0YJQKBZYIE0Z1/MA39BGFZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pOpw3KzGxdOjwJ/TkrcnFihbFz41wbR17m9Hf+7f9aQ=; b=1g1eaNBGzrRncDD0LAr1f9sRtbUZYIoFWbWXpGADs9AoNjVFcJBfFR0b1Hm8aFS+gny5nHSsjfwdbtvZRJpe6PCv9hXRF+5BOfU0E4z+XLXjN2JDV4hZRmZsIutTjy90e6gu86YVfmQhUp19lokKGD+k8chuoCYVYs1TUhWXAMo= Received: from MW4PR04CA0148.namprd04.prod.outlook.com (2603:10b6:303:84::33) by SJ2PR12MB7823.namprd12.prod.outlook.com (2603:10b6:a03:4c9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Mon, 12 Jun 2023 04:37:52 +0000 Received: from CO1PEPF000042AC.namprd03.prod.outlook.com (2603:10b6:303:84:cafe::cc) by MW4PR04CA0148.outlook.office365.com (2603:10b6:303:84::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.33 via Frontend Transport; Mon, 12 Jun 2023 04:37:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000042AC.mail.protection.outlook.com (10.167.243.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6477.13 via Frontend Transport; Mon, 12 Jun 2023 04:37:52 +0000 Received: from localhost (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Sun, 11 Jun 2023 23:37:50 -0500 From: Michael Roth <michael.roth@amd.com> To: <kvm@vger.kernel.org> CC: <linux-coco@lists.linux.dev>, <linux-mm@kvack.org>, <linux-crypto@vger.kernel.org>, <x86@kernel.org>, <linux-kernel@vger.kernel.org>, <tglx@linutronix.de>, <mingo@redhat.com>, <jroedel@suse.de>, <thomas.lendacky@amd.com>, <hpa@zytor.com>, <ardb@kernel.org>, <pbonzini@redhat.com>, <seanjc@google.com>, <vkuznets@redhat.com>, <jmattson@google.com>, <luto@kernel.org>, <dave.hansen@linux.intel.com>, <slp@redhat.com>, <pgonda@google.com>, <peterz@infradead.org>, <srinivas.pandruvada@linux.intel.com>, <rientjes@google.com>, <dovmurik@linux.ibm.com>, <tobin@ibm.com>, <bp@alien8.de>, <vbabka@suse.cz>, <kirill@shutemov.name>, <ak@linux.intel.com>, <tony.luck@intel.com>, <marcorr@google.com>, <sathyanarayanan.kuppuswamy@linux.intel.com>, <alpergun@google.com>, <dgilbert@redhat.com>, <jarkko@kernel.org>, <ashish.kalra@amd.com>, <nikunj.dadhania@amd.com>, <liam.merwick@oracle.com>, <zhi.a.wang@intel.com>, Brijesh Singh <brijesh.singh@amd.com> Subject: [PATCH RFC v9 27/51] KVM: SVM: Add initial SEV-SNP support Date: Sun, 11 Jun 2023 23:25:35 -0500 Message-ID: <20230612042559.375660-28-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230612042559.375660-1-michael.roth@amd.com> References: <20230612042559.375660-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AC:EE_|SJ2PR12MB7823:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a304f1d-13d0-4bf6-408d-08db6afec899 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uLxOKIpZMWOThwXCbr064xUgH6E6BEXvwurUtUUJE6y8Xyh3Ns+MGwSrTLe2xDOBDlNlNpDhqzQM2ox38G2h45Slq50VWTbYTks1w/1NHzNqG2TId4ITzuON1LozCGV7g5A2eLfx6ybroQKMJFHG58oy4B87yx9k2vvCKl2uVIjuT2x9Qi9xYZccGSm+dfi/1kq6LACuFvjvCF6E5kpf7UwWejtJLvMPV1XHw9Wc9Ee5di9Z7Xb3qbgRuCvJjBbGuiy7JoyQZr2nwgl91Iy7e9Es4unsup6Dx2N8LYk5tXgfVHz0vvSZSVv+/lsYs5G2xPmxvBX3ELbp1q3Kv2oPFBsdyl89zfRBXYvRQZI7qX4sOZk+URGizZzTdIcLeljBipQikoCd62+e92Wx3M3B6Z4lvj4zQgtUsk4YlJFPmvA3iYLr0GvfZITr/p5F2lQRbjiMUjOz1lFvkzb3VKtZi7jTOgQMeMd46PE0L4WlfDo1y5PJznczKj4h/5oiBYW7vdshghfPrxgeH394eKuFiRKMrshDcOvZ1aoEde2LKJByWLUrS+YoQ0OKWQpPfqH/oogsqr5O1XVODSZrh0gdAy4XHID+tzKf+EzMQ4Kfz2EyLeuKdPlgcPL2g6bbrEeKK9q8JQuXRjVY/q7wEY4pcYf1al5kYfIOZJ6nBo6NsKKOrVPJ3PbsDXOTgQLl9b8mQJJYKwx3K8o8a/UviNZ4VKPcKAMA4/Ud+50moDtDSzvlcZrzbYpIaXiDQ/aPUv06KeNlyrtCdWdJ0R5bl589hA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(376002)(346002)(136003)(396003)(451199021)(36840700001)(40470700004)(46966006)(70206006)(70586007)(5660300002)(8936002)(8676002)(36756003)(4326008)(6666004)(6916009)(54906003)(478600001)(40460700003)(41300700001)(316002)(81166007)(356005)(40480700001)(82740400003)(336012)(426003)(16526019)(26005)(186003)(44832011)(1076003)(47076005)(7416002)(82310400005)(7406005)(2616005)(83380400001)(86362001)(36860700001)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2023 04:37:52.1218 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2a304f1d-13d0-4bf6-408d-08db6afec899 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AC.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB7823 X-Rspamd-Queue-Id: 84F4F100008 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: dy7z6h5tp1ar8c7prpi7oo1zg9k5hf8e X-HE-Tag: 1686544677-958346 X-HE-Meta: U2FsdGVkX1//Xc8bAEQQ7ZHUUSrevXIMEGM5va9pX/kpjurGZ2x2OWclqz6ZbmmlJ+jWtcav0UunkSpreeZNkLOouMND62TmsyfNnRD0OiI0OxtY6uqynQU3RpjCLIwQXjhtIOOEps1Y+m9enaoGMbSV33+2uTFcF2dnpSAyxx2Q0D6s+i3ouVvn/foB55JXfAJl12xGE5brOFIwS7ICdSDoEcLY2oiLRfPyYbbQC2OpBnDTplCh+W5lSc8OJchQPPqitXoW3nlh4nvV57yTm5qWdzI7/x9V0iG2EgeaXoPg7vpTEDyVOa7WCyDFxUr32j2dyz4sV/VuDwdarbgPWVHHyxoiHvzGXVVhTOJIuNCI9FQ8tuUt58NDBxLU0qCxG7wV5wmM1mdjVygNSkUP7xXHQB+dQqXKjN9gEJNjctuY4z1xMEXEtuAg9fIh3W6UlJJ/R3DKvwR0tvebUZwd1T1K6IbdcjGDutf05Nu6ax3DXAOpa57CwdyBRFTx6zJKT1Ew4Y6WRuS7aIFCEmouJiU8RFYyM5UeSIQk2/PAa6Ht7onMr/QDbZcL3MNHAY/YiBrKP5KniaSNeBGdUGWuTzBEwVUkJTt8JNEzUKa1SrxASlnlxFJWUcK7VQlRr3NFcLIN7JCmEa/KY+yRn+ppFX2tuzDhku+GiMoMBJMhIIpKpSaBW5Owzuz5N/aw2FBAChIJyJ6+1Zm0KpCVwWasbiMmACLi8ope7ZKu2KXuVdz/3Ka4PDj9XwXOldOMdwdyTAA2GUiTD1ck0q09Y77OWgMfsWYOUMavSQ8VVfiP7ciqjfP36UhqkqAGGhqijqBFr330Bz5vcu+c6dQsRVKdfEXZI7X0gIOsIVy1t4/OIRqS+lkU5bJJVK7H9drzSy0EUOXvEtSrG+vX9keocP0gXt3zg2a4wEbjwRDPlr4LKHvHWZO+OqaLOc7lQIszP/lHGmVXxj8cX0KJefg2BcB HE5Br5DW 3vBpilYj6sLtdfeYsYfHp7bkvUGG1HNgppawARqyK1I4Jzjmp+vHEu7t389OxRtXI7SxVQ6jiom0iC7M/u/bWoj+8+Q4WX0qN5ld3rPnpBYQ1LUe94jovXTy9V65ZQQ1cGCj5B2P/nHQvjjCiV/qlzvJI6V2v7CWW+ek4x/uLd53D689ehCCKY+YXGQZRHkxdoykQk5VA3r+meGLjkEdShqPZUBJaf3i7P5JBfEdMJyMzYHihe+NZPKvCr7yGrTG9gVFwdgv5Ihvuk+BsP0u0yCmJtSDIYZXpHTNGMOq125oMTgnS0tjc2vY/kPjlTOrzSWoYaI4coadfmVB2MSkR4WGQWg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> |
Series |
Add AMD Secure Nested Paging (SEV-SNP) Hypervisor Support
|
expand
|
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 69b57e8f0a7f..f5fcf6c33583 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -58,6 +58,9 @@ module_param_named(sev_es, sev_es_enabled, bool, 0444); #define sev_es_enabled false #endif /* CONFIG_KVM_AMD_SEV */ +/* enable/disable SEV-SNP support */ +static bool sev_snp_enabled; + #define AP_RESET_HOLD_NONE 0 #define AP_RESET_HOLD_NAE_EVENT 1 #define AP_RESET_HOLD_MSR_PROTO 2 @@ -2169,6 +2172,7 @@ void __init sev_hardware_setup(void) { #ifdef CONFIG_KVM_AMD_SEV unsigned int eax, ebx, ecx, edx, sev_asid_count, sev_es_asid_count; + bool sev_snp_supported = false; bool sev_es_supported = false; bool sev_supported = false; @@ -2248,12 +2252,16 @@ void __init sev_hardware_setup(void) if (misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count)) goto out; - pr_info("SEV-ES supported: %u ASIDs\n", sev_es_asid_count); sev_es_supported = true; + sev_snp_supported = sev_snp_enabled && cpu_feature_enabled(X86_FEATURE_SEV_SNP); + + pr_info("SEV-ES %ssupported: %u ASIDs\n", + sev_snp_supported ? "and SEV-SNP " : "", sev_es_asid_count); out: sev_enabled = sev_supported; sev_es_enabled = sev_es_supported; + sev_snp_enabled = sev_snp_supported; #endif } diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index e45b54e95495..6974d63c84f9 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -77,6 +77,7 @@ enum { struct kvm_sev_info { bool active; /* SEV enabled guest */ bool es_active; /* SEV-ES enabled guest */ + bool snp_active; /* SEV-SNP enabled guest */ unsigned int asid; /* ASID used for this guest */ unsigned int handle; /* SEV firmware handle */ int fd; /* SEV device fd */ @@ -346,6 +347,13 @@ static __always_inline bool sev_es_guest(struct kvm *kvm) #endif } +static __always_inline bool sev_snp_guest(struct kvm *kvm) +{ + struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; + + return sev_es_guest(kvm) && sev->snp_active; +} + static inline void vmcb_mark_all_dirty(struct vmcb *vmcb) { vmcb->control.clean = 0;