Skip to content

Commit f8380f9

Browse files
KAGA-KOKOPeter Zijlstra
authored andcommitted
rseq: Provide static branch for time slice extensions
Guard the time slice extension functionality with a static key, which can be disabled on the kernel command line. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20251215155708.733429292@linutronix.de
1 parent d7a5da7 commit f8380f9

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6600,6 +6600,11 @@ Kernel parameters
66006600

66016601
rootflags= [KNL] Set root filesystem mount option string
66026602

6603+
rseq_slice_ext= [KNL] RSEQ based time slice extension
6604+
Format: boolean
6605+
Control enablement of RSEQ based time slice extension.
6606+
Default is 'on'.
6607+
66036608
initramfs_options= [KNL]
66046609
Specify mount options for for the initramfs mount.
66056610

include/linux/rseq_entry.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ DECLARE_STATIC_KEY_MAYBE(CONFIG_RSEQ_DEBUG_DEFAULT_ENABLE, rseq_debug_enabled);
7575
#define rseq_inline __always_inline
7676
#endif
7777

78+
#ifdef CONFIG_RSEQ_SLICE_EXTENSION
79+
DECLARE_STATIC_KEY_TRUE(rseq_slice_extension_key);
80+
81+
static __always_inline bool rseq_slice_extension_enabled(void)
82+
{
83+
return static_branch_likely(&rseq_slice_extension_key);
84+
}
85+
#else /* CONFIG_RSEQ_SLICE_EXTENSION */
86+
static inline bool rseq_slice_extension_enabled(void) { return false; }
87+
#endif /* !CONFIG_RSEQ_SLICE_EXTENSION */
88+
7889
bool rseq_debug_update_user_cs(struct task_struct *t, struct pt_regs *regs, unsigned long csaddr);
7990
bool rseq_debug_validate_ids(struct task_struct *t);
8091

kernel/rseq.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,3 +483,20 @@ SYSCALL_DEFINE4(rseq, struct rseq __user *, rseq, u32, rseq_len, int, flags, u32
483483
efault:
484484
return -EFAULT;
485485
}
486+
487+
#ifdef CONFIG_RSEQ_SLICE_EXTENSION
488+
DEFINE_STATIC_KEY_TRUE(rseq_slice_extension_key);
489+
490+
static int __init rseq_slice_cmdline(char *str)
491+
{
492+
bool on;
493+
494+
if (kstrtobool(str, &on))
495+
return 0;
496+
497+
if (!on)
498+
static_branch_disable(&rseq_slice_extension_key);
499+
return 1;
500+
}
501+
__setup("rseq_slice_ext=", rseq_slice_cmdline);
502+
#endif /* CONFIG_RSEQ_SLICE_EXTENSION */

0 commit comments

Comments
 (0)