From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web11.5446.1603071721347450789 for ; Sun, 18 Oct 2020 18:42:02 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: gaoliming@byosoft.com.cn) Received: from DESKTOPS6D0PVI ([58.246.60.130]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Mon, 19 Oct 2020 09:41:50 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: "'Tom Lendacky'" , Cc: "'Brijesh Singh'" , "'Michael D Kinney'" , "'Zhiguang Liu'" , "'Jordan Justen'" , "'Laszlo Ersek'" , "'Ard Biesheuvel'" References: <523f270e4e6f7a62cdbebc541b442bd766e7ab3a.1602864557.git.thomas.lendacky@amd.com> In-Reply-To: <523f270e4e6f7a62cdbebc541b442bd766e7ab3a.1602864557.git.thomas.lendacky@amd.com> Subject: =?UTF-8?B?5Zue5aSNOiBbUEFUQ0ggdjIgMDEvMTFdIE1kZVBrZywgT3ZtZlBrZzogQ2xlYW4gdXAgR0hDQiBmaWVsZCBvZmZzZXRzIGFuZCBzYXZlIGFyZWE=?= Date: Mon, 19 Oct 2020 09:41:50 +0800 Message-ID: <000d01d6a5b9$03d14ef0$0b73ecd0$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQKfp3CfnkRussMBowKfV6mBTee23AEhTXMjqAMXGpA= Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Tom: > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: Tom Lendacky > =B7=A2=CB=CD=CA=B1=BC=E4: 2020=C4=EA10=D4=C217=C8=D5 0:09 > =CA=D5=BC=FE=C8=CB: devel@edk2.groups.io > =B3=AD=CB=CD: Brijesh Singh ; Michael D Kinney > ; Liming Gao ; > Zhiguang Liu ; Jordan Justen > ; Laszlo Ersek ; Ard > Biesheuvel > =D6=F7=CC=E2: [PATCH v2 01/11] MdePkg, OvmfPkg: Clean up GHCB field = offsets and > save area >=20 > From: Tom Lendacky >=20 > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3008 >=20 > 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. >=20 > 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. >=20 > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Zhiguang Liu > Cc: Jordan Justen > Cc: Laszlo Ersek > Cc: Ard Biesheuvel > Cc: Tom Lendacky > Cc: Brijesh Singh > Signed-off-by: Tom Lendacky > --- > MdePkg/Include/Register/Amd/Ghcb.h | 40 > +++++++------------- > OvmfPkg/Library/VmgExitLib/VmgExitVcHandler.c | 4 +- > 2 files changed, 16 insertions(+), 28 deletions(-) >=20 Please separate the patch for the change in OvmfPkg.=20 One commit can't cross the different packages.=20 I understand this is the incompatible change. But, we still need to = follow this rule.=20 > 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) >=20 >=20 > -typedef enum { > - GhcbCpl =3D 25, > - GhcbRflags =3D 46, > - GhcbRip, > - GhcbRsp =3D 59, > - GhcbRax =3D 63, > - GhcbRcx =3D 97, > - GhcbRdx, > - GhcbRbx, > - GhcbRbp =3D 101, > - GhcbRsi, > - GhcbRdi, > - GhcbR8, > - GhcbR9, > - GhcbR10, > - GhcbR11, > - GhcbR12, > - GhcbR13, > - GhcbR14, > - GhcbR15, > - GhcbXCr0 =3D 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; >=20 > +typedef enum { > + GhcbCpl =3D 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 =3D OFFSET_OF (GHCB, SaveArea.Rax) / sizeof > (UINT64), > + GhcbRbx =3D OFFSET_OF (GHCB, SaveArea.Rbx) / sizeof > (UINT64), > + GhcbRcx =3D OFFSET_OF (GHCB, SaveArea.Rcx) / sizeof > (UINT64), > + GhcbRdx =3D OFFSET_OF (GHCB, SaveArea.Rdx) / sizeof > (UINT64), > + GhcbXCr0 =3D OFFSET_OF (GHCB, SaveArea.XCr0) / sizeof > (UINT64), > + GhcbSwExitCode =3D OFFSET_OF (GHCB, SaveArea.SwExitCode) / sizeof > (UINT64), > + GhcbSwExitInfo1 =3D OFFSET_OF (GHCB, SaveArea.SwExitInfo1) / = sizeof > (UINT64), > + GhcbSwExitInfo2 =3D OFFSET_OF (GHCB, SaveArea.SwExitInfo2) / = sizeof > (UINT64), > + GhcbSwScratch =3D 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