mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miaohe Lin <linmiaohe@huawei.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: <tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>,
	<dave.hansen@linux.intel.com>, <hpa@zytor.com>, <x86@kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86/alternative: fix undefined reference to __ibt_endbr_seal[_end]
Date: Tue, 11 Oct 2022 10:26:38 +0800	[thread overview]
Message-ID: <69523133-ad61-1fcf-e78a-d2017608faff@huawei.com> (raw)
In-Reply-To: <Y0LIcwJKRDJVOW7o@hirez.programming.kicks-ass.net>

On 2022/10/9 21:11, Peter Zijlstra wrote:
> On Sun, Oct 09, 2022 at 08:44:26PM +0800, Miaohe Lin wrote:
>> On 2022/10/9 20:28, Peter Zijlstra wrote:
>>> On Sun, Oct 09, 2022 at 11:45:32PM +0800, Miaohe Lin wrote:
>>>> When I compile the kernel bzImage, there are several compile errors:
>>>>
>>>> ld: arch/x86/kernel/alternative.o: in function
>>>> `alternative_instructions':
>>>> alternative.c:(.init.text+0x15d): undefined reference to
>>>> `__ibt_endbr_seal_end'
>>>> ld: alternative.c:(.init.text+0x164): undefined reference to
>>>> `__ibt_endbr_seal'
>>>>
>>>> It's because __ibt_endbr_seal and __ibt_endbr_seal_end are not optimized
>>>> away when CONFIG_X86_KERNEL_IBT isn't enabled. Remove noinline attribute
>>>> to help gcc optimize them away.
>>>>
>>>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
>>>> ---
>>>>  arch/x86/kernel/alternative.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
>>>> index 5cadcea035e0..beaf9fc44e2f 100644
>>>> --- a/arch/x86/kernel/alternative.c
>>>> +++ b/arch/x86/kernel/alternative.c
>>>> @@ -624,7 +624,7 @@ void __init_or_module noinline apply_ibt_endbr(s32 *start, s32 *end)
>>>>  
>>>>  #else
>>>>  
>>>> -void __init_or_module noinline apply_ibt_endbr(s32 *start, s32 *end) { }
>>>> +void __init_or_module apply_ibt_endbr(s32 *start, s32 *end) { }
>>>>  
>>>>  #endif /* CONFIG_X86_KERNEL_IBT */
>>>>  
>>>
>>> None of this makes any sense...
>>
>> This compile error occurs in my env when CONFIG_X86_KERNEL_IBT isn't
>> enabled with gcc version 7.3.0 (GCC).
> 
> *sigh*... geriatric GCC :/

Yes, a geriatric GCC problem. :(

> 
> Anyway; perhaps clarify the changelog to state something like:
> 
> Due to the explicit 'noinline' GCC-7.3 is not able to optimize away the
> argument setup of:
> 
> 	apply_ibt_endbr(__ibt_endbr_seal, __ibt_enbr_seal_end);
> 
> even when X86_KERNEL_IBT=n and the function is an empty stub -- leading
> to link errors due to missing __ibt_endbr_seal* symbols.

Will do it in v2. Thanks for your suggestion and comment.

Thanks,
Miaohe Lin

> 
> 
> .
> 


      reply	other threads:[~2022-10-11  2:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-09 15:45 Miaohe Lin
2022-10-09 12:28 ` Peter Zijlstra
2022-10-09 12:44   ` Miaohe Lin
2022-10-09 13:11     ` Peter Zijlstra
2022-10-11  2:26       ` Miaohe Lin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=69523133-ad61-1fcf-e78a-d2017608faff@huawei.com \
    --to=linmiaohe@huawei.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®