lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220712062100.GG1379820@ls.amr.corp.intel.com>
Date:   Mon, 11 Jul 2022 23:21:00 -0700
From:   Isaku Yamahata <isaku.yamahata@...il.com>
To:     Yuan Yao <yuan.yao@...ux.intel.com>
Cc:     isaku.yamahata@...el.com, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org, isaku.yamahata@...il.com,
        Paolo Bonzini <pbonzini@...hat.com>,
        Sean Christopherson <sean.j.christopherson@...el.com>,
        Kai Huang <kai.huang@...el.com>
Subject: Re: [PATCH v7 022/102] KVM: TDX: create/destroy VM structure

On Thu, Jul 07, 2022 at 02:16:29PM +0800,
Yuan Yao <yuan.yao@...ux.intel.com> wrote:

> On Mon, Jun 27, 2022 at 02:53:14PM -0700, isaku.yamahata@...el.com wrote:
> > diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> > index 3675f7de2735..63f3c7a02cc8 100644
> > --- a/arch/x86/kvm/vmx/tdx.c
> > +++ b/arch/x86/kvm/vmx/tdx.c
...
> >  int __init tdx_module_setup(void)
> >  {
> >  	const struct tdsysinfo_struct *tdsysinfo;
> > @@ -48,6 +406,8 @@ int __init tdx_module_setup(void)
> >  		return ret;
> >  	}
> >
> > +	tdx_global_keyid = tdx_get_global_keyid();
> 
> I remember there's another static variable also named
> "tdx_global_keyid" in arch/x86/virt/vmx/tdx/tdx.c ?
> We can just use tdx_get_global_keyid() here without introducing
> another static variable.

Hmm, it can be done by exporting the variable itself.

 static inline int tdx_keyid_alloc(void) { return -EOPNOTSUPP; }
 static inline void tdx_keyid_free(int keyid) { }
diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
index c1d41350e021..71f6d026bfd2 100644
--- a/arch/x86/kvm/vmx/tdx.c
+++ b/arch/x86/kvm/vmx/tdx.c
@@ -43,14 +43,6 @@ struct tdx_capabilities {
        struct tdx_cpuid_config cpuid_configs[TDX_MAX_NR_CPUID_CONFIGS];
 };
 
-/*
- * Key id globally used by TDX module: TDX module maps TDR with this TDX global
- * key id.  TDR includes key id assigned to the TD.  Then TDX module maps other
- * TD-related pages with the assigned key id.  TDR requires this TDX global key
- * id for cache flush unlike other TD-related pages.
- */
-static u32 tdx_global_keyid __read_mostly;
-
 /* Capabilities of KVM + the TDX module. */
 static struct tdx_capabilities tdx_caps;
 
@@ -3572,8 +3564,6 @@ int __init tdx_module_setup(void)
                return ret;
        }
 
-       tdx_global_keyid = tdx_get_global_keyid();
-
        tdsysinfo = tdx_get_sysinfo();
        if (tdsysinfo->num_cpuid_config > TDX_MAX_NR_CPUID_CONFIGS)
                return -EIO;
diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
index ea35230f0814..68ddcb06c7f1 100644
--- a/arch/x86/virt/vmx/tdx/tdx.c
+++ b/arch/x86/virt/vmx/tdx/tdx.c
@@ -65,13 +65,8 @@ static struct cmr_info tdx_cmr_array[MAX_CMRS] __aligned(CMR_INFO_ARRAY_ALIGNMEN
 static int tdx_cmr_num;
 
 /* TDX module global KeyID.  Used in TDH.SYS.CONFIG ABI. */
-static u32 __read_mostly tdx_global_keyid;
-
-u32 tdx_get_global_keyid(void)
-{
-       return tdx_global_keyid;
-}
-EXPORT_SYMBOL_GPL(tdx_get_global_keyid);
+u32 tdx_global_keyid __ro_after_init;
+EXPORT_SYMBOL_GPL(tdx_global_keyid);
 
 u32 tdx_get_num_keyid(void)
 {

-- 
Isaku Yamahata <isaku.yamahata@...il.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ