[PATCH v18 002/121] x86/virt/tdx: Export SEAMCALL functions

isaku.yamahata@intel.com posted 121 patches 1 year, 11 months ago
There is a newer version of this series
[PATCH v18 002/121] x86/virt/tdx: Export SEAMCALL functions
Posted by isaku.yamahata@intel.com 1 year, 11 months ago
From: Kai Huang <kai.huang@intel.com>

KVM will need to make SEAMCALLs to create and run TDX guests.  Export
SEAMCALL functions for KVM to use.

Also add declaration of SEAMCALL functions to <asm/asm-prototypes.h> to
support CONFIG_MODVERSIONS=y.

Signed-off-by: Kai Huang <kai.huang@intel.com>
---
 arch/x86/include/asm/asm-prototypes.h | 1 +
 arch/x86/virt/vmx/tdx/seamcall.S      | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/arch/x86/include/asm/asm-prototypes.h b/arch/x86/include/asm/asm-prototypes.h
index b1a98fa38828..0ec572ad75f1 100644
--- a/arch/x86/include/asm/asm-prototypes.h
+++ b/arch/x86/include/asm/asm-prototypes.h
@@ -13,6 +13,7 @@
 #include <asm/preempt.h>
 #include <asm/asm.h>
 #include <asm/gsseg.h>
+#include <asm/tdx.h>
 
 #ifndef CONFIG_X86_CMPXCHG64
 extern void cmpxchg8b_emu(void);
diff --git a/arch/x86/virt/vmx/tdx/seamcall.S b/arch/x86/virt/vmx/tdx/seamcall.S
index 5b1f2286aea9..e32cf82ed47e 100644
--- a/arch/x86/virt/vmx/tdx/seamcall.S
+++ b/arch/x86/virt/vmx/tdx/seamcall.S
@@ -1,5 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <linux/linkage.h>
+#include <linux/export.h>
 #include <asm/frame.h>
 
 #include "tdxcall.S"
@@ -21,6 +22,7 @@
 SYM_FUNC_START(__seamcall)
 	TDX_MODULE_CALL host=1
 SYM_FUNC_END(__seamcall)
+EXPORT_SYMBOL_GPL(__seamcall);
 
 /*
  * __seamcall_ret() - Host-side interface functions to SEAM software
@@ -40,6 +42,7 @@ SYM_FUNC_END(__seamcall)
 SYM_FUNC_START(__seamcall_ret)
 	TDX_MODULE_CALL host=1 ret=1
 SYM_FUNC_END(__seamcall_ret)
+EXPORT_SYMBOL_GPL(__seamcall_ret);
 
 /*
  * __seamcall_saved_ret() - Host-side interface functions to SEAM software
@@ -59,3 +62,4 @@ SYM_FUNC_END(__seamcall_ret)
 SYM_FUNC_START(__seamcall_saved_ret)
 	TDX_MODULE_CALL host=1 ret=1 saved=1
 SYM_FUNC_END(__seamcall_saved_ret)
+EXPORT_SYMBOL_GPL(__seamcall_saved_ret);
-- 
2.25.1
Re: [PATCH v18 002/121] x86/virt/tdx: Export SEAMCALL functions
Posted by Paolo Bonzini 1 year, 10 months ago
On Tue, Jan 23, 2024 at 12:54 AM <isaku.yamahata@intel.com> wrote:
>
> From: Kai Huang <kai.huang@intel.com>
>
> KVM will need to make SEAMCALLs to create and run TDX guests.  Export
> SEAMCALL functions for KVM to use.
>
> Also add declaration of SEAMCALL functions to <asm/asm-prototypes.h> to
> support CONFIG_MODVERSIONS=y.
>
> Signed-off-by: Kai Huang <kai.huang@intel.com>

I thought you were going to introduce builtin functions for SEAMCALLs
needed by KVM, instead?

In any case, missing Signed-off-by.

Paolo

> ---
>  arch/x86/include/asm/asm-prototypes.h | 1 +
>  arch/x86/virt/vmx/tdx/seamcall.S      | 4 ++++
>  2 files changed, 5 insertions(+)
>
> diff --git a/arch/x86/include/asm/asm-prototypes.h b/arch/x86/include/asm/asm-prototypes.h
> index b1a98fa38828..0ec572ad75f1 100644
> --- a/arch/x86/include/asm/asm-prototypes.h
> +++ b/arch/x86/include/asm/asm-prototypes.h
> @@ -13,6 +13,7 @@
>  #include <asm/preempt.h>
>  #include <asm/asm.h>
>  #include <asm/gsseg.h>
> +#include <asm/tdx.h>
>
>  #ifndef CONFIG_X86_CMPXCHG64
>  extern void cmpxchg8b_emu(void);
> diff --git a/arch/x86/virt/vmx/tdx/seamcall.S b/arch/x86/virt/vmx/tdx/seamcall.S
> index 5b1f2286aea9..e32cf82ed47e 100644
> --- a/arch/x86/virt/vmx/tdx/seamcall.S
> +++ b/arch/x86/virt/vmx/tdx/seamcall.S
> @@ -1,5 +1,6 @@
>  /* SPDX-License-Identifier: GPL-2.0 */
>  #include <linux/linkage.h>
> +#include <linux/export.h>
>  #include <asm/frame.h>
>
>  #include "tdxcall.S"
> @@ -21,6 +22,7 @@
>  SYM_FUNC_START(__seamcall)
>         TDX_MODULE_CALL host=1
>  SYM_FUNC_END(__seamcall)
> +EXPORT_SYMBOL_GPL(__seamcall);
>
>  /*
>   * __seamcall_ret() - Host-side interface functions to SEAM software
> @@ -40,6 +42,7 @@ SYM_FUNC_END(__seamcall)
>  SYM_FUNC_START(__seamcall_ret)
>         TDX_MODULE_CALL host=1 ret=1
>  SYM_FUNC_END(__seamcall_ret)
> +EXPORT_SYMBOL_GPL(__seamcall_ret);
>
>  /*
>   * __seamcall_saved_ret() - Host-side interface functions to SEAM software
> @@ -59,3 +62,4 @@ SYM_FUNC_END(__seamcall_ret)
>  SYM_FUNC_START(__seamcall_saved_ret)
>         TDX_MODULE_CALL host=1 ret=1 saved=1
>  SYM_FUNC_END(__seamcall_saved_ret)
> +EXPORT_SYMBOL_GPL(__seamcall_saved_ret);
> --
> 2.25.1
>
Re: [PATCH v18 002/121] x86/virt/tdx: Export SEAMCALL functions
Posted by Isaku Yamahata 1 year, 10 months ago
On Thu, Feb 08, 2024 at 02:30:40PM +0100,
Paolo Bonzini <pbonzini@redhat.com> wrote:

> On Tue, Jan 23, 2024 at 12:54 AM <isaku.yamahata@intel.com> wrote:
> >
> > From: Kai Huang <kai.huang@intel.com>
> >
> > KVM will need to make SEAMCALLs to create and run TDX guests.  Export
> > SEAMCALL functions for KVM to use.
> >
> > Also add declaration of SEAMCALL functions to <asm/asm-prototypes.h> to
> > support CONFIG_MODVERSIONS=y.
> >
> > Signed-off-by: Kai Huang <kai.huang@intel.com>
> 
> I thought you were going to introduce builtin functions for SEAMCALLs
> needed by KVM, instead?

After I talked with Kai, I concluded to use the common function.
Probably for TDH.VP.ENTER, we'd like to use customized version to avoid
shuffling registers between struct tdx_module_args and KVM regs.  We can do it
later as optimization.
-- 
Isaku Yamahata <isaku.yamahata@linux.intel.com>