Skip to content

Commit

Permalink
Merge tag 'LA.UM.9.1.r1-12900.01-SMxxx0.QSSI12.0' of https://git.code…
Browse files Browse the repository at this point in the history
…linaro.org/clo/la/kernel/msm-4.14 into a12/flop-stable

"LA.UM.9.1.r1-12900.01-SMxxx0.QSSI12.0"

* tag 'LA.UM.9.1.r1-12900.01-SMxxx0.QSSI12.0' of https://git.codelinaro.org/clo/la/kernel/msm-4.14: (99 commits)
  msm: vidc: fix cts failure issues
  Revert "Revert "msm: vidc: fix msm_comm_get_vidc_buffer fd race issue""
  ANDROID: selinux: modify RTM_GETNEIGH{TBL}
  msm: nfc: maxim nfc defconfig
  msm: nfc: maxim nfc dtsi
  msm: ais: eeprom: Add OOB read check for eeprom memory map
  ANDROID: selinux: modify RTM_GETNEIGH{TBL}
  msm: nfc: maxim nfc driver
  arm64: Use the clearbhb instruction in mitigations
  arm64: add ID_AA64ISAR2_EL1 sys register
  KVM: arm64: Allow SMCCC_ARCH_WORKAROUND_3 to be discovered and migrated
  arm64: Mitigate spectre style branch history side channels
  KVM: arm64: Add templates for BHB mitigation sequences
  arm64: proton-pack: Report Spectre-BHB vulnerabilities as part of Spectre-v2
  arm64: Add percpu vectors for EL1
  arm64: entry: Add macro for reading symbol addresses from the trampoline
  arm64: entry: Add vectors that have the bhb mitigation sequences
  Revert "msm: vidc: fix msm_comm_get_vidc_buffer fd race issue"
  msm: ADSPRPC: Restrict untrusted applications from attaching to GuestOS
  msm: kgsl: Fix gpuaddr_in_range() to check upper bound
  ...

Signed-off-by: Joel Gómez <[email protected]>
  • Loading branch information
Flopster101 committed Dec 3, 2022
2 parents 337d3fd + 6391402 commit 59082ca
Show file tree
Hide file tree
Showing 19 changed files with 1,106 additions and 59 deletions.
1 change: 0 additions & 1 deletion arch/arm/configs/vendor/sdm429-bg-perf_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ CONFIG_QPNP_MISC=y
CONFIG_MD=y
CONFIG_BLK_DEV_DM=y
CONFIG_DM_CRYPT=y
CONFIG_DM_DEFAULT_KEY=y
CONFIG_DM_UEVENT=y
CONFIG_DM_VERITY=y
CONFIG_DM_VERITY_FEC=y
Expand Down
1 change: 0 additions & 1 deletion arch/arm/configs/vendor/sdm429-bg_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ CONFIG_QPNP_MISC=y
CONFIG_MD=y
CONFIG_BLK_DEV_DM=y
CONFIG_DM_CRYPT=y
CONFIG_DM_DEFAULT_KEY=y
CONFIG_DM_UEVENT=y
CONFIG_DM_VERITY=y
CONFIG_DM_VERITY_FEC=y
Expand Down
10 changes: 10 additions & 0 deletions arch/arm64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,16 @@ config ARM64_TAGGED_ADDR_ABI
to system calls as pointer arguments. For details, see
Documentation/arm64/tagged-address-abi.rst.

config MITIGATE_SPECTRE_BRANCH_HISTORY
bool "Mitigate Spectre style attacks against branch history" if EXPERT
default y
depends on HARDEN_BRANCH_PREDICTOR || !KVM
help
Speculation attacks against some high-performance processors can
make use of branch history to influence future speculation.
When taking an exception from user-space, a sequence of branches
or a firmware call overwrites the branch history.

menuconfig ARMV8_DEPRECATED
bool "Emulate deprecated/obsolete ARMv8 instructions"
depends on COMPAT
Expand Down
40 changes: 40 additions & 0 deletions arch/arm64/boot/dts/qcom/sm8150-sdxprairie-audio-overlay.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/

&soc {
quat_mi2s_gpios: quat_mi2s_pinctrl {
compatible = "qcom,msm-cdc-pinctrl";
pinctrl-names = "aud_active", "aud_sleep";
pinctrl-0 = <&quat_mi2s_active
&quat_mi2s_sd0_active &quat_mi2s_sd1_active>;
pinctrl-1 = <&quat_mi2s_sleep
&quat_mi2s_sd0_sleep &quat_mi2s_sd1_sleep>;
};

audio_slimslave {
compatible = "qcom,audio-slimslave";
elemental-addr = [00 01 50 02 17 02];
};
};

&snd_934x {
compatible = "qcom,sm8150-asoc-snd-hana55";
qcom,model = "sm8150-hana55-snd-card";

qcom,quat-mi2s-gpios = <&quat_mi2s_gpios>;
};

&dai_mi2s3 {
qcom,msm-mi2s-rx-lines = <2>;
qcom,msm-mi2s-tx-lines = <1>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "sdx5xm-external-soc.dtsi"
#include "sm8150-sdxprairie-v2.dtsi"
#include "sm8150-mtp-audio-overlay.dtsi"
#include "sm8150-sdxprairie-audio-overlay.dtsi"

/ {
model = "SDXPRAIRIE V3 MTP";
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/configs/vendor/trinket-perf_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ CONFIG_CFG80211_INTERNAL_REGDB=y
# CONFIG_CFG80211_CRDA_SUPPORT is not set
CONFIG_RFKILL=y
CONFIG_NFC_NQ=y
CONFIG_NFC_MAX32560=y
CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
CONFIG_REGMAP_WCD_IRQ=y
CONFIG_REGMAP_ALLOW_WRITE_DEBUGFS=y
Expand Down
1 change: 1 addition & 0 deletions arch/arm64/configs/vendor/trinket_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ CONFIG_CFG80211_INTERNAL_REGDB=y
# CONFIG_CFG80211_CRDA_SUPPORT is not set
CONFIG_RFKILL=y
CONFIG_NFC_NQ=y
CONFIG_NFC_MAX32560=y
CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
CONFIG_REGMAP_WCD_IRQ=y
CONFIG_REGMAP_ALLOW_WRITE_DEBUGFS=y
Expand Down
49 changes: 26 additions & 23 deletions arch/arm64/kernel/cpu_errata.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,28 +284,6 @@ static int __init ssbd_cfg(char *buf)
}
early_param("ssbd", ssbd_cfg);

void __init arm64_update_smccc_conduit(struct alt_instr *alt,
__le32 *origptr, __le32 *updptr,
int nr_inst)
{
u32 insn;

BUG_ON(nr_inst != 1);

switch (psci_ops.conduit) {
case PSCI_CONDUIT_HVC:
insn = aarch64_insn_get_hvc_value();
break;
case PSCI_CONDUIT_SMC:
insn = aarch64_insn_get_smc_value();
break;
default:
return;
}

*updptr = cpu_to_le32(insn);
}

void arm64_set_ssbd_mitigation(bool state)
{
if (!IS_ENABLED(CONFIG_ARM64_SSBD)) {
Expand Down Expand Up @@ -336,6 +314,31 @@ void arm64_set_ssbd_mitigation(bool state)
}
}

#if defined(CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY) || \
defined(CONFIG_ARM64_SSBD)
void __init arm64_update_smccc_conduit(struct alt_instr *alt,
__le32 *origptr, __le32 *updptr,
int nr_inst)
{
u32 insn;

BUG_ON(nr_inst != 1);

switch (psci_ops.conduit) {
case PSCI_CONDUIT_HVC:
insn = aarch64_insn_get_hvc_value();
break;
case PSCI_CONDUIT_SMC:
insn = aarch64_insn_get_smc_value();
break;
default:
return;
}

*updptr = cpu_to_le32(insn);
}
#endif /* CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY || CONFIG_ARM64_SSBD */

static bool has_ssbd_mitigation(const struct arm64_cpu_capabilities *entry,
int scope)
{
Expand Down Expand Up @@ -1180,4 +1183,4 @@ void __init spectre_bhb_patch_loop_iter(struct alt_instr *alt,
AARCH64_INSN_VARIANT_64BIT,
AARCH64_INSN_MOVEWIDE_ZERO);
*updptr++ = cpu_to_le32(insn);
}
}
88 changes: 70 additions & 18 deletions arch/arm64/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
.macro kernel_ventry, el, label, regsize = 64
.align 7
.Lventry_start\@:
#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
.if \el == 0
/*
* This must be the first instruction of the EL0 vector entries. It is
Expand All @@ -90,7 +89,6 @@
.endif
.Lskip_tramp_vectors_cleanup\@:
.endif
#endif

sub sp, sp, #S_FRAME_SIZE
#ifdef CONFIG_VMAP_STACK
Expand Down Expand Up @@ -161,6 +159,9 @@
tbnz \tmp2, #TIF_SSBD, \targ
mov w0, #ARM_SMCCC_ARCH_WORKAROUND_2
mov w1, #\state
alternative_cb arm64_update_smccc_conduit
nop // Patched to SMC/HVC #0
alternative_cb_end
smc #0
#endif
.endm
Expand Down Expand Up @@ -1066,13 +1067,41 @@ alternative_else_nop_endif
sub \dst, \dst, PAGE_SIZE
.endm

.macro tramp_ventry, vector_start, regsize, kpti
.macro tramp_data_read_var dst, var
#ifdef CONFIG_RANDOMIZE_BASE
tramp_data_page \dst
add \dst, \dst, #:lo12:__entry_tramp_data_\var
ldr \dst, [\dst]
#else
ldr \dst, =\var
#endif
.endm

#define BHB_MITIGATION_NONE 0
#define BHB_MITIGATION_LOOP 1
#define BHB_MITIGATION_FW 2
#define BHB_MITIGATION_INSN 3

.macro tramp_ventry, vector_start, regsize, kpti, bhb
.align 7
1:
.if \regsize == 64
msr tpidrro_el0, x30 // Restored in kernel_ventry
.endif

.if \bhb == BHB_MITIGATION_LOOP
/*
* This sequence must appear before the first indirect branch. i.e. the
* ret out of tramp_ventry. It appears here because x30 is free.
*/
__mitigate_spectre_bhb_loop x30
.endif // \bhb == BHB_MITIGATION_LOOP

.if \bhb == BHB_MITIGATION_INSN
clearbhb
isb
.endif // \bhb == BHB_MITIGATION_INSN

.if \kpti == 1
/*
* Defend against branch aliasing attacks by pushing a dummy
Expand All @@ -1083,27 +1112,38 @@ alternative_else_nop_endif
b .
2:
tramp_map_kernel x30
#ifdef CONFIG_RANDOMIZE_BASE
tramp_data_page x30
alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003
ldr x30, [x30]
#else
ldr x30, =vectors
#endif
tramp_data_read_var x30, vectors
prfm plil1strm, [x30, #(1b - \vector_start)]
msr vbar_el1, x30
isb
.else
ldr x30, =vectors
.endif // \kpti == 1

.if \bhb == BHB_MITIGATION_FW
/*
* The firmware sequence must appear before the first indirect branch.
* i.e. the ret out of tramp_ventry. But it also needs the stack to be
* mapped to save/restore the registers the SMC clobbers.
*/
__mitigate_spectre_bhb_fw
.endif // \bhb == BHB_MITIGATION_FW

add x30, x30, #(1b - \vector_start + 4)
ret
.org 1b + 128 // Did we overflow the ventry slot?
.endm

.macro tramp_exit, regsize = 64
adr x30, tramp_vectors
tramp_data_read_var x30, this_cpu_vector
alternative_if_not ARM64_HAS_VIRT_HOST_EXTN
mrs x29, tpidr_el1
alternative_else
mrs x29, tpidr_el2
alternative_endif
ldr x30, [x30, x29]

msr vbar_el1, x30
ldr lr, [sp, #S_LR]
tramp_unmap_kernel x29
Expand All @@ -1114,26 +1154,33 @@ alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003
eret
.endm

.macro generate_tramp_vector, kpti
.macro generate_tramp_vector, kpti, bhb
.Lvector_start\@:
.space 0x400

.rept 4
tramp_ventry .Lvector_start\@, 64, \kpti
tramp_ventry .Lvector_start\@, 64, \kpti, \bhb
.endr
.rept 4
tramp_ventry .Lvector_start\@, 32, \kpti
tramp_ventry .Lvector_start\@, 32, \kpti, \bhb
.endr
.endm

#ifdef CONFIG_UNMAP_KERNEL_AT_EL0
/*
* Exception vectors trampoline.
* The order must match __bp_harden_el1_vectors and the
* arm64_bp_harden_el1_vectors enum.
*/
.pushsection ".entry.tramp.text", "ax"
.align 11
ENTRY(tramp_vectors)
generate_tramp_vector kpti=1
#ifdef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY
generate_tramp_vector kpti=1, bhb=BHB_MITIGATION_LOOP
generate_tramp_vector kpti=1, bhb=BHB_MITIGATION_FW
generate_tramp_vector kpti=1, bhb=BHB_MITIGATION_INSN
#endif /* CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY */
generate_tramp_vector kpti=1, bhb=BHB_MITIGATION_NONE
END(tramp_vectors)

ENTRY(tramp_exit_native)
Expand Down Expand Up @@ -1167,7 +1214,7 @@ __entry_tramp_data_this_cpu_vector:
* Exception vectors for spectre mitigations on entry from EL1 when
* kpti is not in use.
*/
.macro generate_el1_vector
.macro generate_el1_vector, bhb
.Lvector_start\@:
kernel_ventry 1, sync_invalid // Synchronous EL1t
kernel_ventry 1, irq_invalid // IRQ EL1t
Expand All @@ -1180,17 +1227,22 @@ __entry_tramp_data_this_cpu_vector:
kernel_ventry 1, error_invalid // Error EL1h

.rept 4
tramp_ventry .Lvector_start\@, 64, kpti=0
tramp_ventry .Lvector_start\@, 64, 0, \bhb
.endr
.rept 4
tramp_ventry .Lvector_start\@, 32, kpti=0
tramp_ventry .Lvector_start\@, 32, 0, \bhb
.endr
.endm

/* The order must match tramp_vecs and the arm64_bp_harden_el1_vectors enum. */
.pushsection ".entry.text", "ax"
.align 11
ENTRY(__bp_harden_el1_vectors)
generate_el1_vector
#ifdef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY
generate_el1_vector bhb=BHB_MITIGATION_LOOP
generate_el1_vector bhb=BHB_MITIGATION_FW
generate_el1_vector bhb=BHB_MITIGATION_INSN
#endif /* CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY */
END(__bp_harden_el1_vectors)
.popsection

Expand Down
Loading

0 comments on commit 59082ca

Please sign in to comment.