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]
Date:   Wed, 14 Jun 2023 23:14:04 +0000
From:   "Huang, Kai" <kai.huang@...el.com>
To:     "isaku.yamahata@...il.com" <isaku.yamahata@...il.com>
CC:     "Christopherson,, Sean" <seanjc@...gle.com>,
        "Chen, Bo2" <chen.bo@...el.com>, "Shahar, Sagi" <sagis@...gle.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "Aktas, Erdem" <erdemaktas@...gle.com>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "pbonzini@...hat.com" <pbonzini@...hat.com>,
        "Yamahata, Isaku" <isaku.yamahata@...el.com>,
        "dmatlack@...gle.com" <dmatlack@...gle.com>,
        "zhi.wang.linux@...il.com" <zhi.wang.linux@...il.com>
Subject: Re: [PATCH v14 004/113] KVM: TDX: Initialize the TDX module when
 loading the KVM intel kernel module

On Wed, 2023-06-14 at 09:05 -0700, Isaku Yamahata wrote:
> On Wed, Jun 14, 2023 at 09:41:58AM +0000,
> "Huang, Kai" <kai.huang@...el.com> wrote:
> 
> > On Tue, 2023-06-13 at 10:38 -0700, Isaku Yamahata wrote:
> > > On Mon, Jun 12, 2023 at 11:55:14PM +0000,
> > > "Huang, Kai" <kai.huang@...el.com> wrote:
> > > 
> > > > On Wed, 2023-06-07 at 11:06 -0700, Isaku Yamahata wrote:
> > > > > Thanks for pointing it out. The following is the fix.
> > > > > 
> > > > > diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> > > > > index 8a1d0755d275..b0d3f646afb1 100644
> > > > > --- a/arch/x86/kvm/vmx/tdx.c
> > > > > +++ b/arch/x86/kvm/vmx/tdx.c
> > > > > @@ -4499,26 +4499,39 @@ u64 tdx_non_arch_field_switch(u64 field)
> > > > >  	}
> > > > >  }
> > > > >  
> > > > > -static void __init vmx_tdx_on(void *info)
> > > > > +struct vmx_tdx_enabled {
> > > > > +	cpumask_var_t vmx_enabled;
> > > > > +	atomic_t *err;
> > > > > +};
> > > > > +
> > > > 
> > > > Sorry for late reply.
> > > > 
> > > > I think you just need to mimic hardware_enable_all() -- using a per-cpu
> > > > variable.  In this way you can get rid of this structure.
> > > > 
> > > > But again, we have listed a couple of options in the v13 discussion [1]:
> > > > 
> > > > 1) Call kvm_ops_update() twice before and after hardware_setup() in order to use
> > > > hardware_enable_all() directly.
> > > > 
> > > > 2) Expose kvm_x86_ops as symbol so VMX can set hardware_{enable|disable}()
> > > > callback before hardware_setup() in order to use hardware_enable_all().
> > > > 
> > > > 3) Implement VMX's own hardware_enable_all() logic as shown in this patch.
> > > > 
> > > > 4) ???
> > > > 
> > > > I think it would be better if Sean can provide some comments here, but until he
> > > > does, we can keep using option 3) (this patch).
> > > > 
> > > > [1]
> > > > https://lore.kernel.org/lkml/5dc84a2601a47ccc29ef43200cf3ec0d1b485d23.camel@intel.com/
> > > 
> > > Ok, makes sense. Here is the updated version with the fix for the error you
> > > pointed out.  Introduce cpu bitmap to track which cpu enable VMX(VMXON)
> > > successfully.  Disable VMX off only for cpu with bit set.
> > > 
> > > 
> > [...]
> > 
> > > +struct vmx_tdx_enabled {
> > > +	cpumask_var_t vmx_enabled;
> > > +	atomic_t err;
> > > +};
> > > +
> > 
> > Again (and again), why not just mimic hardware_enable_all() to use a per-cpu
> > variable instead of a cpumask, so that you can get rid of this structure?
> 
> Do you mean __hardware_enable_nolock() uses per-cpu variable?

Yes.

> Because hardware setup is one shot on the initialization, we don't want to
> allocate the variable statically. Anyway the following is a patch to use
> per-cpu variable with dynamic allocation.  Which version do you prefer?

This looks over-complicated.  My preference is to mimic
__hardware_enable_nolock() to avoid the 'struct vmx_tdx_enabled'.  But if you
care about the variable being statically, then looks your current cpumask_var_t
looks cleaner to me

Anyway, since you have mentioned the reason, and I understand your concern now,
I will leave this to you.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ