From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.58]) by mx.groups.io with SMTP id smtpd.web11.611.1604685225041539904 for ; Fri, 06 Nov 2020 09:53:45 -0800 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=ZryC+hM8; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.223.58, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FYs2KWRPoNvcuJjImfIaGdurb4sqOz4JQIpgqiPKYjHlSfJHTUYkjzLgcRVl2IlR+br7oHE1BNOj8aIrXTa6ITf6jqfVHVw/S1BndIgsCvpr7MEJWSMI7c8DE1IIwgA2BG748JE4xyOyKjeTxXku8j5L/O6/DgbEPV2Z8pGD7RuJEkZ8PIqgdKOuWwwI2Km1JCQsn2nAm296Z2PfuUapxOtjlKaccyoRsPXVhu9jn2If43EF4fDMWY3QnH9nrJHvv/qVTQEzR8NBKvNWju3+ZhgV52IMQWHG0/ytMeB0r3TZBi77ljXGZ1xJRKV8soz2gIp8lJH4KqL8fyUDl2R/UQ== 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=QSYt5XmuWly9/+653sq8UUvsfvq2lp0+rBHevq0KQM8=; b=DMt006VNd+Rf7nNRTiH4e04hpdhyMdmW/GLug1nTMPd6EmGKaKht4hltGoIo+0jBdA7Y/rOg7HLigoQQkCNVr7PTqIutd1Xz44E37gSv4PScj/VMFE+HJMnwvGBE5i7Yf/UgegGVIzronT9UITefcdSHJqfslV7I035xI+n/ohWHxwtUdSDRAbvu4Eql0pg8xVbfndTr6VO8xdJiKmleDE0TRidaV1Pw+5dgU/2MKNwzyyLQWygbPhi+m5S1Bi2OrLwYgPG3RDNQps8xxShLVVdVYVXFcake8tGboEu2Xx5Z5JUHwF1gy98yZtjEPdmqkyzC5QiYmEEH1tFv/HqjMA== 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=QSYt5XmuWly9/+653sq8UUvsfvq2lp0+rBHevq0KQM8=; b=ZryC+hM8BLwVNL42pxKe2i07xd5HsctUduqeSnwxFqk5jqtxsA80UXvjfsgEZXxvHusEAR+fcKA4/V/TMduDGprHeDsKZdaLLsVscUE8Lo80gYFLidFNWX9UDaPgzcSyi4rvXQxbSrnJhF45tOGnfyqsZZWsESR8FtZVzK0Fe5k= 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 DM6PR12MB4385.namprd12.prod.outlook.com (2603:10b6:5:2a6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3541.21; Fri, 6 Nov 2020 17:53:43 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::e442:c052:8a2c:5fba]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::e442:c052:8a2c:5fba%6]) with mapi id 15.20.3499.032; Fri, 6 Nov 2020 17:53:43 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io CC: Brijesh Singh , Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar Subject: [PATCH v4 02/11] UefiCpuPkg/VmgExitLib: Add interfaces to set/read GHCB ValidBitmap bits Date: Fri, 6 Nov 2020 11:53:04 -0600 Message-ID: <0bcb2373f8c6e0171ae277d3d7c2eb284621355e.1604685192.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR11CA0024.namprd11.prod.outlook.com (2603:10b6:3:115::34) 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 DM5PR11CA0024.namprd11.prod.outlook.com (2603:10b6:3:115::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.32 via Frontend Transport; Fri, 6 Nov 2020 17:53:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 5544c0f8-5142-466d-f58f-08d8827ce700 X-MS-TrafficTypeDiagnostic: DM6PR12MB4385: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PZSvXp+WS+/6pb39e5fVV4ytmfZ24CLkKQ1LZx1gusMopyfCBP/syTAQloh3oDk0RLOaCY4tM60bya22OqnwzGsV6c8ZgHRB4MGWsHNzeAYdcV2p0EWC3OOb7rO5jqKTS6MouQ+0V9ppDf9dQ6AbSj1Fbb5FZ6zFd3XHK03q8UlJyypg4p9GTU58QmMCbeiKatoqwISTFKtvDIEZLqm0PzDrxh5Y9h6zbTwEA5EncZXkfV2SIiS88FDq7PuPjwB0CkX15frJmxbmOyIIjJk1ha5yxvWlJf1xPWR59qEXTspfLYbZ1wQkUsbymKEpn79yMjC+o5TXNQP3/cSdn8AETY9M3xAP3xP75d1xBWJyCQlXBSxnZ4C/Hpuv54Zx0FO68tkvRGgizU5xycYKXEnmOg== 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;SFS:(4636009)(366004)(376002)(136003)(346002)(396003)(39860400002)(316002)(966005)(86362001)(83380400001)(52116002)(7696005)(66946007)(5660300002)(6916009)(6666004)(8936002)(36756003)(8676002)(478600001)(66476007)(16526019)(26005)(2906002)(186003)(66556008)(6486002)(4326008)(54906003)(956004)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: qnONTq97Me5FYgouaMY2Dq6icglkknSTMvTJSd5qpTzK55qOnxrO52FZN2XD29wVd2/duY55HSwWC53vMfxlDQRfEUd10BQwqdq+x6aXck8ejA/N1B2DmxWh1zq7/7soVKgl0yfjiqUA0IKVJ8W0bov1iqaWyEuhMIPld2c0NHu/xisVb1Um619qXG96/A1KtgbGHYz9fMn52JQa2pvbNDGjBVLR9ZbqgIZ7qPSTNbQVnM6qbTgaNJaSBc3W9WzhmTp5P6Iyvw5Udmc0nibf+pRW7kKuWIYd+hPu7Gz7GApGkf/t/NHoibWQio6FxgsyNFhtoQ94LN6hAZzDUx2oSXXkaREiLJGJz+E+OLf5RBcgWymVNqn5peQNZQsQcYqz94Z9NnCQNL9/PYsL5ppYBuWWeN570pjCCr2CctKB3t4TTs6AEbbgYAg39Z5kJN7pP3y5KS3Hnbg5kxnZssfYZ8/rBJ6feU/Q8Ninmg2gs43SYPNv9GgXsaFqsOnSe8gk4cSoBl1O+lJMtJ2pwVyuFVw21qne9zN8LRIRHxua1hZhwz3BfjE+DHmfp/g8VArkzMwwBIlkxNbPUPOjEF1iIvzV/zkWokWuScK0fQ94AQDDvBk/q+SXt07Vu7PXqtDDkFgIP3LUc9OWNnKFPT/Xtw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5544c0f8-5142-466d-f58f-08d8827ce700 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2020 17:53:43.8169 (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: IuOGSkcrDRb9INf+C6QVOB2Js9MgIHzmg9vD/sr/1OT7n1o5FzsSDqtoeC28feDLz3lUJMiLTpat4FxtbMjn1Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4385 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable From: Tom Lendacky BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3008 In upcoming patches, the setting of the bits in the GHCB ValidBitmap will be performed in multiple places. In order to reduce code duplication, add an interface, VmgSetOffsetValid(), to VmgExitLib library to perform this function. Also, to keep management of the ValidBitmap within the library, add an inteface, VmgIsOffsetValid(), to return whether the bit in the ValidBitmap is set for a specified offset. The new VmgSetOffsetValid() function is a VOID function and will be an empty function in the VmgExitLibNull implementation of the VmgExitLib library. The new VmgIsOffsetValid() function returns a BOOLEAN to indicate if the offset is valid. This will always return FALSE in the VmgExitLibNull implementation of the VmgExitLib library. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Rahul Kumar Acked-by: Eric Dong Reviewed-by: Laszlo Ersek Signed-off-by: Tom Lendacky --- UefiCpuPkg/Include/Library/VmgExitLib.h | 37 +++++++++++++++++ UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c | 42 ++++++++++++++++++= ++ 2 files changed, 79 insertions(+) diff --git a/UefiCpuPkg/Include/Library/VmgExitLib.h b/UefiCpuPkg/Include/L= ibrary/VmgExitLib.h index 45fc27d35e29..07e8af6450b9 100644 --- a/UefiCpuPkg/Include/Library/VmgExitLib.h +++ b/UefiCpuPkg/Include/Library/VmgExitLib.h @@ -74,6 +74,43 @@ VmgDone ( IN OUT GHCB *Ghcb ); =20 +/** + Marks a specified offset as valid in the GHCB. + + The ValidBitmap area represents the areas of the GHCB that have been mar= ked + valid. Set the bit in ValidBitmap for the input offset. + + @param[in, out] Ghcb A pointer to the GHCB + @param[in] Offset Qword offset in the GHCB to mark valid + +**/ +VOID +EFIAPI +VmgSetOffsetValid ( + IN OUT GHCB *Ghcb, + IN GHCB_REGISTER Offset + ); + +/** + Checks if a specified offset is valid in the GHCB. + + The ValidBitmap area represents the areas of the GHCB that have been mar= ked + valid. Return whether the bit in the ValidBitmap is set for the input of= fset. + + @param[in] Ghcb A pointer to the GHCB + @param[in] Offset Qword offset in the GHCB to mark valid + + @retval TRUE Offset is marked valid in the GHCB + @retval FALSE Offset is not marked valid in the GHCB + +**/ +BOOLEAN +EFIAPI +VmgIsOffsetValid ( + IN GHCB *Ghcb, + IN GHCB_REGISTER Offset + ); + /** Handle a #VC exception. =20 diff --git a/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c b/UefiCpuPk= g/Library/VmgExitLibNull/VmgExitLibNull.c index bb265e1700d2..b47e282aff82 100644 --- a/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c +++ b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c @@ -89,6 +89,48 @@ VmgDone ( { } =20 +/** + Marks a field at the specified offset as valid in the GHCB. + + The ValidBitmap area represents the areas of the GHCB that have been mar= ked + valid. Set the bit in ValidBitmap for the input offset. + + @param[in, out] Ghcb Pointer to the Guest-Hypervisor Communication Bl= ock + @param[in] Offset Qword offset in the GHCB to mark valid + +**/ +VOID +EFIAPI +VmgSetOffsetValid ( + IN OUT GHCB *Ghcb, + IN GHCB_REGISTER Offset + ) +{ +} + +/** + Checks if a specified offset is valid in the GHCB. + + The ValidBitmap area represents the areas of the GHCB that have been mar= ked + valid. Return whether the bit in the ValidBitmap is set for the input of= fset. + + @param[in] Ghcb A pointer to the GHCB + @param[in] Offset Qword offset in the GHCB to mark valid + + @retval TRUE Offset is marked valid in the GHCB + @retval FALSE Offset is not marked valid in the GHCB + +**/ +BOOLEAN +EFIAPI +VmgIsOffsetValid ( + IN GHCB *Ghcb, + IN GHCB_REGISTER Offset + ) +{ + return FALSE; +} + /** Handle a #VC exception. =20 --=20 2.28.0