Skip to contentSkip to conversation

Linux 4.14.297

DISCUSSION Greg Kroah-Hartman 2 participants 6 messages Nov 1, 2022 – Nov 8, 2022 Stable branch

lore
Share & tools
lore

Greg Kroah-Hartman

author maintainer
#0 lore raw

I'm announcing the release of the 4.14.297 kernel.

All users of the 4.14 kernel series must upgrade.

The updated 4.14.y git tree can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-4.14.y
and can be browsed at the normal kernel.org git web browser:
https://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary

thanks,

greg k-h

------------

 Documentation/admin-guide/hw-vuln/spectre.rst   |    8 
 Documentation/admin-guide/kernel-parameters.txt |   13 
 Makefile                                        |    2 
 arch/x86/entry/calling.h                        |   68 +++
 arch/x86/entry/entry_32.S                       |    2 
 arch/x86/entry/entry_64.S                       |   38 +-
 arch/x86/entry/entry_64_compat.S                |   12 
 arch/x86/include/asm/cpu_device_id.h            |  168 +++++++++
 arch/x86/include/asm/cpufeatures.h              |   16 
 arch/x86/include/asm/intel-family.h             |    6 
 arch/x86/include/asm/msr-index.h                |   14 
 arch/x86/include/asm/nospec-branch.h            |   48 +-
 arch/x86/kernel/cpu/amd.c                       |   21 -
 arch/x86/kernel/cpu/bugs.c                      |  415 +++++++++++++++++++-----
 arch/x86/kernel/cpu/common.c                    |   68 ++-
 arch/x86/kernel/cpu/match.c                     |   44 ++
 arch/x86/kernel/cpu/scattered.c                 |    1 
 arch/x86/kernel/process.c                       |    2 
 arch/x86/kvm/svm.c                              |    1 
 arch/x86/kvm/vmx.c                              |   51 ++
 drivers/base/cpu.c                              |    8 
 drivers/cpufreq/acpi-cpufreq.c                  |    1 
 drivers/cpufreq/amd_freq_sensitivity.c          |    1 
 drivers/idle/intel_idle.c                       |   45 ++
 include/linux/cpu.h                             |    2 
 include/linux/mod_devicetable.h                 |    4 
 tools/arch/x86/include/asm/cpufeatures.h        |    1 
 27 files changed, 898 insertions(+), 162 deletions(-)

Alexandre Chartre (2):
x86/bugs: Report AMD retbleed vulnerability
x86/bugs: Add AMD retbleed= boot parameter

Andrew Cooper (1):
x86/cpu/amd: Enumerate BTC_NO

Daniel Sneddon (1):
x86/speculation: Add RSB VM Exit protections

Greg Kroah-Hartman (1):

      Linux 4.14.297

Ingo Molnar (1):
x86/cpufeature: Fix various quality problems in the <asm/cpu_device_hd.h> header

Josh Poimboeuf (8):
x86/speculation: Fix RSB filling with CONFIG_RETPOLINE=n x86/speculation: Fix firmware entry SPEC_CTRL handling x86/speculation: Fix SPEC_CTRL write on SMT state change x86/speculation: Use cached host SPEC_CTRL value for guest entry/exit x86/speculation: Remove x86_spec_ctrl_mask
KVM: VMX: Prevent guest RSB poisoning attacks with eIBRS
KVM: VMX: Fix IBRS handling after vmexit
x86/speculation: Fill RSB on vmexit for IBRS

Kan Liang (1):
x86/cpufeature: Add facility to check for min microcode revisions

Mark Gross (1):
x86/cpu: Add a steppings field to struct x86_cpu_id

Nathan Chancellor (1):
x86/speculation: Use DECLARE_PER_CPU for x86_spec_ctrl_current

Pawan Gupta (5):
x86/speculation: Add spectre_v2=ibrs option to support Kernel IBRS x86/speculation: Add LFENCE to RSB fill sequence
x86/bugs: Add Cannon lake to RETBleed affected CPU list x86/speculation: Disable RRSBA behavior
x86/bugs: Warn when "ibrs" mitigation is selected on Enhanced IBRS parts

Peter Zijlstra (9):
x86/entry: Remove skip_r11rcx
x86/cpufeatures: Move RETPOLINE flags to word 11
x86/bugs: Keep a per-CPU IA32_SPEC_CTRL value
x86/bugs: Optimize SPEC_CTRL MSR writes
x86/bugs: Split spectre_v2_select_mitigation() and spectre_v2_user_select_mitigation() x86/bugs: Report Intel retbleed vulnerability
entel_idle: Disable IBRS during long idle
x86/speculation: Change FILL_RETURN_BUFFER to work with objtool x86/common: Stamp out the stepping madness

Suraj Jitindar Singh (1):
Revert "x86/cpu: Add a steppings field to struct x86_cpu_id"

Thadeu Lima de Souza Cascardo (1):
x86/entry: Add kernel IBRS implementation

Thomas Gleixner (2):
x86/devicetable: Move x86 specific macro out of generic code x86/cpu: Add consistent CPU match macros

author maintainer
#1 lore raw
Documentation/admin-guide/hw-vuln/spectre.rst +8 -0
index 6bd97cd50d62..7e061ed449aa 100644
@@ -422,6 +422,14 @@ The possible values in this file are:
   'RSB filling'   Protection of RSB on context switch enabled
   =============   ===========================================
 
+  - EIBRS Post-barrier Return Stack Buffer (PBRSB) protection status:
+
+  ===========================  =======================================================
+  'PBRSB-eIBRS: SW sequence'   CPU is affected and protection of RSB on VMEXIT enabled
+  'PBRSB-eIBRS: Vulnerable'    CPU is vulnerable
+  'PBRSB-eIBRS: Not affected'  CPU is not affected by PBRSB
+  ===========================  =======================================================
+
 Full mitigation might require a microcode update from the CPU
 vendor. When the necessary microcode is not available, the kernel will
 report vulnerability.
Documentation/admin-guide/kernel-parameters.txt +13 -0
index 681d429c6426..629d7956ddf1 100644
@@ -3965,6 +3965,18 @@
 
 	retain_initrd	[RAM] Keep initrd memory after extraction
 
+	retbleed=	[X86] Control mitigation of RETBleed (Arbitrary
+			Speculative Code Execution with Return Instructions)
+			vulnerability.
+
+			off         - unconditionally disable
+			auto        - automatically select a migitation
+
+			Selecting 'auto' will choose a mitigation method at run
+			time according to the CPU.
+
+			Not specifying this option is equivalent to retbleed=auto.
+
 	rfkill.default_state=
 		0	"airplane mode".  All wifi, bluetooth, wimax, gps, fm,
 			etc. communication is blocked by default.
@@ -4204,6 +4216,7 @@
 			eibrs		  - enhanced IBRS
 			eibrs,retpoline   - enhanced IBRS + Retpolines
 			eibrs,lfence      - enhanced IBRS + LFENCE
+			ibrs		  - use IBRS to protect kernel
 
 			Not specifying this option is equivalent to
 			spectre_v2=auto.
Makefile +1 -1
index b7978fb873d6..a66c65fcb96f 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 VERSION = 4
 PATCHLEVEL = 14
-SUBLEVEL = 296
+SUBLEVEL = 297
 EXTRAVERSION =
 NAME = Petit Gorille
 
arch/x86/entry/calling.h +59 -9

98 lines not on this page · raw message

arch/x86/entry/entry_32.S +0 -2
index c19974a49378..dbcea4281c30 100644
@@ -245,7 +245,6 @@ ENTRY(__switch_to_asm)
 	movl	%ebx, PER_CPU_VAR(stack_canary)+stack_canary_offset
 #endif
 
-#ifdef CONFIG_RETPOLINE
 	/*
 	 * When switching from a shallower to a deeper call stack
 	 * the RSB may either underflow or use entries populated
@@ -254,7 +253,6 @@ ENTRY(__switch_to_asm)
 	 * speculative execution to prevent attack.
 	 */
 	FILL_RETURN_BUFFER %ebx, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW
-#endif
 
 	/* restore callee-saved registers */
 	popfl
arch/x86/entry/entry_64.S +34 -4
index ac389ffb1822..637a23d404e9 100644
@@ -230,6 +230,10 @@ GLOBAL(entry_SYSCALL_64_after_hwframe)
 
 	/* IRQs are off. */
 	movq	%rsp, %rdi
+
+	/* clobbers %rax, make sure it is after saving the syscall nr */
+	IBRS_ENTER
+
 	call	do_syscall_64		/* returns with IRQs disabled */
 
 	TRACE_IRQS_IRETQ		/* we're about to change IF */
@@ -301,8 +305,8 @@ GLOBAL(entry_SYSCALL_64_after_hwframe)
 	 * perf profiles. Nothing jumps here.
 	 */
 syscall_return_via_sysret:
-	/* rcx and r11 are already restored (see code above) */
-	POP_REGS pop_rdi=0 skip_r11rcx=1
+	IBRS_EXIT
+	POP_REGS pop_rdi=0
 
 	/*
 	 * Now all regs are restored except RSP and RDI.
@@ -353,7 +357,6 @@ ENTRY(__switch_to_asm)
 	movq	%rbx, PER_CPU_VAR(irq_stack_union)+stack_canary_offset
 #endif
 
-#ifdef CONFIG_RETPOLINE
 	/*
 	 * When switching from a shallower to a deeper call stack
 	 * the RSB may either underflow or use entries populated
@@ -362,7 +365,6 @@ ENTRY(__switch_to_asm)
 	 * speculative execution to prevent attack.
 	 */
 	FILL_RETURN_BUFFER %r12, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW
-#endif
 
 	/* restore callee-saved registers */
 	popfq
@@ -591,6 +593,7 @@ GLOBAL(retint_user)
 	TRACE_IRQS_IRETQ
 
 GLOBAL(swapgs_restore_regs_and_return_to_usermode)
+	IBRS_EXIT
 #ifdef CONFIG_DEBUG_ENTRY
 	/* Assert that pt_regs indicates user mode. */
 	testb	$3, CS(%rsp)
@@ -1134,6 +1137,9 @@ idtentry machine_check		do_mce			has_error_code=0	paranoid=1
  * Save all registers in pt_regs, and switch gs if needed.
  * Use slow, but surefire "are we in kernel?" check.
  * Return: ebx=0: need swapgs on exit, ebx=1: otherwise
+ *
+ * R14 - old CR3
+ * R15 - old SPEC_CTRL
  */
 ENTRY(paranoid_entry)
 	UNWIND_HINT_FUNC
@@ -1157,6 +1163,12 @@ ENTRY(paranoid_entry)
 	 */
 	FENCE_SWAPGS_KERNEL_ENTRY
 
+	/*
+	 * Once we have CR3 and %GS setup save and set SPEC_CTRL. Just like
+	 * CR3 above, keep the old value in a callee saved register.
+	 */
+	IBRS_ENTER save_reg=%r15
+
 	ret
 END(paranoid_entry)
 
@@ -1171,9 +1183,19 @@ END(paranoid_entry)
  * to try to handle preemption here.
  *
  * On entry, ebx is "no swapgs" flag (1: don't need swapgs, 0: need it)
+ *
+ * R14 - old CR3
+ * R15 - old SPEC_CTRL
  */
 ENTRY(paranoid_exit)
 	UNWIND_HINT_REGS
+
+	/*
+	 * Must restore IBRS state before both CR3 and %GS since we need access
+	 * to the per-CPU x86_spec_ctrl_shadow variable.
+	 */
+	IBRS_EXIT save_reg=%r15
+
 	DISABLE_INTERRUPTS(CLBR_ANY)
 	TRACE_IRQS_OFF_DEBUG
 	testl	%ebx, %ebx			/* swapgs needed? */
@@ -1208,8 +1230,10 @@ ENTRY(error_entry)
 	FENCE_SWAPGS_USER_ENTRY
 	/* We have user CR3.  Change to kernel CR3. */
 	SWITCH_TO_KERNEL_CR3 scratch_reg=%rax
+	IBRS_ENTER
 
 .Lerror_entry_from_usermode_after_swapgs:
+
 	/* Put us onto the real thread stack. */
 	popq	%r12				/* save return addr in %12 */
 	movq	%rsp, %rdi			/* arg0 = pt_regs pointer */
@@ -1272,6 +1296,7 @@ ENTRY(error_entry)
 	SWAPGS
 	FENCE_SWAPGS_USER_ENTRY
 	SWITCH_TO_KERNEL_CR3 scratch_reg=%rax
+	IBRS_ENTER
 
 	/*
 	 * Pretend that the exception came from user mode: set up pt_regs
@@ -1377,6 +1402,8 @@ ENTRY(nmi)
 	PUSH_AND_CLEAR_REGS rdx=(%rdx)
 	ENCODE_FRAME_POINTER
 
+	IBRS_ENTER
+
 	/*
 	 * At this point we no longer need to worry about stack damage
 	 * due to nesting -- we're on the normal thread stack and we're
@@ -1600,6 +1627,9 @@ end_repeat_nmi:
 	movq	$-1, %rsi
 	call	do_nmi
 
+	/* Always restore stashed SPEC_CTRL value (see paranoid_entry) */
+	IBRS_EXIT save_reg=%r15
+
 	RESTORE_CR3 scratch_reg=%r15 save_reg=%r14
 
 	testl	%ebx, %ebx			/* swapgs needed? */
arch/x86/entry/entry_64_compat.S +11 -1
index 304e3daf82dd..8cdc3af68c53 100644
@@ -4,7 +4,6 @@
  *
  * Copyright 2000-2002 Andi Kleen, SuSE Labs.
  */
-#include "calling.h"
 #include <asm/asm-offsets.h>
 #include <asm/current.h>
 #include <asm/errno.h>
@@ -17,6 +16,8 @@
 #include <linux/linkage.h>
 #include <linux/err.h>
 
+#include "calling.h"
+
 	.section .entry.text, "ax"
 
 /*
@@ -106,6 +107,8 @@ ENTRY(entry_SYSENTER_compat)
 	xorl	%r15d, %r15d		/* nospec   r15 */
 	cld
 
+	IBRS_ENTER
+
 	/*
 	 * SYSENTER doesn't filter flags, so we need to clear NT and AC
 	 * ourselves.  To save a few cycles, we can check whether
@@ -250,6 +253,8 @@ GLOBAL(entry_SYSCALL_compat_after_hwframe)
 	 */
 	TRACE_IRQS_OFF
 
+	IBRS_ENTER
+
 	movq	%rsp, %rdi
 	call	do_fast_syscall_32
 	/* XEN PV guests always use IRET path */
@@ -259,6 +264,9 @@ GLOBAL(entry_SYSCALL_compat_after_hwframe)
 	/* Opportunistic SYSRET */
 sysret32_from_system_call:
 	TRACE_IRQS_ON			/* User mode traces as IRQs on. */
+
+	IBRS_EXIT
+
 	movq	RBX(%rsp), %rbx		/* pt_regs->rbx */
 	movq	RBP(%rsp), %rbp		/* pt_regs->rbp */
 	movq	EFLAGS(%rsp), %r11	/* pt_regs->flags (in r11) */
@@ -385,6 +393,8 @@ ENTRY(entry_INT80_compat)
 	 */
 	TRACE_IRQS_OFF
 
+	IBRS_ENTER
+
 	movq	%rsp, %rdi
 	call	do_int80_syscall_32
 .Lsyscall_32_done:
arch/x86/include/asm/cpu_device_id.h +164 -4

182 lines not on this page · raw message

arch/x86/include/asm/cpufeatures.h +14 -2
index d56634d6b10c..840d8981567e 100644
@@ -202,8 +202,8 @@
 #define X86_FEATURE_PROC_FEEDBACK	( 7*32+ 9) /* AMD ProcFeedbackInterface */
 #define X86_FEATURE_SME			( 7*32+10) /* AMD Secure Memory Encryption */
 #define X86_FEATURE_PTI			( 7*32+11) /* Kernel Page Table Isolation enabled */
-#define X86_FEATURE_RETPOLINE		( 7*32+12) /* "" Generic Retpoline mitigation for Spectre variant 2 */
-#define X86_FEATURE_RETPOLINE_LFENCE	( 7*32+13) /* "" Use LFENCE for Spectre variant 2 */
+#define X86_FEATURE_KERNEL_IBRS		( 7*32+12) /* "" Set/clear IBRS on kernel entry/exit */
+#define X86_FEATURE_RSB_VMEXIT		( 7*32+13) /* "" Fill RSB on VM-Exit */
 #define X86_FEATURE_INTEL_PPIN		( 7*32+14) /* Intel Processor Inventory Number */
 #define X86_FEATURE_CDP_L2		( 7*32+15) /* Code and Data Prioritization L2 */
 #define X86_FEATURE_MSR_SPEC_CTRL	( 7*32+16) /* "" MSR SPEC_CTRL is implemented */
@@ -283,6 +283,15 @@
 #define X86_FEATURE_CQM_MBM_LOCAL	(11*32+ 3) /* LLC Local MBM monitoring */
 #define X86_FEATURE_FENCE_SWAPGS_USER	(11*32+ 4) /* "" LFENCE in user entry SWAPGS path */
 #define X86_FEATURE_FENCE_SWAPGS_KERNEL	(11*32+ 5) /* "" LFENCE in kernel entry SWAPGS path */
+/* FREE!				(11*32+ 6) */
+/* FREE!				(11*32+ 7) */
+/* FREE!				(11*32+ 8) */
+/* FREE!				(11*32+ 9) */
+/* FREE!				(11*32+10) */
+#define X86_FEATURE_RRSBA_CTRL		(11*32+11) /* "" RET prediction control */
+#define X86_FEATURE_RETPOLINE		(11*32+12) /* "" Generic Retpoline mitigation for Spectre variant 2 */
+#define X86_FEATURE_RETPOLINE_LFENCE	(11*32+13) /* "" Use LFENCE for Spectre variant 2 */
+#define X86_FEATURE_RSB_VMEXIT_LITE	(11*32+17) /* "" Fill RSB on VM exit when EIBRS is enabled */
 
 /* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */
 #define X86_FEATURE_CLZERO		(13*32+ 0) /* CLZERO instruction */
@@ -295,6 +304,7 @@
 #define X86_FEATURE_AMD_SSBD		(13*32+24) /* "" Speculative Store Bypass Disable */
 #define X86_FEATURE_VIRT_SSBD		(13*32+25) /* Virtualized Speculative Store Bypass Disable */
 #define X86_FEATURE_AMD_SSB_NO		(13*32+26) /* "" Speculative Store Bypass is fixed in hardware. */
+#define X86_FEATURE_BTC_NO		(13*32+29) /* "" Not vulnerable to Branch Type Confusion */
 
 /* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */
 #define X86_FEATURE_DTHERM		(14*32+ 0) /* Digital Thermal Sensor */
@@ -395,5 +405,7 @@
 #define X86_BUG_SRBDS			X86_BUG(24) /* CPU may leak RNG bits if not mitigated */
 #define X86_BUG_MMIO_STALE_DATA		X86_BUG(25) /* CPU is affected by Processor MMIO Stale Data vulnerabilities */
 #define X86_BUG_MMIO_UNKNOWN		X86_BUG(26) /* CPU is too old and its MMIO Stale Data status is unknown */
+#define X86_BUG_RETBLEED		X86_BUG(27) /* CPU is affected by RETBleed */
+#define X86_BUG_EIBRS_PBRSB		X86_BUG(28) /* EIBRS is vulnerable to Post Barrier RSB Predictions */
 
 #endif /* _ASM_X86_CPUFEATURES_H */
arch/x86/include/asm/intel-family.h +6 -0
index 05d2d7169ab8..7811d42e78ef 100644
@@ -16,6 +16,9 @@
  * that group keep the CPUID for the variants sorted by model number.
  */
 
+/* Wildcard match for FAM6 so X86_MATCH_INTEL_FAM6_MODEL(ANY) works */
+#define INTEL_FAM6_ANY			X86_MODEL_ANY
+
 #define INTEL_FAM6_CORE_YONAH		0x0E
 
 #define INTEL_FAM6_CORE2_MEROM		0x0F
@@ -103,4 +106,7 @@
 #define INTEL_FAM6_XEON_PHI_KNL		0x57 /* Knights Landing */
 #define INTEL_FAM6_XEON_PHI_KNM		0x85 /* Knights Mill */
 
+/* Family 5 */
+#define INTEL_FAM5_QUARK_X1000		0x09 /* Quark X1000 SoC */
+
 #endif /* _ASM_X86_INTEL_FAMILY_H */
arch/x86/include/asm/msr-index.h +14 -0
index c090d8e8fbb3..92c6054f0a00 100644
@@ -47,6 +47,8 @@
 #define SPEC_CTRL_STIBP			BIT(SPEC_CTRL_STIBP_SHIFT)	/* STIBP mask */
 #define SPEC_CTRL_SSBD_SHIFT		2	   /* Speculative Store Bypass Disable bit */
 #define SPEC_CTRL_SSBD			BIT(SPEC_CTRL_SSBD_SHIFT)	/* Speculative Store Bypass Disable */
+#define SPEC_CTRL_RRSBA_DIS_S_SHIFT	6	   /* Disable RRSBA behavior */
+#define SPEC_CTRL_RRSBA_DIS_S		BIT(SPEC_CTRL_RRSBA_DIS_S_SHIFT)
 
 #define MSR_IA32_PRED_CMD		0x00000049 /* Prediction Command */
 #define PRED_CMD_IBPB			BIT(0)	   /* Indirect Branch Prediction Barrier */
@@ -73,6 +75,7 @@
 #define MSR_IA32_ARCH_CAPABILITIES	0x0000010a
 #define ARCH_CAP_RDCL_NO		BIT(0)	/* Not susceptible to Meltdown */
 #define ARCH_CAP_IBRS_ALL		BIT(1)	/* Enhanced IBRS support */
+#define ARCH_CAP_RSBA			BIT(2)	/* RET may use alternative branch predictors */
 #define ARCH_CAP_SKIP_VMENTRY_L1DFLUSH	BIT(3)	/* Skip L1D flush on vmentry */
 #define ARCH_CAP_SSB_NO			BIT(4)	/*
 						 * Not susceptible to Speculative Store Bypass
@@ -120,6 +123,17 @@
 						 * bit available to control VERW
 						 * behavior.
 						 */
+#define ARCH_CAP_RRSBA			BIT(19)	/*
+						 * Indicates RET may use predictors
+						 * other than the RSB. With eIBRS
+						 * enabled predictions in kernel mode
+						 * are restricted to targets in
+						 * kernel.
+						 */
+#define ARCH_CAP_PBRSB_NO		BIT(24)	/*
+						 * Not susceptible to Post-Barrier
+						 * Return Stack Buffer Predictions.
+						 */
 
 #define MSR_IA32_FLUSH_CMD		0x0000010b
 #define L1D_FLUSH			BIT(0)	/*
arch/x86/include/asm/nospec-branch.h +29 -19

111 lines not on this page · raw message

arch/x86/kernel/cpu/amd.c +15 -6
index 3914f9218a6b..0ccd74d37aad 100644
@@ -857,12 +857,21 @@ static void init_amd_zn(struct cpuinfo_x86 *c)
 {
 	set_cpu_cap(c, X86_FEATURE_ZEN);
 
-	/*
-	 * Fix erratum 1076: CPB feature bit not being set in CPUID.
-	 * Always set it, except when running under a hypervisor.
-	 */
-	if (!cpu_has(c, X86_FEATURE_HYPERVISOR) && !cpu_has(c, X86_FEATURE_CPB))
-		set_cpu_cap(c, X86_FEATURE_CPB);
+	/* Fix up CPUID bits, but only if not virtualised. */
+	if (!cpu_has(c, X86_FEATURE_HYPERVISOR)) {
+
+		/* Erratum 1076: CPB feature bit not being set in CPUID. */
+		if (!cpu_has(c, X86_FEATURE_CPB))
+			set_cpu_cap(c, X86_FEATURE_CPB);
+
+		/*
+		 * Zen3 (Fam19 model < 0x10) parts are not susceptible to
+		 * Branch Type Confusion, but predate the allocation of the
+		 * BTC_NO bit.
+		 */
+		if (c->x86 == 0x19 && !cpu_has(c, X86_FEATURE_BTC_NO))
+			set_cpu_cap(c, X86_FEATURE_BTC_NO);
+	}
 }
 
 static void init_amd(struct cpuinfo_x86 *c)
arch/x86/kernel/cpu/bugs.c +345 -70

648 lines not on this page · raw message

arch/x86/kernel/cpu/common.c +44 -24

118 lines not on this page · raw message

arch/x86/kernel/cpu/match.c +40 -4

55 lines not on this page · raw message

arch/x86/kernel/cpu/scattered.c +1 -0
index 0b9c7150cb23..efdb1decf034 100644
@@ -21,6 +21,7 @@ struct cpuid_bit {
 static const struct cpuid_bit cpuid_bits[] = {
 	{ X86_FEATURE_APERFMPERF,       CPUID_ECX,  0, 0x00000006, 0 },
 	{ X86_FEATURE_EPB,		CPUID_ECX,  3, 0x00000006, 0 },
+	{ X86_FEATURE_RRSBA_CTRL,	CPUID_EDX,  2, 0x00000007, 2 },
 	{ X86_FEATURE_CQM_LLC,		CPUID_EDX,  1, 0x0000000f, 0 },
 	{ X86_FEATURE_CQM_OCCUP_LLC,	CPUID_EDX,  0, 0x0000000f, 1 },
 	{ X86_FEATURE_CQM_MBM_TOTAL,	CPUID_EDX,  1, 0x0000000f, 1 },
arch/x86/kernel/process.c +1 -1
index a07b09f68e7e..baa9254149e7 100644
@@ -435,7 +435,7 @@ static __always_inline void __speculation_ctrl_update(unsigned long tifp,
 	}
 
 	if (updmsr)
-		wrmsrl(MSR_IA32_SPEC_CTRL, msr);
+		write_spec_ctrl_current(msr, false);
 }
 
 static unsigned long speculation_ctrl_update_tif(struct task_struct *tsk)
arch/x86/kvm/svm.c +1 -0
index 69056af43a98..7d8670896203 100644
@@ -47,6 +47,7 @@
 #include <asm/irq_remapping.h>
 #include <asm/microcode.h>
 #include <asm/spec-ctrl.h>
+#include <asm/cpu_device_id.h>
 
 #include <asm/virtext.h>
 #include "trace.h"
arch/x86/kvm/vmx.c +45 -6

79 lines not on this page · raw message

drivers/base/cpu.c +8 -0
index ba4e7732e2c7..9ae153124380 100644
@@ -564,6 +564,12 @@ ssize_t __weak cpu_show_mmio_stale_data(struct device *dev,
 	return sysfs_emit(buf, "Not affected\n");
 }
 
+ssize_t __weak cpu_show_retbleed(struct device *dev,
+				 struct device_attribute *attr, char *buf)
+{
+	return sysfs_emit(buf, "Not affected\n");
+}
+
 static DEVICE_ATTR(meltdown, 0444, cpu_show_meltdown, NULL);
 static DEVICE_ATTR(spectre_v1, 0444, cpu_show_spectre_v1, NULL);
 static DEVICE_ATTR(spectre_v2, 0444, cpu_show_spectre_v2, NULL);
@@ -574,6 +580,7 @@ static DEVICE_ATTR(tsx_async_abort, 0444, cpu_show_tsx_async_abort, NULL);
 static DEVICE_ATTR(itlb_multihit, 0444, cpu_show_itlb_multihit, NULL);
 static DEVICE_ATTR(srbds, 0444, cpu_show_srbds, NULL);
 static DEVICE_ATTR(mmio_stale_data, 0444, cpu_show_mmio_stale_data, NULL);
+static DEVICE_ATTR(retbleed, 0444, cpu_show_retbleed, NULL);
 
 static struct attribute *cpu_root_vulnerabilities_attrs[] = {
 	&dev_attr_meltdown.attr,
@@ -586,6 +593,7 @@ static struct attribute *cpu_root_vulnerabilities_attrs[] = {
 	&dev_attr_itlb_multihit.attr,
 	&dev_attr_srbds.attr,
 	&dev_attr_mmio_stale_data.attr,
+	&dev_attr_retbleed.attr,
 	NULL
 };
 
drivers/cpufreq/acpi-cpufreq.c +1 -0
index 8a199b4047c2..6b5304177575 100644
@@ -47,6 +47,7 @@
 #include <asm/msr.h>
 #include <asm/processor.h>
 #include <asm/cpufeature.h>
+#include <asm/cpu_device_id.h>
 
 MODULE_AUTHOR("Paul Diefenbaugh, Dominik Brodowski");
 MODULE_DESCRIPTION("ACPI Processor P-States Driver");
drivers/cpufreq/amd_freq_sensitivity.c +1 -0
index 042023bbbf62..b7692861b2f7 100644
@@ -20,6 +20,7 @@
 
 #include <asm/msr.h>
 #include <asm/cpufeature.h>
+#include <asm/cpu_device_id.h>
 
 #include "cpufreq_ondemand.h"
 
drivers/idle/intel_idle.c +39 -6

116 lines not on this page · raw message

include/linux/cpu.h +2 -0
index f958ecc82de9..8c4d21e71774 100644
@@ -68,6 +68,8 @@ extern ssize_t cpu_show_srbds(struct device *dev, struct device_attribute *attr,
 extern ssize_t cpu_show_mmio_stale_data(struct device *dev,
 					struct device_attribute *attr,
 					char *buf);
+extern ssize_t cpu_show_retbleed(struct device *dev,
+				 struct device_attribute *attr, char *buf);
 
 extern __printf(4, 5)
 struct device *cpu_device_create(struct device *parent, void *drvdata,
include/linux/mod_devicetable.h +1 -3
index 6f8eb1238235..97794823eabd 100644
@@ -604,9 +604,7 @@ struct x86_cpu_id {
 	__u16 steppings;
 };
 
-#define X86_FEATURE_MATCH(x) \
-	{ X86_VENDOR_ANY, X86_FAMILY_ANY, X86_MODEL_ANY, x }
-
+/* Wild cards for x86_cpu_id::vendor, family, model and feature */
 #define X86_VENDOR_ANY 0xffff
 #define X86_FAMILY_ANY 0
 #define X86_MODEL_ANY  0
tools/arch/x86/include/asm/cpufeatures.h +1 -0
index bb5861adb5a0..8fd46c879348 100644
@@ -270,6 +270,7 @@
 
 /* Intel-defined CPU QoS Sub-leaf, CPUID level 0x0000000F:0 (EDX), word 11 */
 #define X86_FEATURE_CQM_LLC		(11*32+ 1) /* LLC QoS if 1 */
+#define X86_FEATURE_RSB_VMEXIT_LITE	(11*32+17) /* "" Fill RSB on VM-Exit when EIBRS is enabled */
 
 /* Intel-defined CPU QoS Sub-leaf, CPUID level 0x0000000F:1 (EDX), word 12 */
 #define X86_FEATURE_CQM_OCCUP_LLC	(12*32+ 0) /* LLC occupancy monitoring */
#2 lore raw
In reply to Greg Kroah-Hartman
Quoted 8 lines · Greg Kroah-Hartman

I'm announcing the release of the 4.14.297 kernel.

All users of the 4.14 kernel series must upgrade.

The updated 4.14.y git tree can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-4.14.y
and can be browsed at the normal kernel.org git web browser:
https://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary

Hi Greg and stable tree maintainers,
Please consider cherry-picking
commit 95b980d62d52 ("linux/bits.h: make BIT(), GENMASK(), and friends available in assembly") back to 4.19.y and 4.14.y. It first landed in v5.3-rc1 and applies
cleanly to both branches. I did not find any fixups to 95b980d62d52,
FWIW.

Otherwise users upgrading to this point release of linux-4.14.y still on versions of the GNU assembler older than v1.28 will observe assembler errors when building this series. See the link below for the error messages.

Please see
https://lore.kernel.org/llvm/[email protected]/
for more info.

Quoted 100 lines

thanks,

greg k-h

------------

 Documentation/admin-guide/hw-vuln/spectre.rst   |    8 
 Documentation/admin-guide/kernel-parameters.txt |   13 
 Makefile                                        |    2 
 arch/x86/entry/calling.h                        |   68 +++
 arch/x86/entry/entry_32.S                       |    2 
 arch/x86/entry/entry_64.S                       |   38 +-
 arch/x86/entry/entry_64_compat.S                |   12 
 arch/x86/include/asm/cpu_device_id.h            |  168 +++++++++
 arch/x86/include/asm/cpufeatures.h              |   16 
 arch/x86/include/asm/intel-family.h             |    6 
 arch/x86/include/asm/msr-index.h                |   14 
 arch/x86/include/asm/nospec-branch.h            |   48 +-
 arch/x86/kernel/cpu/amd.c                       |   21 -
 arch/x86/kernel/cpu/bugs.c                      |  415 +++++++++++++++++++-----
 arch/x86/kernel/cpu/common.c                    |   68 ++-
 arch/x86/kernel/cpu/match.c                     |   44 ++
 arch/x86/kernel/cpu/scattered.c                 |    1 
 arch/x86/kernel/process.c                       |    2 
 arch/x86/kvm/svm.c                              |    1 
 arch/x86/kvm/vmx.c                              |   51 ++
 drivers/base/cpu.c                              |    8 
 drivers/cpufreq/acpi-cpufreq.c                  |    1 
 drivers/cpufreq/amd_freq_sensitivity.c          |    1 
 drivers/idle/intel_idle.c                       |   45 ++
 include/linux/cpu.h                             |    2 
 include/linux/mod_devicetable.h                 |    4 
 tools/arch/x86/include/asm/cpufeatures.h        |    1 
 27 files changed, 898 insertions(+), 162 deletions(-)

Alexandre Chartre (2):
x86/bugs: Report AMD retbleed vulnerability
x86/bugs: Add AMD retbleed= boot parameter

Andrew Cooper (1):
x86/cpu/amd: Enumerate BTC_NO

Daniel Sneddon (1):
x86/speculation: Add RSB VM Exit protections

Greg Kroah-Hartman (1):

      Linux 4.14.297

Ingo Molnar (1):
x86/cpufeature: Fix various quality problems in the <asm/cpu_device_hd.h> header

Josh Poimboeuf (8):
x86/speculation: Fix RSB filling with CONFIG_RETPOLINE=n x86/speculation: Fix firmware entry SPEC_CTRL handling x86/speculation: Fix SPEC_CTRL write on SMT state change x86/speculation: Use cached host SPEC_CTRL value for guest entry/exit x86/speculation: Remove x86_spec_ctrl_mask
KVM: VMX: Prevent guest RSB poisoning attacks with eIBRS
KVM: VMX: Fix IBRS handling after vmexit
x86/speculation: Fill RSB on vmexit for IBRS

Kan Liang (1):
x86/cpufeature: Add facility to check for min microcode revisions

Mark Gross (1):
x86/cpu: Add a steppings field to struct x86_cpu_id

Nathan Chancellor (1):
x86/speculation: Use DECLARE_PER_CPU for x86_spec_ctrl_current

Pawan Gupta (5):
x86/speculation: Add spectre_v2=ibrs option to support Kernel IBRS x86/speculation: Add LFENCE to RSB fill sequence
x86/bugs: Add Cannon lake to RETBleed affected CPU list x86/speculation: Disable RRSBA behavior
x86/bugs: Warn when "ibrs" mitigation is selected on Enhanced IBRS parts

Peter Zijlstra (9):
x86/entry: Remove skip_r11rcx
x86/cpufeatures: Move RETPOLINE flags to word 11
x86/bugs: Keep a per-CPU IA32_SPEC_CTRL value
x86/bugs: Optimize SPEC_CTRL MSR writes
x86/bugs: Split spectre_v2_select_mitigation() and spectre_v2_user_select_mitigation() x86/bugs: Report Intel retbleed vulnerability
entel_idle: Disable IBRS during long idle
x86/speculation: Change FILL_RETURN_BUFFER to work with objtool x86/common: Stamp out the stepping madness

Suraj Jitindar Singh (1):
Revert "x86/cpu: Add a steppings field to struct x86_cpu_id"

Thadeu Lima de Souza Cascardo (1):
x86/entry: Add kernel IBRS implementation

Thomas Gleixner (2):
x86/devicetable: Move x86 specific macro out of generic code x86/cpu: Add consistent CPU match macros

author maintainer
#3 lore raw
Quoted 17 lines · Nick Desaulniers
Quoted 8 lines · Greg Kroah-Hartman

I'm announcing the release of the 4.14.297 kernel.

All users of the 4.14 kernel series must upgrade.

The updated 4.14.y git tree can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-4.14.y
and can be browsed at the normal kernel.org git web browser:
https://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary

Hi Greg and stable tree maintainers,
Please consider cherry-picking
commit 95b980d62d52 ("linux/bits.h: make BIT(), GENMASK(), and friends available in assembly") back to 4.19.y and 4.14.y. It first landed in v5.3-rc1 and applies
cleanly to both branches. I did not find any fixups to 95b980d62d52,
FWIW.

Quoted 8 lines

Otherwise users upgrading to this point release of linux-4.14.y still on versions of the GNU assembler older than v1.28 will observe assembler errors when building this series. See the link below for the error messages.

Please see
https://lore.kernel.org/llvm/[email protected]/
for more info.

Did you try building with that commit applied? I get the following build error when running it through the Android build system:

In file included from /buildbot/src/android/q-common-android-4.14/common/arch/arm64/include/asm/bitops.h:49:
/buildbot/src/android/q-common-android-4.14/common/include/asm-generic/bitops/non-atomic.h:60:23: error: implicit declaration of function 'UL' [-Werror,-Wimplicit-function-declaration]

        unsigned long mask = BIT_MASK(nr);
                             ^

/buildbot/src/android/q-common-android-4.14/common/include/linux/bits.h:10:24: note: expanded from macro 'BIT_MASK'
#define BIT_MASK(nr) (UL(1) << ((nr) % BITS_PER_LONG))

So are you sure this is the correct fix?

thanks,

greg k-h

#4 lore raw
Quoted 24 lines · Greg Kroah-Hartman
Quoted 22 lines · Nick Desaulniers
Quoted 8 lines · Greg Kroah-Hartman

I'm announcing the release of the 4.14.297 kernel.

All users of the 4.14 kernel series must upgrade.

The updated 4.14.y git tree can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-4.14.y
and can be browsed at the normal kernel.org git web browser:
https://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary

Hi Greg and stable tree maintainers,
Please consider cherry-picking
commit 95b980d62d52 ("linux/bits.h: make BIT(), GENMASK(), and friends available in assembly") back to 4.19.y and 4.14.y. It first landed in v5.3-rc1 and applies
cleanly to both branches. I did not find any fixups to 95b980d62d52,
FWIW.

Otherwise users upgrading to this point release of linux-4.14.y still on versions of the GNU assembler older than v1.28 will observe assembler errors when building this series. See the link below for the error messages.

Quoted 5 lines
Quoted 3 lines

Please see
https://lore.kernel.org/llvm/[email protected]/
for more info.

Did you try building with that commit applied? I get the following

I built 4.19 but not 4.14. Sorry! It looks like for 4.14 95b980d62d52 will additionally depend on

commit 2dd8a62c6476 ("linux/const.h: move UL() macro to include/linux/const.h")

which first landed in v4.17-rc1.

That commit will depend on

commit 2a6cc8a6c0cb ("linux/const.h: prefix include guard of uapi/linux/const.h with _UAPI")

which first landed in v4.17-rc1 as well. Looks like they were part of the same series.

So 4.14.y will need the following 3 patches:
1. commit 2a6cc8a6c0cb ("linux/const.h: prefix include guard of uapi/linux/const.h with _UAPI")
2. commit 2dd8a62c6476 ("linux/const.h: move UL() macro to include/linux/const.h")
3. commit 95b980d62d52 ("linux/bits.h: make BIT(), GENMASK(), and friends available in assembly")

2a6cc8a6c0cb will have a minor conflict in include/uapi/linux/const.h because commit a85cbe6159ff ("uapi: move constants from <linux/kernel.h> to <linux/const.h>")
was backported before 2a6cc8a6c0cb as b732e14e6218b (in 4.14). Attached is a compile tested (x86 make CC=clang) mbox for 4.14.y. Please let me know if that works for you.

Quoted 14 lines

build error when running it through the Android build system:

In file included from /buildbot/src/android/q-common-android-4.14/common/arch/arm64/include/asm/bitops.h:49:
/buildbot/src/android/q-common-android-4.14/common/include/asm-generic/bitops/non-atomic.h:60:23: error: implicit declaration of function 'UL' [-Werror,-Wimplicit-function-declaration]

        unsigned long mask = BIT_MASK(nr);
                             ^

/buildbot/src/android/q-common-android-4.14/common/include/linux/bits.h:10:24: note: expanded from macro 'BIT_MASK'
#define BIT_MASK(nr) (UL(1) << ((nr) % BITS_PER_LONG))

So are you sure this is the correct fix?

thanks,

greg k-h

Signature · 2 lines
Thanks,
~Nick Desaulniers
author maintainer
#5 lore raw
Quoted 55 lines · Nick Desaulniers
Quoted 24 lines · Greg Kroah-Hartman
Quoted 22 lines · Nick Desaulniers
Quoted 8 lines · Greg Kroah-Hartman

I'm announcing the release of the 4.14.297 kernel.

All users of the 4.14 kernel series must upgrade.

The updated 4.14.y git tree can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-4.14.y
and can be browsed at the normal kernel.org git web browser:
https://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary

Hi Greg and stable tree maintainers,
Please consider cherry-picking
commit 95b980d62d52 ("linux/bits.h: make BIT(), GENMASK(), and friends available in assembly") back to 4.19.y and 4.14.y. It first landed in v5.3-rc1 and applies
cleanly to both branches. I did not find any fixups to 95b980d62d52,
FWIW.

Otherwise users upgrading to this point release of linux-4.14.y still on versions of the GNU assembler older than v1.28 will observe assembler errors when building this series. See the link below for the error messages.

Quoted 5 lines
Quoted 3 lines

Please see
https://lore.kernel.org/llvm/[email protected]/
for more info.

Did you try building with that commit applied? I get the following

I built 4.19 but not 4.14. Sorry! It looks like for 4.14 95b980d62d52 will additionally depend on

commit 2dd8a62c6476 ("linux/const.h: move UL() macro to include/linux/const.h")

which first landed in v4.17-rc1.

That commit will depend on

commit 2a6cc8a6c0cb ("linux/const.h: prefix include guard of uapi/linux/const.h with _UAPI")

which first landed in v4.17-rc1 as well. Looks like they were part of the same series.

So 4.14.y will need the following 3 patches:
1. commit 2a6cc8a6c0cb ("linux/const.h: prefix include guard of uapi/linux/const.h with _UAPI")
2. commit 2dd8a62c6476 ("linux/const.h: move UL() macro to include/linux/const.h")
3. commit 95b980d62d52 ("linux/bits.h: make BIT(), GENMASK(), and friends available in assembly")

Quoted 6 lines

2a6cc8a6c0cb will have a minor conflict in include/uapi/linux/const.h because commit a85cbe6159ff ("uapi: move constants from <linux/kernel.h> to <linux/const.h>")
was backported before 2a6cc8a6c0cb as b732e14e6218b (in 4.14). Attached is a compile tested (x86 make CC=clang) mbox for 4.14.y. Please let me know if that works for you.

Thanks, I've queued these up now and will test them later today on the Android build system as well.

greg k-h