]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
arm64: ssbd: Skip apply_ssbd if not using dynamic mitigation
authorMarc Zyngier <marc.zyngier@arm.com>
Fri, 20 Jul 2018 09:53:05 +0000 (10:53 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 5 Sep 2018 12:53:31 +0000 (14:53 +0200)
BugLink: https://bugs.launchpad.net/bugs/1787993
CVE-2018-3639 (arm64)

commit 986372c4367f46b34a3c0f6918d7fb95cbdf39d6 upstream.

In order to avoid checking arm64_ssbd_callback_required on each
kernel entry/exit even if no mitigation is required, let's
add yet another alternative that by default jumps over the mitigation,
and that gets nop'ed out if we're doing dynamic mitigation.

Think of it as a poor man's static key...

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: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 02e26bd9ad58197533a7d5fcd62f975891a9e936
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git /
linux-4.14.y)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
arch/arm64/kernel/cpu_errata.c
arch/arm64/kernel/entry.S

index b3df8e5986e03b8b69883de4a78db1be22d42139..012dab9d9a010c64ac7051038a4b3841ce632aaa 100644 (file)
@@ -285,6 +285,20 @@ void __init arm64_update_smccc_conduit(struct alt_instr *alt,
        *updptr = cpu_to_le32(insn);
 }
 
+void __init arm64_enable_wa2_handling(struct alt_instr *alt,
+                                     __le32 *origptr, __le32 *updptr,
+                                     int nr_inst)
+{
+       BUG_ON(nr_inst != 1);
+       /*
+        * Only allow mitigation on EL1 entry/exit and guest
+        * ARCH_WORKAROUND_2 handling if the SSBD state allows it to
+        * be flipped.
+        */
+       if (arm64_get_ssbd_state() == ARM64_SSBD_KERNEL)
+               *updptr = cpu_to_le32(aarch64_insn_gen_nop());
+}
+
 static void arm64_set_ssbd_mitigation(bool state)
 {
        switch (psci_ops.conduit) {
index d0eb6fb61f2811b487e3b557dc26ce877d8f6d34..8bcc6a5eb8318455e98d46d0692a42ca66a00f4c 100644 (file)
@@ -142,6 +142,9 @@ alternative_else_nop_endif
        // to save/restore them if required.
        .macro  apply_ssbd, state, targ, tmp1, tmp2
 #ifdef CONFIG_ARM64_SSBD
+alternative_cb arm64_enable_wa2_handling
+       b       \targ
+alternative_cb_end
        ldr_this_cpu    \tmp2, arm64_ssbd_callback_required, \tmp1
        cbz     \tmp2, \targ
        mov     w0, #ARM_SMCCC_ARCH_WORKAROUND_2