From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.55]) by mx.groups.io with SMTP id smtpd.web10.9838.1597325245366202105 for ; Thu, 13 Aug 2020 06:27:25 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=lY6nf97g; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.92.55, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RYPMcsUpaAJVT88UrLbDsZedFC1ljh1xOOrZ2L9MnhiQpy1JDO1Un732R6rF0JnJ7eWFN9XWSnKfa84nhjsM3pFVykJmLQSsq1uZ+8RXoGoV1dGlDn4zzx0e3cv2ZMbI7s5blFog+x11BkEs6pi/B7HNZY9kIZudfhSabb0IkSxbokwPrsGttl4xQRIoKwUlwNNLgULc76taV1WGV92IUasJVjOLWhE86kJbVA7qUIrBH/9eTNQuK0+Yy+HTZIpN+AhFBSJMEpsWTgkX4d0RzZZ5Sh7LJHBrziDKv58x2NyjCY0zxUlFjBdvjMXarKglus68ngsk5kpOvLJYdr0f8Q== 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-SenderADCheck; bh=HzQbgETOBWbOt02L/6/R1+JQC+TYX8/WkkvrsNeeigo=; b=gRVEAlA9gbJzJrh73FBYzOWZVYAH4FocpibCylA9eAODJSuLvUjzw1CeA2/8Jb2PBO7WMWyRtf7PbNKXLlJrxHSjXWO3rEJqqFwaYqcXnQTaNrLPcvSi8efhuEdFiYVeJqt2lPnkP7gV7wMRXSVPoVZtO5cr+i8zZojkTH79ijzSUZrdw5r7zEKMc7s1i5CK+3ykQ4rsWVT/IXlJUcPOnIseOYU/210IoS6aAfb9QIQO+aBefpsDnKgIVOz/9c24SJ8g0Oqc900B1Ekr9hriCZ6oTBMEL8nBz0uPqzujr7gq9nU/+Pt6Fiq/GCAcEJCc6ti9yAnalXoj1yC7bfDYgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HzQbgETOBWbOt02L/6/R1+JQC+TYX8/WkkvrsNeeigo=; b=lY6nf97gNDggQIIy8yY3eiThuTTZPyj8envq6oJbrkb4QktuHB+Qz2wAEYDLd1D8u6oiwwmDHkd2SY/65nLObwwzvIBtVzSsOUCYHHJsFbWrPABxy9+wbdR/gL7WxXXvCD4UoK3tYUWmVVUupU9er4eEW87NTdIt4L+KK/VeqXs= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=amd.com; Received: from DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) by DM6PR12MB4220.namprd12.prod.outlook.com (2603:10b6:5:21d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.15; Thu, 13 Aug 2020 13:27:24 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::25ec:e6ba:197c:4eb0]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::25ec:e6ba:197c:4eb0%8]) with mapi id 15.20.3261.025; Thu, 13 Aug 2020 13:27:23 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io CC: Brijesh Singh , Ard Biesheuvel , Eric Dong , Jordan Justen , Laszlo Ersek , Liming Gao , Michael D Kinney , Ray Ni Subject: [PATCH v15 28/46] OvmfPkg: Add support to perform SEV-ES initialization Date: Thu, 13 Aug 2020 08:23:15 -0500 Message-ID: <6472ae0d35fa9a78df4393235d7ad7d05e099baa.1597325013.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: X-ClientProxiedBy: DM6PR06CA0058.namprd06.prod.outlook.com (2603:10b6:5:54::35) To DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tlendack-t1.amd.com (165.204.77.1) by DM6PR06CA0058.namprd06.prod.outlook.com (2603:10b6:5:54::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.15 via Frontend Transport; Thu, 13 Aug 2020 13:27:23 +0000 X-Mailer: git-send-email 2.28.0 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 49491744-a396-445e-207d-08d83f8c9cfb X-MS-TrafficTypeDiagnostic: DM6PR12MB4220: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZxY28K9BRzVldc5XM5vt4PBObhl68P8JmrtfG/WezwzIK3GEzH42KVSZpJjuXrPxsVBprQQ2xcME4NwMGjvos0y4a2c1k8M/WsJ6jcYENh4qCqYyqhp9EYZ9pg6pKqlRXa17XrwfzJw9WjsnpDkOrz8DVwB8mLRNCZZbQZvs2n67psigPyOJhKDV4tzEa5t+s1O60v9np5S7LLSM+OQkL4eDnI2d3bbLyzmuv5sDTxUI8293AbPFfRX2orF14AOqm/CHYpSKVB0K0/8OmvUPgnkKBFTHLukwdtIy/+W+scClqsUntGDWKY0hTM5eGHJ79bxj7PWF9de5JdC94IjYmzHTHUByejH9uLSQ/xAaII3CbXS4hpC3JBtHiHVPtDWZnO6gAF/caG7Ewetm9cXxlfe5GWgtNDxph2MAFwOc1pesKeZw4T4HaM8ZXm/6yUibXNherNVyf5npy/ZF5oNKFg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR12MB1355.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(136003)(396003)(346002)(39860400002)(376002)(2906002)(956004)(36756003)(66556008)(54906003)(86362001)(966005)(2616005)(6666004)(6916009)(478600001)(8676002)(66476007)(316002)(52116002)(6486002)(7696005)(8936002)(66946007)(19627235002)(5660300002)(186003)(4326008)(16526019)(26005)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: cjd5zlrwNlDT6wUQQSMdM+YsBSafet0wmuwZq3k4M54wE4ylEtgk8nhV8e4VgMnhGFHGSH0n+C7mxj03Kxnk+9XQ3bWBHIbn1ENxyPnj0vI+pDsJOGmBWW247O/JQHXL29Pbp0UHzlMB/cToBv0lkcuvvN7pTaeV9ShkXIVkZ1KafL32DP9MugWg43//yKsCqNFNb7AB07daJbydc14CXgyTsIv39grlfPpxa5sZxvc5XLmSIOn2/4nvMxyrI+1Ms3LFTJVPMOJEyk8AhddCbNTqxQrcTw3o2dmkJGQui6USixF3+Lp0h0MBbWnho+jq3LjzQFn97k1vJ+KLmd1Dr2+eDY+D+YU12dAUq8SCDemLQL2SqaXc0HngIUEuwc/SztGY++9WO74hOQq30cGA1MwtrjBkNOr2ecWpT/kZ0t+QTYmUqMVj1DGQ8mWHqQi/h2zu7loY5TKAMCPWFbziW3PIqGys7Rq9Itoii8RPVGPfWEzv1siISni3aHL8uqGBCqQHchOrxOMq8+Ka9F03ykaMlaDC30Cip0HAvC/frP/45GI4GNnbFuBF2XDPz7e9NddCJvwgzkgcb5QopsBJ8mA9w4ow8uNx9DXNSWLVTp7uacVeK60iThpX8wP41G/KH86yDSjnc0nhrLLXniaR/A== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49491744-a396-445e-207d-08d83f8c9cfb X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2020 13:27:23.8148 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: arc846LZ43vHhwJZbee3KOrQxISMG4XqoMj9Yn7EEkKN24ojliNatB5q889U+cBChTKA+POmQ2jJG5mTqjwjJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4220 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable From: Tom Lendacky BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2198 When SEV-ES is enabled, then SEV is also enabled. Add support to the SEV initialization function to also check for SEV-ES being enabled, and if enabled, set the SEV-ES enabled PCD (PcdSevEsIsEnabled). Cc: Jordan Justen Cc: Laszlo Ersek Cc: Ard Biesheuvel Reviewed-by: Laszlo Ersek Signed-off-by: Tom Lendacky --- OvmfPkg/OvmfPkgIa32.dsc | 3 +++ OvmfPkg/OvmfPkgIa32X64.dsc | 3 +++ OvmfPkg/OvmfPkgX64.dsc | 3 +++ OvmfPkg/PlatformPei/PlatformPei.inf | 1 + OvmfPkg/PlatformPei/AmdSev.c | 26 ++++++++++++++++++++ 5 files changed, 36 insertions(+) diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index c57bba1ba197..f84f23f250ef 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -607,6 +607,9 @@ [PcdsDynamicDefault] # Set memory encryption mask gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0 =20 + # Set SEV-ES defaults + gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled|0 + !if $(SMM_REQUIRE) =3D=3D TRUE gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8 gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase|FALSE diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 22e930b12b9b..a66abccf8266 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -619,6 +619,9 @@ [PcdsDynamicDefault] # Set memory encryption mask gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0 =20 + # Set SEV-ES defaults + gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled|0 + !if $(SMM_REQUIRE) =3D=3D TRUE gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8 gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase|FALSE diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 60be5eae3d2b..2a8975fd3d29 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -617,6 +617,9 @@ [PcdsDynamicDefault] # Set memory encryption mask gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0 =20 + # Set SEV-ES defaults + gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled|0 + !if $(SMM_REQUIRE) =3D=3D TRUE gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8 gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase|FALSE diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/Plat= formPei.inf index ff397b3ee9d7..00feb96c9308 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -103,6 +103,7 @@ [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize + gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled =20 [FixedPcd] gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress diff --git a/OvmfPkg/PlatformPei/AmdSev.c b/OvmfPkg/PlatformPei/AmdSev.c index e484f4b311fe..4dc5340caa7a 100644 --- a/OvmfPkg/PlatformPei/AmdSev.c +++ b/OvmfPkg/PlatformPei/AmdSev.c @@ -21,6 +21,27 @@ =20 #include "Platform.h" =20 +/** + + Initialize SEV-ES support if running as an SEV-ES guest. + + **/ +STATIC +VOID +AmdSevEsInitialize ( + VOID + ) +{ + RETURN_STATUS PcdStatus; + + if (!MemEncryptSevEsIsEnabled ()) { + return; + } + + PcdStatus =3D PcdSetBoolS (PcdSevEsIsEnabled, TRUE); + ASSERT_RETURN_ERROR (PcdStatus); +} + /** =20 Function checks if SEV support is available, if present then it sets @@ -103,4 +124,9 @@ AmdSevInitialize ( ); } } + + // + // Check and perform SEV-ES initialization if required. + // + AmdSevEsInitialize (); } --=20 2.28.0