public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] preempt: Move PREEMPT_RT before PREEMPT in vermagic.
@ 2024-12-05 16:06 Sebastian Andrzej Siewior
  2024-12-10 13:52 ` Petr Pavlu
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-12-05 16:06 UTC (permalink / raw)
  To: linux-modules, linux-kernel, linux-rt-devel
  Cc: Ben Segall, Clark Williams, Daniel Gomez, Dietmar Eggemann,
	Ingo Molnar, Juri Lelli, Luis Chamberlain, Mel Gorman,
	Peter Zijlstra, Petr Pavlu, Sami Tolvanen, Steven Rostedt,
	Valentin Schneider, Vincent Guittot, Thomas Gleixner

Since the dynamic preemption has been enabled for PREEMPT_RT we have now
CONFIG_PREEMPT and CONFIG_PREEMPT_RT set simultaneously. This affects
the vermagic strings which comes now PREEMPT with PREEMPT_RT enabled.

The PREEMPT_RT module usually can not be loaded on a PREEMPT kernel
because some symbols are missing.
However if the symbols are fine then it continues and it crashes later.
The problem is that the struct module has a different layout and the
num_exentries or init members are at a different position leading to a
crash later on. This is not necessary caught by the size check in
elf_validity_cache_index_mod() because the mem member has an alignment
requirement of __module_memory_align which is big enough keep the total
size unchanged. Therefore we should keep the string accurate instead of
removing it.

Move the PREEMPT_RT check before the PREEMPT so that it takes precedence
if both symbols are enabled.

Fixes: 35772d627b55c ("sched: Enable PREEMPT_DYNAMIC for PREEMPT_RT")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 include/linux/vermagic.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
index a54046bf37e55..939ceabcaf06f 100644
--- a/include/linux/vermagic.h
+++ b/include/linux/vermagic.h
@@ -15,10 +15,10 @@
 #else
 #define MODULE_VERMAGIC_SMP ""
 #endif
-#ifdef CONFIG_PREEMPT_BUILD
-#define MODULE_VERMAGIC_PREEMPT "preempt "
-#elif defined(CONFIG_PREEMPT_RT)
+#ifdef CONFIG_PREEMPT_RT
 #define MODULE_VERMAGIC_PREEMPT "preempt_rt "
+#elif defined(CONFIG_PREEMPT_BUILD)
+#define MODULE_VERMAGIC_PREEMPT "preempt "
 #else
 #define MODULE_VERMAGIC_PREEMPT ""
 #endif
-- 
2.45.2


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

* Re: [PATCH] preempt: Move PREEMPT_RT before PREEMPT in vermagic.
  2024-12-05 16:06 [PATCH] preempt: Move PREEMPT_RT before PREEMPT in vermagic Sebastian Andrzej Siewior
@ 2024-12-10 13:52 ` Petr Pavlu
  2024-12-10 14:10   ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Pavlu @ 2024-12-10 13:52 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: linux-modules, linux-kernel, linux-rt-devel, Ben Segall,
	Clark Williams, Daniel Gomez, Dietmar Eggemann, Ingo Molnar,
	Juri Lelli, Luis Chamberlain, Mel Gorman, Peter Zijlstra,
	Petr Pavlu, Sami Tolvanen, Steven Rostedt, Valentin Schneider,
	Vincent Guittot, Thomas Gleixner

On 12/5/24 17:06, Sebastian Andrzej Siewior wrote:
> Since the dynamic preemption has been enabled for PREEMPT_RT we have now
> CONFIG_PREEMPT and CONFIG_PREEMPT_RT set simultaneously. This affects
> the vermagic strings which comes now PREEMPT with PREEMPT_RT enabled.
> 
> The PREEMPT_RT module usually can not be loaded on a PREEMPT kernel
> because some symbols are missing.
> However if the symbols are fine then it continues and it crashes later.
> The problem is that the struct module has a different layout and the
> num_exentries or init members are at a different position leading to a
> crash later on. This is not necessary caught by the size check in
> elf_validity_cache_index_mod() because the mem member has an alignment
> requirement of __module_memory_align which is big enough keep the total
> size unchanged. Therefore we should keep the string accurate instead of
> removing it.
> 
> Move the PREEMPT_RT check before the PREEMPT so that it takes precedence
> if both symbols are enabled.
> 
> Fixes: 35772d627b55c ("sched: Enable PREEMPT_DYNAMIC for PREEMPT_RT")
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>

I'm going to wait for a few days if others want to comment and then plan
to take this through the modules tree for 6.13-rcX fixes.

[Luis asked me to look after the modules tree for a while, with the plan
to rotate it.]

-- 
Thanks,
Petr

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

* Re: [PATCH] preempt: Move PREEMPT_RT before PREEMPT in vermagic.
  2024-12-10 13:52 ` Petr Pavlu
@ 2024-12-10 14:10   ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2024-12-10 14:10 UTC (permalink / raw)
  To: Petr Pavlu
  Cc: linux-modules, linux-kernel, linux-rt-devel, Ben Segall,
	Clark Williams, Daniel Gomez, Dietmar Eggemann, Ingo Molnar,
	Juri Lelli, Luis Chamberlain, Mel Gorman, Peter Zijlstra,
	Sami Tolvanen, Steven Rostedt, Valentin Schneider,
	Vincent Guittot, Thomas Gleixner

On 2024-12-10 14:52:23 [+0100], Petr Pavlu wrote:
> 
> Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>
> 
> I'm going to wait for a few days if others want to comment and then plan
> to take this through the modules tree for 6.13-rcX fixes.

thank you.

> [Luis asked me to look after the modules tree for a while, with the plan
> to rotate it.]

understood.

Sebastian

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

end of thread, other threads:[~2024-12-10 14:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-05 16:06 [PATCH] preempt: Move PREEMPT_RT before PREEMPT in vermagic Sebastian Andrzej Siewior
2024-12-10 13:52 ` Petr Pavlu
2024-12-10 14:10   ` Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox