public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Lendacky, Thomas" <thomas.lendacky@amd.com>
To: gaoliming <gaoliming@byosoft.com.cn>, devel@edk2.groups.io
Cc: 'Brijesh Singh' <brijesh.singh@amd.com>,
	'Michael D Kinney' <michael.d.kinney@intel.com>,
	'Zhiguang Liu' <zhiguang.liu@intel.com>,
	'Jordan Justen' <jordan.l.justen@intel.com>,
	'Laszlo Ersek' <lersek@redhat.com>,
	'Ard Biesheuvel' <ard.biesheuvel@arm.com>
Subject: Re: 回复: [PATCH v2 01/11] MdePkg, OvmfPkg: Clean up GHCB field offsets and save area
Date: Mon, 19 Oct 2020 07:50:56 -0500	[thread overview]
Message-ID: <93c3b271-ccdb-6242-ce23-957eb73a66c0@amd.com> (raw)
In-Reply-To: <000d01d6a5b9$03d14ef0$0b73ecd0$@byosoft.com.cn>

On 10/18/20 8:41 PM, gaoliming wrote:
> Tom:
> 
>> -----邮件原件-----
>> 发件人: Tom Lendacky <thomas.lendacky@amd.com>
>> 发送时间: 2020年10月17日 0:09
>> 收件人: devel@edk2.groups.io
>> 抄送: Brijesh Singh <brijesh.singh@amd.com>; Michael D Kinney
>> <michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>;
>> Zhiguang Liu <zhiguang.liu@intel.com>; Jordan Justen
>> <jordan.l.justen@intel.com>; Laszlo Ersek <lersek@redhat.com>; Ard
>> Biesheuvel <ard.biesheuvel@arm.com>
>> 主题: [PATCH v2 01/11] MdePkg, OvmfPkg: Clean up GHCB field offsets and
>> save area
>>
>> From: Tom Lendacky <thomas.lendacky@amd.com>
>>
>> BZ: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D3008&amp;data=04%7C01%7Cthomas.lendacky%40amd.com%7C4fd17a68a915477d9d1508d873d027b1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637386685165902990%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=NBPdQ98RyMUlma0qkEvhBjUdykQ24p7pTK9I61ttX7Q%3D&amp;reserved=0
>>
>> Use OFFSET_OF () and sizeof () to calculate the GHCB register field
>> offsets instead of hardcoding the values in the GHCB_REGISTER enum.
>> Rename GHCB_REGISTER to GHCB_QWORD_OFFSET to more appropriately
>> describe
>> the enum. While redefining the values, only include (and add) fields that
>> are used per the GHCB specification.
>>
>> Also, remove the DR7 field from the GHCB_SAVE_AREA structure since it is
>> not used/defined in the GHCB specification and then rename the reserved
>> fields as appropriate.
>>
>> Cc: Michael D Kinney <michael.d.kinney@intel.com>
>> Cc: Liming Gao <gaoliming@byosoft.com.cn>
>> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
>> Cc: Jordan Justen <jordan.l.justen@intel.com>
>> Cc: Laszlo Ersek <lersek@redhat.com>
>> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
>> Cc: Tom Lendacky <thomas.lendacky@amd.com>
>> Cc: Brijesh Singh <brijesh.singh@amd.com>
>> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
>> ---
>>  MdePkg/Include/Register/Amd/Ghcb.h            | 40
>> +++++++-------------
>>  OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c |  4 +-
>>  2 files changed, 16 insertions(+), 28 deletions(-)
>>
> 
> Please separate the patch for the change in OvmfPkg. 
> One commit can't cross the different packages. 
> I understand this is the incompatible change. But, we still need to follow
> this rule. 

Ok, then I'll resubmit without the name change. To me, it's not worth
doing 3 commits just to accomplish the rename from GHCB_REGISTER to
GHCB_QWORD_OFFSET.

Thanks,
Tom

> 
>> diff --git a/MdePkg/Include/Register/Amd/Ghcb.h
>> b/MdePkg/Include/Register/Amd/Ghcb.h
>> index 54a80da0f6d7..93fb6e3cb0fc 100644
>> --- a/MdePkg/Include/Register/Amd/Ghcb.h
>> +++ b/MdePkg/Include/Register/Amd/Ghcb.h
>> @@ -82,35 +82,10 @@
>>  #define IOIO_SEG_DS         (BIT11 | BIT10)
>>
>>
>> -typedef enum {
>> -  GhcbCpl              = 25,
>> -  GhcbRflags           = 46,
>> -  GhcbRip,
>> -  GhcbRsp              = 59,
>> -  GhcbRax              = 63,
>> -  GhcbRcx              = 97,
>> -  GhcbRdx,
>> -  GhcbRbx,
>> -  GhcbRbp              = 101,
>> -  GhcbRsi,
>> -  GhcbRdi,
>> -  GhcbR8,
>> -  GhcbR9,
>> -  GhcbR10,
>> -  GhcbR11,
>> -  GhcbR12,
>> -  GhcbR13,
>> -  GhcbR14,
>> -  GhcbR15,
>> -  GhcbXCr0             = 125,
>> -} GHCB_REGISTER;
>> -
>>  typedef PACKED struct {
>>    UINT8                  Reserved1[203];
>>    UINT8                  Cpl;
>> -  UINT8                  Reserved2[148];
>> -  UINT64                 Dr7;
>> -  UINT8                  Reserved3[144];
>> +  UINT8                  Reserved8[300];
>>    UINT64                 Rax;
>>    UINT8                  Reserved4[264];
>>    UINT64                 Rcx;
>> @@ -136,6 +111,19 @@ typedef PACKED struct {
>>    UINT32                 GhcbUsage;
>>  } GHCB;
>>
>> +typedef enum {
>> +  GhcbCpl          = OFFSET_OF (GHCB, SaveArea.Cpl) / sizeof (UINT64),
> 
> OFFSET_OF (GHCB, SaveArea.Cpl) is 204. But, it can't fully divide 8
> (sizeof(UINT64)). Is it correct?
> 
> Thanks
> Liming
>> +  GhcbRax          = OFFSET_OF (GHCB, SaveArea.Rax) / sizeof
>> (UINT64),
>> +  GhcbRbx          = OFFSET_OF (GHCB, SaveArea.Rbx) / sizeof
>> (UINT64),
>> +  GhcbRcx          = OFFSET_OF (GHCB, SaveArea.Rcx) / sizeof
>> (UINT64),
>> +  GhcbRdx          = OFFSET_OF (GHCB, SaveArea.Rdx) / sizeof
>> (UINT64),
>> +  GhcbXCr0         = OFFSET_OF (GHCB, SaveArea.XCr0) / sizeof
>> (UINT64),
>> +  GhcbSwExitCode   = OFFSET_OF (GHCB, SaveArea.SwExitCode) / sizeof
>> (UINT64),
>> +  GhcbSwExitInfo1  = OFFSET_OF (GHCB, SaveArea.SwExitInfo1) / sizeof
>> (UINT64),
>> +  GhcbSwExitInfo2  = OFFSET_OF (GHCB, SaveArea.SwExitInfo2) / sizeof
>> (UINT64),
>> +  GhcbSwScratch    = OFFSET_OF (GHCB, SaveArea.SwScratch) / sizeof
>> (UINT64),
>> +} GHCB_QWORD_OFFSET;
>> +
>>  typedef union {
>>    struct {
>>      UINT32  Lower32Bits;
>> diff --git a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c
>> b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c
>> index 8e42b305e83c..c5484a3f478c 100644
>> --- a/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c
>> +++ b/OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c
>> @@ -153,7 +153,7 @@ STATIC
>>  BOOLEAN
>>  GhcbIsRegValid (
>>    IN GHCB                *Ghcb,
>> -  IN GHCB_REGISTER       Reg
>> +  IN GHCB_QWORD_OFFSET   Reg
>>    )
>>  {
>>    UINT32  RegIndex;
>> @@ -179,7 +179,7 @@ STATIC
>>  VOID
>>  GhcbSetRegValid (
>>    IN OUT GHCB                *Ghcb,
>> -  IN     GHCB_REGISTER       Reg
>> +  IN     GHCB_QWORD_OFFSET   Reg
>>    )
>>  {
>>    UINT32  RegIndex;
>> --
>> 2.28.0
> 
> 
> 

  reply	other threads:[~2020-10-19 12:51 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-16 16:09 [PATCH v2 00/11] SEV-ES guest support fixes and cleanup Lendacky, Thomas
2020-10-16 16:09 ` [PATCH v2 01/11] MdePkg, OvmfPkg: Clean up GHCB field offsets and save area Lendacky, Thomas
2020-10-19  1:41   ` 回复: " gaoliming
2020-10-19 12:50     ` Lendacky, Thomas [this message]
2020-10-19 20:17       ` Laszlo Ersek
2020-10-19 20:48         ` Lendacky, Thomas
2020-10-19 20:42       ` Laszlo Ersek
2020-10-20  1:08         ` 回复: " gaoliming
2020-10-20  8:31           ` Laszlo Ersek
2020-10-20 13:10             ` Lendacky, Thomas
2020-10-21  0:54               ` 回复: " gaoliming
2020-10-21 21:54                 ` Lendacky, Thomas
2020-10-22  1:25                   ` 回复: [edk2-devel] " gaoliming
2020-10-22 13:12                     ` Laszlo Ersek
2020-10-23  2:57                       ` 回复: " gaoliming
2020-10-26 16:34                         ` Lendacky, Thomas
2020-10-27  7:57                           ` Dong, Eric
2020-10-28 17:42                             ` Lendacky, Thomas
2020-10-21 12:29               ` Laszlo Ersek
2020-10-16 16:09 ` [PATCH v2 02/11] UefiCpuPkg/VmgExitLib: Add interfaces to set/read GHCB ValidBitmap bits Lendacky, Thomas
2020-10-19 20:46   ` [edk2-devel] " Laszlo Ersek
2020-10-16 16:09 ` [PATCH v2 03/11] OvmfPkg/VmgExitLib: Implement new VmgExitLib interfaces Lendacky, Thomas
2020-10-19 20:51   ` [edk2-devel] " Laszlo Ersek
2020-10-16 16:09 ` [PATCH v2 04/11] OvmfPkg/VmgExitLib: Set the SW exit fields when performing VMGEXIT Lendacky, Thomas
2020-10-19 20:53   ` [edk2-devel] " Laszlo Ersek
2020-10-16 16:09 ` [PATCH v2 05/11] OvmfPkg/VmgExitLib: Set the SwScratch valid bit for IOIO events Lendacky, Thomas
2020-10-19 20:54   ` [edk2-devel] " Laszlo Ersek
2020-10-16 16:09 ` [PATCH v2 06/11] OvmfPkg/VmgExitLib: Set the SwScratch valid bit for MMIO events Lendacky, Thomas
2020-10-16 16:09 ` [PATCH v2 07/11] UefiCpuPkg/MpInitLib: Set the SW exit fields when performing VMGEXIT Lendacky, Thomas
2020-10-16 16:09 ` [PATCH v2 08/11] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Set the SwScratch valid bit Lendacky, Thomas
2020-10-19 20:57   ` [edk2-devel] " Laszlo Ersek
2020-10-16 16:09 ` [PATCH v2 09/11] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: Fix erase blocks for SEV-ES Lendacky, Thomas
2020-10-16 16:09 ` [PATCH v2 10/11] UefiCpuPkg, OvmfPkg: Disable interrupts when using the GHCB Lendacky, Thomas
2020-10-19 21:07   ` [edk2-devel] " Laszlo Ersek
2020-10-16 16:09 ` [PATCH v2 11/11] UefiCpuPkg/MpInitLib: For SEV-ES guest, set stack based on processor number Lendacky, Thomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=93c3b271-ccdb-6242-ce23-957eb73a66c0@amd.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox