From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web12.964.1589925117656726354 for ; Tue, 19 May 2020 14:51:58 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=MypXNC5c; spf=none, err=SPF record not found (domain: amd.com, ip: , mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iOohnXNO7Y8dwfWy9UiYrYGGaJefQFvaNvl7FvhKwXOl4kuUsgpTSBV4c0lR8JIesxltNG/TEsrqs2EyvHQgBw5zM9mSyjJ8mxoNAvTZJD6Q8eTo7lEjGZOu7H/M6vjGF8LLFb3zonFLh1i7YYXNXJBjChaT0gWr0tgiMJtKfK0hRngchFGBV7qnl2Nn/lJ+qFENrr+J+cXcBIpg+4lmmgDk40oS7z0wT7aIv6nDD4K59GJBJZt6THHpLEFNYGwml/9s17yv7WshDoyjGZpL1UOn0Eey8diM9L1XWrru4ZjLQnLAycgj6oYBOQA/k1dqo+ReSfgaAVf8cINnBhOWgQ== 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=rII2G9ok5sqgs6xoyidfXKZD9xj4WEtq+2F2wiUv75w=; b=nEnGVgQmGpVguxIIrmumLC9/vmC4FGj34eubr6lNl+uycQ1v8H36bG0boJMTo0kTFNdZyDqxRPomNWu/UetgRZMJ/2RNOJ39MeyB5X6E0CjubIU/Da60gUn53DNGsnTFoTciHI8vKLPO9KcyHsnqjn0jpn9nQ0NSQQrqbfxnHQ1T1SyqWL2ddq4CqF4e4Yw1Ltp1zIuCosT4r2B8pE0e00CkeJh40YXTlq+6GidazlKq1GmAmSGG+/VgUgCJgE2uOqEQ78SlC7JAlsPAc5fa2J0YwRtOxE7n1/RGNomEZ9GUey6HjlwwYQ1YkiOeIhsO/lxg18i5iB7uvQJDfq/jPw== 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=rII2G9ok5sqgs6xoyidfXKZD9xj4WEtq+2F2wiUv75w=; b=MypXNC5cHROPN/Dzp4sNrN3CZJCQlCLR2e572nQA80U1jlZaL6n5mSy7YS6D1TNHarT6NuiVw9RwzHceHxpVhLljiOrF/1vcXUIcCUZn/MIxybLMk8xjleieVk8zLEUIcHI04LPqQzruUmnM76WFqn+mTM8E+IcmeWpIg2z40Zc= 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 DM5PR12MB2504.namprd12.prod.outlook.com (2603:10b6:4:b5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.20; Tue, 19 May 2020 21:51:57 +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.3000.034; Tue, 19 May 2020 21:51:57 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io Cc: Jordan Justen , Laszlo Ersek , Ard Biesheuvel , Michael D Kinney , Liming Gao , Eric Dong , Ray Ni , Brijesh Singh Subject: [PATCH v8 28/46] OvmfPkg: Add support to perform SEV-ES initialization Date: Tue, 19 May 2020 16:50:56 -0500 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: DM6PR11CA0048.namprd11.prod.outlook.com (2603:10b6:5:14c::25) 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 DM6PR11CA0048.namprd11.prod.outlook.com (2603:10b6:5:14c::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.25 via Frontend Transport; Tue, 19 May 2020 21:51:56 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [165.204.77.1] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 13d09e77-dad9-4d51-6297-08d7fc3eda08 X-MS-TrafficTypeDiagnostic: DM5PR12MB2504: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-Forefront-PRVS: 040866B734 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4IIGMGXXzpriVg28J1gmUR1c0YI7j4OLIgBZ8Z9tnE1QXu/kF2mzHXWwnxYZ08HNvZZ5vVMq46EPu3qM4ZdIHFWMiCSHEJVvCmjGawNjhb0rmLhdfKcZk5GEfEAjzMtqLp7T4FW5eyy/IOQmKBfSD6tZUxB97KEXU1X9f4WVHkHXQLUoNpsHRadDJY6oyGgVWO/rolRQQWMgmJ1W8h4CEmlBUPKg+8dS20AUdyzHtc54nsBYAMRyXUihVO9ts8tdkdFmS34qRAAgQfYZSNGrMrctaX3B7UQT5PQTTk5z/k0yrBwsz0e5WP2HTdvX1HkD5x3pN9e9n2WO762v2qPwkWT1DUC8qA2aDwJvwt2UZRlTtax1OM+7nkljHqanJlTdzzijLiOQ5dIxPn4AU7+ogwCbUV9HNIhFM+6RN+A0pi1ZehUiN2imsxkLIiX6BY0ss9Yips8jKz9KBXMcXWPDTfH41Gg6JmFm45l9yrAGvQdxefhZ+5cFdFElmSWWSSNm3wQ3VOGR0MdmKqOmSw3NTFIA1nYJd1l4tT3vl7iUuW/0Hb8BcJ7x0QOmaoDjYIe145uOYm9XLGDyZ+6+LJzmOg== 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)(376002)(39860400002)(136003)(346002)(396003)(366004)(316002)(86362001)(2906002)(54906003)(7696005)(52116002)(2616005)(956004)(66946007)(66476007)(19627235002)(66556008)(36756003)(26005)(16526019)(186003)(4326008)(8676002)(5660300002)(966005)(6486002)(8936002)(6916009)(478600001)(136400200001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 0N7x857ugnHc5m5c6xdVzY8g/Mhjb9LxT10JfLCRDcjWSr3/U7njkRiigFn3SalgVDApAZyHfusbdA6BsptPV2cyBb+kQg5gHPnsNOdTfh4lIqP7HGpG1GZqjIMpw35S05Pr2Y34VHGCNBnxY+cgbMe9RQQ7lHP9SgQYcjFVIR27GiQZWMiD2j2L4m8PA9fd7LAiIxV5d+Z56yjDJa9jO0KA4EX1vv/V1amK+o6Wj1hA3Xy9sx08Rfp5wcMVMrtoA7Tmzusnr2hKrZDE8mnMw4oCZIa8iM7xtMvKRFCAqHB8rXT5MM9wSgNp541pnr/PiN2VD5BZ0QaZJi+8EKJlQqt236/Z8RKN1oBaZggmJWQ2Cyv2eNB5qO14V+2Zg5PQ8JFN393RZBbtbwWtb9G7rKJPgk/U4/ScGoVBb4HtqkeaeqfoR0WgH7KDFr9JMuLZ2mWeOj/tQ5pp0aR1E6bGVat8eYumObWw9vXfG/YEZZA= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 13d09e77-dad9-4d51-6297-08d7fc3eda08 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 May 2020 21:51:57.3938 (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: wOgK3ECUXeE7iY8jpZDKATupwBHnVXSPiRc6jwFXYISh0aVkvAnSjfpsctdDqXd+JbFxNgJqoHEGOSePCrN9XQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB2504 Content-Type: text/plain BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198 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 gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0 + # Set SEV-ES defaults + gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled|0 + !if $(SMM_REQUIRE) == TRUE gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8 gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase|FALSE 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 gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0 + # Set SEV-ES defaults + gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled|0 + !if $(SMM_REQUIRE) == TRUE gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8 gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase|FALSE 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 gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0 + # Set SEV-ES defaults + gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled|0 + !if $(SMM_REQUIRE) == TRUE gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8 gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase|FALSE diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.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 [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 @@ #include "Platform.h" +/** + + Initialize SEV-ES support if running as an SEV-ES guest. + + **/ +STATIC +VOID +AmdSevEsInitialize ( + VOID + ) +{ + RETURN_STATUS PcdStatus; + + if (!MemEncryptSevEsIsEnabled ()) { + return; + } + + PcdStatus = PcdSetBoolS (PcdSevEsIsEnabled, TRUE); + ASSERT_RETURN_ERROR (PcdStatus); +} + /** 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 (); } -- 2.17.1