All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2] x86/alternative: fix undefined reference to __ibt_endbr_seal[_end]
  2022-10-11 11:38 [PATCH v2] x86/alternative: fix undefined reference to __ibt_endbr_seal[_end] Miaohe Lin
@ 2022-10-11  3:46 ` Miaohe Lin
  2022-12-02  8:46 ` Miaohe Lin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Miaohe Lin @ 2022-10-11  3:46 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen; +Cc: hpa, x86, linux-kernel, Peter Zijlstra

On 2022/10/11 19:38, Miaohe Lin wrote:
> 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 which leads
> to link errors due to missing __ibt_endbr_seal* symbols like below:
> 
> 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'
> 
> Remove explicit 'noinline' to help gcc optimize them away.
> [Thanks Peter Zijlstra for tweaking the commit log.]
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>

Add cc Peter Zijlstra.

Change log for v2:
Tweak the commit log per Peter Zijlstra. Thanks!

I should have done this in previous thread. Sorry for make noise.

Thanks,
Miaohe Lin


> ---
>  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 */
>  
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] x86/alternative: fix undefined reference to __ibt_endbr_seal[_end]
@ 2022-10-11 11:38 Miaohe Lin
  2022-10-11  3:46 ` Miaohe Lin
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Miaohe Lin @ 2022-10-11 11:38 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen; +Cc: hpa, x86, linux-kernel, linmiaohe

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 which leads
to link errors due to missing __ibt_endbr_seal* symbols like below:

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'

Remove explicit 'noinline' to help gcc optimize them away.
[Thanks Peter Zijlstra for tweaking the commit log.]

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 */
 
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] x86/alternative: fix undefined reference to __ibt_endbr_seal[_end]
  2022-10-11 11:38 [PATCH v2] x86/alternative: fix undefined reference to __ibt_endbr_seal[_end] Miaohe Lin
  2022-10-11  3:46 ` Miaohe Lin
@ 2022-12-02  8:46 ` Miaohe Lin
  2022-12-02 11:59 ` Thomas Gleixner
  2022-12-05 10:59 ` [tip: x86/urgent] x86/alternative: Remove noinline from __ibt_endbr_seal[_end]() stubs tip-bot2 for Miaohe Lin
  3 siblings, 0 replies; 6+ messages in thread
From: Miaohe Lin @ 2022-12-02  8:46 UTC (permalink / raw)
  To: tglx, mingo, bp, dave.hansen; +Cc: hpa, x86, linux-kernel

Friendly ping ;)

On 2022/10/11 19:38, Miaohe Lin wrote:
> 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 which leads
> to link errors due to missing __ibt_endbr_seal* symbols like below:
> 
> 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'
> 
> Remove explicit 'noinline' to help gcc optimize them away.
> [Thanks Peter Zijlstra for tweaking the commit log.]
> 
> 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 */
>  
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] x86/alternative: fix undefined reference to __ibt_endbr_seal[_end]
  2022-10-11 11:38 [PATCH v2] x86/alternative: fix undefined reference to __ibt_endbr_seal[_end] Miaohe Lin
  2022-10-11  3:46 ` Miaohe Lin
  2022-12-02  8:46 ` Miaohe Lin
@ 2022-12-02 11:59 ` Thomas Gleixner
  2022-12-03  1:20   ` Miaohe Lin
  2022-12-05 10:59 ` [tip: x86/urgent] x86/alternative: Remove noinline from __ibt_endbr_seal[_end]() stubs tip-bot2 for Miaohe Lin
  3 siblings, 1 reply; 6+ messages in thread
From: Thomas Gleixner @ 2022-12-02 11:59 UTC (permalink / raw)
  To: Miaohe Lin, mingo, bp, dave.hansen; +Cc: hpa, x86, linux-kernel, linmiaohe

On Tue, Oct 11 2022 at 19:38, Miaohe Lin wrote:
> 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 which leads
> to link errors due to missing __ibt_endbr_seal* symbols like below:
>
> 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'

This is incomplete because the noinline is only visible within
alternative.c, but there is another caller in module.c

This needs an inline stub in the header to be correct.

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] x86/alternative: fix undefined reference to __ibt_endbr_seal[_end]
  2022-12-02 11:59 ` Thomas Gleixner
@ 2022-12-03  1:20   ` Miaohe Lin
  0 siblings, 0 replies; 6+ messages in thread
From: Miaohe Lin @ 2022-12-03  1:20 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: hpa, x86, linux-kernel, mingo, bp, dave.hansen

On 2022/12/2 19:59, Thomas Gleixner wrote:
> On Tue, Oct 11 2022 at 19:38, Miaohe Lin wrote:
>> 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 which leads
>> to link errors due to missing __ibt_endbr_seal* symbols like below:
>>
>> 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'
> 
> This is incomplete because the noinline is only visible within
> alternative.c, but there is another caller in module.c
> 
> This needs an inline stub in the header to be correct.
> 

I see. I think I should update my gcc instead :) Thanks for your reply.

Thanks,
Miaohe Lin



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip: x86/urgent] x86/alternative: Remove noinline from __ibt_endbr_seal[_end]() stubs
  2022-10-11 11:38 [PATCH v2] x86/alternative: fix undefined reference to __ibt_endbr_seal[_end] Miaohe Lin
                   ` (2 preceding siblings ...)
  2022-12-02 11:59 ` Thomas Gleixner
@ 2022-12-05 10:59 ` tip-bot2 for Miaohe Lin
  3 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Miaohe Lin @ 2022-12-05 10:59 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Miaohe Lin, Thomas Gleixner, x86, linux-kernel

The following commit has been merged into the x86/urgent branch of tip:

Commit-ID:     023e59d4cee91dd3ca811eb01db2c5fb9f783dc2
Gitweb:        https://git.kernel.org/tip/023e59d4cee91dd3ca811eb01db2c5fb9f783dc2
Author:        Miaohe Lin <linmiaohe@huawei.com>
AuthorDate:    Tue, 11 Oct 2022 19:38:03 +08:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 02 Dec 2022 12:54:43 +01:00

x86/alternative: Remove noinline from __ibt_endbr_seal[_end]() stubs

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, which leads
to link errors due to missing __ibt_endbr_seal* symbols:

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'

Remove the explicit 'noinline' to help gcc optimize them away.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20221011113803.956808-1-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 5cadcea..beaf9fc 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 */
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-12-05 10:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-11 11:38 [PATCH v2] x86/alternative: fix undefined reference to __ibt_endbr_seal[_end] Miaohe Lin
2022-10-11  3:46 ` Miaohe Lin
2022-12-02  8:46 ` Miaohe Lin
2022-12-02 11:59 ` Thomas Gleixner
2022-12-03  1:20   ` Miaohe Lin
2022-12-05 10:59 ` [tip: x86/urgent] x86/alternative: Remove noinline from __ibt_endbr_seal[_end]() stubs tip-bot2 for Miaohe Lin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.