Message ID | 20220307213356.2797205-12-brijesh.singh@amd.com (mailing list archive) |
---|---|
State | Deferred, archived |
Headers | show
Return-Path: <platform-driver-x86-owner@kernel.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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB0B0C433EF for <platform-driver-x86@archiver.kernel.org>; Mon, 7 Mar 2022 21:35:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245655AbiCGVf5 (ORCPT <rfc822;platform-driver-x86@archiver.kernel.org>); Mon, 7 Mar 2022 16:35:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245600AbiCGVfn (ORCPT <rfc822;platform-driver-x86@vger.kernel.org>); Mon, 7 Mar 2022 16:35:43 -0500 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2047.outbound.protection.outlook.com [40.107.237.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79F7C70F5F; Mon, 7 Mar 2022 13:34:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=atJ6+Stmb6FxeQsZe1WVsIAMDd+2oakJJtR5/ki+SYHPhsthAwxsdFGO8VDKP+QQOp/tg1d9D0YXWwyClinaBGpKBMJkCXXWoWfe2uo1zMKjYjMx6JjsxmR3Q4JcH3/UJMqBwsf8d0KiVI/T8/I0yKrRHNcGZhHgm/Bdo1SkGKe/eNUw8qsPn/m0CPHPRkpZJeAmZCkI4e/TBQka0JXt6Sap+SA4rYRsRHWJRiPkbHe3i4lyy37YFWpMm95EOuY2N39x92lv9KBPb+N/dglMKGLIn7C6IG/u4Mvi+HSFoLcO4AmFU172amwpjPXsVtA4GStVol9oWstHfu9dKhXM0A== 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=NW12IGctCHQ59PAs+7VbIe+Nhdv+NxvQBr3aNl1R/eU=; b=TCBLGAkkqYm9I7FXqxloxO6tgyF0KLU/W7dxGAL1Xz1Tmi672o0eTqm2s9DAuMNc7soy/VvbbXyFo1wF9uG2gKpZmutxSF+tsO2z1+SPEW14EtFYg8l5U1AJvtTmJudNL32nbcAFgo1LBTlAniS0MRUVPTsCWjkUldF0Hx4l4y6TZu2n9BKW6PRANwPErgVayd3jU3XxBgrfK3pRoF0ZD5scfwiFsoJIl8uftRrzrIvWe5Eh/d1Azgc05NDPrwI+WSgG186u9ie1ieJis2CdsY59Qsq4YosxrMAdsCRYgqXixapfseHfb10jiVrERj+7vnLVtdGRlTBp7OJfm5O9MA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=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=NW12IGctCHQ59PAs+7VbIe+Nhdv+NxvQBr3aNl1R/eU=; b=CteKe0Mc23WTbrq/q2IDtd67hLJIJtfx0xSJv/ieOP9PSJWKGpuMg178dgCALCg5rWiVMqBLmq9rxH7n0mhu7v/tn6bPZtEJMlthXHRW6AB14j91bo+4qDzZZxr8ya+mQUYqm9407Pf5184Dc1mtmvSp8o7LUcoFkQ0B6RmafSc= Received: from BN6PR18CA0001.namprd18.prod.outlook.com (2603:10b6:404:121::11) by CY4PR12MB1575.namprd12.prod.outlook.com (2603:10b6:910:f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.26; Mon, 7 Mar 2022 21:34:39 +0000 Received: from BN8NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:404:121:cafe::31) by BN6PR18CA0001.outlook.office365.com (2603:10b6:404:121::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14 via Frontend Transport; Mon, 7 Mar 2022 21:34:39 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT029.mail.protection.outlook.com (10.13.177.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5038.14 via Frontend Transport; Mon, 7 Mar 2022 21:34:39 +0000 Received: from sbrijesh-desktop.amd.com (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.2375.18; Mon, 7 Mar 2022 15:34:36 -0600 From: Brijesh Singh <brijesh.singh@amd.com> To: <x86@kernel.org>, <linux-kernel@vger.kernel.org>, <kvm@vger.kernel.org>, <linux-efi@vger.kernel.org>, <platform-driver-x86@vger.kernel.org>, <linux-coco@lists.linux.dev>, <linux-mm@kvack.org> CC: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Joerg Roedel <jroedel@suse.de>, Tom Lendacky <thomas.lendacky@amd.com>, "H. Peter Anvin" <hpa@zytor.com>, Ard Biesheuvel <ardb@kernel.org>, Paolo Bonzini <pbonzini@redhat.com>, Sean Christopherson <seanjc@google.com>, "Vitaly Kuznetsov" <vkuznets@redhat.com>, Jim Mattson <jmattson@google.com>, "Andy Lutomirski" <luto@kernel.org>, Dave Hansen <dave.hansen@linux.intel.com>, Sergio Lopez <slp@redhat.com>, Peter Gonda <pgonda@google.com>, "Peter Zijlstra" <peterz@infradead.org>, Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>, David Rientjes <rientjes@google.com>, Dov Murik <dovmurik@linux.ibm.com>, Tobin Feldman-Fitzthum <tobin@ibm.com>, Borislav Petkov <bp@alien8.de>, Michael Roth <michael.roth@amd.com>, Vlastimil Babka <vbabka@suse.cz>, "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>, Andi Kleen <ak@linux.intel.com>, "Dr . David Alan Gilbert" <dgilbert@redhat.com>, <brijesh.ksingh@gmail.com>, <tony.luck@intel.com>, <marcorr@google.com>, <sathyanarayanan.kuppuswamy@linux.intel.com>, Brijesh Singh <brijesh.singh@amd.com>, Venu Busireddy <venu.busireddy@oracle.com> Subject: [PATCH v12 11/46] x86/sev: Save the negotiated GHCB version Date: Mon, 7 Mar 2022 15:33:21 -0600 Message-ID: <20220307213356.2797205-12-brijesh.singh@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307213356.2797205-1-brijesh.singh@amd.com> References: <20220307213356.2797205-1-brijesh.singh@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-Office365-Filtering-Correlation-Id: da8d6c11-80d0-4cb5-4539-08da008248db X-MS-TrafficTypeDiagnostic: CY4PR12MB1575:EE_ X-Microsoft-Antispam-PRVS: <CY4PR12MB1575DC599D3DD26022F2F9E0E5089@CY4PR12MB1575.namprd12.prod.outlook.com> X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uKv3AvFGJjl/eUVLhEnrEoDGIFl5CII3dUDDop+9ZY+WFNaeLl0jjlRZblWcnSA6mJewXDzdq+Q3DIdJ7jcFY1SqNDsmKQTZZvovA0vfJRBYu/R9UF24Ln0oNwkvudwFiP+NQymJjYlI9I0KipzGO7yzxhD+cGJFnaPAgnsgsblbEtKi68VIV+7yUuXsp3nfg38emLgOzyDjEigASn4abZL/wnapL6iP8YYW5928K+i/k6PTB/yjOuFYHcAs985Gz7LmmuTrPZxbM+tkmdDjpZ+lela0jnEUbmGp7A94AOSYEXyAnaaI0YFtvtX6Y0jE46bSc7lgeo/Wu81qOKOBwr6ei5VeJXN1hUp/4jgeFFLVJqfaQ1H6ldE0/0kSiLU9FIO4CfB+hdUyX0dkweyinjXlMb1KQblLRcar27Xy5WXqvDNRdS9cuWDRCwyvD1zNH5FqROggolhGqsKdFxQ+wdS+hKNkWIFizaxetjqWjHkMR9C6nl+4TS34+Ql3EZftrhqAtyznSuMb2bcprktE2zRCcJPPWq+HOTkRjbpsPQzk9IpnXflnMhq+qijdwvzPTo9aKmXLd3ow9NKZVh0VAzheYA5acCm8FUCQvn0OQnzyAZMEgUftD2YnkTJhNUizNBUcGC5COVAy297uU+8VFZpaMLbT9L9O7+9kA3NUNSrlABDhvNHTSxFxAZvJ5GyCWppvxa094dYmKnVywsNduh0W67Abprippy1yz15s10A= 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:(13230001)(4636009)(36840700001)(46966006)(40470700004)(82310400004)(426003)(336012)(83380400001)(8936002)(4326008)(7696005)(508600001)(86362001)(6666004)(1076003)(70586007)(2616005)(70206006)(8676002)(26005)(186003)(16526019)(316002)(110136005)(54906003)(36756003)(47076005)(36860700001)(40460700003)(7406005)(356005)(7416002)(5660300002)(81166007)(44832011)(2906002)(36900700001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2022 21:34:39.3799 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: da8d6c11-80d0-4cb5-4539-08da008248db 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: BN8NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1575 Precedence: bulk List-ID: <platform-driver-x86.vger.kernel.org> X-Mailing-List: platform-driver-x86@vger.kernel.org |
Series |
Add AMD Secure Nested Paging (SEV-SNP) Guest Support
|
expand
|
diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h index ec060c433589..9b9c190e8c3b 100644 --- a/arch/x86/include/asm/sev.h +++ b/arch/x86/include/asm/sev.h @@ -12,7 +12,7 @@ #include <asm/insn.h> #include <asm/sev-common.h> -#define GHCB_PROTO_OUR 0x0001UL +#define GHCB_PROTOCOL_MIN 1ULL #define GHCB_PROTOCOL_MAX 1ULL #define GHCB_DEFAULT_USAGE 0ULL diff --git a/arch/x86/kernel/sev-shared.c b/arch/x86/kernel/sev-shared.c index 2abf8a7d75e5..91105f5a02a8 100644 --- a/arch/x86/kernel/sev-shared.c +++ b/arch/x86/kernel/sev-shared.c @@ -14,6 +14,15 @@ #define has_cpuflag(f) boot_cpu_has(f) #endif +/* + * Since feature negotiation related variables are set early in the boot + * process they must reside in the .data section so as not to be zeroed + * out when the .bss section is later cleared. + * + * GHCB protocol version negotiated with the hypervisor. + */ +static u16 ghcb_version __ro_after_init; + static bool __init sev_es_check_cpu_features(void) { if (!has_cpuflag(X86_FEATURE_RDRAND)) { @@ -51,10 +60,12 @@ static bool sev_es_negotiate_protocol(void) if (GHCB_MSR_INFO(val) != GHCB_MSR_SEV_INFO_RESP) return false; - if (GHCB_MSR_PROTO_MAX(val) < GHCB_PROTO_OUR || - GHCB_MSR_PROTO_MIN(val) > GHCB_PROTO_OUR) + if (GHCB_MSR_PROTO_MAX(val) < GHCB_PROTOCOL_MIN || + GHCB_MSR_PROTO_MIN(val) > GHCB_PROTOCOL_MAX) return false; + ghcb_version = min_t(size_t, GHCB_MSR_PROTO_MAX(val), GHCB_PROTOCOL_MAX); + return true; } @@ -127,7 +138,7 @@ enum es_result sev_es_ghcb_hv_call(struct ghcb *ghcb, bool set_ghcb_msr, u64 exit_info_1, u64 exit_info_2) { /* Fill in protocol and format specifiers */ - ghcb->protocol_version = GHCB_PROTOCOL_MAX; + ghcb->protocol_version = ghcb_version; ghcb->ghcb_usage = GHCB_DEFAULT_USAGE; ghcb_set_sw_exit_code(ghcb, exit_code);