Skip to content

Commit

Permalink
Merge tag 'core_urgent_for_v6.3_rc4' of git://git.kernel.org/pub/scm/…
Browse files Browse the repository at this point in the history
…linux/kernel/git/tip/tip

Pull core fixes from Borislav Petkov:

 - Do the delayed RCU wakeup for kthreads in the proper order so that
   former doesn't get ignored

 - A noinstr warning fix

* tag 'core_urgent_for_v6.3_rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  entry/rcu: Check TIF_RESCHED _after_ delayed RCU wake-up
  entry: Fix noinstr warning in __enter_from_user_mode()
  • Loading branch information
Linus Torvalds committed Mar 26, 2023
2 parents 986c637 + b416514 commit f6cdaeb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/linux/context_tracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ static inline void user_exit_irqoff(void) { }
static inline int exception_enter(void) { return 0; }
static inline void exception_exit(enum ctx_state prev_ctx) { }
static inline int ct_state(void) { return -1; }
static inline int __ct_state(void) { return -1; }
static __always_inline bool context_tracking_guest_enter(void) { return false; }
static inline void context_tracking_guest_exit(void) { }
#define CT_WARN_ON(cond) do { } while (0)
Expand Down
2 changes: 2 additions & 0 deletions include/linux/context_tracking_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ struct context_tracking {

#ifdef CONFIG_CONTEXT_TRACKING
DECLARE_PER_CPU(struct context_tracking, context_tracking);
#endif

#ifdef CONFIG_CONTEXT_TRACKING_USER
static __always_inline int __ct_state(void)
{
return arch_atomic_read(this_cpu_ptr(&context_tracking.state)) & CT_STATE_MASK;
Expand Down
5 changes: 3 additions & 2 deletions kernel/entry/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static __always_inline void __enter_from_user_mode(struct pt_regs *regs)
arch_enter_from_user_mode(regs);
lockdep_hardirqs_off(CALLER_ADDR0);

CT_WARN_ON(ct_state() != CONTEXT_USER);
CT_WARN_ON(__ct_state() != CONTEXT_USER);
user_exit_irqoff();

instrumentation_begin();
Expand Down Expand Up @@ -192,13 +192,14 @@ static unsigned long exit_to_user_mode_loop(struct pt_regs *regs,

static void exit_to_user_mode_prepare(struct pt_regs *regs)
{
unsigned long ti_work = read_thread_flags();
unsigned long ti_work;

lockdep_assert_irqs_disabled();

/* Flush pending rcuog wakeup before the last need_resched() check */
tick_nohz_user_enter_prepare();

ti_work = read_thread_flags();
if (unlikely(ti_work & EXIT_TO_USER_MODE_WORK))
ti_work = exit_to_user_mode_loop(regs, ti_work);

Expand Down

0 comments on commit f6cdaeb

Please sign in to comment.