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, 18 Oct 2023 06:51:38 +0000
From:   "Huang, Kai" <kai.huang@...el.com>
To:     "sathyanarayanan.kuppuswamy@...ux.intel.com" 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC:     "Hansen, Dave" <dave.hansen@...el.com>,
        "david@...hat.com" <david@...hat.com>,
        "bagasdotme@...il.com" <bagasdotme@...il.com>,
        "ak@...ux.intel.com" <ak@...ux.intel.com>,
        "kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>,
        "Christopherson,, Sean" <seanjc@...gle.com>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "pbonzini@...hat.com" <pbonzini@...hat.com>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "Yamahata, Isaku" <isaku.yamahata@...el.com>,
        "nik.borisov@...e.com" <nik.borisov@...e.com>,
        "Luck, Tony" <tony.luck@...el.com>,
        "hpa@...or.com" <hpa@...or.com>,
        "peterz@...radead.org" <peterz@...radead.org>,
        "Shahar, Sagi" <sagis@...gle.com>,
        "imammedo@...hat.com" <imammedo@...hat.com>,
        "bp@...en8.de" <bp@...en8.de>, "Gao, Chao" <chao.gao@...el.com>,
        "rafael@...nel.org" <rafael@...nel.org>,
        "Brown, Len" <len.brown@...el.com>,
        "Huang, Ying" <ying.huang@...el.com>,
        "Williams, Dan J" <dan.j.williams@...el.com>,
        "x86@...nel.org" <x86@...nel.org>
Subject: Re: [PATCH v14 07/23] x86/virt/tdx: Add skeleton to enable TDX on
 demand


> > +/*
> > + * Do the module global initialization once and return its result.
> > + * It can be done on any cpu.  It's always called with interrupts
> > + * disabled.
> > + */
> > +static int try_init_module_global(void)
> > +{
> > +	struct tdx_module_args args = {};
> > +	static DEFINE_RAW_SPINLOCK(sysinit_lock);
> > +	static bool sysinit_done;
> > +	static int sysinit_ret;
> > +
> > +	lockdep_assert_irqs_disabled();
> > +
> > +	raw_spin_lock(&sysinit_lock);
> > +
> > +	if (sysinit_done)
> > +		goto out;
> > +
> > +	/* RCX is module attributes and all bits are reserved */
> > +	args.rcx = 0;
> 
> Isn't args.rcx already initialized to 0, why explixitly set it?

The purpose was to indicate SYS.INIT takes RCX as input, but OK I agree it's
unnecessary.

I found the existing upstream TDX code uses this pattern (please see
tdx_parse_info(), hv_tdx_hypercall() and try_accept_one()):

	struct tdx_module_args args = {};

	args.xx = xx;
	args.yy = yy;
	...

So I followed in this series.  

But I think explicit zeroing the structure isn't needed, so I think I'll just
remove the explicit initialization in the @args declaration in all SEAMCALLs
which use this pattern in this series:

	struct tdx_module_args args;

	/* RCX is module attributes and all bits are reserved */
	args.rcx = 0;

Or just explicitly init RCX in the declaration:

	struct tdx_module_args args = {
		.rcx = 0;	/* Module attributes. All bits reserved. */
	};
	// other variable declarations

But it seems many people don't like tail comment.

Hi Kirill/Dave,

Do you have any preference?
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ