Message ID | c0206c457f366ab007ab67ca16970cc4fc562877.1689151537.git.kai.huang@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Unify TDCALL/SEAMCALL and TDVMCALL assembly | expand |
On 7/12/23 1:55 AM, Kai Huang wrote: > Currently, the TDX_MODULE_CALL asm macro and the __tdx_module_call() > take registers directly as input and a 'struct tdx_module_output' as > optional output. This is different from the __tdx_hypercall(), which > simply uses a structure to carry all input/output. There's no point to > leave __tdx_module_call() complicated as it is. > > As a preparation to simplify the __tdx_module_call() to make it look > like __tdx_hypercall(), move FRAME_BEGIN/END and RET from the > __tdx_module_call() to the TDX_MODULE_CALL assembly macro. This also > allows more implementation flexibility of the assembly inside the > TDX_MODULE_CALL macro, e.g., allowing putting an _ASM_EXTABLE() after > the main body of the assembly. > > 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> > --- Looks fine to me. Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> > arch/x86/coco/tdx/tdcall.S | 3 --- > arch/x86/virt/vmx/tdx/tdxcall.S | 5 +++++ > 2 files changed, 5 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/coco/tdx/tdcall.S b/arch/x86/coco/tdx/tdcall.S > index 2eca5f43734f..e5d4b7d8ecd4 100644 > --- a/arch/x86/coco/tdx/tdcall.S > +++ b/arch/x86/coco/tdx/tdcall.S > @@ -78,10 +78,7 @@ > * Return status of TDCALL via RAX. > */ > SYM_FUNC_START(__tdx_module_call) > - FRAME_BEGIN > TDX_MODULE_CALL host=0 > - FRAME_END > - RET > SYM_FUNC_END(__tdx_module_call) > > /* > diff --git a/arch/x86/virt/vmx/tdx/tdxcall.S b/arch/x86/virt/vmx/tdx/tdxcall.S > index 3524915d8bd9..b5ab919c7fa8 100644 > --- a/arch/x86/virt/vmx/tdx/tdxcall.S > +++ b/arch/x86/virt/vmx/tdx/tdxcall.S > @@ -1,5 +1,6 @@ > /* SPDX-License-Identifier: GPL-2.0 */ > #include <asm/asm-offsets.h> > +#include <asm/frame.h> > #include <asm/tdx.h> > > /* > @@ -18,6 +19,7 @@ > * TDX module. > */ > .macro TDX_MODULE_CALL host:req > + FRAME_BEGIN > /* > * R12 will be used as temporary storage for struct tdx_module_output > * pointer. Since R12-R15 registers are not used by TDCALL/SEAMCALL > @@ -91,4 +93,7 @@ > .Lno_output_struct: > /* Restore the state of R12 register */ > pop %r12 > + > + FRAME_END > + RET > .endm
On Wed, Jul 12, 2023 at 08:55:17PM +1200, Kai Huang <kai.huang@intel.com> wrote: > Currently, the TDX_MODULE_CALL asm macro and the __tdx_module_call() > take registers directly as input and a 'struct tdx_module_output' as > optional output. This is different from the __tdx_hypercall(), which > simply uses a structure to carry all input/output. There's no point to > leave __tdx_module_call() complicated as it is. > > As a preparation to simplify the __tdx_module_call() to make it look > like __tdx_hypercall(), move FRAME_BEGIN/END and RET from the > __tdx_module_call() to the TDX_MODULE_CALL assembly macro. This also > allows more implementation flexibility of the assembly inside the > TDX_MODULE_CALL macro, e.g., allowing putting an _ASM_EXTABLE() after > the main body of the assembly. > > 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/coco/tdx/tdcall.S | 3 --- > arch/x86/virt/vmx/tdx/tdxcall.S | 5 +++++ > 2 files changed, 5 insertions(+), 3 deletions(-) > > diff --git a/arch/x86/coco/tdx/tdcall.S b/arch/x86/coco/tdx/tdcall.S > index 2eca5f43734f..e5d4b7d8ecd4 100644 > --- a/arch/x86/coco/tdx/tdcall.S > +++ b/arch/x86/coco/tdx/tdcall.S > @@ -78,10 +78,7 @@ > * Return status of TDCALL via RAX. > */ > SYM_FUNC_START(__tdx_module_call) > - FRAME_BEGIN > TDX_MODULE_CALL host=0 > - FRAME_END > - RET > SYM_FUNC_END(__tdx_module_call) > > /* > diff --git a/arch/x86/virt/vmx/tdx/tdxcall.S b/arch/x86/virt/vmx/tdx/tdxcall.S > index 3524915d8bd9..b5ab919c7fa8 100644 > --- a/arch/x86/virt/vmx/tdx/tdxcall.S > +++ b/arch/x86/virt/vmx/tdx/tdxcall.S > @@ -1,5 +1,6 @@ > /* SPDX-License-Identifier: GPL-2.0 */ > #include <asm/asm-offsets.h> > +#include <asm/frame.h> > #include <asm/tdx.h> > > /* > @@ -18,6 +19,7 @@ > * TDX module. > */ > .macro TDX_MODULE_CALL host:req > + FRAME_BEGIN > /* > * R12 will be used as temporary storage for struct tdx_module_output > * pointer. Since R12-R15 registers are not used by TDCALL/SEAMCALL > @@ -91,4 +93,7 @@ > .Lno_output_struct: > /* Restore the state of R12 register */ > pop %r12 > + > + FRAME_END > + RET > .endm > -- > 2.41.0 > Reviewed-by: Isaku Yamahata <isaku.yamahata@intel.com>
diff --git a/arch/x86/coco/tdx/tdcall.S b/arch/x86/coco/tdx/tdcall.S index 2eca5f43734f..e5d4b7d8ecd4 100644 --- a/arch/x86/coco/tdx/tdcall.S +++ b/arch/x86/coco/tdx/tdcall.S @@ -78,10 +78,7 @@ * Return status of TDCALL via RAX. */ SYM_FUNC_START(__tdx_module_call) - FRAME_BEGIN TDX_MODULE_CALL host=0 - FRAME_END - RET SYM_FUNC_END(__tdx_module_call) /* diff --git a/arch/x86/virt/vmx/tdx/tdxcall.S b/arch/x86/virt/vmx/tdx/tdxcall.S index 3524915d8bd9..b5ab919c7fa8 100644 --- a/arch/x86/virt/vmx/tdx/tdxcall.S +++ b/arch/x86/virt/vmx/tdx/tdxcall.S @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ #include <asm/asm-offsets.h> +#include <asm/frame.h> #include <asm/tdx.h> /* @@ -18,6 +19,7 @@ * TDX module. */ .macro TDX_MODULE_CALL host:req + FRAME_BEGIN /* * R12 will be used as temporary storage for struct tdx_module_output * pointer. Since R12-R15 registers are not used by TDCALL/SEAMCALL @@ -91,4 +93,7 @@ .Lno_output_struct: /* Restore the state of R12 register */ pop %r12 + + FRAME_END + RET .endm
Currently, the TDX_MODULE_CALL asm macro and the __tdx_module_call() take registers directly as input and a 'struct tdx_module_output' as optional output. This is different from the __tdx_hypercall(), which simply uses a structure to carry all input/output. There's no point to leave __tdx_module_call() complicated as it is. As a preparation to simplify the __tdx_module_call() to make it look like __tdx_hypercall(), move FRAME_BEGIN/END and RET from the __tdx_module_call() to the TDX_MODULE_CALL assembly macro. This also allows more implementation flexibility of the assembly inside the TDX_MODULE_CALL macro, e.g., allowing putting an _ASM_EXTABLE() after the main body of the assembly. 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/coco/tdx/tdcall.S | 3 --- arch/x86/virt/vmx/tdx/tdxcall.S | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-)