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>,
Marc Zyngier <marc.zyngier@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>
Subject: [PATCH 4.17 089/101] arm64: Add ssbd command-line option
Date: Fri, 20 Jul 2018 14:14:35 +0200 [thread overview]
Message-ID: <20180720121427.014533862@linuxfoundation.org> (raw)
In-Reply-To: <20180720121422.837870592@linuxfoundation.org>
4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <marc.zyngier@arm.com>
commit a43ae4dfe56a01f5b98ba0cb2f784b6a43bafcc6 upstream.
On a system where the firmware implements ARCH_WORKAROUND_2,
it may be useful to either permanently enable or disable the
workaround for cases where the user decides that they'd rather
not get a trap overhead, and keep the mitigation permanently
on or off instead of switching it on exception entry/exit.
In any case, default to the mitigation being enabled.
Reviewed-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
Documentation/admin-guide/kernel-parameters.txt | 17 +++
arch/arm64/include/asm/cpufeature.h | 6 +
arch/arm64/kernel/cpu_errata.c | 103 ++++++++++++++++++++----
3 files changed, 110 insertions(+), 16 deletions(-)
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -4092,6 +4092,23 @@
expediting. Set to zero to disable automatic
expediting.
+ ssbd= [ARM64,HW]
+ Speculative Store Bypass Disable control
+
+ On CPUs that are vulnerable to the Speculative
+ Store Bypass vulnerability and offer a
+ firmware based mitigation, this parameter
+ indicates how the mitigation should be used:
+
+ force-on: Unconditionally enable mitigation for
+ for both kernel and userspace
+ force-off: Unconditionally disable mitigation for
+ for both kernel and userspace
+ kernel: Always enable mitigation in the
+ kernel, and offer a prctl interface
+ to allow userspace to register its
+ interest in being mitigated too.
+
stack_guard_gap= [MM]
override the default stack gap protection. The value
is in page units and it defines how many pages prior
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -537,6 +537,12 @@ static inline u64 read_zcr_features(void
return zcr;
}
+#define ARM64_SSBD_UNKNOWN -1
+#define ARM64_SSBD_FORCE_DISABLE 0
+#define ARM64_SSBD_KERNEL 1
+#define ARM64_SSBD_FORCE_ENABLE 2
+#define ARM64_SSBD_MITIGATED 3
+
#endif /* __ASSEMBLY__ */
#endif
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -235,6 +235,38 @@ enable_smccc_arch_workaround_1(const str
#ifdef CONFIG_ARM64_SSBD
DEFINE_PER_CPU_READ_MOSTLY(u64, arm64_ssbd_callback_required);
+int ssbd_state __read_mostly = ARM64_SSBD_KERNEL;
+
+static const struct ssbd_options {
+ const char *str;
+ int state;
+} ssbd_options[] = {
+ { "force-on", ARM64_SSBD_FORCE_ENABLE, },
+ { "force-off", ARM64_SSBD_FORCE_DISABLE, },
+ { "kernel", ARM64_SSBD_KERNEL, },
+};
+
+static int __init ssbd_cfg(char *buf)
+{
+ int i;
+
+ if (!buf || !buf[0])
+ return -EINVAL;
+
+ for (i = 0; i < ARRAY_SIZE(ssbd_options); i++) {
+ int len = strlen(ssbd_options[i].str);
+
+ if (strncmp(buf, ssbd_options[i].str, len))
+ continue;
+
+ ssbd_state = ssbd_options[i].state;
+ return 0;
+ }
+
+ return -EINVAL;
+}
+early_param("ssbd", ssbd_cfg);
+
void __init arm64_update_smccc_conduit(struct alt_instr *alt,
__le32 *origptr, __le32 *updptr,
int nr_inst)
@@ -278,44 +310,83 @@ static bool has_ssbd_mitigation(const st
int scope)
{
struct arm_smccc_res res;
- bool supported = true;
+ bool required = true;
+ s32 val;
WARN_ON(scope != SCOPE_LOCAL_CPU || preemptible());
- if (psci_ops.smccc_version == SMCCC_VERSION_1_0)
+ if (psci_ops.smccc_version == SMCCC_VERSION_1_0) {
+ ssbd_state = ARM64_SSBD_UNKNOWN;
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;
+ ssbd_state = ARM64_SSBD_UNKNOWN;
+ return false;
+ }
+
+ val = (s32)res.a0;
+
+ switch (val) {
+ case SMCCC_RET_NOT_SUPPORTED:
+ ssbd_state = ARM64_SSBD_UNKNOWN;
+ return false;
+
+ case SMCCC_RET_NOT_REQUIRED:
+ pr_info_once("%s mitigation not required\n", entry->desc);
+ ssbd_state = ARM64_SSBD_MITIGATED;
+ return false;
+
+ case SMCCC_RET_SUCCESS:
+ required = true;
+ break;
+
+ case 1: /* Mitigation not required on this CPU */
+ required = false;
+ break;
+
+ default:
+ WARN_ON(1);
+ return false;
}
- if (supported) {
- __this_cpu_write(arm64_ssbd_callback_required, 1);
+ switch (ssbd_state) {
+ case ARM64_SSBD_FORCE_DISABLE:
+ pr_info_once("%s disabled from command-line\n", entry->desc);
+ arm64_set_ssbd_mitigation(false);
+ required = false;
+ break;
+
+ case ARM64_SSBD_KERNEL:
+ if (required) {
+ __this_cpu_write(arm64_ssbd_callback_required, 1);
+ arm64_set_ssbd_mitigation(true);
+ }
+ break;
+
+ case ARM64_SSBD_FORCE_ENABLE:
+ pr_info_once("%s forced from command-line\n", entry->desc);
arm64_set_ssbd_mitigation(true);
+ required = true;
+ break;
+
+ default:
+ WARN_ON(1);
+ break;
}
- return supported;
+ return required;
}
#endif /* CONFIG_ARM64_SSBD */
next prev parent reply other threads:[~2018-07-20 12:14 UTC|newest]
Thread overview: 101+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-20 12:13 [PATCH 4.17 000/101] 4.17.9-stable review Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 001/101] compiler-gcc.h: Add __attribute__((gnu_inline)) to all inline declarations Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 002/101] x86/asm: Add _ASM_ARG* constants for argument registers to <asm/asm.h> Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 003/101] x86/paravirt: Make native_save_fl() extern inline Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 005/101] pinctrl: mt7622: fix error path on failing at groups building Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 006/101] pinctrl: mt7622: stop using the deprecated pinctrl_add_gpio_range Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 007/101] pinctrl: mt7622: fix a kernel panic when gpio-hog is being applied Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 008/101] alx: take rtnl before calling __alx_open from resume Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 010/101] atm: zatm: Fix potential Spectre v1 Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 011/101] hv_netvsc: split sub-channel setup into async and sync Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 012/101] ipv6: sr: fix passing wrong flags to crypto_alloc_shash() Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 013/101] ipvlan: fix IFLA_MTU ignored on NEWLINK Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 014/101] ixgbe: split XDP_TX tail and XDP_REDIRECT map flushing Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 015/101] net: dccp: avoid crash in ccid3_hc_rx_send_feedback() Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 016/101] net: dccp: switch rx_tstamp_last_feedback to monotonic clock Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 017/101] net: fix use-after-free in GRO with ESP Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 018/101] net: macb: Fix ptp time adjustment for large negative delta Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 019/101] net/mlx5e: Avoid dealing with vport representors if not being e-switch manager Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 020/101] net/mlx5e: Dont attempt to dereference the ppriv struct if not being eswitch manager Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 021/101] net/mlx5: E-Switch, Avoid setup attempt if not being e-switch manager Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 022/101] net/mlx5: Fix command interface race in polling mode Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 023/101] net/mlx5: Fix incorrect raw command length parsing Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 024/101] net/mlx5: Fix required capability for manipulating MPFS Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 025/101] net/mlx5: Fix wrong size allocation for QoS ETC TC regitster Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 026/101] net: mvneta: fix the Rx desc DMA address in the Rx path Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 027/101] net/packet: fix use-after-free Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 028/101] net/sched: act_ife: fix recursive lock and idr leak Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 029/101] net/sched: act_ife: preserve the action control in case of error Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 030/101] net_sched: blackhole: tell upper qdisc about dropped packets Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 031/101] net: sungem: fix rx checksum support Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 032/101] net/tcp: Fix socket lookups with SO_BINDTODEVICE Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 033/101] qede: Adverstise software timestamp caps when PHC is not available Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 034/101] qed: Fix setting of incorrect eswitch mode Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 035/101] qed: Fix use of incorrect size in memcpy call Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 036/101] qed: Limit msix vectors in kdump kernel to the minimum required count Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 038/101] r8152: napi hangup fix after disconnect Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 039/101] s390/qeth: dont clobber buffer on async TX completion Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 040/101] stmmac: fix DMA channel hang in half-duplex mode Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 041/101] strparser: Remove early eaten to fix full tcp receive buffer stall Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 042/101] tcp: fix Fast Open key endianness Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 044/101] vhost_net: validate sock before trying to put its fd Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 045/101] VSOCK: fix loopback on big-endian systems Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 046/101] hinic: reset irq affinity before freeing irq Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 047/101] nfp: flower: fix mpls ether type detection Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 048/101] net: macb: initialize bp->queues[0].bp for at91rm9200 Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 049/101] net: use dev_change_tx_queue_len() for SIOCSIFTXQLEN Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 050/101] nfp: reject binding to shared blocks Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 051/101] xen-netfront: Fix mismatched rtnl_unlock Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 052/101] xen-netfront: Update features after registering netdev Greg Kroah-Hartman
2018-07-20 12:13 ` [PATCH 4.17 053/101] enic: do not overwrite error code Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 055/101] IB/mlx5: Avoid dealing with vport representors if not being e-switch manager Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 056/101] Revert "s390/qeth: use Read device to query hypervisor for MAC" Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 057/101] s390/qeth: avoid using is_multicast_ether_addr_64bits on (u8 *)[6] Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 058/101] s390/qeth: fix race when setting MAC address Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 059/101] sfc: correctly initialise filter rwsem for farch Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 060/101] virtio_net: split XDP_TX kick and XDP_REDIRECT map flushing Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 061/101] x86/kvm/Kconfig: Ensure CRYPTO_DEV_CCP_DD state at minimum matches KVM_AMD Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 062/101] net: cxgb3_main: fix potential Spectre v1 Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 063/101] rtlwifi: Fix kernel Oops "Fw download fail!!" Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 064/101] rtlwifi: rtl8821ae: fix firmware is not ready to run Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 065/101] net: lan78xx: Fix race in tx pending skb size calculation Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 066/101] crypto: af_alg - Initialize sg_num_bytes in error code path Greg Kroah-Hartman
2018-07-20 13:08 ` KMSAN: uninit-value in af_alg_free_areq_sgls syzbot
2018-07-20 12:14 ` [PATCH 4.17 067/101] PCI: hv: Disable/enable IRQs rather than BH in hv_compose_msi_msg() Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 068/101] netfilter: ebtables: reject non-bridge targets Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 069/101] reiserfs: fix buffer overflow with long warning messages Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 070/101] KEYS: DNS: fix parsing multiple options Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 071/101] tls: Stricter error checking in zerocopy sendmsg path Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 072/101] autofs: fix slab out of bounds read in getname_kernel() Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 073/101] nsh: set mac len based on inner packet Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 074/101] netfilter: ipv6: nf_defrag: drop skb dst before queueing Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 075/101] bdi: Fix another oops in wb_workfn() Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 076/101] bpf: reject any prog that failed read-only lock Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 077/101] rds: avoid unenecessary cong_update in loop transport Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 078/101] block: dont use blocking queue entered for recursive bio submits Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 079/101] bpf: sockmap, fix crash when ipv6 sock is added Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 080/101] bpf: sockmap, consume_skb in close path Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 081/101] bpf: dont leave partial mangled prog in jit_subprogs error path Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 082/101] net/nfc: Avoid stalls when nfc_alloc_send_skb() returned NULL Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 083/101] ipvs: initialize tbl->entries after allocation Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 084/101] ipvs: initialize tbl->entries in ip_vs_lblc_init_svc() Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 085/101] arm/arm64: smccc: Add SMCCC-specific return codes Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 086/101] arm64: Call ARCH_WORKAROUND_2 on transitions between EL0 and EL1 Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 087/101] arm64: Add per-cpu infrastructure to call ARCH_WORKAROUND_2 Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 088/101] arm64: Add ARCH_WORKAROUND_2 probing Greg Kroah-Hartman
2018-07-20 12:14 ` Greg Kroah-Hartman [this message]
2018-07-20 12:14 ` [PATCH 4.17 090/101] arm64: ssbd: Add global mitigation state accessor Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 091/101] arm64: ssbd: Skip apply_ssbd if not using dynamic mitigation Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 092/101] arm64: ssbd: Restore mitigation status on CPU resume Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 093/101] arm64: ssbd: Introduce thread flag to control userspace mitigation Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 094/101] arm64: ssbd: Add prctl interface for per-thread mitigation Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 095/101] arm64: KVM: Add HYP per-cpu accessors Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 096/101] arm64: KVM: Add ARCH_WORKAROUND_2 support for guests Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 097/101] arm64: KVM: Handle guests ARCH_WORKAROUND_2 requests Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 098/101] arm64: KVM: Add ARCH_WORKAROUND_2 discovery through ARCH_FEATURES_FUNC_ID Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 099/101] bpf: enforce correct alignment for instructions Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 100/101] bpf, arm32: fix to use bpf_jit_binary_lock_ro api Greg Kroah-Hartman
2018-07-20 12:14 ` [PATCH 4.17 101/101] bpf: undo prog rejection on read-only lock failure Greg Kroah-Hartman
2018-07-21 7:54 ` [PATCH 4.17 000/101] 4.17.9-stable review Naresh Kamboju
2018-07-22 11:42 ` Greg Kroah-Hartman
2018-07-21 13:42 ` 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=20180720121427.014533862@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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).