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
7575 */
7676 static inline bool __xfer_to_guest_mode_work_pending(void)
7777 {
78− unsigned long ti_work = READ_ONCE(current_thread_info()->flags);
78+ unsigned long ti_work = read_thread_flags();
7979
8080 return !!(ti_work & XFER_TO_GUEST_MODE_WORK);
8181 }
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
118118 return test_bit(flag, (unsigned long *)&ti->flags);
119119 }
120120
121+/*
122+ * This may be used in noinstr code, and needs to be __always_inline to prevent
123+ * inadvertent instrumentation.
124+ */
125+static __always_inline unsigned long read_ti_thread_flags(struct thread_info *ti)
126+{
127+ return READ_ONCE(ti->flags);
128+}
129+
121130 #define set_thread_flag(flag) \
122131 set_ti_thread_flag(current_thread_info(), flag)
123132 #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
130139 test_and_clear_ti_thread_flag(current_thread_info(), flag)
131140 #define test_thread_flag(flag) \
132141 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))
133147
134148 #ifdef CONFIG_GENERIC_ENTRY
135149 #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