From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.59]) by mx.groups.io with SMTP id smtpd.web11.4273.1596829413417679354 for ; Fri, 07 Aug 2020 12:43:33 -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=nV9M7m5B; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.94.59, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kO/eoE2acnbCFEOyllrEifsVgSBxEIc44bKlJLM6HSA5WjlTLxd1SHTSSfwnKAmKs1z9qzTMJBiq8glaf+aONIlRpjldwxr9T7QQJP6T8iwBSsbfzsYgIEXcjaSPGbgDLAAEXNlT9zyHkBhKfyjc/0M4llhDoZbQ5ZEnpBA0tWh9saoUS44t8VlBXD/OFT7O+xKDMEN13u4G2QwZEToNthijyht4340bPcnAGz62eeRxnygvrfrvxV2AWTxeJMDf0PNzkHgb/6ZfVFipb0Yy+oNAPWioWdQg46hbkdD6q0lKzxpKh8ORWqTtQxd1k/BUdGSVsZMzEidew0CpumZu0w== 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=tpMCGKkJ/vd5g9S5fco/aQoufjhaVtd6vFQYZt6tvPo=; b=TI6g/eWY0jGBBNuTgFPmkbiX1GxAW3a1PW1IYRGge7q+u1x52JErFFHRYRHom01puho+4PGP27x//gvrgLuORYWNzgSllv1a1VsmkrrQoS3T+tFq3Vo8dwcVy4Wvg3S0dGdTCiGbzODg77PIDg6OEH78H1EXalE/0ApLIGFwOg+ZKRUFv+dvOajROsG5A518bftt8ljeMKglfLaNtq7hWZetaDl9QJIDwHq8FZRop7aJaVJUhnG5Pj89oYQd5tKp22IJMnWsBK3i2K3sJ+omtmOwYR771t1u2tgOgveiRDYi0minPMoKHUTFOhf8hezX2/4HzM4gE33XngXMA3Xurw== 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=tpMCGKkJ/vd5g9S5fco/aQoufjhaVtd6vFQYZt6tvPo=; b=nV9M7m5BpsFx3lGOC3k8laL2lLhS0R6gyKR/EcDnAQPfYc7It2JmhXNNGfWZDrKGt/Kraz5vRGVJRuuVZF/gom64ukj/D8/iYMnSUgjr7RVw6WEfwnqB1ICHImU4lFbEDgA5+isGGclOLUB9frEJERvtd+PhCD9FceZ51judLG8= 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 CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) by CY4PR12MB1798.namprd12.prod.outlook.com (2603:10b6:903:11a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19; Fri, 7 Aug 2020 19:43:32 +0000 Received: from CY4PR12MB1352.namprd12.prod.outlook.com ([fe80::9181:78bf:bf0:702b]) by CY4PR12MB1352.namprd12.prod.outlook.com ([fe80::9181:78bf:bf0:702b%5]) with mapi id 15.20.3239.024; Fri, 7 Aug 2020 19:43:32 +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 v14 28/46] OvmfPkg: Add support to perform SEV-ES initialization Date: Fri, 7 Aug 2020 14:39:13 -0500 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-ClientProxiedBy: SN4PR0801CA0008.namprd08.prod.outlook.com (2603:10b6:803:29::18) To CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) 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 SN4PR0801CA0008.namprd08.prod.outlook.com (2603:10b6:803:29::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.20 via Frontend Transport; Fri, 7 Aug 2020 19:43:30 +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: 8137ddba-476b-4d0a-2a92-08d83b0a2a34 X-MS-TrafficTypeDiagnostic: CY4PR12MB1798: 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: W4dvaDlOR36J3iU9gmFCgPNKlrDbvrIphQaMFeDwT1wsVXXkz6DaxTKFlKfIjE3GnK2S34I55ylirD7Y+sK8VMDCPg67G74TW7ILp0PQUwxAOANMI2mBZXdGZ5nzH7elIJFNA6yVLYqGGiwS4QxMvDXQxwYMYWSYlXR5J6z7Jez0OIeFDfD2m7Dmgj/yIseWYQ6qOCnrzbPASVDyac/c74Ox/MrRDRPVnMFYROneWZsdB6CULX6ySDrPuBZwfr5daK3hgpSfBKzsnCMD2HOudJHx22FiGm31JikkFiFJWOFo2RMKPm4lDcDnHdW1d/CpeyModvpALA2d3rOHR7yXbxh8ZMHXKAnWpE5zljdyobzRBRQgQp1xQmUnPa5sc1yuN5I04F7UZysN36D+zrxhEWTZazlwmwGPxIryI9Cxv/szlFxLeLRakQ7qhLh1ggHYS08E9r9+1T0M1Nm8enwoxw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR12MB1352.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(376002)(136003)(366004)(39860400002)(346002)(396003)(4326008)(19627235002)(66946007)(6486002)(2906002)(66556008)(66476007)(5660300002)(966005)(478600001)(8676002)(7696005)(26005)(8936002)(16526019)(186003)(86362001)(956004)(6916009)(36756003)(2616005)(6666004)(52116002)(316002)(54906003)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: p44qzkq650HbA3pG60ftY4GmRNevynUxA4oTghmfz/Z3LoYLAT6vCdKwMJ5kH10PyjhbS+YFbq0aPGC4KBsO7UXj0BaGVHI9ysVveVX4yy4bwEYY2FW822TgAqcmpXdamwiOcE5P1nCvoxknT4wVRUEm1YwEUKgEfX51XSqIU+GcE9RyvsC/Kqbxi1ECPfw4++dq3vF/MFiQokUVNsJzNxJSnx5gxoomdHPIt4OiQc74/9CA8l3R7MO2NxBfhFWYr1KzzKcbFuHRExVFzNHqDIN3dbbiY8h4x8sDH4af3+z80NAqjVrv8R505lhOi/AD113h4t6wbJJrsVvWSfX50c6biM1j0+GaXkiIO3H9POky4FPDWPIfwxpu1Jy4D9x2CQ2r7AoNKdOIuxZFimk/wUK2PpQE6sdou1GfjogRdwByLqHoy2ivSS2FIvY+9EYGmwjQdMaaWCVI534v+I+bsjmeX4thlGgpQn6Pn4eHkehIbUaiAQ8BWVTLKga4X1FLk6b2tA6SKPlQir0x/tXfDnkY8nz7YUCK6AdHLHeR7Dc0Lq/lv6Ky6pO0V84fHkJe1qDOtYLoUo4CFh9TFHpF25Up1fY2Vnk6y9IRBQWuklNqoqafaPD4ELBsFNfNq4i3qkIszvw5VfhvjuhqN2znPQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8137ddba-476b-4d0a-2a92-08d83b0a2a34 X-MS-Exchange-CrossTenant-AuthSource: CY4PR12MB1352.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2020 19:43:31.9207 (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: XQ2SdVob50zr4J+gAvfAn5XbI07frcl6fgeiPfsH8JjW1ySK6I3VjLwTli/hNdetcnRnL0+nUqCRsQyrCUx42g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1798 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.27.0