History

Merge tag 'core_entry_for_v5.17_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull thread_info flag accessor helper updates from Borislav Petkov: "Add a set of thread_info.flags accessors which snapshot it before accesing it in order to prevent any potential data races, and convert all users to those new accessors" * tag 'core_entry_for_v5.17_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: powerpc: Snapshot thread flags powerpc: Avoid discarding flags in system_call_exception() openrisc: Snapshot thread flags microblaze: Snapshot thread flags arm64: Snapshot thread flags ARM: Snapshot thread flags alpha: Snapshot thread flags sched: Snapshot thread flags entry: Snapshot thread flags x86: Snapshot thread flags thread_info: Add helpers to snapshot thread flags

Linus Torvalds committed 4 years ago

Commit 48a60bd2 parents 5ba13c1 985faa719 files · +46 −34Browse files

Showing the changes to kernel (3 of 19 files). Show all

Unified · Split

3 files
  1. kernel/entry/common.c +2 −2
  2. kernel/entry/kvm.c +2 −2
  3. kernel/sched/core.c +1 −1
kernel/entry/common.c+2−2
@@ -187,7 +187,7 @@ static unsigned long exit_to_user_mode_loop(struct pt_regs *regs, · 186 unmodified lines
187 /* Check if any of the above work has queued a deferred wakeup */187 /* Check if any of the above work has queued a deferred wakeup */
188 tick_nohz_user_enter_prepare();188 tick_nohz_user_enter_prepare();
189 189
190 ti_work = READ_ONCE(current_thread_info()->flags);190 ti_work = read_thread_flags();
191 }191 }
192 192
193 /* Return the latest work state for arch_exit_to_user_mode() */193 /* Return the latest work state for arch_exit_to_user_mode() */
@@ -196,7 +196,7 @@ static unsigned long exit_to_user_mode_loop(struct pt_regs *regs, · 2 unmodified lines
196 196
197static void exit_to_user_mode_prepare(struct pt_regs *regs)197static void exit_to_user_mode_prepare(struct pt_regs *regs)
198{198{
199 unsigned long ti_work = READ_ONCE(current_thread_info()->flags);199 unsigned long ti_work = read_thread_flags();
200 200
201 lockdep_assert_irqs_disabled();201 lockdep_assert_irqs_disabled();
202 202
kernel/entry/kvm.c+2−2
@@ -26,7 +26,7 @@ static int xfer_to_guest_mode_work(struct kvm_vcpu *vcpu, unsigned long ti_work) · 25 unmodified lines
26 if (ret)26 if (ret)
27 return ret;27 return ret;
28 28
29 ti_work = READ_ONCE(current_thread_info()->flags);29 ti_work = read_thread_flags();
30 } while (ti_work & XFER_TO_GUEST_MODE_WORK || need_resched());30 } while (ti_work & XFER_TO_GUEST_MODE_WORK || need_resched());
31 return 0;31 return 0;
32}32}
@@ -43,7 +43,7 @@ int xfer_to_guest_mode_handle_work(struct kvm_vcpu *vcpu) · 10 unmodified lines
43 * disabled in the inner loop before going into guest mode. No need43 * disabled in the inner loop before going into guest mode. No need
44 * to disable interrupts here.44 * to disable interrupts here.
45 */45 */
46 ti_work = READ_ONCE(current_thread_info()->flags);46 ti_work = read_thread_flags();
47 if (!(ti_work & XFER_TO_GUEST_MODE_WORK))47 if (!(ti_work & XFER_TO_GUEST_MODE_WORK))
48 return 0;48 return 0;
49 49
kernel/sched/core.c+1−1
@@ -8520,7 +8520,7 @@ void sched_show_task(struct task_struct *p) · 8519 unmodified lines
8520 rcu_read_unlock();8520 rcu_read_unlock();
8521 pr_cont(" stack:%5lu pid:%5d ppid:%6d flags:0x%08lx\n",8521 pr_cont(" stack:%5lu pid:%5d ppid:%6d flags:0x%08lx\n",
8522 free, task_pid_nr(p), ppid,8522 free, task_pid_nr(p), ppid,
8523 (unsigned long)task_thread_info(p)->flags);8523 read_task_thread_flags(p));
8524 8524
8525 print_worker_info(KERN_INFO, p);8525 print_worker_info(KERN_INFO, p);
8526 print_stop_info(KERN_INFO, p);8526 print_stop_info(KERN_INFO, p);