From nobody Tue Nov 26 22:25:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+46095+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1566301165865810.0927154232714; Tue, 20 Aug 2019 04:39:25 -0700 (PDT) Return-Path: X-Received: from NAM02-SN1-obe.outbound.protection.outlook.com (NAM02-SN1-obe.outbound.protection.outlook.com []) by groups.io with SMTP; Mon, 19 Aug 2019 14:35:56 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AK7NTv7DE255glbdKZz1x9NQVBCI37TIN9ASsVjN7//8yT+k6RPUPnoGKqmbRE4qJQT0zqZt3JGmq4xCsTIR0EHf+tyxLzXyswccQgTeil1SMja3teCnWBr1Lz81uCiu0SeHA05C6nox3M66ixA26zFHZnqEdSjx0ELzS7kthsbFC+i2uky77MN0kcDYIaINQIXKMnFO9uHVulAiFPU9MAUEVl609jrzjT8sbZXRWDToYg1ho5MOG88ECazRItTQ05RqFgLK3fb7bk+mOhgGS3wjV5G9t7MBrxW9PyNvyal84NxpiwU3UupZsK6pfacKAB/OIE1hH3pK0gnkEftyVQ== 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=/4BmvwnvOw4MiD5QKQnHAtv/vlcq4utQ2PAVYs/hUWM=; b=V3fZZBOyP1xXbcGHqJlmxyi1JhbJFiqHmi3iBWFYD0KfR5GItWB+kLJhdmU40qLh751/xTbhADm2OsMHaJT5IZmcMb0dEWwaGDLvxu7Ks9P2OAmHkmw5UqyRwxWJvKjioAz8T1MpSwXDO2WkuP4R/cZDgonT3km1r67KvP9k6kh22v8tCZbCpiv/4sstN5Y3fsgFOTmAKprPS0bNYGfXz6hJECJPWJhV2okGZG1NxO0/ZXlMVEegvyJZCXRfa0siAleBF6s3WsgK40ZUVtGiUGAKslHDB0XZQC8zJvaqa8k30vpCikGUhhsgO9Ryy8EwDYcyvCBtEB0CaqHzv7fvBg== 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 X-Received: from BYAPR12MB3158.namprd12.prod.outlook.com (20.179.92.19) by BYAPR12MB2965.namprd12.prod.outlook.com (20.178.52.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2178.18; Mon, 19 Aug 2019 21:35:50 +0000 X-Received: from BYAPR12MB3158.namprd12.prod.outlook.com ([fe80::39b9:76bd:a491:1f27]) by BYAPR12MB3158.namprd12.prod.outlook.com ([fe80::39b9:76bd:a491:1f27%6]) with mapi id 15.20.2157.022; Mon, 19 Aug 2019 21:35:50 +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 , "Singh, Brijesh" Subject: [edk2-devel] [RFC PATCH 03/28] OvmfPkg/MemEncryptSevLib: Add an SEV-ES guest indicator function Thread-Topic: [RFC PATCH 03/28] OvmfPkg/MemEncryptSevLib: Add an SEV-ES guest indicator function Thread-Index: AQHVVtYSTdja6yIymkmrJ2qBfbMDfw== Date: Mon, 19 Aug 2019 21:35:50 +0000 Message-ID: <245fa1e02ca67ac85174af8e68b1c7a7f5278c81.1566250534.git.thomas.lendacky@amd.com> References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: SN2PR01CA0031.prod.exchangelabs.com (2603:10b6:804:2::41) To BYAPR12MB3158.namprd12.prod.outlook.com (2603:10b6:a03:132::19) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [165.204.77.1] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2d36aee5-36e3-432e-60ca-08d724ed3479 x-ms-office365-filtering-ht: Tenant x-ms-traffictypediagnostic: BYAPR12MB2965: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4125; Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+46095+1787277+3901457@groups.io; helo=web01.groups.io; received-spf: None (protection.outlook.com: amd.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 1pCo3qxgMnISWqRdnS7pwt0EsdJWqErlo+DOfNhY5nVbdp1O/hKaz9KTeQtxY9J7XJrlJ2OKg0Qt8LRdMwy0FEUJrQc9jPJFIdCupH6qjKttWg6QTXPZR9CtlWReREfmEQTLw6FkhTkixW9kmLGw4jSv9ES2FDVcP0wPLeTyAuOFt1LoFO23jxdDvgUrmoRpEB5oPiRgNd4jBMd+qzh8INahFSMd8dCZB3RbzNX05/QmDWuI23FVBrxW6797Vp0jzhWIYYBZ0bAuD/FQMQOHGiLY4r7BOIuWapUD/EmHw1ZJpkBTERl7CaSke3SMJjns56GOgSTzUulCKS0g3d2tHgSJZW/e1yeEmrcVS/xrMXLu9hrhXnGFt8ZODUtxaeZeQ0gEkTqGuAGLDeRtoaf3NwkuyhBCWy8jS8MGfh+ZX60= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d36aee5-36e3-432e-60ca-08d724ed3479 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Aug 2019 21:35:50.4982 (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: IchxSs3aj3nPpL+INvDQdDhpj437peU5Fpp0ras+BWG2r0dSYuHraaIcFFQtovnOIeVYEyfkktTBXpbWdoJieA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2965 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,thomas.lendacky@amd.com Content-Language: en-US Content-ID: <012F2A0456AEB14EBF8834E46A7EFBF0@namprd12.prod.outlook.com> Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1566301165; bh=oWC31QULOusUYa/zXX6DHSEgK4khB5k++5A4cJ6uVlQ=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=Oi11MhlSaFHhlWXTMRxCcpjx8Y+ZOkFDQPfbzkRZt7zZdMGAdHD2zO8+uYlRgIw6TTM gbHQiMFZR/9IVAA2PVPVH5ubVZ55kfXF7xZVc2pFnxDA+Um5Z7mAIFthoQh1hJug7D0rX PWXwgiZz5FsFj8TnEZfgOZpAqj94DjD3FWI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Tom Lendacky Create a function that can be used to determine if the VM is running as an SEV-ES guest. Signed-off-by: Tom Lendacky --- OvmfPkg/Include/Library/MemEncryptSevLib.h | 12 +++ .../MemEncryptSevLibInternal.c | 77 ++++++++++++------- 2 files changed, 62 insertions(+), 27 deletions(-) diff --git a/OvmfPkg/Include/Library/MemEncryptSevLib.h b/OvmfPkg/Include/L= ibrary/MemEncryptSevLib.h index 64dd6977b0f8..a50a0de9c870 100644 --- a/OvmfPkg/Include/Library/MemEncryptSevLib.h +++ b/OvmfPkg/Include/Library/MemEncryptSevLib.h @@ -13,6 +13,18 @@ =20 #include =20 +/** + Returns a boolean to indicate whether SEV-ES is enabled + + @retval TRUE SEV-ES is enabled + @retval FALSE SEV-ES is not enabled +**/ +BOOLEAN +EFIAPI +MemEncryptSevEsIsEnabled ( + VOID + ); + /** Returns a boolean to indicate whether SEV is enabled =20 diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/MemEncryptSevLibInternal.= c b/OvmfPkg/Library/BaseMemEncryptSevLib/MemEncryptSevLibInternal.c index 96a66e373f11..9c1d68e017fe 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/MemEncryptSevLibInternal.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/MemEncryptSevLibInternal.c @@ -20,19 +20,17 @@ #include =20 STATIC BOOLEAN mSevStatus =3D FALSE; +STATIC BOOLEAN mSevEsStatus =3D FALSE; STATIC BOOLEAN mSevStatusChecked =3D FALSE; =20 /** =20 - Returns a boolean to indicate whether SEV is enabled - - @retval TRUE SEV is enabled - @retval FALSE SEV is not enabled + Reads and sets the status of SEV features **/ STATIC -BOOLEAN +VOID EFIAPI -InternalMemEncryptSevIsEnabled ( +InternalMemEncryptSevStatus ( VOID ) { @@ -56,32 +54,57 @@ InternalMemEncryptSevIsEnabled ( // Msr.Uint32 =3D AsmReadMsr32 (MSR_SEV_STATUS); if (Msr.Bits.SevBit) { - return TRUE; + mSevStatus =3D TRUE; + } + + if (Eax.Bits.SevEsBit) { + // + // Check MSR_0xC0010131 Bit 1 (Sev-Es Enabled) + // + if (Msr.Bits.SevEsBit) { + mSevEsStatus =3D TRUE; + } } } } =20 - return FALSE; -} - -/** - Returns a boolean to indicate whether SEV is enabled - - @retval TRUE SEV is enabled - @retval FALSE SEV is not enabled -**/ -BOOLEAN -EFIAPI -MemEncryptSevIsEnabled ( - VOID - ) -{ - if (mSevStatusChecked) { - return mSevStatus; - } - - mSevStatus =3D InternalMemEncryptSevIsEnabled(); mSevStatusChecked =3D TRUE; +} + +/** + Returns a boolean to indicate whether SEV-ES is enabled + + @retval TRUE SEV-ES is enabled + @retval FALSE SEV-ES is not enabled +**/ +BOOLEAN +EFIAPI +MemEncryptSevEsIsEnabled ( + VOID + ) +{ + if (!mSevStatusChecked) { + InternalMemEncryptSevStatus(); + } + + return mSevEsStatus; +} + +/** + Returns a boolean to indicate whether SEV is enabled + + @retval TRUE SEV is enabled + @retval FALSE SEV is not enabled +**/ +BOOLEAN +EFIAPI +MemEncryptSevIsEnabled ( + VOID + ) +{ + if (!mSevStatusChecked) { + InternalMemEncryptSevStatus(); + } =20 return mSevStatus; } --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#46095): https://edk2.groups.io/g/devel/message/46095 Mute This Topic: https://groups.io/mt/32966268/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-