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.56]) by mx.groups.io with SMTP id smtpd.web11.1662.1580857348756254860 for ; Tue, 04 Feb 2020 15:02:29 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=NcSshRnk; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.92.56, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MebPRVLy073S4jS/AeTNZIlRFziKKQJNWv1ECmO6YWHS5GLDUga6B7RnTBoZIGIxsQ2sD8Hd7cvEigLcsgnrl1RzevSCygrErWkdas1tZCvJv+wS7c6OYFisFYyBKvJ5pxoVhmhHUr/c2kS88HVgsLDiXjtGuQL0foTP0+V27uEYuRFi1pHPbwEpex6b1NKHLMcWsXqdNoZYa9NUd1t1oQ40jlKK9xIFJptnKSVwWRWjmt4pRzu0HymIf66pHn2KOea8rZashug1Cbb+EdpOx0ohTl8hMwb6T0b3jqR0yJFx+i8hYevJkvBuxS3Fi0XyfkYiIzt7LvlIHxJzq/Dk8g== 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=h+xNPODanO7j1iZmxSMCO8bZvuy3/0IuXghAhpEzVlM=; b=KMFxsJYMBGnCbXn5UaIK0c7qN/zzKjo0ASmII2UNMFCfql44drTAdGVi3KTwZtoARJX1kvyLMetONL3CfTkS22cPlFx8ak1gNy/cKomtG6Ur0L8NOmP/MwrPAn358y4AO8PtHbRPeWFUQXSUVZI8sNm3pkHjrEx1v70/uaZ+u1uetGm5f3kz9vJP6shf1sEa07X1P3Z009FLlZ1NMoZRjcfPDLt1iXNXBBgIGoRRYcpj44Bu/TaH16f10mCudx7MFSu6zvlfokdwnn1gB05c+UBKFzZtH0+/vf2WIv/gS1OLDTNMFqFGyiy/ay/VRhFbmtiG/niwnBepb+9hzSA5fA== 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=h+xNPODanO7j1iZmxSMCO8bZvuy3/0IuXghAhpEzVlM=; b=NcSshRnkDacKI0xvymt08OC7Qd9eD3iSOtYXlMxtNrUr6G70KeQb7C7EhGu+WqbPxe5OinVRZzDhfUU8EZdRbdloaEnYtBDYTsl2dFJUMb2AjT8MvXoslaFXPq/3NG8E7nu6f5od7vt3Ln4UlNsLM3kBa4hAUhBtE1nYT1Sw3M8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Thomas.Lendacky@amd.com; Received: from DM6PR12MB3163.namprd12.prod.outlook.com (20.179.71.154) by DM6PR12MB3930.namprd12.prod.outlook.com (10.255.174.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.29; Tue, 4 Feb 2020 23:02:27 +0000 Received: from DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::a0cd:463:f444:c270]) by DM6PR12MB3163.namprd12.prod.outlook.com ([fe80::a0cd:463:f444:c270%7]) with mapi id 15.20.2707.020; Tue, 4 Feb 2020 23:02:27 +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 v4 24/40] OvmfPkg: Add support to perform SEV-ES initialization Date: Tue, 4 Feb 2020 17:01:28 -0600 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) To DM6PR12MB3163.namprd12.prod.outlook.com (2603:10b6:5:15e::26) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 Received: from tlendack-t1.amd.com (165.204.77.1) by SN6PR16CA0062.namprd16.prod.outlook.com (2603:10b6:805:ca::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2686.32 via Frontend Transport; Tue, 4 Feb 2020 23:02:26 +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: cc329d91-d1fb-4f64-7efa-08d7a9c64df0 X-MS-TrafficTypeDiagnostic: DM6PR12MB3930:|DM6PR12MB3930: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-Forefront-PRVS: 03030B9493 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4636009)(39860400002)(366004)(376002)(136003)(396003)(346002)(199004)(189003)(4326008)(478600001)(6916009)(81156014)(2616005)(956004)(81166006)(8676002)(966005)(316002)(54906003)(19627235002)(2906002)(6486002)(66476007)(66556008)(52116002)(7696005)(186003)(26005)(16526019)(5660300002)(86362001)(36756003)(66946007)(8936002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM6PR12MB3930;H:DM6PR12MB3163.namprd12.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ySyIHP2jfpCcuuYpOTllQXHdc3Ged0OEKmivd+eECGq5cgZfNksCb6Ie16pSqqAj5B0bCTYfUA3Yh8WJFc5kRVDzZUseNxcRuxL4+ucqNK0jHNMpTWXzgg/WwxSvIA/2YnTXQTkzTBNDkjUScOmzsYCPNY8jnrA+l/Vc+unPcZtKdNRCkitXau2FZfp2PN+2ZFCSpKPorFLBjHKcJJ6m0wFN/g3JFz098u8fAZFq6onbrwg4cRBnf7OWSzITg5A882TUPRl0c4hkI+kBJ6Q0X9sh4jJdGLgu26rW52DnBjNMn+Zuj5N1rhdf9ntB4+GvJJm+tMM0cCXdJE9QhH3iPDHfU40pUzRzb8VwPTApNpY/5vVbLRLe+jz5FU7ET4uCwHH+rbFIthKF4wJgZ943rpjsOK4LSgRtgj5etwL33L48qsTpo2QH3Oa4y/CuvbIqFWNtxRzqtG/lZ+7vUejrX0ISwV8tEDszZysVmtjh49HwFxSFM5wdkj3a7tttYQvQdiYX1IRf+ZnvavM0CZhZoQ== X-MS-Exchange-AntiSpam-MessageData: lp3gSSkSXXIqHcui+0OWQsMDJMhCvlqOI3Zt6RAwDnwZ+Kz0g/fg8YeOwyXrO1LE7yIgiuWV1bl1jcQ4KrrEHg9s+hXvt+is7ErrxBXciQNcDhQQ6nZRzqYVNmkjx3t4bzaMm1hICW5ydPAd2rH53g== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc329d91-d1fb-4f64-7efa-08d7a9c64df0 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2020 23:02:27.4628 (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: gsyRBH6sQGNGnO6le+3PWWpn19N/mGGZbTAVQC44ykQBTlF59PXPkqQ3NIym+NUpiW1qXuJk1W4jj346PfjSSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3930 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 41ec761e3f17..6642f2b008dc 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -568,6 +568,9 @@ [PcdsDynamicDefault] # Set memory encryption mask gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0 + # Set SEV-ES defaults + gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled|0 + !if $(SMM_REQUIRE) == TRUE gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8 gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01 diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 41cc3eec3757..66589b2228c4 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -580,6 +580,9 @@ [PcdsDynamicDefault] # Set memory encryption mask gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0 + # Set SEV-ES defaults + gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled|0 + !if $(SMM_REQUIRE) == TRUE gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8 gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01 diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 46a679a0073e..2e5c30d5c631 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -579,6 +579,9 @@ [PcdsDynamicDefault] # Set memory encryption mask gEfiMdeModulePkgTokenSpaceGuid.PcdPteMemoryEncryptionAddressOrMask|0x0 + # Set SEV-ES defaults + gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled|0 + !if $(SMM_REQUIRE) == TRUE gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes|8 gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x01 diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf index 30eaebdfae63..8af236a5c23e 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -100,6 +100,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 2ae8126ccf8a..c12aea46d94e 100644 --- a/OvmfPkg/PlatformPei/AmdSev.c +++ b/OvmfPkg/PlatformPei/AmdSev.c @@ -19,6 +19,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 @@ -89,4 +110,9 @@ AmdSevInitialize ( EfiBootServicesData // MemoryType ); } + + // + // Check and perform SEV-ES initialization if required. + // + AmdSevEsInitialize (); } -- 2.17.1