[edk2-devel] [PATCH V3 1/2] MdePkg/BaseLib: Update TdVmcall to always output the value in R11

sunceping posted 2 patches 2 years, 3 months ago
There is a newer version of this series
[edk2-devel] [PATCH V3 1/2] MdePkg/BaseLib: Update TdVmcall to always output the value in R11
Posted by sunceping 2 years, 3 months ago
From: Ceping Sun <cepingx.sun@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4572

According to section 3.2 of the [GHCI] spec, if the return status
of MapGPA is "TDG.VP.VMCALL_RETRY", TD must retry this operation
for the pages in the region starting at the GPA specified in R11.

Currently, TDVF has not handled the retry results and always clears
the R11 on unsuccessful return status. For this, the TdVmcall needs
to output the value of R11 on unsuccessful return status to handle
the retry results of MapGPA.

Reference:
[GHCI]: TDX Guest-Host-Communication Interface v1.0
https://cdrdv2.intel.com/v1/dl/getContent/726790

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Michael Roth <michael.roth@amd.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
---
 MdePkg/Library/BaseLib/X64/TdVmcall.nasm | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/MdePkg/Library/BaseLib/X64/TdVmcall.nasm b/MdePkg/Library/BaseLib/X64/TdVmcall.nasm
index 5ecc10b17193..8dd9bfcbfa14 100644
--- a/MdePkg/Library/BaseLib/X64/TdVmcall.nasm
+++ b/MdePkg/Library/BaseLib/X64/TdVmcall.nasm
@@ -133,9 +133,7 @@ ASM_PFX(TdVmCall):
        test r9, r9
        jz .no_return_data
 
-       ; On success, propagate TDVMCALL output value to output param
-       test rax, rax
-       jnz .no_return_data
+       ; Propagate TDVMCALL output value to output param
        mov [r9], r11
 .no_return_data:
        tdcall_regs_postamble
-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110904): https://edk2.groups.io/g/devel/message/110904
Mute This Topic: https://groups.io/mt/102460272/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH V3 1/2] MdePkg/BaseLib: Update TdVmcall to always output the value in R11
Posted by Min Xu 2 years, 3 months ago
Hi, Liming & Miachel
Can you help to review this patch (because it is changed in MdePkg)?

Thanks!
Min

> -----Original Message-----
> From: Sun, CepingX <cepingx.sun@intel.com>
> Sent: Wednesday, November 8, 2023 4:32 PM
> To: devel@edk2.groups.io
> Cc: Sun, CepingX <cepingx.sun@intel.com>; Gao, Liming
> <gaoliming@byosoft.com.cn>; Kinney, Michael D
> <michael.d.kinney@intel.com>; Aktas, Erdem <erdemaktas@google.com>;
> James Bottomley <jejb@linux.ibm.com>; Xu, Min M <min.m.xu@intel.com>;
> Tom Lendacky <thomas.lendacky@amd.com>; Michael Roth
> <michael.roth@amd.com>; Gerd Hoffmann <kraxel@redhat.com>; Yao,
> Jiewen <jiewen.yao@intel.com>
> Subject: [PATCH V3 1/2] MdePkg/BaseLib: Update TdVmcall to always output
> the value in R11
> 
> From: Ceping Sun <cepingx.sun@intel.com>
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4572
> 
> According to section 3.2 of the [GHCI] spec, if the return status of MapGPA is
> "TDG.VP.VMCALL_RETRY", TD must retry this operation for the pages in the
> region starting at the GPA specified in R11.
> 
> Currently, TDVF has not handled the retry results and always clears the R11
> on unsuccessful return status. For this, the TdVmcall needs to output the
> value of R11 on unsuccessful return status to handle the retry results of
> MapGPA.
> 
> Reference:
> [GHCI]: TDX Guest-Host-Communication Interface v1.0
> https://cdrdv2.intel.com/v1/dl/getContent/726790
> 
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Erdem Aktas <erdemaktas@google.com>
> Cc: James Bottomley <jejb@linux.ibm.com>
> Cc: Min Xu <min.m.xu@intel.com>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Cc: Michael Roth <michael.roth@amd.com>
> Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
> Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
> ---
>  MdePkg/Library/BaseLib/X64/TdVmcall.nasm | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/MdePkg/Library/BaseLib/X64/TdVmcall.nasm
> b/MdePkg/Library/BaseLib/X64/TdVmcall.nasm
> index 5ecc10b17193..8dd9bfcbfa14 100644
> --- a/MdePkg/Library/BaseLib/X64/TdVmcall.nasm
> +++ b/MdePkg/Library/BaseLib/X64/TdVmcall.nasm
> @@ -133,9 +133,7 @@ ASM_PFX(TdVmCall):
>         test r9, r9
>         jz .no_return_data
> 
> -       ; On success, propagate TDVMCALL output value to output param
> -       test rax, rax
> -       jnz .no_return_data
> +       ; Propagate TDVMCALL output value to output param
>         mov [r9], r11
>  .no_return_data:
>         tdcall_regs_postamble
> --
> 2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110906): https://edk2.groups.io/g/devel/message/110906
Mute This Topic: https://groups.io/mt/102460272/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
[edk2-devel] 回复: [PATCH V3 1/2] MdePkg/BaseLib: Update TdVmcall to always output the value in R11
Posted by gaoliming via groups.io 2 years, 3 months ago
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>

> -----邮件原件-----
> 发件人: Xu, Min M <min.m.xu@intel.com>
> 发送时间: 2023年11月8日 16:41
> 收件人: Gao, Liming <gaoliming@byosoft.com.cn>; Kinney, Michael D
> <michael.d.kinney@intel.com>
> 抄送: Aktas, Erdem <erdemaktas@google.com>; James Bottomley
> <jejb@linux.ibm.com>; Tom Lendacky <thomas.lendacky@amd.com>;
> Michael Roth <michael.roth@amd.com>; Gerd Hoffmann
> <kraxel@redhat.com>; Yao, Jiewen <jiewen.yao@intel.com>; Sun, CepingX
> <cepingx.sun@intel.com>; devel@edk2.groups.io; Xu, Min M
> <min.m.xu@intel.com>
> 主题: RE: [PATCH V3 1/2] MdePkg/BaseLib: Update TdVmcall to always
> output the value in R11
> 
> Hi, Liming & Miachel
> Can you help to review this patch (because it is changed in MdePkg)?
> 
> Thanks!
> Min
> 
> > -----Original Message-----
> > From: Sun, CepingX <cepingx.sun@intel.com>
> > Sent: Wednesday, November 8, 2023 4:32 PM
> > To: devel@edk2.groups.io
> > Cc: Sun, CepingX <cepingx.sun@intel.com>; Gao, Liming
> > <gaoliming@byosoft.com.cn>; Kinney, Michael D
> > <michael.d.kinney@intel.com>; Aktas, Erdem <erdemaktas@google.com>;
> > James Bottomley <jejb@linux.ibm.com>; Xu, Min M
> <min.m.xu@intel.com>;
> > Tom Lendacky <thomas.lendacky@amd.com>; Michael Roth
> > <michael.roth@amd.com>; Gerd Hoffmann <kraxel@redhat.com>; Yao,
> > Jiewen <jiewen.yao@intel.com>
> > Subject: [PATCH V3 1/2] MdePkg/BaseLib: Update TdVmcall to always
> output
> > the value in R11
> >
> > From: Ceping Sun <cepingx.sun@intel.com>
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4572
> >
> > According to section 3.2 of the [GHCI] spec, if the return status of
MapGPA is
> > "TDG.VP.VMCALL_RETRY", TD must retry this operation for the pages in the
> > region starting at the GPA specified in R11.
> >
> > Currently, TDVF has not handled the retry results and always clears the
R11
> > on unsuccessful return status. For this, the TdVmcall needs to output
the
> > value of R11 on unsuccessful return status to handle the retry results
of
> > MapGPA.
> >
> > Reference:
> > [GHCI]: TDX Guest-Host-Communication Interface v1.0
> > https://cdrdv2.intel.com/v1/dl/getContent/726790
> >
> > Cc: Liming Gao <gaoliming@byosoft.com.cn>
> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > Cc: Erdem Aktas <erdemaktas@google.com>
> > Cc: James Bottomley <jejb@linux.ibm.com>
> > Cc: Min Xu <min.m.xu@intel.com>
> > Cc: Tom Lendacky <thomas.lendacky@amd.com>
> > Cc: Michael Roth <michael.roth@amd.com>
> > Acked-by: Gerd Hoffmann <kraxel@redhat.com>
> > Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
> > Signed-off-by: Ceping Sun <cepingx.sun@intel.com>
> > ---
> >  MdePkg/Library/BaseLib/X64/TdVmcall.nasm | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/MdePkg/Library/BaseLib/X64/TdVmcall.nasm
> > b/MdePkg/Library/BaseLib/X64/TdVmcall.nasm
> > index 5ecc10b17193..8dd9bfcbfa14 100644
> > --- a/MdePkg/Library/BaseLib/X64/TdVmcall.nasm
> > +++ b/MdePkg/Library/BaseLib/X64/TdVmcall.nasm
> > @@ -133,9 +133,7 @@ ASM_PFX(TdVmCall):
> >         test r9, r9
> >         jz .no_return_data
> >
> > -       ; On success, propagate TDVMCALL output value to output param
> > -       test rax, rax
> > -       jnz .no_return_data
> > +       ; Propagate TDVMCALL output value to output param
> >         mov [r9], r11
> >  .no_return_data:
> >         tdcall_regs_postamble
> > --
> > 2.34.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110980): https://edk2.groups.io/g/devel/message/110980
Mute This Topic: https://groups.io/mt/102485604/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-