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 include (2 of 19 files). Show all

Unified · Split

2 files
  1. include/linux/entry-kvm.h +1 −1
  2. include/linux/thread_info.h +14 −0
include/linux/entry-kvm.h+1−1
@@ -75,7 +75,7 @@ static inline void xfer_to_guest_mode_prepare(void) · 74 unmodified lines
75 */75 */
76static inline bool __xfer_to_guest_mode_work_pending(void)76static inline bool __xfer_to_guest_mode_work_pending(void)
77{77{
78 unsigned long ti_work = READ_ONCE(current_thread_info()->flags);78 unsigned long ti_work = read_thread_flags();
79 79
80 return !!(ti_work & XFER_TO_GUEST_MODE_WORK);80 return !!(ti_work & XFER_TO_GUEST_MODE_WORK);
81}81}
include/linux/thread_info.h+14−0
@@ -118,6 +118,15 @@ static inline int test_ti_thread_flag(struct thread_info *ti, int flag) · 117 unmodified lines
118 return test_bit(flag, (unsigned long *)&ti->flags);118 return test_bit(flag, (unsigned long *)&ti->flags);
119}119}
120 120
121/*
122 * This may be used in noinstr code, and needs to be __always_inline to prevent
123 * inadvertent instrumentation.
124 */
125static __always_inline unsigned long read_ti_thread_flags(struct thread_info *ti)
126{
127 return READ_ONCE(ti->flags);
128}
129
121#define set_thread_flag(flag) \130#define set_thread_flag(flag) \
122 set_ti_thread_flag(current_thread_info(), flag)131 set_ti_thread_flag(current_thread_info(), flag)
123#define clear_thread_flag(flag) \132#define clear_thread_flag(flag) \
@@ -130,6 +139,11 @@ static inline int test_ti_thread_flag(struct thread_info *ti, int flag) · 6 unmodified lines
130 test_and_clear_ti_thread_flag(current_thread_info(), flag)139 test_and_clear_ti_thread_flag(current_thread_info(), flag)
131#define test_thread_flag(flag) \140#define test_thread_flag(flag) \
132 test_ti_thread_flag(current_thread_info(), flag)141 test_ti_thread_flag(current_thread_info(), flag)
142#define read_thread_flags() \
143 read_ti_thread_flags(current_thread_info())
144
145#define read_task_thread_flags(t) \
146 read_ti_thread_flags(task_thread_info(t))
133 147
134#ifdef CONFIG_GENERIC_ENTRY148#ifdef CONFIG_GENERIC_ENTRY
135#define set_syscall_work(fl) \149#define set_syscall_work(fl) \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t