From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.83]) by mx.groups.io with SMTP id smtpd.web11.10861.1591363698311548995 for ; Fri, 05 Jun 2020 06:28:18 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=3ewvw7XT; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.243.83, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T5qyzq31llTHIAjZ0zSOx5u2O6ZmsVplX/ZdqBC6Rr2W3HGDRP1v2svnRrqViftNcI3kLSM6uFMgl1aPjTHKrg+6OvEidL8h6CJoP5Y0QLTj2mO9CEz8lIFTgn3p9dm2zHkYKf8Ar+nKKJXK1wgn8PZ+Imi/59lqBYbBW5OsTWSU8zfKw+1M1V+tbl4p9dz9u++7hBtZE+Yjq4fx1+2ZV35+6lJ6AYhHG/+q4eTCOOhKaOw+LFoGqBC4Flls516FOZ4ydwhClZLoJgwyGcpBNtMHAzQcITH3BVpp3nm6AN9ZLiggE+rShE4eDi81MSSapFC0EcbF2y6BKZON0mCrXA== 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=bKLmBEpVm5kbuOWEVTI6r9Ip9p20j09xkGx7FrGkS1c=; b=I9x45jraoyk7DkSXIwtBG+QrJ0F7GMswA1JYk4CxfclO2cWUbcUgZmimoP+jKOGsN7i34SXjw3DBhPoM881KvDI1Rd4TITot2tvTkemMr3pydnQYS8ZQW56IKBcBPN040R8rlRl3s1VAAC1Q0X0ddt0qX2cb9Gv6kNMalQgWq4WYsITym3TjPkTs+fTbU2BkgHDfEesM7R0fiBxqjZAcpR2AN3k1MwMJCWSXN+wzIvfeg2p1D/fgs9PwVQTWJCvdFuN41C5tGOLxwSp9F+DiX8aouh0VE89G1xhQVFlfOFxwf7cgQANcL1rxeXd3QDyiVrOR/bF3l67wP2W2JvebIA== 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=bKLmBEpVm5kbuOWEVTI6r9Ip9p20j09xkGx7FrGkS1c=; b=3ewvw7XT0nXqtRkHEZNCN5SpiWnyGycg9GEaZu+tM8joyPtMBfvNRcBqF7prFQiiiH3hEWjP9uT98pkBFUrdopmu9cmy8oIVLiE/8jVqFoVvawLAZbYsPrwyeeJ2EdQb+E8XBw0gHRKiZBwoHFK/Nf44KwpP7G5J5uLf/pzVPyI= 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 DM5PR12MB1354.namprd12.prod.outlook.com (2603:10b6:3:7a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.20; Fri, 5 Jun 2020 13:28:17 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4ce1:9947:9681:c8b1]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4ce1:9947:9681:c8b1%10]) with mapi id 15.20.3066.019; Fri, 5 Jun 2020 13:28:17 +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 v9 28/46] OvmfPkg: Add support to perform SEV-ES initialization Date: Fri, 5 Jun 2020 08:27:19 -0500 Message-Id: <23f5b65be63fa98f190e4fc06da90d4bf27ff2d9.1591363657.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: DM5PR19CA0060.namprd19.prod.outlook.com (2603:10b6:3:116::22) 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 DM5PR19CA0060.namprd19.prod.outlook.com (2603:10b6:3:116::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Fri, 5 Jun 2020 13:28:16 +0000 X-Mailer: git-send-email 2.27.0 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 1966c2d0-b526-4acf-7c77-08d809544e27 X-MS-TrafficTypeDiagnostic: DM5PR12MB1354: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-Forefront-PRVS: 0425A67DEF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RZXFwmh5cO3ESA+Deq2jDZ+mQNjdqcveOBsXW4bLDmuAAW2cSvWKYAWDg/sAhuU50wKBsag5pknCkzXycZuZ5wQF9dAedXGGQnkaeThvpZIut7cOuCIUxF4DI6T4Ac/vYKSu6rKS9EW1E5Cc/wKcoCPe7WuH96n1L0WU4Fm78Cy1rCi0oMZiv/mgFVWWT8l02p17KspJpZIHHqtrkRAK5u1pDW64stfH8ZbvzQpA0z20VnJqjVoU/58aQ834lZbSW8igWIB1W739lE01so0pHsAuPvKBm709+eGgK6Y/anfQ44KtyC+Cpb/6BM7b3c4zN6lze8vTe4y3hbIDvceM28lrvjqT4KZbmaOlnQTOWiSB6r4tpVyeNm5t6q8/d62JkLD8YHWEDAYQwdRdTOGJ8N71zSeEhbXWDwz7nBRQyoUZChNgFde9k3Nb8dEFoH74pDAseYIAGNGUWCDsKsZlGg== 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;SFTY:;SFS:(4636009)(346002)(39860400002)(376002)(366004)(396003)(136003)(52116002)(26005)(316002)(19627235002)(7696005)(54906003)(6486002)(478600001)(956004)(16526019)(86362001)(4326008)(36756003)(2616005)(966005)(6916009)(2906002)(8936002)(5660300002)(8676002)(66476007)(66946007)(66556008)(186003)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: tNTTwS64qSTZsVRFLPi2/PgPztGjlMuzwuIang/779p37VQT+qtUcx4NxrzVxLhTHwZ8fFJVuyGFzCnq4fE87eB2osB+RfNccOWeUZJ24+x09oetwK0qVGZ37eYHEDGJOZ0xX5GcvtXlXJdxHcH63KtWV9KlhxZORKn5xRatqzjjLruKT9hb3xHjrqIo9ovpPm+Ue39FJDChypkfvCE+J83Fptx7KLzZO6GjDmBDg5CmJVD5dgUprr3HKW1JZifvZDpbHeE1GVy5f2WKV4zH0n2yPU4dj41RX3ZZt+8PHIqQyV9AfElyW0srwhAXXyustToRyS6jUVg2jyn0aBI8DSoALqEYbGqpVVeJI+pLjucNX5k7p+N7lOWsbEv36+cbr88MQS0WZ9fEgsbwnehvrB/KuFOl5BsBYa3Tl2/RSZ6pa1Yfeu60xbFqt33psdjC5CZaj6Oe5TzYXOZdX7pUYTg/1W4jqNYRH1EdjGsVaBo= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1966c2d0-b526-4acf-7c77-08d809544e27 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2020 13:28:16.8817 (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: wT1xsurnK2WYTlfGAM7cfqK7YcsaIm++AMwp4Kly3kcfVrPe7uwuw3Zx7vKelMMAQBwFHHIF1koekxz2aDgzQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1354 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain 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 7d7297aa1cd8..b289260c1f2d 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -610,6 +610,9 @@ [PcdsDynamicDefault] # Set memory encryption mask=0D gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0=0D =0D + # Set SEV-ES defaults=0D + gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled|0=0D +=0D !if $(SMM_REQUIRE) =3D=3D TRUE=0D gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8=0D gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase|FALSE=0D diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index c85e988372ec..00faf5036670 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -622,6 +622,9 @@ [PcdsDynamicDefault] # Set memory encryption mask=0D gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0=0D =0D + # Set SEV-ES defaults=0D + gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled|0=0D +=0D !if $(SMM_REQUIRE) =3D=3D TRUE=0D gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8=0D gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase|FALSE=0D diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index b5f3859420d0..58671828c5fe 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -620,6 +620,9 @@ [PcdsDynamicDefault] # Set memory encryption mask=0D gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0=0D =0D + # Set SEV-ES defaults=0D + gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled|0=0D +=0D !if $(SMM_REQUIRE) =3D=3D TRUE=0D gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8=0D gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase|FALSE=0D 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=0D gUefiCpuPkgTokenSpaceGuid.PcdCpuBootLogicalProcessorNumber=0D gUefiCpuPkgTokenSpaceGuid.PcdCpuApStackSize=0D + gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled=0D =0D [FixedPcd]=0D gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress=0D 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 @@ =0D #include "Platform.h"=0D =0D +/**=0D +=0D + Initialize SEV-ES support if running as an SEV-ES guest.=0D +=0D + **/=0D +STATIC=0D +VOID=0D +AmdSevEsInitialize (=0D + VOID=0D + )=0D +{=0D + RETURN_STATUS PcdStatus;=0D +=0D + if (!MemEncryptSevEsIsEnabled ()) {=0D + return;=0D + }=0D +=0D + PcdStatus =3D PcdSetBoolS (PcdSevEsIsEnabled, TRUE);=0D + ASSERT_RETURN_ERROR (PcdStatus);=0D +}=0D +=0D /**=0D =0D Function checks if SEV support is available, if present then it sets=0D @@ -103,4 +124,9 @@ AmdSevInitialize ( );=0D }=0D }=0D +=0D + //=0D + // Check and perform SEV-ES initialization if required.=0D + //=0D + AmdSevEsInitialize ();=0D }=0D --=20 2.27.0