v6.13-rc6-rt3
Subsystems (18)
Sebastian Andrzej Siewior
maintainerDear RT folks!
I'm pleased to announce the v6.13-rc6-rt3 patch set.
Changes since v6.13-rc6-rt2:
- Adding Lazy-Preempt for PowerPC. This also fixes a boot problem on certain PowerPC parts. The regression was introduced after dropping the old Lazy-Preempt patches for PowerPC back in v6.6-rc6-rt10. Reported by Robert Joslyn, patch by Shrikanth Hegde.
- Update the modules core clean up patch series to v3.
Known issues
None.
The delta patch against v6.13-rc6-rt2 is appended below and can be found here:
https://cdn.kernel.org/pub/linux/kernel/projects/rt/6.13/incr/patch-6.13-rc6-rt2-rt3.patch.xz
You can get this release via the git tree at:
https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git v6.13-rc6-rt3
The RT patch against v6.13-rc6 can be found here:
https://cdn.kernel.org/pub/linux/kernel/projects/rt/6.13/older/patch-6.13-rc6-rt3.patch.xz
The split quilt queue is available at:
https://cdn.kernel.org/pub/linux/kernel/projects/rt/6.13/older/patches-6.13-rc6-rt3.tar.xz
Sebastian
arch/arm/kernel/module-plts.c +1 -3
@@ -285,11 +285,9 @@ bool in_module_plt(unsigned long loc)struct module *mod;bool ret; -preempt_disable (); +guard (rcu)(); mod =__module_text_address (loc); ret = mod && (loc - (u32 )mod->arch.core.plt_ent < mod->arch.core.plt_count *PLT_ENT_SIZE || loc - (u32 )mod->arch.init.plt_ent < mod->arch.init.plt_count *PLT_ENT_SIZE ); -preempt_enable (); -return ret; }
arch/arm64/kernel/ftrace.c +3 -4
@@ -257,14 +257,13 @@ static bool ftrace_find_callable_addr(struct dyn_ftrace *rec,* dealing with an out-of-range condition, we can assume it * is due to a module being loaded far away from the kernel. * -* NOTE: __module_text_address() must be called with preemption -* disabled, but we can rely on ftrace_lock to ensure that 'mod' +* NOTE: __module_text_address() must be called within a RCU read +* section, but we can rely on ftrace_lock to ensure that 'mod' * retains its validity throughout the remainder of this code. */ if (!mod) { -preempt_disable (); +guard (rcu)(); mod =__module_text_address (pc); -preempt_enable (); }if (WARN_ON (!mod))
arch/loongarch/kernel/ftrace_dyn.c +4 -5
@@ -85,14 +85,13 @@ static bool ftrace_find_callable_addr(struct dyn_ftrace *rec, struct module *mod* dealing with an out-of-range condition, we can assume it * is due to a module being loaded far away from the kernel. * -* NOTE: __module_text_address() must be called with preemption -* disabled, but we can rely on ftrace_lock to ensure that 'mod' +* NOTE: __module_text_address() must be called within a RCU read +* section, but we can rely on ftrace_lock to ensure that 'mod' * retains its validity throughout the remainder of this code. */ if (!mod) { -preempt_disable (); - mod =__module_text_address (pc); -preempt_enable (); +scoped_guard (rcu) + mod =__module_text_address (pc); }if (WARN_ON (!mod))
arch/loongarch/kernel/unwind_orc.c +1 -3
@@ -399,7 +399,7 @@ bool unwind_next_frame(struct unwind_state *state)return false;/* Don't let modules unload while we're reading their ORC data. */ -preempt_disable (); +guard (rcu)();if (is_entry_func (state->pc)) goto end;
@@ -514,14 +514,12 @@ bool unwind_next_frame(struct unwind_state *state)if (!__kernel_text_address (state->pc)) goto err; -preempt_enable ();return true; err: state->error = true; end: -preempt_enable (); state->stack_info.type =STACK_TYPE_UNKNOWN ;return false; }
arch/powerpc/Kconfig +1 -0
@@ -145,6 +145,7 @@ config PPC select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE select ARCH_HAS_PHYS_TO_DMA select ARCH_HAS_PMEM_API + select ARCH_HAS_PREEMPT_LAZY select ARCH_HAS_PTE_DEVMAP if PPC_BOOK3S_64 select ARCH_HAS_PTE_SPECIAL select ARCH_HAS_SCALED_CPUTIME if VIRT_CPU_ACCOUNTING_NATIVE && PPC_BOOK3S_64
arch/powerpc/include/asm/thread_info.h +6 -3
@@ -103,6 +103,7 @@ void arch_setup_new_exec(void);#define TIF_PATCH_PENDING 6/* pending live patching update */ #define TIF_SYSCALL_AUDIT 7/* syscall auditing active */ #define TIF_SINGLESTEP 8/* singlestepping active */ +#define TIF_NEED_RESCHED_LAZY 9/* Scheduler driven lazy preemption */ #define TIF_SECCOMP 10/* secure computing */ #define TIF_RESTOREALL 11/* Restore all regs (implies NOERROR) */ #define TIF_NOERROR 12/* Force successful syscall return */
@@ -122,6 +123,7 @@ void arch_setup_new_exec(void);#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) +#define _TIF_NEED_RESCHED_LAZY (1<<TIF_NEED_RESCHED_LAZY)#define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL)#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)#define _TIF_32BIT (1<<TIF_32BIT)
@@ -142,9 +144,10 @@ void arch_setup_new_exec(void); _TIF_SYSCALL_EMU)#define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \ - _TIF_NOTIFY_RESUME | _TIF_UPROBE | \ - _TIF_RESTORE_TM | _TIF_PATCH_PENDING | \ - _TIF_NOTIFY_SIGNAL) + _TIF_NEED_RESCHED_LAZY | _TIF_NOTIFY_RESUME | \ + _TIF_UPROBE | _TIF_RESTORE_TM | \ + _TIF_PATCH_PENDING | _TIF_NOTIFY_SIGNAL) +#define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR)/* Bits in local_flags */
arch/powerpc/kernel/interrupt.c +2 -2
@@ -185,7 +185,7 @@ interrupt_exit_user_prepare_main(unsigned long ret, struct pt_regs *regs) ti_flags =read_thread_flags ();while (unlikely (ti_flags & (_TIF_USER_WORK_MASK & ~_TIF_RESTORE_TM))) {local_irq_enable (); -if (ti_flags & _TIF_NEED_RESCHED) { +if (ti_flags & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY)) {schedule (); }else {/*
@@ -396,7 +396,7 @@ notrace unsigned long interrupt_exit_kernel_prepare(struct pt_regs *regs)/* Returning to a kernel context with local irqs enabled. */ WARN_ON_ONCE (!(regs->msr &MSR_EE )); again: -if (IS_ENABLED (CONFIG_PREEMPT )) { +if (IS_ENABLED (CONFIG_PREEMPTION )) {/* Return to preemptible kernel context */ if (unlikely (read_thread_flags () & _TIF_NEED_RESCHED)) {if (preempt_count () ==0 )
arch/powerpc/kernel/trace/ftrace.c +2 -4
@@ -115,10 +115,8 @@ static unsigned long ftrace_lookup_module_stub(unsigned long ip, unsigned long a {struct module *mod =NULL ; -preempt_disable (); - mod =__module_text_address (ip); -preempt_enable (); - +scoped_guard (rcu) + mod =__module_text_address (ip);if (!mod)pr_err ("No module loaded at addr=%lx\n" , ip);
arch/powerpc/kernel/trace/ftrace_64_pg.c +2 -4
@@ -120,10 +120,8 @@ static struct module *ftrace_lookup_module(struct dyn_ftrace *rec) {struct module *mod; -preempt_disable (); - mod =__module_text_address (rec->ip); -preempt_enable (); - +scoped_guard (rcu) + mod =__module_text_address (rec->ip);if (!mod)pr_err ("No module loaded at addr=%lx\n" , rec->ip);
arch/powerpc/lib/vmx-helper.c +1 -1
@@ -45,7 +45,7 @@ int exit_vmx_usercopy(void)* set and we are preemptible. The hack here is to schedule a * decrementer to fire here and reschedule for us if necessary. */ -if (IS_ENABLED (CONFIG_PREEMPT ) &&need_resched ()) +if (IS_ENABLED (CONFIG_PREEMPTION ) &&need_resched ())set_dec (1 );return 0 ; }
arch/x86/kernel/callthunks.c +1 -2
@@ -98,11 +98,10 @@ static inline bool within_module_coretext(void *addr)#ifdef CONFIG_MODULES struct module *mod; -preempt_disable (); +guard (rcu)(); mod =__module_address ((unsigned long )addr);if (mod &&within_module_core ((unsigned long )addr, mod)) ret = true; -preempt_enable ();#endif return ret; }
arch/x86/kernel/unwind_orc.c +1 -3
@@ -476,7 +476,7 @@ bool unwind_next_frame(struct unwind_state *state)return false;/* Don't let modules unload while we're reading their ORC data. */ -preempt_disable (); +guard (rcu)();/* End-of-stack check for user tasks: */ if (state->regs &&user_mode (state->regs))
@@ -669,14 +669,12 @@ bool unwind_next_frame(struct unwind_state *state) goto err; } -preempt_enable ();return true; err: state->error = true; the_end: -preempt_enable (); state->stack_info.type =STACK_TYPE_UNKNOWN ;return false; }
include/linux/kallsyms.h +1 -2
@@ -55,9 +55,8 @@ static inline void *dereference_symbol_descriptor(void *ptr)if (is_ksym_addr ((unsigned long )ptr))return ptr; -preempt_disable (); +guard (rcu)(); mod =__module_address ((unsigned long )ptr); -preempt_enable ();if (mod) ptr =dereference_module_function_descriptor (mod, ptr);
include/linux/module.h +1 -1
@@ -663,7 +663,7 @@ static inline bool within_module(unsigned long addr, const struct module *mod)return within_module_init (addr, mod) ||within_module_core (addr, mod); } -/* Search for module by name: must be in a RCU-sched critical section. */ +/* Search for module by name: must be in a RCU critical section. */ struct module *find_module (const char *name); extern void __noreturn __module_put_and_kthread_exit(struct module *mod,
kernel/cfi.c +1 -4
@@ -71,14 +71,11 @@ static bool is_module_cfi_trap(unsigned long addr)struct module *mod;bool found = false; -rcu_read_lock_sched_notrace (); - +guard (rcu)(); mod =__module_address (addr);if (mod) found =is_trap (addr, mod->kcfi_traps, mod->kcfi_traps_end); -rcu_read_unlock_sched_notrace (); - return found; }#else /* CONFIG_MODULES */
kernel/jump_label.c +15 -16
@@ -653,13 +653,12 @@ static int __jump_label_mod_text_reserved(void *start, void *end)struct module *mod;int ret; -preempt_disable (); - mod =__module_text_address ((unsigned long )start); -WARN_ON_ONCE (__module_text_address ((unsigned long )end) != mod); -if (!try_module_get (mod)) - mod =NULL ; -preempt_enable (); - +scoped_guard (rcu) { + mod =__module_text_address ((unsigned long )start); +WARN_ON_ONCE (__module_text_address ((unsigned long )end) != mod); +if (!try_module_get (mod)) + mod =NULL ; + }if (!mod)return 0 ;
@@ -746,9 +745,9 @@ static int jump_label_add_module(struct module *mod)kfree (jlm);return -ENOMEM ; } -preempt_disable (); - jlm2->mod =__module_address ((unsigned long )key); -preempt_enable (); +scoped_guard (rcu) + jlm2->mod = __module_address((unsigned long)key); + jlm2->entries =static_key_entries (key); jlm2->next =NULL ;static_key_set_mod (key, jlm2);
@@ -906,13 +905,13 @@ static void jump_label_update(struct static_key *key) return; } -preempt_disable (); - mod =__module_address ((unsigned long )key); -if (mod) { - stop = mod->jump_entries + mod->num_jump_entries; - init = mod->state ==MODULE_STATE_COMING ; +scoped_guard (rcu) { + mod =__module_address ((unsigned long )key); +if (mod) { + stop = mod->jump_entries + mod->num_jump_entries; + init = mod->state ==MODULE_STATE_COMING ; + } } -preempt_enable ();#endif entry =static_key_entries (key);/* if there are no users, entry can be NULL */
kernel/kprobes.c +2 -2
@@ -1566,7 +1566,7 @@ static int check_kprobe_address_safe(struct kprobe *p,if (ret)return ret;jump_label_lock (); -preempt_disable (); +rcu_read_lock ();/* Ensure the address is in a text area, and find a module if exists. */ *probed_mod =NULL ;
@@ -1612,7 +1612,7 @@ static int check_kprobe_address_safe(struct kprobe *p, } out: -preempt_enable (); +rcu_read_unlock ();jump_label_unlock ();return ret;
kernel/livepatch/core.c +1 -3
@@ -59,7 +59,7 @@ static void klp_find_object_module(struct klp_object *obj)if (!klp_is_module (obj))return ; -rcu_read_lock_sched (); +guard (rcu)();/* * We do not want to block removal of patched modules and therefore * we do not take a reference here. The patches are removed by
@@ -75,8 +75,6 @@ static void klp_find_object_module(struct klp_object *obj)*/ if (mod && mod->klp_alive) obj->mod = mod; - -rcu_read_unlock_sched (); }static bool klp_initialized (void )
kernel/module/kallsyms.c +15 -17
@@ -177,18 +177,15 @@ void add_kallsyms(struct module *mod, const struct load_info *info)unsigned long strtab_size;void *data_base = mod->mem[MOD_DATA ].base;void *init_data_base = mod->mem[MOD_INIT_DATA ].base; +struct mod_kallsyms *kallsyms; -/* Set up to point into init section. */ -rcu_assign_pointer (mod->kallsyms, init_data_base + info->mod_kallsyms_init_off); + kallsyms = init_data_base + info->mod_kallsyms_init_off; -rcu_read_lock (); -/* The following is safe since this pointer cannot change */ -rcu_dereference (mod->kallsyms)->symtab = (void *)symsec->sh_addr; -rcu_dereference (mod->kallsyms)->num_symtab = symsec->sh_size /sizeof (Elf_Sym); + kallsyms->symtab = (void *)symsec->sh_addr; + kallsyms->num_symtab = symsec->sh_size /sizeof (Elf_Sym);/* Make sure we get permanent strtab: don't use info->strtab. */ -rcu_dereference (mod->kallsyms)->strtab = - (void *)info->sechdrs[info->index.str].sh_addr; -rcu_dereference (mod->kallsyms)->typetab = init_data_base + info->init_typeoffs; + kallsyms->strtab = (void *)info->sechdrs[info->index.str].sh_addr; + kallsyms->typetab = init_data_base + info->init_typeoffs;/* * Now populate the cut down core kallsyms for after init
@@ -198,20 +195,19 @@ void add_kallsyms(struct module *mod, const struct load_info *info) mod->core_kallsyms.strtab = s = data_base + info->stroffs; mod->core_kallsyms.typetab = data_base + info->core_typeoffs; strtab_size = info->core_typeoffs - info->stroffs; - src =rcu_dereference (mod->kallsyms)->symtab; -for (ndst = i =0 ; i <rcu_dereference (mod->kallsyms)->num_symtab; i++) { -rcu_dereference (mod->kallsyms)->typetab[i] =elf_type (src + i, info); + src = kallsyms->symtab; +for (ndst = i =0 ; i < kallsyms->num_symtab; i++) { + kallsyms->typetab[i] =elf_type (src + i, info);if (i ==0 ||is_livepatch_module (mod) ||is_core_symbol (src + i, info->sechdrs, info->hdr->e_shnum, info->index.pcpu)) {ssize_t ret; mod->core_kallsyms.typetab[ndst] = -rcu_dereference (mod->kallsyms)->typetab[i]; + kallsyms->typetab[i]; dst[ndst] = src[i]; dst[ndst++].st_name = s - mod->core_kallsyms.strtab; - ret =strscpy (s, - &rcu_dereference (mod->kallsyms)->strtab[src[i].st_name], + ret =strscpy (s, &kallsyms->strtab[src[i].st_name], strtab_size);if (ret <0 )break ;
@@ -219,7 +215,9 @@ void add_kallsyms(struct module *mod, const struct load_info *info) strtab_size -= ret +1 ; } } -rcu_read_unlock (); + +/* Set up to point into init section. */ +rcu_assign_pointer (mod->kallsyms, kallsyms); mod->core_kallsyms.num_symtab = ndst; }
@@ -349,7 +347,6 @@ int module_address_lookup(unsigned long addr,if (sym) ret =strscpy (namebuf, sym,KSYM_NAME_LEN ); } -return ret; }
@@ -478,6 +475,7 @@ int module_kallsyms_on_each_symbol(const char *modname, kallsyms =rcu_dereference_check (mod->kallsyms,lockdep_is_held (&module_mutex)); +for (i =0 ; i < kallsyms->num_symtab; i++) {const Elf_Sym *sym = &kallsyms->symtab[i];
kernel/module/main.c +26 -31
111 lines not on this page · raw message
kernel/module/tree_lookup.c +4 -4
@@ -12,11 +12,11 @@/* * Use a latched RB-tree for __module_address(); this allows us to use -* RCU-sched lookups of the address from any context. +* RCU lookups of the address from any context. * -* This is conditional on PERF_EVENTS || TRACING because those can really hit -* __module_address() hard by doing a lot of stack unwinding; potentially from -* NMI context. +* This is conditional on PERF_EVENTS || TRACING || CFI_CLANG because those can +* really hit __module_address() hard by doing a lot of stack unwinding; +* potentially from NMI context. */ static __always_inline unsigned long __mod_tree_val (struct latch_tree_node *n)
kernel/module/version.c +5 -4
@@ -62,16 +62,17 @@ int check_modstruct_version(const struct load_info *info, .name = "module_layout", .gplok = true, }; +bool have_symbol;/* * Since this should be found in kernel (which can't be removed), no * locking is necessary. Regardless use a RCU read section to keep * lockdep happy. */ -scoped_guard (rcu) { -if (!find_symbol (&fsa)) -BUG (); - } +scoped_guard (rcu) + have_symbol =find_symbol (&fsa); +BUG_ON (!have_symbol); +return check_version (info,"module_layout" , mod, fsa.crc); }
kernel/static_call_inline.c +6 -7
@@ -325,13 +325,12 @@ static int __static_call_mod_text_reserved(void *start, void *end)struct module *mod;int ret; -preempt_disable (); - mod =__module_text_address ((unsigned long )start); -WARN_ON_ONCE (__module_text_address ((unsigned long )end) != mod); -if (!try_module_get (mod)) - mod =NULL ; -preempt_enable (); - +scoped_guard (rcu) { + mod =__module_text_address ((unsigned long )start); +WARN_ON_ONCE (__module_text_address ((unsigned long )end) != mod); +if (!try_module_get (mod)) + mod =NULL ; + }if (!mod)return 0 ;
kernel/trace/bpf_trace.c +8 -11
@@ -2336,10 +2336,9 @@ void bpf_put_raw_tracepoint(struct bpf_raw_event_map *btp) {struct module *mod; -preempt_disable (); +guard (rcu)(); mod =__module_address ((unsigned long )btp);module_put (mod); -preempt_enable (); } static __always_inline
@@ -2907,16 +2906,14 @@ static int get_modules_for_addrs(struct module ***mods, unsigned long *addrs, u3for (i =0 ; i < addrs_cnt; i++) {struct module *mod; -preempt_disable (); - mod =__module_address (addrs[i]); -/* Either no module or we it's already stored */ -if (!mod ||has_module (&arr, mod)) { -preempt_enable (); -continue ; +scoped_guard (rcu) { + mod =__module_address (addrs[i]); +/* Either no module or we it's already stored */ +if (!mod ||has_module (&arr, mod)) +continue ; +if (!try_module_get (mod)) + err = -EINVAL ; } -if (!try_module_get (mod)) - err = -EINVAL ; -preempt_enable ();if (err)break ; err =add_module (&arr, mod);
kernel/trace/trace_kprobe.c +3 -6
@@ -123,9 +123,8 @@ static nokprobe_inline bool trace_kprobe_module_exist(struct trace_kprobe *tk)if (!p)return true; *p ='\0' ; -rcu_read_lock_sched (); - ret = !!find_module (tk->symbol); -rcu_read_unlock_sched (); +scoped_guard (rcu) + ret = !!find_module (tk->symbol); *p =':' ;return ret;
@@ -800,12 +799,10 @@ static struct module *try_module_get_by_name(const char *name) {struct module *mod; -rcu_read_lock_sched (); +guard (rcu)(); mod =find_module (name);if (mod && !try_module_get (mod)) mod =NULL ; -rcu_read_unlock_sched (); -return mod; }#else
lib/bug.c +9 -13
@@ -66,23 +66,19 @@ static LIST_HEAD(module_bug_list);static struct bug_entry *module_find_bug (unsigned long bugaddr) { +struct bug_entry *bug;struct module *mod; -struct bug_entry *bug =NULL ; -rcu_read_lock_sched (); +guard (rcu)();list_for_each_entry_rcu (mod, &module_bug_list, bug_list) {unsigned i; bug = mod->bug_table;for (i =0 ; i < mod->num_bugs; ++i, ++bug)if (bugaddr ==bug_addr (bug)) - goto out; +return bug; } - bug =NULL ; -out: -rcu_read_unlock_sched (); - -return bug; +return NULL ; } void module_bug_finalize(const Elf_Ehdr *hdr, const Elf_Shdr *sechdrs,
@@ -235,11 +231,11 @@ void generic_bug_clear_once(void)#ifdef CONFIG_MODULES struct module *mod; -rcu_read_lock_sched (); -list_for_each_entry_rcu (mod, &module_bug_list, bug_list) -clear_once_table (mod->bug_table, - mod->bug_table + mod->num_bugs); -rcu_read_unlock_sched (); +scoped_guard (rcu) { +list_for_each_entry_rcu (mod, &module_bug_list, bug_list) +clear_once_table (mod->bug_table, + mod->bug_table + mod->num_bugs); + }#endif clear_once_table (__start___bug_table, __stop___bug_table);
localversion-rt +1 -1
@@ -1 +1 @@ --rt2 +-rt3