From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.42]) by mx.groups.io with SMTP id smtpd.web11.7269.1592574662945361822 for ; Fri, 19 Jun 2020 06:51:03 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=nFUxXw8i; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.243.42, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BlmqTzyaVmgqtZCJP62LmTbDPakU4ZsNdYcDuSpDI1cljcT2O9zdxSl3gLAOuGTscM+OLwxT07nT9Yo5rUkR0paQXsmSGzZ77Us828czwn7UeDunsDI+pVbkTHb+c+yzHLA9VfE2teR+ZCZMvArB3tmTt55AEJCq7pj3C1bb/5GOY2Jvr5bVn5K7GxQ106STw5XBfMdlGg028sZqQfGtaVavHyjOewnQHOmNa0nwN4epsEq+NoWhZqEvX6UaDLfWzBe3aWnh+gR11PmZx47Nk48Bz8NmIuPLZ9VyUQq/7HBpxRs+/TEd5XQoNY2OyheJAHIk9tcv/uiCiVBQwYJpRg== 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=Vf5hIViddgxinaUK/GxBaRl+kc5pXphZCFWG4C4Q9E8=; b=GLckSLPMTTW8afCrlV6UNJ1CGShiF3CKVyE+jp5DNXuD0NWX26xvTOEfjf5/OvBxd7puZpL3R6cuxaRGFMD3jE3b1vGUKnSvXI6k5ZMo2kVidYBVkRJW05e3Mx1YgzgqaMy0hNHIvRXDrIph95RH4fmtAh5Ez42wW4VfcHfKOjyMBApirMNSaCYSgyiIpC9cHmITeiJXDF7jTm/ZS+dNcHqSiV9TS7Ta0HDwem5yUu5YckTvAmAqjNfVXmYCKFpBdWiEmnwgHYzygES9PNeU9EXlTt6d2eZKYqZaZiFrJYOouaFu27uYlwDchCx1f7DV226D9LO1EhqLlxtgIm4FOA== 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=Vf5hIViddgxinaUK/GxBaRl+kc5pXphZCFWG4C4Q9E8=; b=nFUxXw8iSAOCThvmFzKAWakDndNvUYrwGiqMY1MQtMyFYnAia6LFL/TSm2TemDy+8utt65iAh3AKXazMraJnCITqunFnGyDVb55DPXAMRRNkD7Ll9kUaE56fNKPW1KWyIPug0qZOPs0xK181OqIU90tim/CxzroUpsu07jMcQrw= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=amd.com; Received: from DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) by DM5PR12MB1644.namprd12.prod.outlook.com (2603:10b6:4:f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Fri, 19 Jun 2020 13:51:01 +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.3109.023; Fri, 19 Jun 2020 13:51:01 +0000 Subject: Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library support for VMGEXIT To: devel@edk2.groups.io, eric.dong@intel.com Cc: Brijesh Singh , Ard Biesheuvel , "Justen, Jordan L" , Laszlo Ersek , "Gao, Liming" , "Kinney, Michael D" , "Ni, Ray" References: <79f21141-07c6-d63f-7680-1ef08c53ecec@amd.com> From: "Lendacky, Thomas" Message-ID: <2d5f88ec-b3c4-8beb-dd60-68640f96b0da@amd.com> Date: Fri, 19 Jun 2020 08:50:58 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 In-Reply-To: X-ClientProxiedBy: SN4PR0501CA0089.namprd05.prod.outlook.com (2603:10b6:803:22::27) 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 office-linux.texastahm.com (67.79.209.213) by SN4PR0501CA0089.namprd05.prod.outlook.com (2603:10b6:803:22::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.12 via Frontend Transport; Fri, 19 Jun 2020 13:51:00 +0000 X-Originating-IP: [67.79.209.213] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: d254b1df-1357-476b-260f-08d81457ccfb X-MS-TrafficTypeDiagnostic: DM5PR12MB1644: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-Forefront-PRVS: 0439571D1D X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fHWOXxpmJuwzhe+JR7r/IqHQzC5lLllmIFhFk18STuBV64Xux//sVk6Rlrrk4+71gWTC3dmcqZhG2KnNE93ZkRKXlT5s2+Sx/1y7IAlLnJZLIofmcLE2dytVppXIqMAZG/xRka9ZgHHKIF4cvfJF4KdmjkQvNTOh6zoz4ZmiwxqqPk9yKAPF+qdofFWtxx5A7UogW5PYkELI/9l48QRLVf5X5QTe4oyvfnWjjC2bgFdpjbGOBF+EDz6mWlHin6nZz5Uyg4RflHA6yTFsiPeptunDMqBZl8Z6TPStQdpTdV+Y3dpLLU8Yxg756HXgblN0k1hZi8idIbyxZBKN/4qn3xYFWVWs+73GE4VK3IYjAnQjm9vyytJtL0/Vovean55dy7rTgoUnAdssuH59EablJn6mNbisVk5FJx+RrM6akurxa5jGEloT8r7kwgt90/EVvHrkdA06z2E5u+hCTFcamg== 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)(39860400002)(366004)(396003)(376002)(136003)(346002)(2906002)(26005)(966005)(16526019)(66946007)(66476007)(66556008)(52116002)(30864003)(54906003)(4326008)(5660300002)(6512007)(316002)(186003)(6506007)(53546011)(36756003)(83080400001)(478600001)(2616005)(956004)(83380400001)(31686004)(86362001)(31696002)(8936002)(45080400002)(8676002)(6486002)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: F1uSTKaqd7buf59+hkYzwynlhw1Wa5cnZuhk+ExvQr6UvUlit7AaXgREh88PNIDYny47aEKQQGf5dmwjUxWn0UxHxZjq+ByG7/vsb5TJlUk1zpy/f/WMGQ649lhlJsgqgy3rj9tHB0Ex7aAeOaOFeZ5zoZyeyn0vMlDc9mSmIwAES9VZixjWSwaEeu0kykd0/eQxdh+/p4p/NlzDH4guEtOuX8n8VaPnjKTJOsMkCcxQGNDLp21OJRPJa1zqzV5yPYwdx9miOTZwJuWyPDvp1uei+xyb2nvkBaCMWYC7DHvhpZEe7mmI7HO6l7hNtAUYCgn790aioXhqe+14ed+EKF7KKDJEtBSPRfgPa2h7KECbWTrwfn+HpVpi6Wy2zGyNsb/gaK0sL/pWqRi69a7GZ6++DAkNysVeO16D8ljeRLTeOBaf2MAjvzM0SIM/J9fEcTBMA9FO8kqnB5TJkd+OXmh3ewmqNju6gqAuGgHBgvxzLmGh80nKNKQTT3CRqoyM X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d254b1df-1357-476b-260f-08d81457ccfb X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2020 13:51:01.0115 (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: OUzubX6hJzILmMiMJW4TIKxh+lU+ffZ1AKtwR1hEJc8jQWz8CYxnU35zWyTtxxweFCB/kct+KvKcsTxV6HpykA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1644 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 6/19/20 2:47 AM, Dong, Eric via groups.io wrote: > > >> -----Original Message----- >> From: devel@edk2.groups.io On Behalf Of >> Lendacky, Thomas >> Sent: Thursday, June 18, 2020 10:09 PM >> To: Dong, Eric ; devel@edk2.groups.io >> Cc: Brijesh Singh ; Ard Biesheuvel >> ; Justen, Jordan L ; >> Laszlo Ersek ; Gao, Liming ; >> Kinney, Michael D ; Ni, Ray >> Subject: Re: [edk2-devel] [PATCH v9 08/46] UefiCpuPkg: Implement library >> support for VMGEXIT >> >> On 6/18/20 2:23 AM, Dong, Eric wrote: >>> Hi Tom, >>> >>> When use VS2015 to build this code, it reports below error. Please help to >> fix it. >>> >>> k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: error C2220: warning >>> treated as error - no 'object' file generated >>> k:\edk2\UefiCpuPkg\Include\Library/VmgExitLib.h: warning C4335: Mac >>> file format detected: please convert the source file to either DOS or >>> UNIX format >> >> That is strange... I didn't see this when I ran through the CI. When I do a file >> command against the file it reports: >> >> UefiCpuPkg/Include/Library/VmgExitLib.h: C source, ASCII text, with CRLF >> line terminators >> >> I'll investigate this and try and figure out what's going on, but if anyone else >> has some ideas, please let me know. > > Hi Tom, > > I met this error again when I trig below patch from AMD again for CPU change. > "UefiCpuPkg: Move StandardSignatureIsAuthenticAMD to BaseUefiCpuLib" Hmmm... I think we could be running into issues with sending patches through our mail servers. Let me send you the patch series directly using some changes I made to my git config file to see if that helps. Would that be ok? Thanks, Tom > > I'm not sure whether this is patch issue, or our internal test sever issue. I have reported this error to our internal team to check also. > Please check it from your side and make sure no error from your side. I will update the status from my side when I get the update. > > Thanks, > Eric > >> >> Thanks, >> Tom >> >>> >>> Thanks, >>> Eric >>> >>>> -----Original Message----- >>>> From: Tom Lendacky >>>> Sent: Friday, June 5, 2020 9:27 PM >>>> To: devel@edk2.groups.io >>>> Cc: Brijesh Singh ; Ard Biesheuvel >>>> ; Dong, Eric ; Justen, >>>> Jordan L ; Laszlo Ersek >>>> ; Gao, Liming ; Kinney, >>>> Michael D ; Ni, Ray >>>> Subject: [PATCH v9 08/46] UefiCpuPkg: Implement library support for >>>> VMGEXIT >>>> >>>> BZ: >>>> >> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbug >>>> >> zilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2198&data=02%7C01%7Ct >> ho >>>> >> mas.lendacky%40amd.com%7Cd75554da4959407c967608d8135877be%7C3dd >> 8961fe >>>> >> 4884e608e11a82d994e183d%7C0%7C0%7C637280617975250842&sdata= >> fBlK2B >>>> FkRdAS5EWcM8YShf1ZswfRN%2F41L7XeUsb4ZCs%3D&reserved=0 >>>> >>>> To support handling #VC exceptions and issuing VMGEXIT instructions, >>>> create a library with functions that can be used to perform these >>>> #VC/VMGEXIT related operations. This includes functions for: >>>> - Handling #VC exceptions >>>> - Preparing for and issuing a VMGEXIT >>>> - Performing MMIO-related write operations to support flash emulation >>>> - Performing AP related boot opeations >>>> >>>> The base functions in this driver will not do anything and will >>>> return an error if a return value is required. It is expected that >>>> other packages (like OvmfPkg) will create a version of the library to >>>> fully support an SEV-ES guest. >>>> >>>> Cc: Eric Dong >>>> Cc: Ray Ni >>>> Cc: Laszlo Ersek >>>> Signed-off-by: Tom Lendacky >>>> --- >>>> UefiCpuPkg/UefiCpuPkg.dec | 3 + >>>> UefiCpuPkg/UefiCpuPkg.dsc | 2 + >>>> UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf | 27 +++++ >>>> UefiCpuPkg/Include/Library/VmgExitLib.h | 103 >> +++++++++++++++++ >>>> UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c | 121 >>>> ++++++++++++++++++++ >>>> UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.uni | 15 +++ >>>> 6 files changed, 271 insertions(+) >>>> >>>> diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec >>>> index df5d02bae6b4..cb92f34b6f55 100644 >>>> --- a/UefiCpuPkg/UefiCpuPkg.dec >>>> +++ b/UefiCpuPkg/UefiCpuPkg.dec >>>> @@ -53,6 +53,9 @@ [LibraryClasses.IA32, LibraryClasses.X64] >>>> ## >>>> >>>> MpInitLib|Include/Library/MpInitLib.h >>>> >>>> >>>> >>>> + ## @libraryclass Provides function to support VMGEXIT processing. >>>> >>>> + VmgExitLib|Include/Library/VmgExitLib.h >>>> >>>> + >>>> >>>> [Guids] >>>> >>>> gUefiCpuPkgTokenSpaceGuid = { 0xac05bf33, 0x995a, 0x4ed4, { 0xaa, >>>> 0xb8, 0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }} >>>> >>>> gMsegSmramGuid = { 0x5802bce4, 0xeeee, 0x4e33, { 0xa1, 0x30, >>>> 0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }} >>>> >>>> diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc >>>> index afa304128221..f0e58b90ff0a 100644 >>>> --- a/UefiCpuPkg/UefiCpuPkg.dsc >>>> +++ b/UefiCpuPkg/UefiCpuPkg.dsc >>>> @@ -56,6 +56,7 @@ [LibraryClasses] >>>> >>>> >> PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/Base >>>> PeCoffGetEntryPointLib.inf >>>> >>>> >>>> >> PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/Base >>>> PeCoffExtraActionLib|P >>>> eCoffExtraActionLibNull.inf >>>> >>>> >>>> >> TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/Tp >>>> mMeasurementLibNull.inf >>>> >>>> + VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf >>>> >>>> >>>> >>>> [LibraryClasses.common.SEC] >>>> >>>> >>>> >> PlatformSecLib|UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNu >>>> PlatformSecLib|ll.i >>>> nf >>>> >>>> @@ -143,6 +144,7 @@ [Components.IA32, Components.X64] >>>> >>>> >> UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLib >>>> Null.inf >>>> >>>> UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf >>>> >>>> UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf >>>> >>>> + UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf >>>> >>>> UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf >>>> >>>> UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf >>>> >>>> UefiCpuPkg/SecCore/SecCore.inf >>>> >>>> diff --git a/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf >>>> b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf >>>> new file mode 100644 >>>> index 000000000000..d8770a21c355 >>>> --- /dev/null >>>> +++ b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf >>>> @@ -0,0 +1,27 @@ >>>> +## @file >>>> >>>> +# VMGEXIT Support Library. >>>> >>>> +# >>>> >>>> +# Copyright (C) 2020, Advanced Micro Devices, Inc. All rights >>>> +reserved.
>>>> >>>> +# SPDX-License-Identifier: BSD-2-Clause-Patent >>>> >>>> +# >>>> >>>> +## >>>> >>>> + >>>> >>>> +[Defines] >>>> >>>> + INF_VERSION = 0x00010005 >>>> >>>> + BASE_NAME = VmgExitLibNull >>>> >>>> + MODULE_UNI_FILE = VmgExitLibNull.uni >>>> >>>> + FILE_GUID = 3cd7368f-ef9b-4a9b-9571-2ed93813677e >>>> >>>> + MODULE_TYPE = BASE >>>> >>>> + VERSION_STRING = 1.0 >>>> >>>> + LIBRARY_CLASS = VmgExitLib >>>> >>>> + >>>> >>>> +[Sources.common] >>>> >>>> + VmgExitLibNull.c >>>> >>>> + >>>> >>>> +[Packages] >>>> >>>> + MdePkg/MdePkg.dec >>>> >>>> + UefiCpuPkg/UefiCpuPkg.dec >>>> >>>> + >>>> >>>> +[LibraryClasses] >>>> >>>> + BaseLib >>>> >>>> + >>>> >>>> diff --git a/UefiCpuPkg/Include/Library/VmgExitLib.h >>>> b/UefiCpuPkg/Include/Library/VmgExitLib.h >>>> new file mode 100644 >>>> index 000000000000..0b2f39026a4a >>>> --- /dev/null >>>> +++ b/UefiCpuPkg/Include/Library/VmgExitLib.h >>>> @@ -0,0 +1,103 @@ >>>> +/** @file >>>> >>>> + Public header file for the VMGEXIT Support library class. >>>> >>>> + >>>> >>>> + This library class defines some routines used when invoking the >>>> + VMGEXIT >>>> >>>> + instruction in support of SEV-ES and to handle #VC exceptions. >>>> >>>> + >>>> >>>> + Copyright (C) 2020, Advanced Micro Devices, Inc. All rights >>>> + reserved.
>>>> >>>> + SPDX-License-Identifier: BSD-2-Clause-Patent >>>> >>>> + >>>> >>>> +**/ >>>> >>>> + >>>> >>>> +#ifndef __VMG_EXIT_LIB_H__ >>>> >>>> +#define __VMG_EXIT_LIB_H__ >>>> >>>> + >>>> >>>> +#include >>>> >>>> +#include >>>> >>>> + >>>> >>>> + >>>> >>>> +/** >>>> >>>> + Perform VMGEXIT. >>>> >>>> + >>>> >>>> + Sets the necessary fields of the GHCB, invokes the VMGEXIT >>>> + instruction >>>> and >>>> >>>> + then handles the return actions. >>>> >>>> + >>>> >>>> + @param[in, out] Ghcb A pointer to the GHCB >>>> >>>> + @param[in] ExitCode VMGEXIT code to be assigned to the >> SwExitCode >>>> >>>> + field of the GHCB. >>>> >>>> + @param[in] ExitInfo1 VMGEXIT information to be assigned to the >>>> >>>> + SwExitInfo1 field of the GHCB. >>>> >>>> + @param[in] ExitInfo2 VMGEXIT information to be assigned to the >>>> >>>> + SwExitInfo2 field of the GHCB. >>>> >>>> + >>>> >>>> + @return 0 VMGEXIT succeeded. >>>> >>>> + @return Others VMGEXIT processing did not succeed. Exception >>>> >>>> + number to be propagated. >>>> >>>> + >>>> >>>> +**/ >>>> >>>> +UINT64 >>>> >>>> +EFIAPI >>>> >>>> +VmgExit ( >>>> >>>> + IN OUT GHCB *Ghcb, >>>> >>>> + IN UINT64 ExitCode, >>>> >>>> + IN UINT64 ExitInfo1, >>>> >>>> + IN UINT64 ExitInfo2 >>>> >>>> + ); >>>> >>>> + >>>> >>>> +/** >>>> >>>> + Perform pre-VMGEXIT initialization/preparation. >>>> >>>> + >>>> >>>> + Performs the necessary steps in preparation for invoking VMGEXIT. >>>> + Must >>>> be >>>> >>>> + called before setting any fields within the GHCB. >>>> >>>> + >>>> >>>> + @param[in, out] Ghcb A pointer to the GHCB >>>> >>>> + >>>> >>>> +**/ >>>> >>>> +VOID >>>> >>>> +EFIAPI >>>> >>>> +VmgInit ( >>>> >>>> + IN OUT GHCB *Ghcb >>>> >>>> + ); >>>> >>>> + >>>> >>>> +/** >>>> >>>> + Perform post-VMGEXIT cleanup. >>>> >>>> + >>>> >>>> + Performs the necessary steps to cleanup after invoking VMGEXIT. >>>> + Must be >>>> >>>> + called after obtaining needed fields within the GHCB. >>>> >>>> + >>>> >>>> + @param[in, out] Ghcb A pointer to the GHCB >>>> >>>> + >>>> >>>> +**/ >>>> >>>> +VOID >>>> >>>> +EFIAPI >>>> >>>> +VmgDone ( >>>> >>>> + IN OUT GHCB *Ghcb >>>> >>>> + ); >>>> >>>> + >>>> >>>> +/** >>>> >>>> + Handle a #VC exception. >>>> >>>> + >>>> >>>> + Performs the necessary processing to handle a #VC exception. >>>> >>>> + >>>> >>>> + The base library function returns an error equal to VC_EXCEPTION, >>>> >>>> + to be propagated to the standard exception handling stack. >>>> >>>> + >>>> >>>> + @param[in, out] ExceptionType Pointer to an EFI_EXCEPTION_TYPE >>>> + to be >>>> set >>>> >>>> + as value to use on error. >>>> >>>> + @param[in, out] SystemContext Pointer to EFI_SYSTEM_CONTEXT >>>> >>>> + >>>> >>>> + @retval EFI_SUCCESS Exception handled >>>> >>>> + @retval EFI_UNSUPPORTED #VC not supported, (new) exception >>>> value to >>>> >>>> + propagate provided >>>> >>>> + @retval EFI_PROTOCOL_ERROR #VC handling failed, (new) exception >>>> value to >>>> >>>> + propagate provided >>>> >>>> + >>>> >>>> +**/ >>>> >>>> +EFI_STATUS >>>> >>>> +EFIAPI >>>> >>>> +VmgExitHandleVc ( >>>> >>>> + IN OUT EFI_EXCEPTION_TYPE *ExceptionType, >>>> >>>> + IN OUT EFI_SYSTEM_CONTEXT SystemContext >>>> >>>> + ); >>>> >>>> + >>>> >>>> +#endif >>>> >>>> diff --git a/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c >>>> b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c >>>> new file mode 100644 >>>> index 000000000000..30a239df298e >>>> --- /dev/null >>>> +++ b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.c >>>> @@ -0,0 +1,121 @@ >>>> +/** @file >>>> >>>> + VMGEXIT Base Support Library. >>>> >>>> + >>>> >>>> + Copyright (C) 2020, Advanced Micro Devices, Inc. All rights >>>> + reserved.
>>>> >>>> + SPDX-License-Identifier: BSD-2-Clause-Patent >>>> >>>> + >>>> >>>> +**/ >>>> >>>> + >>>> >>>> +#include >>>> >>>> +#include >>>> >>>> +#include >>>> >>>> + >>>> >>>> +/** >>>> >>>> + Perform VMGEXIT. >>>> >>>> + >>>> >>>> + Sets the necessary fields of the GHCB, invokes the VMGEXIT >>>> + instruction >>>> and >>>> >>>> + then handles the return actions. >>>> >>>> + >>>> >>>> + The base library function returns an error in the form of a >>>> >>>> + GHCB_EVENT_INJECTION representing a GP_EXCEPTION. >>>> >>>> + >>>> >>>> + @param[in, out] Ghcb A pointer to the GHCB >>>> >>>> + @param[in] ExitCode VMGEXIT code to be assigned to the >> SwExitCode >>>> >>>> + field of the GHCB. >>>> >>>> + @param[in] ExitInfo1 VMGEXIT information to be assigned to the >>>> >>>> + SwExitInfo1 field of the GHCB. >>>> >>>> + @param[in] ExitInfo2 VMGEXIT information to be assigned to the >>>> >>>> + SwExitInfo2 field of the GHCB. >>>> >>>> + >>>> >>>> + @return 0 VMGEXIT succeeded. >>>> >>>> + @return Others VMGEXIT processing did not succeed. Exception >>>> >>>> + event to be propagated. >>>> >>>> + >>>> >>>> +**/ >>>> >>>> +UINT64 >>>> >>>> +EFIAPI >>>> >>>> +VmgExit ( >>>> >>>> + IN OUT GHCB *Ghcb, >>>> >>>> + IN UINT64 ExitCode, >>>> >>>> + IN UINT64 ExitInfo1, >>>> >>>> + IN UINT64 ExitInfo2 >>>> >>>> + ) >>>> >>>> +{ >>>> >>>> + GHCB_EVENT_INJECTION Event; >>>> >>>> + >>>> >>>> + Event.Uint64 = 0; >>>> >>>> + Event.Elements.Vector = GP_EXCEPTION; >>>> >>>> + Event.Elements.Type = GHCB_EVENT_INJECTION_TYPE_EXCEPTION; >>>> >>>> + Event.Elements.Valid = 1; >>>> >>>> + >>>> >>>> + return Event.Uint64; >>>> >>>> +} >>>> >>>> + >>>> >>>> +/** >>>> >>>> + Perform pre-VMGEXIT initialization/preparation. >>>> >>>> + >>>> >>>> + Performs the necessary steps in preparation for invoking VMGEXIT. >>>> + Must >>>> be >>>> >>>> + called before setting any fields within the GHCB. >>>> >>>> + >>>> >>>> + The base library function does nothing. >>>> >>>> + >>>> >>>> + @param[in, out] Ghcb A pointer to the GHCB >>>> >>>> + >>>> >>>> +**/ >>>> >>>> +VOID >>>> >>>> +EFIAPI >>>> >>>> +VmgInit ( >>>> >>>> + IN OUT GHCB *Ghcb >>>> >>>> + ) >>>> >>>> +{ >>>> >>>> +} >>>> >>>> + >>>> >>>> +/** >>>> >>>> + Perform post-VMGEXIT cleanup. >>>> >>>> + >>>> >>>> + Performs the necessary steps to cleanup after invoking VMGEXIT. >>>> + Must be >>>> >>>> + called after obtaining needed fields within the GHCB. >>>> >>>> + >>>> >>>> + The base library function does nothing. >>>> >>>> + >>>> >>>> + @param[in, out] Ghcb A pointer to the GHCB >>>> >>>> + >>>> >>>> +**/ >>>> >>>> +VOID >>>> >>>> +EFIAPI >>>> >>>> +VmgDone ( >>>> >>>> + IN OUT GHCB *Ghcb >>>> >>>> + ) >>>> >>>> +{ >>>> >>>> +} >>>> >>>> + >>>> >>>> +/** >>>> >>>> + Handle a #VC exception. >>>> >>>> + >>>> >>>> + Performs the necessary processing to handle a #VC exception. >>>> >>>> + >>>> >>>> + The base library function returns an error equal to VC_EXCEPTION, >>>> >>>> + to be propagated to the standard exception handling stack. >>>> >>>> + >>>> >>>> + @param[in, out] ExceptionType Pointer to an EFI_EXCEPTION_TYPE >>>> + to be >>>> set >>>> >>>> + as value to use on error. >>>> >>>> + @param[in, out] SystemContext Pointer to EFI_SYSTEM_CONTEXT >>>> >>>> + >>>> >>>> + @retval EFI_SUCCESS Exception handled >>>> >>>> + @retval EFI_UNSUPPORTED #VC not supported, (new) exception >>>> value to >>>> >>>> + propagate provided >>>> >>>> + @retval EFI_PROTOCOL_ERROR #VC handling failed, (new) exception >>>> value to >>>> >>>> + propagate provided >>>> >>>> + >>>> >>>> +**/ >>>> >>>> +EFI_STATUS >>>> >>>> +EFIAPI >>>> >>>> +VmgExitHandleVc ( >>>> >>>> + IN OUT EFI_EXCEPTION_TYPE *ExceptionType, >>>> >>>> + IN OUT EFI_SYSTEM_CONTEXT SystemContext >>>> >>>> + ) >>>> >>>> +{ >>>> >>>> + *ExceptionType = VC_EXCEPTION; >>>> >>>> + >>>> >>>> + return EFI_UNSUPPORTED; >>>> >>>> +} >>>> >>>> diff --git a/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.uni >>>> b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.uni >>>> new file mode 100644 >>>> index 000000000000..8639bc0e8ce9 >>>> --- /dev/null >>>> +++ b/UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.uni >>>> @@ -0,0 +1,15 @@ >>>> +// /** @file >>>> >>>> +// VMGEXIT support library instance. >>>> >>>> +// >>>> >>>> +// VMGEXIT support library instance. >>>> >>>> +// >>>> >>>> +// Copyright (C) 2020, Advanced Micro Devices, Inc. All rights >>>> +reserved.
>>>> >>>> +// SPDX-License-Identifier: BSD-2-Clause-Patent >>>> >>>> +// >>>> >>>> +// **/ >>>> >>>> + >>>> >>>> + >>>> >>>> +#string STR_MODULE_ABSTRACT #language en-US "VMGEXIT >> support >>>> NULL library instance" >>>> >>>> + >>>> >>>> +#string STR_MODULE_DESCRIPTION #language en-US "VMGEXIT >>>> support NULL library instance." >>>> >>>> + >>>> >>>> -- >>>> 2.27.0 >>> >> >> > > >