From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 518CD7803D1 for ; Fri, 26 Jan 2024 22:13:51 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=aFehOlIDwB3KMYP0g4AulPqSzaQXmWMqEgFSJP3nrmY=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1706307230; v=1; b=fE/zi8F1gEmrj6Pubc53Dxd4N730me4IyhaTRGJpJoHRVS6386GzguwUa4lv92MldvddoGIj ttCKmX0KglacJF2VH70fuvREKV9x5PPSjNknpYqXRwDFmWtKM40rmXz2offZPDjpLfk2UNJRgqN vT3GBPSC/EOmuGWh0RDWa/b4= X-Received: by 127.0.0.2 with SMTP id iALNYY7687511x3O1PwsWQXJ; Fri, 26 Jan 2024 14:13:50 -0800 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.73]) by mx.groups.io with SMTP id smtpd.web10.2855.1706307229312568291 for ; Fri, 26 Jan 2024 14:13:49 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BoGZO3W9n/N0NTTutAOs0YHlp8dCz+WKaWSdR1go5US8QTJT9zphKQy+360NiIjxTv5XMfPnzUFNh2B5brf32IcKjS6YYvzdDV04hBdHJvI5UCo3/qTIuPOBbBJobPCHynMcnYHi0N7PpP8ZIugz6noiUUSGzJAB7TJTYYQI4XYBYp3w7MeV/s3NLNvASy6+WmzEvmoIe/yJeXlNPj3v0FzpEM2IIWru1RibCk0eq6osX//vGoylQLrf+y7JPIUpqH9cnmLyYdRxTmM7dDpZriY+botZraYXLhrVCEeQZzx1Kw1oAM+uXOJQyUWWr82W5nFM3fXLn/TrBRPXOJluaQ== 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=e2MgcVKnqXK1HFPr7nmqQQAlS0LT9tXRdRh53cYfo58=; b=ToOZ/TnMKyyvR6MAjpAyzwHaSJ6DInyw5nTo2okgRzGwmcP1HBkAfpPujsDh+2B1YN70pUgdDPtpiRRmx98BAAkosUJXvRJna23fusJzbS7NvNV7CMdRt3U2YkiJ+eQQkQpUfSQP1+mZ4omC+9uB0r1eB7rkruP62q19Dr+X4dQjUeq3QMU+00P/jKtIhxD1qpebzBZ56u831gG5m562YpsWzWCnqXLwRvX1dExppYnkPbKrGwSnOvQ2xulF9YEWi+EpSfJ8G7+1YwqqQ9mp1RO94g4y0Hb077MQWeUQJDK+N5Lj3UBA0pOyn07Lj12JGqtZZe2lTgEpCpO9uHt4Ug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io 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 (0) X-Received: from CY5PR17CA0027.namprd17.prod.outlook.com (2603:10b6:930:17::26) by PH8PR12MB7351.namprd12.prod.outlook.com (2603:10b6:510:215::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27; Fri, 26 Jan 2024 22:13:45 +0000 X-Received: from CY4PEPF0000E9CE.namprd03.prod.outlook.com (2603:10b6:930:17:cafe::db) by CY5PR17CA0027.outlook.office365.com (2603:10b6:930:17::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.27 via Frontend Transport; Fri, 26 Jan 2024 22:13:45 +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 X-Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9CE.mail.protection.outlook.com (10.167.241.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7228.16 via Frontend Transport; Fri, 26 Jan 2024 22:13:44 +0000 X-Received: from tlendack-t1.amdoffice.net (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.34; Fri, 26 Jan 2024 16:13:43 -0600 From: "Lendacky, Thomas via groups.io" To: CC: Ard Biesheuvel , Erdem Aktas , Gerd Hoffmann , Jiewen Yao , Laszlo Ersek , Liming Gao , Michael D Kinney , Min Xu , Zhiguang Liu , "Rahul Kumar" , Ray Ni , Michael Roth Subject: [edk2-devel] [PATCH 02/16] MdePkg/Register/Amd: Define the SVSM related information Date: Fri, 26 Jan 2024 16:13:01 -0600 Message-ID: <8c14a9ce8e25bd5e0fed2c6f758be8ee674dd83e.1706307195.git.thomas.lendacky@amd.com> In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9CE:EE_|PH8PR12MB7351:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a498237-cd15-4aab-8ae3-08dc1ebc0ff8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: C2LpSpEqACszatfHCjs8w84Jv9kOSwLMBgTBumrL1Y2+fHHU8SpmJMEWkMQTjfza1HSa1Ccah+sPZEo1sPO2L9mHDcHnpfLslDKoTbYuK7KTP+TdQHUVFPkEGW1MCrew4kwNtz3pGc/ZmnTSgUQ2RP78wAAEzBv5cZsRRSBr2fgkucmYEZuqCtKY3LLohaKfg0usT4YhHTKLkuxP+qAyRUC1ymOXPAdtpXxRhblTV3DJmPErzBcJ6OHYq8CXwrPgCdPcIA4W8arv/2vVGAj+JzgPP7s0r0ZpQcltY7Yc4otJW6w5xbodRd4GP93DZcNh+1NBjU3LNMy5YepQXsJ9u+UGDAa+Bpdx9h3ZGv924N+eBIFJuWK+8fjbPVgzO0dY1JK3qXUiNWxSsxyo69uAnsh17agxaJfTtoojnRNm9SH6jWZICIYdRSDuqSCFnBoYb2Cu9bSE85YaYtQYfrYemaSxjI7fs9ATmhF9cbBlpFLsyzVexPLG73J8lgPjmIn25wcO2WnQ9oAkdm5t4seFPCddtaLZjdEGkwPBqgG7aZ+NoFPQ76HEvaUeTFbD0Xuwfb86gcV1wpthANwBY4Q1dkG9kRwQncLQvzvRudtxZYnaLa4WS2JB23EGPJ1clvYk+YUdI80u+epuaVZZYaLCWu0RpoBRHrRGEZ/wSh3tcMUk62Jo7MASSdw3y8YT62M10i9J2KfVPdSV66D6foQEKqZf4Lf8hjQqp8tX4RUsA1pNhUIDJvlT0/ceUYFJ9W4H X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 22:13:44.9149 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0a498237-cd15-4aab-8ae3-08dc1ebc0ff8 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: CY4PEPF0000E9CE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7351 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,thomas.lendacky@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: Dzrzp76huawJGAXm5shYrsqLx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="fE/zi8F1"; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4654 The Secure VM Service Module specification defines the interfaces needed to allow multi-VMPL level execution of an SEV-SNP guest. Define the SVSM related structures for the SVSM Calling Area as well as the SVSM CAA MSR. The SVSM CAA MSR is an MSR register that is reserved for software use and will not be implemented in hardware. Signed-off-by: Tom Lendacky --- MdePkg/Include/Register/Amd/Fam17Msr.h | 19 +++- MdePkg/Include/Register/Amd/Msr.h | 3 +- MdePkg/Include/Register/Amd/Svsm.h | 101 ++++++++++++++++++++ MdePkg/Include/Register/Amd/SvsmMsr.h | 35 +++++++ 4 files changed, 156 insertions(+), 2 deletions(-) diff --git a/MdePkg/Include/Register/Amd/Fam17Msr.h b/MdePkg/Include/Regist= er/Amd/Fam17Msr.h index bb4e143e2456..f2d5ccb39dc7 100644 --- a/MdePkg/Include/Register/Amd/Fam17Msr.h +++ b/MdePkg/Include/Register/Amd/Fam17Msr.h @@ -6,7 +6,7 @@ returned is a single 32-bit or 64-bit value, then a data structure is no= t provided for that MSR. =20 - Copyright (c) 2017, Advanced Micro Devices. All rights reserved.
+ Copyright (c) 2017 - 2024, Advanced Micro Devices. All rights reserved.<= BR> SPDX-License-Identifier: BSD-2-Clause-Patent =20 @par Specification Reference: @@ -71,9 +71,24 @@ typedef union { UINT32 ErrorCode; } SnpPageStateChangeResponse; =20 + struct { + UINT64 Function : 12; + UINT64 Reserved1 : 20; + UINT64 Vmpl : 8; + UINT64 Reserved2 : 56; + } SnpVmplRequest; + + struct { + UINT32 Function : 12; + UINT32 Reserved : 20; + UINT32 ErrorCode; + } SnpVmplResponse; + VOID *Ghcb; =20 UINT64 GhcbPhysicalAddress; + + UINT64 Uint64; } MSR_SEV_ES_GHCB_REGISTER; =20 #define GHCB_INFO_SEV_INFO 1 @@ -84,6 +99,8 @@ typedef union { #define GHCB_INFO_GHCB_GPA_REGISTER_RESPONSE 19 #define GHCB_INFO_SNP_PAGE_STATE_CHANGE_REQUEST 20 #define GHCB_INFO_SNP_PAGE_STATE_CHANGE_RESPONSE 21 +#define GHCB_INFO_SNP_VMPL_REQUEST 22 +#define GHCB_INFO_SNP_VMPL_RESPONSE 23 #define GHCB_HYPERVISOR_FEATURES_REQUEST 128 #define GHCB_HYPERVISOR_FEATURES_RESPONSE 129 #define GHCB_INFO_TERMINATE_REQUEST 256 diff --git a/MdePkg/Include/Register/Amd/Msr.h b/MdePkg/Include/Register/Am= d/Msr.h index 084eb892cdd9..04a3cbeb4315 100644 --- a/MdePkg/Include/Register/Amd/Msr.h +++ b/MdePkg/Include/Register/Amd/Msr.h @@ -6,7 +6,7 @@ returned is a single 32-bit or 64-bit value, then a data structure is no= t provided for that MSR. =20 - Copyright (c) 2017 - 2019, Advanced Micro Devices. All rights reserved.<= BR> + Copyright (c) 2017 - 2024, Advanced Micro Devices. All rights reserved.<= BR> SPDX-License-Identifier: BSD-2-Clause-Patent =20 @par Specification Reference: @@ -19,5 +19,6 @@ =20 #include #include +#include =20 #endif diff --git a/MdePkg/Include/Register/Amd/Svsm.h b/MdePkg/Include/Register/A= md/Svsm.h new file mode 100644 index 000000000000..9a989f803107 --- /dev/null +++ b/MdePkg/Include/Register/Amd/Svsm.h @@ -0,0 +1,101 @@ +/** @file + Secure VM Service Module (SVSM) Definition. + + Provides data types allowing an SEV-SNP guest to interact with the SVSM. + + Copyright (C) 2024, Advanced Micro Devices, Inc. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Specification Reference: + Secure VM Service Module Specification + +**/ + +#ifndef SVSM_H_ +#define SVSM_H_ + +#include +#include +#include + +// +// The SVSM definitions are part of the SNP Secrets Page: +// An SVSM is considered present if the SvsmSize field is non-zero. +// +typedef PACKED struct { + UINT8 Reserved1[320]; + + UINT64 SvsmBase; + UINT64 SvsmSize; + UINT64 SvsmCaa; + UINT32 SvsmMaxVersion; + UINT8 SvsmGuestVmpl; + UINT8 Reserved2[3]; +} SVSM_INFORMATION; + +typedef PACKED struct { + UINT8 SvsmCallPending; + UINT8 SvsmMemAvailable; + UINT8 Reserved1[6]; + + // + // The remainder of the CAA 4KB area can be used for argument + // passing to the SVSM. + // + UINT8 SvsmBuffer[SIZE_4KB - 8]; +} SVSM_CAA; + +#define SVSM_SUCCESS 0x00000000 +#define SVSM_ERR_INCOMPLETE 0x80000000 +#define SVSM_ERR_UNSUPPORTED_PROTOCOL 0x80000001 +#define SVSM_ERR_UNSUPPORTED_CALL 0x80000002 +#define SVSM_ERR_INVALID_ADDRESS 0x80000003 +#define SVSM_ERR_INVALID_FORMAT 0x80000004 +#define SVSM_ERR_INVALID_PARAMETER 0x80000005 +#define SVSM_ERR_INVALID_REQUEST 0x80000006 +#define SVSM_ERR_BUSY 0x80000007 + +#define SVSM_ERR_PVALIDATE_FAIL_INPUT 0x80001001 +#define SVSM_ERR_PVALIDATE_FAIL_SIZE_MISMATCH 0x80001006 +#define SVSM_ERR_PVALIDATE_FAIL_NO_CHANGE 0x80001010 + +typedef PACKED struct { + UINT16 Entries; + UINT16 Next; + + UINT8 Reserved[4]; +} SVSM_PVALIDATE_HEADER; + +typedef union { + struct { + UINT64 PageSize : 2; + UINT64 Action : 1; + UINT64 IgnoreCf : 1; + UINT64 Reserved_2 : 8; + UINT64 Address : 52; + } Bits; + UINT64 Uint64; +} SVSM_PVALIDATE_ENTRY; + +typedef PACKED struct { + SVSM_PVALIDATE_HEADER Header; + SVSM_PVALIDATE_ENTRY Entry[]; +} SVSM_PVALIDATE_REQUEST; + +#define SVSM_PVALIDATE_MAX_ENTRY \ + ((sizeof (((SVSM_CAA *)0)->SvsmBuffer) - sizeof (SVSM_PVALIDATE_HEADER))= / sizeof (SVSM_PVALIDATE_ENTRY)) + +typedef union { + SVSM_PVALIDATE_REQUEST PvalidateRequest; +} SVSM_REQUEST; + +typedef union { + struct { + UINT32 CallId; + UINT32 Protocol; + } Id; + + UINT64 Uint64; +} SVSM_FUNCTION; + +#endif diff --git a/MdePkg/Include/Register/Amd/SvsmMsr.h b/MdePkg/Include/Registe= r/Amd/SvsmMsr.h new file mode 100644 index 000000000000..9e7fca880ba5 --- /dev/null +++ b/MdePkg/Include/Register/Amd/SvsmMsr.h @@ -0,0 +1,35 @@ +/** @file + MSR Definitions. + + Provides defines for Machine Specific Registers(MSR) indexes. Data struc= tures + are provided for MSRs that contain one or more bit fields. If the MSR v= alue + returned is a single 32-bit or 64-bit value, then a data structure is no= t + provided for that MSR. + + Copyright (c) 2024, Advanced Micro Devices. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef SVSM_MSR_H_ +#define SVSM_MSR_H_ + +/** + Secure VM Service Module CAA register + +**/ +#define MSR_SVSM_CAA 0xc001f000 + +/** + MSR information returned for #MSR_SVSM_CAA +**/ +typedef union { + struct { + UINT32 Lower32Bits; + UINT32 Upper32Bits; + } Bits; + + UINT64 Uint64; +} MSR_SVSM_CAA_REGISTER; + +#endif --=20 2.42.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114628): https://edk2.groups.io/g/devel/message/114628 Mute This Topic: https://groups.io/mt/103986439/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-