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.43]) by mx.groups.io with SMTP id smtpd.web12.19842.1602864586509193855 for ; Fri, 16 Oct 2020 09:09:46 -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=k/CcCdJR; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.94.43, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EED3AVW3pU+TrDkaMeSORot7bZzFD0X28caEuD6SH6KPlFebxgkKhoMJ536WkN002U812Y1rojOLbKJ31OYQSzYts62/HeVbCHRCPyhwqzqHTCXHLWLSBE1TPkp7+qP3gNqSNPd0yYqHuUju1g0n2H5TqfnidmRd3el611QplGSNnrWpnwJAd+lXDY8OjEaeCxXbbyY3T08A+t6e3Kg+ryOz1ByCl1k5NfBP+bsNDz05dbdISWlK4q62zNZ6kjbs/HyGXUukbYWjZYphhYT5zkK3kGHWycAjqTXwafsrjgC5hu+zzVZaKngUNZ8A+u4gmU9OR77iUIB9ZMsZ7/45aA== 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=OMtKKF/5m7m7orLLIxLAlWfqpPgXOiq6LFtA2KYdmyA=; b=OgFYFH44Uf2z7TVYIUe1GnvlmL8blJRPizuTSp9KO141SH0gBZbBNMkJboIgdWcnBK3ZRjyqvfYWpZDb36+eF6fhZrPRO4Q3H55ZfaE1v/HO78GsK+H3fjm31pv6a//ZJr0Kb2pRJ/hGWqMYUKtKmSH69dsF16aTEyoTQ/DADpH978aDc6Miog1SMDc5oN1qPfJA72qHxHNkb/4CwlSBCYdfSN/LIbtWgO8jOCf0YBGsrPBMEtWinO2qCyfAcox7feD6TdCzQCx7U60fNG9dnH5Qn8UlB5OMu8N5keDSNLpM3LcKkyr3mTXzx4qKuAMbhScgZ2hIdG1RE5yEQ7DBbA== 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=OMtKKF/5m7m7orLLIxLAlWfqpPgXOiq6LFtA2KYdmyA=; b=k/CcCdJRVjhCoOgvYABu18eVKQluKOHTYoQY0osZ/7N7RTobDprqIVrpSOt07llgEeCelj856vG4cpLZ1CBWt6t8CpucbeC+HQQpN/LbXSUgC6RAe9ipAIsYgnZrWNp6hb6ILtyCyK2qTbE213cExjnnzo0CLydm1AXJ4RYX6C4= 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 DM6PR12MB4926.namprd12.prod.outlook.com (2603:10b6:5:1bb::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.20; Fri, 16 Oct 2020 16:09:45 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4d88:9239:2419:7348]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4d88:9239:2419:7348%2]) with mapi id 15.20.3455.030; Fri, 16 Oct 2020 16:09:45 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io CC: Brijesh Singh , Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar Subject: [PATCH v2 02/11] UefiCpuPkg/VmgExitLib: Add interfaces to set/read GHCB ValidBitmap bits Date: Fri, 16 Oct 2020 11:09:08 -0500 Message-ID: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM6PR02CA0085.namprd02.prod.outlook.com (2603:10b6:5:1f4::26) 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 DM6PR02CA0085.namprd02.prod.outlook.com (2603:10b6:5:1f4::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21 via Frontend Transport; Fri, 16 Oct 2020 16:09:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e3642e7c-5e31-40e5-cbe9-08d871ede5ca X-MS-TrafficTypeDiagnostic: DM6PR12MB4926: 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: U6nL5p+mCK9/L6ze6aewcbjkRLFKqC2vnEZd180tKZYQkXQp0AYhLhRhvDwwH4F48xnloftYm9T3PHZyhvoGzvni226RNxKsFgEtEsovN3s8SE0kO9yXb2M1w2MDwPyqU1/mOpUW0bd1MWBeu7ekPJXWjTlJlfYbAOpAtnDgqIb4JhMs3J1swjDCGSX99dX39GuTWe31hXQFLpUvA0aa812ehXpgAQtLnKd3V3e6FdgUGOCKJkTVgRQLJz+jB0vUc+iWLhZCN4HnaIkXfsC7o9IZUi8e3LJBi2wJeNYidiumcTL7X8Pk7gt3Jx3O2NCvOIf9USm+HfKwJoIC+jNAoEtCPme49cjZ2swfVtAJLq8T68bmjwIOqyPJkGzjuPFjUQZYxjLKCOqyJGhen7G+5FZJRJlTUI04G0HPAjZdCssT9ITgIfTqHRwZ4W3GZPBkUdT2Y46xdUnqeArLAm5rIA== 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)(39860400002)(136003)(396003)(376002)(366004)(346002)(7696005)(52116002)(83380400001)(66556008)(66476007)(86362001)(66946007)(36756003)(4326008)(2906002)(316002)(6666004)(54906003)(6486002)(34490700002)(5660300002)(6916009)(26005)(956004)(2616005)(16526019)(478600001)(8936002)(966005)(8676002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: s9PY1fGjfApGHX/z5dQyFyYbuOWqD9eG9CiXPJZDKIWv9HuTrdixu5QNjDaW/v0p3FAQU1/BPCXKNaZ9eqvbhbMROP6Q0cbecHQtTTFu0LfzRyL7gOTbCidRxvVd1pvHAT2jpo2rR0ESXo49bJtwdvDLlrenFiiq4Amw+gH6Ew/rVbHZKPCsL1if/ZPRRjK2T4aC3vG5yHtTlAHghYcHPz7yoZROyZZWP50sIQc19B9TcrB+R8xfpa444rQmvzdK6mIZYosib+NKVzvJTJcqH+K3k2rpaJabbokGAP3cAhKP9t7cLnrcA1U3ds7VCPsJ9/Boeczqs8rOThca2ZAsQ1Ie8YUu94uDKaeygDBV+kzttUeBQlOsc6krTnS4+ZI37TXBD1Tm2MW5vf6AUwgaXpIKZ/IJ2OEGzOfbzlzfmjLohuuKmSxaHsDd/pI0Zx7NAIQl8ggNQLCymH/cYav2ar/tFxoIF8bIf0nea485o3e7unH79JYjslogSUH3aWxIFDC5iaQ//erTZbbECKkDx5Wa5TMKsdg2ansb8CIv/0fwbAsp3ACnuk8NgS4fAD/lEiVLQJPyZBCmvnoVd7KR2iA3UWf78EfR4k3KEPMOnCxplTkNzzGEA0WG6UE4E8XwENf1PDsxKOhx1SQG/4lDqA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: e3642e7c-5e31-40e5-cbe9-08d871ede5ca X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2020 16:09:45.1504 (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: y2GvXnlkMXJUy5YewFTPCJpORle7OJ/ZM/owUTK3lY9b5ly9fQCxhuO3QlB437J8+pVqD58sSe3uZYyoyAbGCg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4926 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 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..ba5ea024839e 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_QWORD_OFFSET 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 vald in the GHCB + @retval FALSE Offset is not marked valid in the GHCB + +**/ +BOOLEAN +EFIAPI +VmgIsOffsetValid ( + IN GHCB *Ghcb, + IN GHCB_QWORD_OFFSET Offset + ); + /** Handle a #VC exception. =20 diff --git a/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c b/UefiCpuPk= g/Library/VmgExitLibNull/VmgExitLibNull.c index bb265e1700d2..b000232c472e 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_QWORD_OFFSET 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 vald in the GHCB + @retval FALSE Offset is not marked valid in the GHCB + +**/ +BOOLEAN +EFIAPI +VmgIsOffsetValid ( + IN GHCB *Ghcb, + IN GHCB_QWORD_OFFSET Offset + ) +{ + return FALSE; +} + /** Handle a #VC exception. =20 --=20 2.28.0