lkml.org 
[lkml]   [2022]   [Nov]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v7 07/20] x86/virt/tdx: Do TDX module global initialization
    Date
    The first step of initializing the module is to call TDH.SYS.INIT once
    on any logical cpu to do module global initialization. Do the module
    global initialization.

    It also detects the TDX module, as seamcall() returns -ENODEV when the
    module is not loaded.

    Signed-off-by: Kai Huang <kai.huang@intel.com>
    ---

    v6 -> v7:
    - Improved changelog.

    ---
    arch/x86/virt/vmx/tdx/tdx.c | 19 +++++++++++++++++--
    arch/x86/virt/vmx/tdx/tdx.h | 1 +
    2 files changed, 18 insertions(+), 2 deletions(-)

    diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
    index 5db1a05cb4bd..f292292313bd 100644
    --- a/arch/x86/virt/vmx/tdx/tdx.c
    +++ b/arch/x86/virt/vmx/tdx/tdx.c
    @@ -208,8 +208,23 @@ static void seamcall_on_each_cpu(struct seamcall_ctx *sc)
    */
    static int init_tdx_module(void)
    {
    - /* The TDX module hasn't been detected */
    - return -ENODEV;
    + int ret;
    +
    + /*
    + * Call TDH.SYS.INIT to do the global initialization of
    + * the TDX module. It also detects the module.
    + */
    + ret = seamcall(TDH_SYS_INIT, 0, 0, 0, 0, NULL, NULL);
    + if (ret)
    + goto out;
    +
    + /*
    + * Return -EINVAL until all steps of TDX module initialization
    + * process are done.
    + */
    + ret = -EINVAL;
    +out:
    + return ret;
    }

    static void shutdown_tdx_module(void)
    diff --git a/arch/x86/virt/vmx/tdx/tdx.h b/arch/x86/virt/vmx/tdx/tdx.h
    index 215cc1065d78..0b415805c921 100644
    --- a/arch/x86/virt/vmx/tdx/tdx.h
    +++ b/arch/x86/virt/vmx/tdx/tdx.h
    @@ -15,6 +15,7 @@
    /*
    * TDX module SEAMCALL leaf functions
    */
    +#define TDH_SYS_INIT 33
    #define TDH_SYS_LP_SHUTDOWN 44

    /*
    --
    2.38.1
    \
     
     \ /
      Last update: 2022-11-21 01:28    [W:4.480 / U:1.080 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site