[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <FFC7041A-2CCA-4C7E-A9C9-6C2C30CE7D28@intel.com>
Date: Mon, 30 Nov 2020 20:40:32 +0000
From: "Bae, Chang Seok" <chang.seok.bae@...el.com>
To: Borislav Petkov <bp@...en8.de>
CC: Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...nel.org>,
Andy Lutomirski <luto@...nel.org>,
"x86@...nel.org" <x86@...nel.org>,
"Brown, Len" <len.brown@...el.com>,
"Hansen, Dave" <dave.hansen@...el.com>,
"hjl.tools@...il.com" <hjl.tools@...il.com>,
"Dave.Martin@....com" <Dave.Martin@....com>,
"mpe@...erman.id.au" <mpe@...erman.id.au>,
"Luck, Tony" <tony.luck@...el.com>,
"Shankar, Ravi V" <ravi.v.shankar@...el.com>,
"libc-alpha@...rceware.org" <libc-alpha@...rceware.org>,
"linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
"linux-api@...r.kernel.org" <linux-api@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 1/4] x86/signal: Introduce helpers to get the maximum
signal frame size
> On Nov 25, 2020, at 20:17, Borislav Petkov <bp@...en8.de> wrote:
>
> On Thu, Nov 19, 2020 at 11:02:34AM -0800, Chang S. Bae wrote:
>> diff --git a/arch/x86/include/asm/sigframe.h b/arch/x86/include/asm/sigframe.h
>> index 84eab2724875..ac77f3f90bc9 100644
>> --- a/arch/x86/include/asm/sigframe.h
>> +++ b/arch/x86/include/asm/sigframe.h
>> @@ -52,6 +52,15 @@ struct rt_sigframe_ia32 {
>> char retcode[8];
>> /* fp state follows here */
>> };
>> +
>> +#define SIZEOF_sigframe_ia32 sizeof(struct sigframe_ia32)
>> +#define SIZEOF_rt_sigframe_ia32 sizeof(struct rt_sigframe_ia32)
>> +
>> +#else
>> +
>> +#define SIZEOF_sigframe_ia32 0
>> +#define SIZEOF_rt_sigframe_ia32 0
>> +
>> #endif /* defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION) */
>>
>> #ifdef CONFIG_X86_64
>> @@ -81,8 +90,22 @@ struct rt_sigframe_x32 {
>> /* fp state follows here */
>> };
>>
>> +#define SIZEOF_rt_sigframe_x32 sizeof(struct rt_sigframe_x32)
>> +
>> #endif /* CONFIG_X86_X32_ABI */
>>
>> +#define SIZEOF_rt_sigframe sizeof(struct rt_sigframe)
>> +
>> +#else
>> +
>> +#define SIZEOF_rt_sigframe 0
>> +
>> #endif /* CONFIG_X86_64 */
>>
>> +#ifndef SIZEOF_rt_sigframe_x32
>> +#define SIZEOF_rt_sigframe_x32 0
>> +#endif
>
> Those are defined here to be used in only one place -
> init_sigframe_size() - where there already is ifdeffery. Just use the
> normal sizeof() operator there instead of adding more gunk here.
[ Just want to clarify your comment. ]
Admittedly, this is an (ugly) workaround to avoid compile errors.
E.g. when code is written like this in the function:
if (IS_ENABLED(CONFIG_X86_X32_ABI))
size = max(size, sizeof(struct rt_sigframe_x32));
and compile with CONFIG_X86_X32_ABI=n, got such a message:
"invalid application of 'sizeof' to incomplete type 'struct
sigframe_ia32’"
While the coding-style doc [1] seems to mention this:
"However, this approach still allows the C compiler to see the
code inside the block, and check it for correctness (syntax,
types, symbol references, etc). Thus, you still have to use an
#ifdef if the code inside the block references symbols that
will not exist if the condition is not met.”
In general, putting #ifdef in a C file is advised to avoid. I wonder
whether it is okay to include #ifdef in the C file in this case.
Thanks,
Chang
[1] https://www.kernel.org/doc/html/v5.9/process/coding-style.html
Powered by blists - more mailing lists