All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Julien Grall <julien.grall@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Marc Zyngier <marc.zyngier@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>
Subject: [PATCH 4.14 81/92] arm64: Add ARCH_WORKAROUND_2 probing
Date: Fri, 20 Jul 2018 14:14:25 +0200	[thread overview]
Message-ID: <20180720121422.364866651@linuxfoundation.org> (raw)
In-Reply-To: <20180720121417.206337808@linuxfoundation.org>

4.14-stable review patch.  If anyone has any objections, please let me know.

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

From: Marc Zyngier <marc.zyngier@arm.com>

commit a725e3dda1813ed306734823ac4c65ca04e38500 upstream.

As for Spectre variant-2, we rely on SMCCC 1.1 to provide the
discovery mechanism for detecting the SSBD mitigation.

A new capability is also allocated for that purpose, and a
config option.

Reviewed-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 arch/arm64/Kconfig               |    9 +++++
 arch/arm64/include/asm/cpucaps.h |    3 +
 arch/arm64/kernel/cpu_errata.c   |   69 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 80 insertions(+), 1 deletion(-)

--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -849,6 +849,15 @@ config HARDEN_BRANCH_PREDICTOR
 
 	  If unsure, say Y.
 
+config ARM64_SSBD
+	bool "Speculative Store Bypass Disable" if EXPERT
+	default y
+	help
+	  This enables mitigation of the bypassing of previous stores
+	  by speculative loads.
+
+	  If unsure, say Y.
+
 menuconfig ARMV8_DEPRECATED
 	bool "Emulate deprecated/obsolete ARMv8 instructions"
 	depends on COMPAT
--- a/arch/arm64/include/asm/cpucaps.h
+++ b/arch/arm64/include/asm/cpucaps.h
@@ -43,7 +43,8 @@
 #define ARM64_UNMAP_KERNEL_AT_EL0		23
 #define ARM64_HARDEN_BRANCH_PREDICTOR		24
 #define ARM64_HARDEN_BP_POST_GUEST_EXIT		25
+#define ARM64_SSBD				26
 
-#define ARM64_NCAPS				26
+#define ARM64_NCAPS				27
 
 #endif /* __ASM_CPUCAPS_H */
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -252,6 +252,67 @@ void __init arm64_update_smccc_conduit(s
 
 	*updptr = cpu_to_le32(insn);
 }
+
+static void arm64_set_ssbd_mitigation(bool state)
+{
+	switch (psci_ops.conduit) {
+	case PSCI_CONDUIT_HVC:
+		arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_WORKAROUND_2, state, NULL);
+		break;
+
+	case PSCI_CONDUIT_SMC:
+		arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2, state, NULL);
+		break;
+
+	default:
+		WARN_ON_ONCE(1);
+		break;
+	}
+}
+
+static bool has_ssbd_mitigation(const struct arm64_cpu_capabilities *entry,
+				    int scope)
+{
+	struct arm_smccc_res res;
+	bool supported = true;
+
+	WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
+
+	if (psci_ops.smccc_version == SMCCC_VERSION_1_0)
+		return false;
+
+	/*
+	 * The probe function return value is either negative
+	 * (unsupported or mitigated), positive (unaffected), or zero
+	 * (requires mitigation). We only need to do anything in the
+	 * last case.
+	 */
+	switch (psci_ops.conduit) {
+	case PSCI_CONDUIT_HVC:
+		arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
+				  ARM_SMCCC_ARCH_WORKAROUND_2, &res);
+		if ((int)res.a0 != 0)
+			supported = false;
+		break;
+
+	case PSCI_CONDUIT_SMC:
+		arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
+				  ARM_SMCCC_ARCH_WORKAROUND_2, &res);
+		if ((int)res.a0 != 0)
+			supported = false;
+		break;
+
+	default:
+		supported = false;
+	}
+
+	if (supported) {
+		__this_cpu_write(arm64_ssbd_callback_required, 1);
+		arm64_set_ssbd_mitigation(true);
+	}
+
+	return supported;
+}
 #endif	/* CONFIG_ARM64_SSBD */
 
 #define MIDR_RANGE(model, min, max) \
@@ -452,6 +513,14 @@ const struct arm64_cpu_capabilities arm6
 		.enable = enable_smccc_arch_workaround_1,
 	},
 #endif
+#ifdef CONFIG_ARM64_SSBD
+	{
+		.desc = "Speculative Store Bypass Disable",
+		.def_scope = SCOPE_LOCAL_CPU,
+		.capability = ARM64_SSBD,
+		.matches = has_ssbd_mitigation,
+	},
+#endif
 	{
 	}
 };



  parent reply	other threads:[~2018-07-20 12:53 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-20 12:13 [PATCH 4.14 00/92] 4.14.57-stable review Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 01/92] compiler-gcc.h: Add __attribute__((gnu_inline)) to all inline declarations Greg Kroah-Hartman
2018-07-20 12:13   ` Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 02/92] x86/asm: Add _ASM_ARG* constants for argument registers to <asm/asm.h> Greg Kroah-Hartman
2018-07-20 12:13   ` Greg Kroah-Hartman
2018-07-20 12:13 ` Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 03/92] x86/paravirt: Make native_save_fl() extern inline Greg Kroah-Hartman
2018-07-20 12:13 ` Greg Kroah-Hartman
2018-07-20 12:13   ` Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 04/92] Btrfs: fix duplicate extents after fsync of file with prealloc extents Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 05/92] cpufreq / CPPC: Set platform specific transition_delay_us Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 06/92] xprtrdma: Fix corner cases when handling device removal Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 07/92] ocfs2: subsystem.su_mutex is required while accessing the item->ci_parent Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 08/92] ocfs2: ip_alloc_sem should be taken in ocfs2_get_block() Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 09/92] bcm63xx_enet: correct clock usage Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 10/92] bcm63xx_enet: do not write to random DMA channel on BCM6345 Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 11/92] PCI: exynos: Fix a potential init_clk_resources NULL pointer dereference Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 12/92] crypto: crypto4xx - remove bad list_del Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 13/92] crypto: crypto4xx - fix crypto4xx_build_pdr, crypto4xx_build_sdr leak Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 14/92] alx: take rtnl before calling __alx_open from resume Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 16/92] atm: zatm: Fix potential Spectre v1 Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 17/92] hv_netvsc: split sub-channel setup into async and sync Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 18/92] ipv6: sr: fix passing wrong flags to crypto_alloc_shash() Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 19/92] ipvlan: fix IFLA_MTU ignored on NEWLINK Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 20/92] ixgbe: split XDP_TX tail and XDP_REDIRECT map flushing Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 21/92] net: dccp: avoid crash in ccid3_hc_rx_send_feedback() Greg Kroah-Hartman
2018-07-20 12:13   ` Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 22/92] net: dccp: switch rx_tstamp_last_feedback to monotonic clock Greg Kroah-Hartman
2018-07-20 12:13   ` Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 23/92] net: fix use-after-free in GRO with ESP Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 24/92] net: macb: Fix ptp time adjustment for large negative delta Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 25/92] net/mlx5e: Avoid dealing with vport representors if not being e-switch manager Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 26/92] net/mlx5e: Dont attempt to dereference the ppriv struct if not being eswitch manager Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 27/92] net/mlx5: E-Switch, Avoid setup attempt if not being e-switch manager Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 28/92] net/mlx5: Fix command interface race in polling mode Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 29/92] net/mlx5: Fix incorrect raw command length parsing Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 30/92] net/mlx5: Fix required capability for manipulating MPFS Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 31/92] net/mlx5: Fix wrong size allocation for QoS ETC TC regitster Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 32/92] net: mvneta: fix the Rx desc DMA address in the Rx path Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 33/92] net/packet: fix use-after-free Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 34/92] net_sched: blackhole: tell upper qdisc about dropped packets Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 35/92] net: sungem: fix rx checksum support Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 36/92] net/tcp: Fix socket lookups with SO_BINDTODEVICE Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 37/92] qede: Adverstise software timestamp caps when PHC is not available Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 38/92] qed: Fix setting of incorrect eswitch mode Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 39/92] qed: Fix use of incorrect size in memcpy call Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 40/92] qed: Limit msix vectors in kdump kernel to the minimum required count Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 42/92] r8152: napi hangup fix after disconnect Greg Kroah-Hartman
2018-07-20 12:13   ` [4.14,42/92] " Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 43/92] stmmac: fix DMA channel hang in half-duplex mode Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 44/92] strparser: Remove early eaten to fix full tcp receive buffer stall Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 45/92] tcp: fix Fast Open key endianness Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 47/92] vhost_net: validate sock before trying to put its fd Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 48/92] VSOCK: fix loopback on big-endian systems Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 49/92] net: cxgb3_main: fix potential Spectre v1 Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 50/92] rtlwifi: Fix kernel Oops "Fw download fail!!" Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 51/92] rtlwifi: rtl8821ae: fix firmware is not ready to run Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 52/92] net: lan78xx: Fix race in tx pending skb size calculation Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 53/92] xhci: Fix USB3 NULL pointer dereference at logical disconnect Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 54/92] media: rc: oops in ir_timer_keyup after device unplug Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.14 55/92] clocksource: Initialize cs->wd_list Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 56/92] crypto: af_alg - Initialize sg_num_bytes in error code path Greg Kroah-Hartman
2018-07-20 12:54   ` KMSAN: uninit-value in af_alg_free_areq_sgls syzbot
2018-07-20 12:14 ` [PATCH 4.14 57/92] mtd: rawnand: denali_dt: set clk_x_rate to 200 MHz unconditionally Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 58/92] block: do not use interruptible wait anywhere Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 59/92] PCI: hv: Disable/enable IRQs rather than BH in hv_compose_msi_msg() Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 60/92] netfilter: ebtables: reject non-bridge targets Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 61/92] reiserfs: fix buffer overflow with long warning messages Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 62/92] KEYS: DNS: fix parsing multiple options Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 63/92] tls: Stricter error checking in zerocopy sendmsg path Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 64/92] autofs: fix slab out of bounds read in getname_kernel() Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 65/92] nsh: set mac len based on inner packet Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 66/92] netfilter: ipv6: nf_defrag: drop skb dst before queueing Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 67/92] bdi: Fix another oops in wb_workfn() Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 68/92] rds: avoid unenecessary cong_update in loop transport Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 69/92] net/nfc: Avoid stalls when nfc_alloc_send_skb() returned NULL Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 70/92] KVM: arm64: Store vcpu on the stack during __guest_enter() Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 71/92] KVM: arm/arm64: Convert kvm_host_cpu_state to a static per-cpu allocation Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 72/92] KVM: arm64: Change hyp_panic()s dependency on tpidr_el2 Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 73/92] arm64: alternatives: use tpidr_el2 on VHE hosts Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 74/92] KVM: arm64: Stop save/restoring host tpidr_el1 on VHE Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 75/92] arm64: alternatives: Add dynamic patching feature Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 76/92] KVM: arm/arm64: Do not use kern_hyp_va() with kvm_vgic_global_state Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 77/92] KVM: arm64: Avoid storing the vcpu pointer on the stack Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 78/92] arm/arm64: smccc: Add SMCCC-specific return codes Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 79/92] arm64: Call ARCH_WORKAROUND_2 on transitions between EL0 and EL1 Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 80/92] arm64: Add per-cpu infrastructure to call ARCH_WORKAROUND_2 Greg Kroah-Hartman
2018-07-20 12:14 ` Greg Kroah-Hartman [this message]
2018-07-20 12:14 ` [PATCH 4.14 82/92] arm64: Add ssbd command-line option Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 83/92] arm64: ssbd: Add global mitigation state accessor Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 84/92] arm64: ssbd: Skip apply_ssbd if not using dynamic mitigation Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 85/92] arm64: ssbd: Restore mitigation status on CPU resume Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 86/92] arm64: ssbd: Introduce thread flag to control userspace mitigation Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 87/92] arm64: ssbd: Add prctl interface for per-thread mitigation Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 88/92] arm64: KVM: Add HYP per-cpu accessors Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 89/92] arm64: KVM: Add ARCH_WORKAROUND_2 support for guests Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 90/92] arm64: KVM: Handle guests ARCH_WORKAROUND_2 requests Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.14 91/92] arm64: KVM: Add ARCH_WORKAROUND_2 discovery through ARCH_FEATURES_FUNC_ID Greg Kroah-Hartman
2018-07-21  9:16 ` [PATCH 4.14 00/92] 4.14.57-stable review Naresh Kamboju
2018-07-21 13:41 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180720121422.364866651@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=julien.grall@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=stable@vger.kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.