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: <BL1PR11MB597838368ECEC7C54DA0FE74F7DD9@BL1PR11MB5978.namprd11.prod.outlook.com>
Date:   Mon, 13 Feb 2023 21:21:45 +0000
From:   "Huang, Kai" <kai.huang@...el.com>
To:     "Hansen, Dave" <dave.hansen@...el.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>
CC:     "linux-mm@...ck.org" <linux-mm@...ck.org>,
        "peterz@...radead.org" <peterz@...radead.org>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "Christopherson,, Sean" <seanjc@...gle.com>,
        "pbonzini@...hat.com" <pbonzini@...hat.com>,
        "Williams, Dan J" <dan.j.williams@...el.com>,
        "Wysocki, Rafael J" <rafael.j.wysocki@...el.com>,
        "kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>,
        "Huang, Ying" <ying.huang@...el.com>,
        "Chatre, Reinette" <reinette.chatre@...el.com>,
        "Brown, Len" <len.brown@...el.com>,
        "Luck, Tony" <tony.luck@...el.com>,
        "ak@...ux.intel.com" <ak@...ux.intel.com>,
        "Yamahata, Isaku" <isaku.yamahata@...el.com>,
        "Gao, Chao" <chao.gao@...el.com>,
        "sathyanarayanan.kuppuswamy@...ux.intel.com" 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>,
        "david@...hat.com" <david@...hat.com>,
        "bagasdotme@...il.com" <bagasdotme@...il.com>,
        "Shahar, Sagi" <sagis@...gle.com>,
        "imammedo@...hat.com" <imammedo@...hat.com>
Subject: RE: [PATCH v9 05/18] x86/virt/tdx: Add SEAMCALL infrastructure

> On 2/13/23 03:59, Kai Huang wrote:
> > diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h
> > index 4a3ee64c1ca7..5c5ecfddb15b 100644
> > --- a/arch/x86/include/asm/tdx.h
> > +++ b/arch/x86/include/asm/tdx.h
> > @@ -8,6 +8,10 @@
> >  #include <asm/ptrace.h>
> >  #include <asm/shared/tdx.h>
> >
> > +#ifdef CONFIG_INTEL_TDX_HOST
> ...
> > +#define TDX_SEAMCALL_GP			(TDX_SW_ERROR |
> X86_TRAP_GP)
> > +#define TDX_SEAMCALL_UD			(TDX_SW_ERROR |
> X86_TRAP_UD)
> > +
> > +#endif
> 
> All these kinds of header #ifdefs do it make it harder to write code in .c files
> without matching #ifdefs.  Think of code like this completely made up example:
> 
> 	if (!tdx_enable()) {
> 		// Success!  Make a seamcall:
> 		int something = tdx_seamcall();
> 		if (something == TDX_SEAMCALL_UD)
> 			// oh no!
> 	}
> 
> tdx_enable() can never return 0 if CONFIG_INTEL_TDX_HOST=n, so the entire if()
> block is optimized away by the compiler.  *BUT*, if you've #ifdef'd away
> TDX_SEAMCALL_UD, you'll get a compile error.  People usually fix the compile
> error like this:
> 
> 	if (!tdx_enable()) {
> #ifdef CONFIG_INTEL_TDX_HOST
> 		// Success!  Make a seamcall:
> 		int something = tdx_seamcall();
> 		if (something == TDX_SEAMCALL_UD)
> 			// oh no!
> #endif
> 	}
> 
> Which isn't great.
> 
> Defining things unconditionally in header files is *FINE*, as long as the #ifdefs
> are there somewhere to make the code go away at compile time.

Thanks for the explanation above!

> 
> Please post an updated (and tested) patch as a reply to this.

Will do.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ