aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel
diff options
context:
space:
mode:
authorAwais Belal <awais_belal@mentor.com>2018-05-22 12:26:56 +0500
committerAwais Belal <awais_belal@mentor.com>2018-05-22 12:34:47 +0500
commita22ea39eda6a75001b178b4fb9c91607a0192539 (patch)
treea2f78e70780e04e6a7e021737a4c54158895c0f6 /common/recipes-kernel
parentfc0608d06162434b55680715ebb335af9c68f57e (diff)
downloadmeta-amd-a22ea39eda6a75001b178b4fb9c91607a0192539.tar.gz
meta-amd-a22ea39eda6a75001b178b4fb9c91607a0192539.tar.bz2
meta-amd-a22ea39eda6a75001b178b4fb9c91607a0192539.zip
linux-yocto/rt: adjust spectre/meltdown backports
This includes spectre/meltdown backports for the RT kernel as well by moving the patches fragment to the common include. A patch that conflicts with RT changes has been taken out of the backport set and added separately for both type of kernels after adjusting accordingly. Signed-off-by: Awais Belal <awais_belal@mentor.com>
Diffstat (limited to 'common/recipes-kernel')
-rw-r--r--common/recipes-kernel/linux/linux-yocto-4.9.21/upstream-backports.scc1
-rw-r--r--common/recipes-kernel/linux/linux-yocto-4.9.21/x86-asm-Move-status-from-thread_struct-to-thread_inf-linux-yocto-rt.patch186
-rw-r--r--common/recipes-kernel/linux/linux-yocto-4.9.21/x86-asm-Move-status-from-thread_struct-to-thread_inf-linux-yocto.patch (renamed from common/recipes-kernel/linux/linux-yocto-4.9.21/0023-x86-asm-Move-status-from-thread_struct-to-thread_inf.patch)0
-rw-r--r--common/recipes-kernel/linux/linux-yocto-common_4.9.inc1
-rw-r--r--common/recipes-kernel/linux/linux-yocto-rt_4.9.bbappend1
-rw-r--r--common/recipes-kernel/linux/linux-yocto_4.9.bbappend4
6 files changed, 189 insertions, 4 deletions
diff --git a/common/recipes-kernel/linux/linux-yocto-4.9.21/upstream-backports.scc b/common/recipes-kernel/linux/linux-yocto-4.9.21/upstream-backports.scc
index 4f4e698c..06d6de30 100644
--- a/common/recipes-kernel/linux/linux-yocto-4.9.21/upstream-backports.scc
+++ b/common/recipes-kernel/linux/linux-yocto-4.9.21/upstream-backports.scc
@@ -123,7 +123,6 @@ patch 0019-x86-retpoline-Simplify-vmexit_fill_RSB.patch
patch 0020-x86-spectre-Check-CONFIG_RETPOLINE-in-command-line-p.patch
patch 0021-x86-entry-64-Remove-the-SYSCALL64-fast-path.patch
patch 0022-x86-entry-64-Push-extra-regs-right-away.patch
-patch 0023-x86-asm-Move-status-from-thread_struct-to-thread_inf.patch
patch 0024-Documentation-Document-array_index_nospec.patch
patch 0025-array_index_nospec-Sanitize-speculative-array-de-ref.patch
patch 0026-x86-Implement-array_index_mask_nospec.patch
diff --git a/common/recipes-kernel/linux/linux-yocto-4.9.21/x86-asm-Move-status-from-thread_struct-to-thread_inf-linux-yocto-rt.patch b/common/recipes-kernel/linux/linux-yocto-4.9.21/x86-asm-Move-status-from-thread_struct-to-thread_inf-linux-yocto-rt.patch
new file mode 100644
index 00000000..4ce23f3a
--- /dev/null
+++ b/common/recipes-kernel/linux/linux-yocto-4.9.21/x86-asm-Move-status-from-thread_struct-to-thread_inf-linux-yocto-rt.patch
@@ -0,0 +1,186 @@
+From c4c4bc077dd11d2b5626a7033a265e78c43ccf8e Mon Sep 17 00:00:00 2001
+From: Andy Lutomirski <luto@kernel.org>
+Date: Sun, 28 Jan 2018 10:38:50 -0800
+Subject: [PATCH] x86/asm: Move 'status' from thread_struct to thread_info
+
+(cherry picked from commit 37a8f7c38339b22b69876d6f5a0ab851565284e3)
+
+The TS_COMPAT bit is very hot and is accessed from code paths that mostly
+also touch thread_info::flags. Move it into struct thread_info to improve
+cache locality.
+
+The only reason it was in thread_struct is that there was a brief period
+during which arch-specific fields were not allowed in struct thread_info.
+
+Linus suggested further changing:
+
+ ti->status &= ~(TS_COMPAT|TS_I386_REGS_POKED);
+
+to:
+
+ if (unlikely(ti->status & (TS_COMPAT|TS_I386_REGS_POKED)))
+ ti->status &= ~(TS_COMPAT|TS_I386_REGS_POKED);
+
+on the theory that frequently dirtying the cacheline even in pure 64-bit
+code that never needs to modify status hurts performance. That could be a
+reasonable followup patch, but I suspect it matters less on top of this
+patch.
+
+Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Andy Lutomirski <luto@kernel.org>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Ingo Molnar <mingo@kernel.org>
+Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Borislav Petkov <bp@alien8.de>
+Cc: Kernel Hardening <kernel-hardening@lists.openwall.com>
+Link: https://lkml.kernel.org/r/03148bcc1b217100e6e8ecf6a5468c45cf4304b6.1517164461.git.luto@kernel.org
+Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/entry/common.c | 4 ++--
+ arch/x86/include/asm/processor.h | 2 --
+ arch/x86/include/asm/syscall.h | 6 +++---
+ arch/x86/include/asm/thread_info.h | 3 ++-
+ arch/x86/kernel/process_64.c | 4 ++--
+ arch/x86/kernel/ptrace.c | 2 +-
+ arch/x86/kernel/signal.c | 2 +-
+ 7 files changed, 11 insertions(+), 12 deletions(-)
+
+diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
+index 56d01a339ba4..021cebbdab92 100644
+--- a/arch/x86/entry/common.c
++++ b/arch/x86/entry/common.c
+@@ -208,7 +208,7 @@ __visible inline void prepare_exit_to_usermode(struct pt_regs *regs)
+ * special case only applies after poking regs and before the
+ * very next return to user mode.
+ */
+- current->thread.status &= ~(TS_COMPAT|TS_I386_REGS_POKED);
++ ti->status &= ~(TS_COMPAT|TS_I386_REGS_POKED);
+ #endif
+
+ user_enter_irqoff();
+@@ -306,7 +306,7 @@ static __always_inline void do_syscall_32_irqs_on(struct pt_regs *regs)
+ unsigned int nr = (unsigned int)regs->orig_ax;
+
+ #ifdef CONFIG_IA32_EMULATION
+- current->thread.status |= TS_COMPAT;
++ ti->status |= TS_COMPAT;
+ #endif
+
+ if (READ_ONCE(ti->flags) & _TIF_WORK_SYSCALL_ENTRY) {
+diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
+index 83db0eae9979..f9cb6c03cf49 100644
+--- a/arch/x86/include/asm/processor.h
++++ b/arch/x86/include/asm/processor.h
+@@ -391,8 +391,6 @@ struct thread_struct {
+ unsigned short gsindex;
+ #endif
+
+- u32 status; /* thread synchronous flags */
+-
+ #ifdef CONFIG_X86_64
+ unsigned long fsbase;
+ unsigned long gsbase;
+diff --git a/arch/x86/include/asm/syscall.h b/arch/x86/include/asm/syscall.h
+index e3c95e8e61c5..03eedc21246d 100644
+--- a/arch/x86/include/asm/syscall.h
++++ b/arch/x86/include/asm/syscall.h
+@@ -60,7 +60,7 @@ static inline long syscall_get_error(struct task_struct *task,
+ * TS_COMPAT is set for 32-bit syscall entries and then
+ * remains set until we return to user mode.
+ */
+- if (task->thread.status & (TS_COMPAT|TS_I386_REGS_POKED))
++ if (task->thread_info.status & (TS_COMPAT|TS_I386_REGS_POKED))
+ /*
+ * Sign-extend the value so (int)-EFOO becomes (long)-EFOO
+ * and will match correctly in comparisons.
+@@ -116,7 +116,7 @@ static inline void syscall_get_arguments(struct task_struct *task,
+ unsigned long *args)
+ {
+ # ifdef CONFIG_IA32_EMULATION
+- if (task->thread.status & TS_COMPAT)
++ if (task->thread_info.status & TS_COMPAT)
+ switch (i) {
+ case 0:
+ if (!n--) break;
+@@ -177,7 +177,7 @@ static inline void syscall_set_arguments(struct task_struct *task,
+ const unsigned long *args)
+ {
+ # ifdef CONFIG_IA32_EMULATION
+- if (task->thread.status & TS_COMPAT)
++ if (task->thread_info.status & TS_COMPAT)
+ switch (i) {
+ case 0:
+ if (!n--) break;
+diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
+index 5ceb3a1c2b1a..f581e2642a9f 100644
+--- a/arch/x86/include/asm/thread_info.h
++++ b/arch/x86/include/asm/thread_info.h
+@@ -56,6 +56,7 @@ struct thread_info {
+ unsigned long flags; /* low level flags */
+ int preempt_lazy_count; /* 0 => lazy preemptable
+ <0 => BUG */
++ u32 status; /* thread synchronous flags */
+ };
+
+ #define INIT_THREAD_INFO(tsk) \
+@@ -235,7 +236,7 @@ static inline int arch_within_stack_frames(const void * const stack,
+ #define in_ia32_syscall() true
+ #else
+ #define in_ia32_syscall() (IS_ENABLED(CONFIG_IA32_EMULATION) && \
+- current->thread.status & TS_COMPAT)
++ current_thread_info()->status & TS_COMPAT)
+ #endif
+
+ /*
+diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
+index b3760b3c1ca0..dca15e11d6ae 100644
+--- a/arch/x86/kernel/process_64.c
++++ b/arch/x86/kernel/process_64.c
+@@ -512,7 +512,7 @@ void set_personality_ia32(bool x32)
+ current->personality &= ~READ_IMPLIES_EXEC;
+ /* in_compat_syscall() uses the presence of the x32
+ syscall bit flag to determine compat status */
+- current->thread.status &= ~TS_COMPAT;
++ current_thread_info()->status &= ~TS_COMPAT;
+ } else {
+ set_thread_flag(TIF_IA32);
+ clear_thread_flag(TIF_X32);
+@@ -520,7 +520,7 @@ void set_personality_ia32(bool x32)
+ current->mm->context.ia32_compat = TIF_IA32;
+ current->personality |= force_personality32;
+ /* Prepare the first "return" to user space */
+- current->thread.status |= TS_COMPAT;
++ current_thread_info()->status |= TS_COMPAT;
+ }
+ }
+ EXPORT_SYMBOL_GPL(set_personality_ia32);
+diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
+index 0e63c0267f99..e497d374412a 100644
+--- a/arch/x86/kernel/ptrace.c
++++ b/arch/x86/kernel/ptrace.c
+@@ -934,7 +934,7 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 value)
+ */
+ regs->orig_ax = value;
+ if (syscall_get_nr(child, regs) >= 0)
+- child->thread.status |= TS_I386_REGS_POKED;
++ child->thread_info.status |= TS_I386_REGS_POKED;
+ break;
+
+ case offsetof(struct user32, regs.eflags):
+diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
+index 763af1d0de64..b1a5d252d482 100644
+--- a/arch/x86/kernel/signal.c
++++ b/arch/x86/kernel/signal.c
+@@ -785,7 +785,7 @@ static inline unsigned long get_nr_restart_syscall(const struct pt_regs *regs)
+ * than the tracee.
+ */
+ #ifdef CONFIG_IA32_EMULATION
+- if (current->thread.status & (TS_COMPAT|TS_I386_REGS_POKED))
++ if (current_thread_info()->status & (TS_COMPAT|TS_I386_REGS_POKED))
+ return __NR_ia32_restart_syscall;
+ #endif
+ #ifdef CONFIG_X86_X32_ABI
+--
+2.11.1
+
diff --git a/common/recipes-kernel/linux/linux-yocto-4.9.21/0023-x86-asm-Move-status-from-thread_struct-to-thread_inf.patch b/common/recipes-kernel/linux/linux-yocto-4.9.21/x86-asm-Move-status-from-thread_struct-to-thread_inf-linux-yocto.patch
index 28daae3a..28daae3a 100644
--- a/common/recipes-kernel/linux/linux-yocto-4.9.21/0023-x86-asm-Move-status-from-thread_struct-to-thread_inf.patch
+++ b/common/recipes-kernel/linux/linux-yocto-4.9.21/x86-asm-Move-status-from-thread_struct-to-thread_inf-linux-yocto.patch
diff --git a/common/recipes-kernel/linux/linux-yocto-common_4.9.inc b/common/recipes-kernel/linux/linux-yocto-common_4.9.inc
index de646bbe..20bfc9cf 100644
--- a/common/recipes-kernel/linux/linux-yocto-common_4.9.inc
+++ b/common/recipes-kernel/linux/linux-yocto-common_4.9.inc
@@ -7,6 +7,7 @@ SRCREV_meta_amdx86 ?= "803b8d600e45afa0375459bf599fe365571a3866"
LINUX_VERSION_amdx86 ?= "4.9.21"
SRC_URI_append_amdx86 += " \
+ file://upstream-backports.scc \
file://hid.cfg \
file://efi-partition.cfg \
file://usb-serial.cfg \
diff --git a/common/recipes-kernel/linux/linux-yocto-rt_4.9.bbappend b/common/recipes-kernel/linux/linux-yocto-rt_4.9.bbappend
index 0bb73748..50e232e2 100644
--- a/common/recipes-kernel/linux/linux-yocto-rt_4.9.bbappend
+++ b/common/recipes-kernel/linux/linux-yocto-rt_4.9.bbappend
@@ -1,3 +1,4 @@
require linux-yocto-common_4.9.inc
KBRANCH_amdx86 ?= "standard/preempt-rt/base"
SRCREV_machine_amdx86 ?= "b6f5c933ce66e4a00412bb5c5691a2ab4187c979"
+SRC_URI_append_amdx86 = " file://x86-asm-Move-status-from-thread_struct-to-thread_inf-linux-yocto-rt.patch"
diff --git a/common/recipes-kernel/linux/linux-yocto_4.9.bbappend b/common/recipes-kernel/linux/linux-yocto_4.9.bbappend
index f646d13d..4fb27974 100644
--- a/common/recipes-kernel/linux/linux-yocto_4.9.bbappend
+++ b/common/recipes-kernel/linux/linux-yocto_4.9.bbappend
@@ -1,6 +1,4 @@
require linux-yocto-common_4.9.inc
-
KBRANCH_amdx86 ?= "standard/base"
SRCREV_machine_amdx86 ?= "81055b89bd32414ecaf95156ce9a5fa6643e530a"
-
-SRC_URI_append_amdx86 = " file://upstream-backports.scc"
+SRC_URI_append_amdx86 = " file://x86-asm-Move-status-from-thread_struct-to-thread_inf-linux-yocto.patch"