diff mbox series

[02/10] x86/tdx: Use cmovc to save a label in TDX_MODULE_CALL asm

Message ID 70784afc0a42d4dc1b1e743f90d89f7728496add.1689151537.git.kai.huang@intel.com (mailing list archive)
State New, archived
Headers show
Series Unify TDCALL/SEAMCALL and TDVMCALL assembly | expand

Commit Message

Huang, Kai July 12, 2023, 8:55 a.m. UTC
Change 'jnc .Lno_vmfailinvalid' to 'cmovc %rdi, %rax' to save the
.Lno_vmfailinvalid label in the TDX_MODULE_CALL asm macro.

Note %rdi, which is used as the first argument, has been saved to %rax
as TDCALL leaf ID thus is free to hold the error code for cmovc.

This is basically based on Peter's code.

Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Kai Huang <kai.huang@intel.com>
---
 arch/x86/virt/vmx/tdx/tdxcall.S | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Kuppuswamy Sathyanarayanan July 12, 2023, 7:27 p.m. UTC | #1
On 7/12/23 1:55 AM, Kai Huang wrote:
> Change 'jnc .Lno_vmfailinvalid' to 'cmovc %rdi, %rax' to save the
> .Lno_vmfailinvalid label in the TDX_MODULE_CALL asm macro.

You are removing the label, right? What use "save"?

> 
> Note %rdi, which is used as the first argument, has been saved to %rax
> as TDCALL leaf ID thus is free to hold the error code for cmovc.

> 
> This is basically based on Peter's code.
> 
> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Suggested-by: Peter Zijlstra <peterz@infradead.org>
> Signed-off-by: Kai Huang <kai.huang@intel.com>
> ---
>  arch/x86/virt/vmx/tdx/tdxcall.S | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/virt/vmx/tdx/tdxcall.S b/arch/x86/virt/vmx/tdx/tdxcall.S
> index 49a54356ae99..3524915d8bd9 100644
> --- a/arch/x86/virt/vmx/tdx/tdxcall.S
> +++ b/arch/x86/virt/vmx/tdx/tdxcall.S
> @@ -57,10 +57,8 @@
>  	 * This value will never be used as actual SEAMCALL error code as
>  	 * it is from the Reserved status code class.
>  	 */
> -	jnc .Lno_vmfailinvalid
> -	mov $TDX_SEAMCALL_VMFAILINVALID, %rax
> -.Lno_vmfailinvalid:
> -
> +	mov $TDX_SEAMCALL_VMFAILINVALID, %rdi
> +	cmovc %rdi, %rax
>  	.else
>  	tdcall
>  	.endif
Huang, Kai July 13, 2023, 10:32 a.m. UTC | #2
On Wed, 2023-07-12 at 12:27 -0700, Sathyanarayanan Kuppuswamy wrote:
> 
> On 7/12/23 1:55 AM, Kai Huang wrote:
> > Change 'jnc .Lno_vmfailinvalid' to 'cmovc %rdi, %rax' to save the
> > .Lno_vmfailinvalid label in the TDX_MODULE_CALL asm macro.
> 
> You are removing the label, right? What use "save"?
 
Per comments to patch 10 I'll drop this patch, so doesn't matter anymore.
diff mbox series

Patch

diff --git a/arch/x86/virt/vmx/tdx/tdxcall.S b/arch/x86/virt/vmx/tdx/tdxcall.S
index 49a54356ae99..3524915d8bd9 100644
--- a/arch/x86/virt/vmx/tdx/tdxcall.S
+++ b/arch/x86/virt/vmx/tdx/tdxcall.S
@@ -57,10 +57,8 @@ 
 	 * This value will never be used as actual SEAMCALL error code as
 	 * it is from the Reserved status code class.
 	 */
-	jnc .Lno_vmfailinvalid
-	mov $TDX_SEAMCALL_VMFAILINVALID, %rax
-.Lno_vmfailinvalid:
-
+	mov $TDX_SEAMCALL_VMFAILINVALID, %rdi
+	cmovc %rdi, %rax
 	.else
 	tdcall
 	.endif