5.4.186-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainercover 5.4.186-rc1 review
This is the start of the stable review cycle for the 5.4.186 release. There are 43 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 19 Mar 2022 12:45:16 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.186-rc1.gz
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-5.4.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <[email protected]>
Linux 5.4.186-rc1
Chengming Zhou <[email protected]>
kselftest/vm: fix tests build with old libc
Christophe JAILLET <[email protected]>
bnx2: Fix an error message
Niels Dossche <[email protected]>
sfc: extend the locking on mcdi->seqno
Eric Dumazet <[email protected]>
tcp: make tcp_read_sock() more robust
Sreeramya Soratkal <[email protected]>
nl80211: Update bss channel on channel switch for P2P_CLIENT
Manasi Navare <[email protected]>
drm/vrr: Set VRR capable prop only if it is attached to connector
Golan Ben Ami <[email protected]>
iwlwifi: don't advertise TWT support
Jia-Ju Bai <[email protected]>
atm: firestream: check the return value of ioremap() in fs_init()
Lad Prabhakar <[email protected]>
can: rcar_canfd: rcar_canfd_channel_probe(): register the CAN device when fully ready
Julian Braha <[email protected]>
ARM: 9178/1: fix unmet dependency on BITREVERSE for HAVE_ARCH_BITREVERSE
Alexander Lobakin <[email protected]>
MIPS: smp: fill in sibling and core maps earlier
Johannes Berg <[email protected]>
mac80211: refuse aggregations sessions before authorized
Corentin Labbe <[email protected]>
ARM: dts: rockchip: fix a typo on rk3288 crypto-controller
Sascha Hauer <[email protected]>
ARM: dts: rockchip: reorder rk322x hmdi clocks
Dinh Nguyen <[email protected]>
arm64: dts: agilex: use the compatible "intel,socfpga-agilex-hsotg"
Sascha Hauer <[email protected]>
arm64: dts: rockchip: reorder rk3399 hdmi clocks
Jakob Unterwurzacher <[email protected]>
arm64: dts: rockchip: fix rk3399-puma eMMC HS400 signal integrity
Yan Yan <[email protected]>
xfrm: Fix xfrm migrate issues when address family changes
Yan Yan <[email protected]>
xfrm: Check if_id in xfrm_migrate
James Morse <[email protected]>
arm64: Use the clearbhb instruction in mitigations
James Morse <[email protected]>
KVM: arm64: Allow SMCCC_ARCH_WORKAROUND_3 to be discovered and migrated
James Morse <[email protected]>
arm64: Mitigate spectre style branch history side channels
James Morse <[email protected]>
KVM: arm64: Add templates for BHB mitigation sequences
James Morse <[email protected]>
arm64: proton-pack: Report Spectre-BHB vulnerabilities as part of Spectre-v2
James Morse <[email protected]>
arm64: Add percpu vectors for EL1
James Morse <[email protected]>
arm64: entry: Add macro for reading symbol addresses from the trampoline
James Morse <[email protected]>
arm64: entry: Add vectors that have the bhb mitigation sequences
James Morse <[email protected]>
arm64: entry: Add non-kpti __bp_harden_el1_vectors for mitigations
James Morse <[email protected]>
arm64: entry: Allow the trampoline text to occupy multiple pages
James Morse <[email protected]>
arm64: entry: Make the kpti trampoline's kpti sequence optional
James Morse <[email protected]>
arm64: entry: Move trampoline macros out of ifdef'd section
James Morse <[email protected]>
arm64: entry: Don't assume tramp_vectors is the start of the vectors
James Morse <[email protected]>
arm64: entry: Allow tramp_alias to access symbols after the 4K boundary
James Morse <[email protected]>
arm64: entry: Move the trampoline data page before the text page
James Morse <[email protected]>
arm64: entry: Free up another register on kpti's tramp_exit path
James Morse <[email protected]>
arm64: entry: Make the trampoline cleanup optional
James Morse <[email protected]>
arm64: entry.S: Add ventry overflow sanity checks
Anshuman Khandual <[email protected]>
arm64: Add Cortex-X2 CPU part definition
Joey Gouly <[email protected]>
arm64: add ID_AA64ISAR2_EL1 sys register
Suzuki K Poulose <[email protected]>
arm64: Add Neoverse-N2, Cortex-A710 CPU part definition
Rob Herring <[email protected]>
arm64: Add part number for Arm Cortex-A77
Xin Long <[email protected]>
sctp: fix the processing for INIT chunk
Kai Lueke <[email protected]>
Revert "xfrm: state and policy should fail if XFRMA_IF_ID 0"
-------------
Diffstat:
Makefile | 4 +- arch/arm/boot/dts/rk322x.dtsi | 4 +- arch/arm/boot/dts/rk3288.dtsi | 2 +- arch/arm/include/asm/kvm_host.h | 7 + arch/arm/include/uapi/asm/kvm.h | 6 + arch/arm64/Kconfig | 9 + arch/arm64/boot/dts/intel/socfpga_agilex.dtsi | 4 +- arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi | 6 + arch/arm64/boot/dts/rockchip/rk3399.dtsi | 6 +- arch/arm64/include/asm/assembler.h | 33 ++ arch/arm64/include/asm/cpu.h | 1 + arch/arm64/include/asm/cpucaps.h | 3 +- arch/arm64/include/asm/cpufeature.h | 40 +++ arch/arm64/include/asm/cputype.h | 16 + arch/arm64/include/asm/fixmap.h | 6 +- arch/arm64/include/asm/kvm_host.h | 5 + arch/arm64/include/asm/kvm_mmu.h | 6 +- arch/arm64/include/asm/mmu.h | 8 +- arch/arm64/include/asm/sections.h | 5 + arch/arm64/include/asm/sysreg.h | 17 + arch/arm64/include/asm/vectors.h | 73 ++++ arch/arm64/include/uapi/asm/kvm.h | 5 + arch/arm64/kernel/cpu_errata.c | 385 ++++++++++++++++++++- arch/arm64/kernel/cpufeature.c | 21 ++ arch/arm64/kernel/cpuinfo.c | 1 + arch/arm64/kernel/entry.S | 213 +++++++++--- arch/arm64/kernel/vmlinux.lds.S | 2 +- arch/arm64/kvm/hyp/hyp-entry.S | 64 ++++ arch/arm64/kvm/hyp/switch.c | 8 +- arch/arm64/kvm/sys_regs.c | 2 +- arch/arm64/mm/mmu.c | 12 +- arch/mips/kernel/smp.c | 6 +- drivers/atm/firestream.c | 2 + drivers/gpu/drm/drm_connector.c | 3 + drivers/net/can/rcar/rcar_canfd.c | 6 +- drivers/net/ethernet/broadcom/bnx2.c | 2 +- drivers/net/ethernet/sfc/mcdi.c | 2 +- drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c | 3 +- drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 1 - include/linux/arm-smccc.h | 5 + include/net/xfrm.h | 5 +- lib/Kconfig | 1 - net/ipv4/tcp.c | 10 +- net/key/af_key.c | 2 +- net/mac80211/agg-tx.c | 10 +- net/sctp/sm_statefuns.c | 71 ++-- net/wireless/nl80211.c | 3 +- net/xfrm/xfrm_policy.c | 14 +- net/xfrm/xfrm_state.c | 15 +- net/xfrm/xfrm_user.c | 27 +- tools/testing/selftests/vm/userfaultfd.c | 1 + virt/kvm/arm/psci.c | 34 +- 52 files changed, 1037 insertions(+), 160 deletions(-)
Greg Kroah-Hartman
maintainerPATCH 1/43 Revert "xfrm: state and policy should fail if XFRMA_IF_ID 0"
From: Kai Lueke <[email protected]>
commit a3d9001b4e287fc043e5539d03d71a32ab114bcb upstream.
This reverts commit 68ac0f3810e76a853b5f7b90601a05c3048b8b54 because ID 0 was meant to be used for configuring the policy/state without matching for a specific interface (e.g., Cilium is affected, see
https://github.com/cilium/cilium/pull/18789 and
https://github.com/cilium/cilium/pull/19019).
--- net/xfrm/xfrm_user.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-)
net/xfrm/xfrm_user.c +3 -18
@@ -621,13 +621,8 @@ static struct xfrm_state *xfrm_state_conxfrm_smark_init (attrs, &x->props.smark); -if (attrs[XFRMA_IF_ID ]) { +if (attrs[XFRMA_IF_ID ]) x->if_id =nla_get_u32 (attrs[XFRMA_IF_ID ]); -if (!x->if_id) { - err = -EINVAL ; - goto error; - } - } err =__xfrm_init_state (x, false, attrs[XFRMA_OFFLOAD_DEV ]);if (err)
@@ -1333,13 +1328,8 @@ static int xfrm_alloc_userspi(struct sk_ mark =xfrm_mark_get (attrs, &m); -if (attrs[XFRMA_IF_ID ]) { +if (attrs[XFRMA_IF_ID ]) if_id =nla_get_u32 (attrs[XFRMA_IF_ID ]); -if (!if_id) { - err = -EINVAL ; - goto out_noput; - } - }if (p->info.seq) { x =xfrm_find_acq_byseq (net, mark, p->info.seq);
@@ -1641,13 +1631,8 @@ static struct xfrm_policy *xfrm_policy_cxfrm_mark_get (attrs, &xp->mark); -if (attrs[XFRMA_IF_ID ]) { +if (attrs[XFRMA_IF_ID ]) xp->if_id =nla_get_u32 (attrs[XFRMA_IF_ID ]); -if (!xp->if_id) { - err = -EINVAL ; - goto error; - } - }return xp; error:
Greg Kroah-Hartman
maintainerPATCH 2/43 sctp: fix the processing for INIT chunk
In reply to Greg Kroah-HartmanFrom: Xin Long <[email protected]>
commit eae5783908042a762c24e1bd11876edb91d314b1 upstream.
This patch fixes the problems below:
1. In non-shutdown_ack_sent states: in sctp_sf_do_5_1B_init() and sctp_sf_do_5_2_2_dupinit():
chunk length check should be done before any checks that may cause to send abort, as making packet for abort will access the init_tag from init_hdr in sctp_ootb_pkt_new().
2. In shutdown_ack_sent state: in sctp_sf_do_9_2_reshutack():
The same checks as does in sctp_sf_do_5_2_2_dupinit() is needed for sctp_sf_do_9_2_reshutack().
--- net/sctp/sm_statefuns.c | 71 +++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 25 deletions(-)
net/sctp/sm_statefuns.c +46 -25
@@ -149,6 +149,12 @@ static enum sctp_disposition __sctp_sf_dvoid *arg, struct sctp_cmd_seq *commands); +static enum sctp_disposition +__sctp_sf_do_9_2_reshutack (struct net *net,const struct sctp_endpoint *ep, +const struct sctp_association *asoc, +const union sctp_subtype type,void *arg, +struct sctp_cmd_seq *commands); +/* Small helper function that checks if the chunk length * is of the appropriate length. The 'required_length' argument * is set to be the size of a specific chunk we are testing.
@@ -330,6 +336,14 @@ enum sctp_disposition sctp_sf_do_5_1B_inif (!chunk->singleton)return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands); +/* Make sure that the INIT chunk has a valid length. +* Normally, this would cause an ABORT with a Protocol Violation +* error, but since we don't have an association, we'll +* just discard the packet. +*/ +if (!sctp_chunk_length_valid (chunk,sizeof (struct sctp_init_chunk ))) +return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands); +/* If the packet is an OOTB packet which is temporarily on the * control endpoint, respond with an ABORT. */
@@ -344,14 +358,6 @@ enum sctp_disposition sctp_sf_do_5_1B_inif (chunk->sctp_hdr->vtag !=0 )return sctp_sf_tabort_8_4_8 (net, ep, asoc, type, arg, commands); -/* Make sure that the INIT chunk has a valid length. -* Normally, this would cause an ABORT with a Protocol Violation -* error, but since we don't have an association, we'll -* just discard the packet. -*/ -if (!sctp_chunk_length_valid (chunk,sizeof (struct sctp_init_chunk ))) -return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands); -/* If the INIT is coming toward a closing socket, we'll send back * and ABORT. Essentially, this catches the race of INIT being * backloged to the socket at the same time as the user isses close().
@@ -1484,19 +1490,16 @@ static enum sctp_disposition sctp_sf_do_if (!chunk->singleton)return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands); +/* Make sure that the INIT chunk has a valid length. */ +if (!sctp_chunk_length_valid (chunk,sizeof (struct sctp_init_chunk ))) +return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands); +/* 3.1 A packet containing an INIT chunk MUST have a zero Verification * Tag. */ if (chunk->sctp_hdr->vtag !=0 )return sctp_sf_tabort_8_4_8 (net, ep, asoc, type, arg, commands); -/* Make sure that the INIT chunk has a valid length. -* In this case, we generate a protocol violation since we have -* an association established. -*/ -if (!sctp_chunk_length_valid (chunk,sizeof (struct sctp_init_chunk ))) -return sctp_sf_violation_chunklen (net, ep, asoc, type, arg, - commands);/* Grab the INIT header. */ chunk->subh.init_hdr = (struct sctp_inithdr *)chunk->skb->data;
@@ -1814,9 +1817,9 @@ static enum sctp_disposition sctp_sf_do_* its peer. */ if (sctp_state (asoc,SHUTDOWN_ACK_SENT )) { - disposition =sctp_sf_do_9_2_reshutack (net, ep, asoc, -SCTP_ST_CHUNK (chunk->chunk_hdr->type), - chunk, commands); + disposition =__sctp_sf_do_9_2_reshutack (net, ep, asoc, +SCTP_ST_CHUNK (chunk->chunk_hdr->type), + chunk, commands);if (SCTP_DISPOSITION_NOMEM == disposition) goto nomem;
@@ -2915,13 +2918,11 @@ enum sctp_disposition sctp_sf_do_9_2_shu* that belong to this association, it should discard the INIT chunk and * retransmit the SHUTDOWN ACK chunk. */ -enum sctp_disposition sctp_sf_do_9_2_reshutack ( -struct net *net, -const struct sctp_endpoint *ep, -const struct sctp_association *asoc, -const union sctp_subtype type, -void *arg, -struct sctp_cmd_seq *commands) +static enum sctp_disposition +__sctp_sf_do_9_2_reshutack (struct net *net,const struct sctp_endpoint *ep, +const struct sctp_association *asoc, +const union sctp_subtype type,void *arg, +struct sctp_cmd_seq *commands) {struct sctp_chunk *chunk = arg;struct sctp_chunk *reply;
@@ -2955,6 +2956,26 @@ nomem:return SCTP_DISPOSITION_NOMEM ; } +enum sctp_disposition +sctp_sf_do_9_2_reshutack (struct net *net,const struct sctp_endpoint *ep, +const struct sctp_association *asoc, +const union sctp_subtype type,void *arg, +struct sctp_cmd_seq *commands) +{ +struct sctp_chunk *chunk = arg; + +if (!chunk->singleton) +return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands); + +if (!sctp_chunk_length_valid (chunk,sizeof (struct sctp_init_chunk ))) +return sctp_sf_pdiscard (net, ep, asoc, type, arg, commands); + +if (chunk->sctp_hdr->vtag !=0 ) +return sctp_sf_tabort_8_4_8 (net, ep, asoc, type, arg, commands); + +return __sctp_sf_do_9_2_reshutack (net, ep, asoc, type, arg, commands); +} +/* * sctp_sf_do_ecn_cwr *
Greg Kroah-Hartman
maintainerPATCH 3/43 arm64: Add part number for Arm Cortex-A77
In reply to Greg Kroah-HartmanFrom: Rob Herring <[email protected]>
commit 8a6b88e66233f5f1779b0a1342aa9dc030dddcd5 upstream.
Add the MIDR part number info for the Arm Cortex-A77.
--- arch/arm64/include/asm/cputype.h | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/include/asm/cputype.h +2 -0
@@ -71,6 +71,7 @@#define ARM_CPU_PART_CORTEX_A55 0xD05#define ARM_CPU_PART_CORTEX_A76 0xD0B#define ARM_CPU_PART_NEOVERSE_N1 0xD0C +#define ARM_CPU_PART_CORTEX_A77 0xD0D#define APM_CPU_PART_POTENZA 0x000
@@ -102,6 +103,7 @@#define MIDR_CORTEX_A55 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A55)#define MIDR_CORTEX_A76 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A76)#define MIDR_NEOVERSE_N1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N1) +#define MIDR_CORTEX_A77 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A77)#define MIDR_THUNDERX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX)#define MIDR_THUNDERX_81XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_81XX)#define MIDR_THUNDERX_83XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_83XX)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 4/43 arm64: Add Neoverse-N2, Cortex-A710 CPU part definition
In reply to Greg Kroah-HartmanFrom: Suzuki K Poulose <[email protected]>
commit 2d0d656700d67239a57afaf617439143d8dac9be upstream.
Add the CPU Partnumbers for the new Arm designs.
--- arch/arm64/include/asm/cputype.h | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/include/asm/cputype.h +4 -0
@@ -72,6 +72,8 @@#define ARM_CPU_PART_CORTEX_A76 0xD0B#define ARM_CPU_PART_NEOVERSE_N1 0xD0C#define ARM_CPU_PART_CORTEX_A77 0xD0D +#define ARM_CPU_PART_CORTEX_A710 0xD47 +#define ARM_CPU_PART_NEOVERSE_N2 0xD49#define APM_CPU_PART_POTENZA 0x000
@@ -104,6 +106,8 @@#define MIDR_CORTEX_A76 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A76)#define MIDR_NEOVERSE_N1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N1)#define MIDR_CORTEX_A77 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A77) +#define MIDR_CORTEX_A710 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A710) +#define MIDR_NEOVERSE_N2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N2)#define MIDR_THUNDERX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX)#define MIDR_THUNDERX_81XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_81XX)#define MIDR_THUNDERX_83XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_83XX)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 5/43 arm64: add ID_AA64ISAR2_EL1 sys register
In reply to Greg Kroah-HartmanFrom: Joey Gouly <[email protected]>
commit 9e45365f1469ef2b934f9d035975dbc9ad352116 upstream.
This is a new ID register, introduced in 8.7.
--- arch/arm64/include/asm/cpu.h | 1 + arch/arm64/include/asm/sysreg.h | 15 +++++++++++++++ arch/arm64/kernel/cpufeature.c | 9 +++++++++ arch/arm64/kernel/cpuinfo.c | 1 + arch/arm64/kvm/sys_regs.c | 2 +- 5 files changed, 27 insertions(+), 1 deletion(-)
arch/arm64/include/asm/cpu.h +1 -0
@@ -25,6 +25,7 @@ struct cpuinfo_arm64 {u64 reg_id_aa64dfr1;u64 reg_id_aa64isar0;u64 reg_id_aa64isar1; +u64 reg_id_aa64isar2;u64 reg_id_aa64mmfr0;u64 reg_id_aa64mmfr1;u64 reg_id_aa64mmfr2;
arch/arm64/include/asm/sysreg.h +15 -0
@@ -165,6 +165,7 @@#define SYS_ID_AA64ISAR0_EL1 sys_reg(3, 0, 0, 6, 0)#define SYS_ID_AA64ISAR1_EL1 sys_reg(3, 0, 0, 6, 1) +#define SYS_ID_AA64ISAR2_EL1 sys_reg(3, 0, 0, 6, 2)#define SYS_ID_AA64MMFR0_EL1 sys_reg(3, 0, 0, 7, 0)#define SYS_ID_AA64MMFR1_EL1 sys_reg(3, 0, 0, 7, 1)
@@ -575,6 +576,20 @@#define ID_AA64ISAR1_GPI_NI 0x0#define ID_AA64ISAR1_GPI_IMP_DEF 0x1 +/* id_aa64isar2 */ +#define ID_AA64ISAR2_RPRES_SHIFT 4 +#define ID_AA64ISAR2_WFXT_SHIFT 0 + +#define ID_AA64ISAR2_RPRES_8BIT 0x0 +#define ID_AA64ISAR2_RPRES_12BIT 0x1 +/* +* Value 0x1 has been removed from the architecture, and is +* reserved, but has not yet been removed from the ARM ARM +* as of ARM DDI 0487G.b. +*/ +#define ID_AA64ISAR2_WFXT_NI 0x0 +#define ID_AA64ISAR2_WFXT_SUPPORTED 0x2 +/* id_aa64pfr0 */ #define ID_AA64PFR0_CSV3_SHIFT 60#define ID_AA64PFR0_CSV2_SHIFT 56
arch/arm64/kernel/cpufeature.c +9 -0
@@ -150,6 +150,10 @@ static const struct arm64_ftr_bits ftr_id_aa64isar1[] = { ARM64_FTR_END, }; +static const struct arm64_ftr_bits ftr_id_aa64isar2[] = { +ARM64_FTR_END , +}; +static const struct arm64_ftr_bits ftr_id_aa64pfr0[] = {ARM64_FTR_BITS (FTR_HIDDEN ,FTR_NONSTRICT ,FTR_LOWER_SAFE ,ID_AA64PFR0_CSV3_SHIFT ,4 ,0 ),ARM64_FTR_BITS (FTR_HIDDEN ,FTR_NONSTRICT ,FTR_LOWER_SAFE ,ID_AA64PFR0_CSV2_SHIFT ,4 ,0 ),
@@ -410,6 +414,7 @@ static const struct __ftr_reg_entry {/* Op1 = 0, CRn = 0, CRm = 6 */ ARM64_FTR_REG (SYS_ID_AA64ISAR0_EL1 , ftr_id_aa64isar0),ARM64_FTR_REG (SYS_ID_AA64ISAR1_EL1 , ftr_id_aa64isar1), +ARM64_FTR_REG (SYS_ID_AA64ISAR2_EL1 , ftr_id_aa64isar2),/* Op1 = 0, CRn = 0, CRm = 7 */ ARM64_FTR_REG(SYS_ID_AA64MMFR0_EL1, ftr_id_aa64mmfr0),
@@ -581,6 +586,7 @@ void __init init_cpu_features(struct cpuinfo_arm64 *info)init_cpu_ftr_reg (SYS_ID_AA64DFR1_EL1 , info->reg_id_aa64dfr1);init_cpu_ftr_reg (SYS_ID_AA64ISAR0_EL1 , info->reg_id_aa64isar0);init_cpu_ftr_reg (SYS_ID_AA64ISAR1_EL1 , info->reg_id_aa64isar1); +init_cpu_ftr_reg (SYS_ID_AA64ISAR2_EL1 , info->reg_id_aa64isar2);init_cpu_ftr_reg (SYS_ID_AA64MMFR0_EL1 , info->reg_id_aa64mmfr0);init_cpu_ftr_reg (SYS_ID_AA64MMFR1_EL1 , info->reg_id_aa64mmfr1);init_cpu_ftr_reg (SYS_ID_AA64MMFR2_EL1 , info->reg_id_aa64mmfr2);
@@ -704,6 +710,8 @@ void update_cpu_features(int cpu, info->reg_id_aa64isar0, boot->reg_id_aa64isar0); taint |=check_update_ftr_reg (SYS_ID_AA64ISAR1_EL1 , cpu, info->reg_id_aa64isar1, boot->reg_id_aa64isar1); + taint |=check_update_ftr_reg (SYS_ID_AA64ISAR2_EL1 , cpu, + info->reg_id_aa64isar2, boot->reg_id_aa64isar2);/* * Differing PARange support is fine as long as all peripherals and
@@ -838,6 +846,7 @@ static u64 __read_sysreg_by_encoding(u32 sys_id)read_sysreg_case (SYS_ID_AA64MMFR2_EL1 );read_sysreg_case (SYS_ID_AA64ISAR0_EL1 );read_sysreg_case (SYS_ID_AA64ISAR1_EL1 ); +read_sysreg_case (SYS_ID_AA64ISAR2_EL1 );read_sysreg_case (SYS_CNTFRQ_EL0 );read_sysreg_case (SYS_CTR_EL0 );
arch/arm64/kernel/cpuinfo.c +1 -0
@@ -344,6 +344,7 @@ static void __cpuinfo_store_cpu(struct cpuinfo_arm64 *info) info->reg_id_aa64dfr1 =read_cpuid (ID_AA64DFR1_EL1 ); info->reg_id_aa64isar0 =read_cpuid (ID_AA64ISAR0_EL1 ); info->reg_id_aa64isar1 =read_cpuid (ID_AA64ISAR1_EL1 ); + info->reg_id_aa64isar2 =read_cpuid (ID_AA64ISAR2_EL1 ); info->reg_id_aa64mmfr0 =read_cpuid (ID_AA64MMFR0_EL1 ); info->reg_id_aa64mmfr1 =read_cpuid (ID_AA64MMFR1_EL1 ); info->reg_id_aa64mmfr2 =read_cpuid (ID_AA64MMFR2_EL1 );
arch/arm64/kvm/sys_regs.c +1 -1
@@ -1454,7 +1454,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {/* CRm=6 */ ID_SANITISED (ID_AA64ISAR0_EL1 ),ID_SANITISED (ID_AA64ISAR1_EL1 ), -ID_UNALLOCATED (6 ,2 ), +ID_SANITISED (ID_AA64ISAR2_EL1 ),ID_UNALLOCATED (6 ,3 ),ID_UNALLOCATED (6 ,4 ), ID_UNALLOCATED(6,5),
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 6/43 arm64: Add Cortex-X2 CPU part definition
In reply to Greg Kroah-HartmanFrom: Anshuman Khandual <[email protected]>
commit 72bb9dcb6c33cfac80282713c2b4f2b254cd24d1 upstream.
Add the CPU Partnumbers for the new Arm designs.
--- arch/arm64/include/asm/cputype.h | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/include/asm/cputype.h +2 -0
@@ -73,6 +73,7 @@#define ARM_CPU_PART_NEOVERSE_N1 0xD0C#define ARM_CPU_PART_CORTEX_A77 0xD0D#define ARM_CPU_PART_CORTEX_A710 0xD47 +#define ARM_CPU_PART_CORTEX_X2 0xD48#define ARM_CPU_PART_NEOVERSE_N2 0xD49#define APM_CPU_PART_POTENZA 0x000
@@ -107,6 +108,7 @@#define MIDR_NEOVERSE_N1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N1)#define MIDR_CORTEX_A77 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A77)#define MIDR_CORTEX_A710 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A710) +#define MIDR_CORTEX_X2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X2)#define MIDR_NEOVERSE_N2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N2)#define MIDR_THUNDERX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX)#define MIDR_THUNDERX_81XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_81XX)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 7/43 arm64: entry.S: Add ventry overflow sanity checks
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit 4330e2c5c04c27bebf89d34e0bc14e6943413067 upstream.
Subsequent patches add even more code to the ventry slots. Ensure kernels that overflow a ventry slot don't get built.
--- arch/arm64/kernel/entry.S | 3 +++ 1 file changed, 3 insertions(+)
arch/arm64/kernel/entry.S +3 -0
@@ -59,6 +59,7 @@ .macro kernel_ventry, el, label, regsize = 64 .align 7 +.Lventry_start\@: #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 alternative_if ARM64_UNMAP_KERNEL_AT_EL0 .if \el == 0
@@ -116,6 +117,7 @@ alternative_else_nop_endif mrs x0, tpidrro_el0 #endif b el\()\el\()_\label +.org .Lventry_start\@ + 128 // Did we overflow the ventry slot? .endm .macro tramp_alias, dst, sym
@@ -1080,6 +1082,7 @@ alternative_else_nop_endif add x30, x30, #(1b - tramp_vectors) isb ret +.org 1b + 128 // Did we overflow the ventry slot? .endm .macro tramp_exit, regsize = 64
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 8/43 arm64: entry: Make the trampoline cleanup optional
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit d739da1694a0eaef0358a42b76904b611539b77b upstream.
Subsequent patches will add additional sets of vectors that use the same tricks as the kpti vectors to reach the full-fat vectors. The full-fat vectors contain some cleanup for kpti that is patched in by alternatives when kpti is in use. Once there are additional vectors, the cleanup will be needed in more cases.
But on big/little systems, the cleanup would be harmful if no trampoline vector were in use. Instead of forcing CPUs that don't need a trampoline vector to use one, make the trampoline cleanup optional.
Entry at the top of the vectors will skip the cleanup. The trampoline vectors can then skip the first instruction, triggering the cleanup to run.
--- arch/arm64/kernel/entry.S | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
arch/arm64/kernel/entry.S +7 -3
@@ -61,16 +61,20 @@ .align 7 .Lventry_start\@: #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 -alternative_if ARM64_UNMAP_KERNEL_AT_EL0 .if \el == 0 + /* + * This must be the first instruction of the EL0 vector entries. It is + * skipped by the trampoline vectors, to trigger the cleanup. + */ + b .Lskip_tramp_vectors_cleanup\@ .if \regsize == 64 mrs x30, tpidrro_el0 msr tpidrro_el0, xzr .else mov x30, xzr .endif +.Lskip_tramp_vectors_cleanup\@: .endif -alternative_else_nop_endif #endif sub sp, sp, #S_FRAME_SIZE
@@ -1079,7 +1083,7 @@ alternative_if_not ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM prfm plil1strm, [x30, #(1b - tramp_vectors)] alternative_else_nop_endif msr vbar_el1, x30 - add x30, x30, #(1b - tramp_vectors) + add x30, x30, #(1b - tramp_vectors + 4) isb ret .org 1b + 128 // Did we overflow the ventry slot?
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 9/43 arm64: entry: Free up another register on kptis tramp_exit path
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit 03aff3a77a58b5b52a77e00537a42090ad57b80b upstream.
Kpti stashes x30 in far_el1 while it uses x30 for all its work.
Making the vectors a per-cpu data structure will require a second register.
Allow tramp_exit two registers before it unmaps the kernel, by leaving x30 on the stack, and stashing x29 in far_el1.
--- arch/arm64/kernel/entry.S | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
arch/arm64/kernel/entry.S +12 -6
@@ -367,14 +367,16 @@ alternative_else_nop_endif ldp x24, x25, [sp, #16 * 12] ldp x26, x27, [sp, #16 * 13] ldp x28, x29, [sp, #16 * 14] - ldr lr, [sp, #S_LR] - add sp, sp, #S_FRAME_SIZE // restore sp .if \el == 0 -alternative_insn eret, nop, ARM64_UNMAP_KERNEL_AT_EL0 +alternative_if_not ARM64_UNMAP_KERNEL_AT_EL0 + ldr lr, [sp, #S_LR] + add sp, sp, #S_FRAME_SIZE // restore sp + eret +alternative_else_nop_endif #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 bne 5f - msr far_el1, x30 + msr far_el1, x29 tramp_alias x30, tramp_exit_native br x30 5:
@@ -382,6 +384,8 @@ alternative_insn eret, nop, ARM64_UNMAP_KERNEL_AT_EL0 br x30 #endif .else + ldr lr, [sp, #S_LR] + add sp, sp, #S_FRAME_SIZE // restore sp eret .endif sb
@@ -1092,10 +1096,12 @@ alternative_else_nop_endif .macro tramp_exit, regsize = 64 adr x30, tramp_vectors msr vbar_el1, x30 - tramp_unmap_kernel x30 + ldr lr, [sp, #S_LR] + tramp_unmap_kernel x29 .if \regsize == 64 - mrs x30, far_el1 + mrs x29, far_el1 .endif + add sp, sp, #S_FRAME_SIZE // restore sp eret sb .endm
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 10/43 arm64: entry: Move the trampoline data page before the text page
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit c091fb6ae059cda563b2a4d93fdbc548ef34e1d6 upstream.
The trampoline code has a data page that holds the address of the vectors, which is unmapped when running in user-space. This ensures that with CONFIG_RANDOMIZE_BASE, the randomised address of the kernel can't be discovered until after the kernel has been mapped.
If the trampoline text page is extended to include multiple sets of vectors, it will be larger than a single page, making it tricky to find the data page without knowing the size of the trampoline text pages, which will vary with PAGE_SIZE.
Move the data page to appear before the text page. This allows the data page to be found without knowing the size of the trampoline text pages. 'tramp_vectors' is used to refer to the beginning of the .entry.tramp.text section, do that explicitly.
--- arch/arm64/include/asm/fixmap.h | 2 +- arch/arm64/kernel/entry.S | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-)
arch/arm64/include/asm/fixmap.h +1 -1
@@ -63,8 +63,8 @@ enum fixed_addresses {#endif /* CONFIG_ACPI_APEI_GHES */ #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 -FIX_ENTRY_TRAMP_DATA ,FIX_ENTRY_TRAMP_TEXT , +FIX_ENTRY_TRAMP_DATA , #define TRAMP_VALIAS (__fix_to_virt(FIX_ENTRY_TRAMP_TEXT))#endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */ __end_of_permanent_fixed_addresses,
arch/arm64/kernel/entry.S +7 -2
@@ -1061,6 +1061,11 @@ alternative_else_nop_endif */ .endm + .macro tramp_data_page dst + adr \dst, .entry.tramp.text + sub \dst, \dst, PAGE_SIZE + .endm + .macro tramp_ventry, regsize = 64 .align 7 1:
@@ -1077,7 +1082,7 @@ alternative_else_nop_endif 2: tramp_map_kernel x30 #ifdef CONFIG_RANDOMIZE_BASE - adr x30, tramp_vectors + PAGE_SIZE + tramp_data_page x30 alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003 ldr x30, [x30] #else
@@ -1228,7 +1233,7 @@ ENTRY(__sdei_asm_entry_trampoline) 1: str x4, [x1, #(SDEI_EVENT_INTREGS + S_ORIG_ADDR_LIMIT)] #ifdef CONFIG_RANDOMIZE_BASE - adr x4, tramp_vectors + PAGE_SIZE + tramp_data_page x4 add x4, x4, #:lo12:__sdei_asm_trampoline_next_handler ldr x4, [x4] #else
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 11/43 arm64: entry: Allow tramp_alias to access symbols after the 4K boundary
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit 6c5bf79b69f911560fbf82214c0971af6e58e682 upstream.
Systems using kpti enter and exit the kernel through a trampoline mapping that is always mapped, even when the kernel is not. tramp_valias is a macro to find the address of a symbol in the trampoline mapping.
Adding extra sets of vectors will expand the size of the entry.tramp.text section to beyond 4K. tramp_valias will be unable to generate addresses for symbols beyond 4K as it uses the 12 bit immediate of the add instruction.
As there are now two registers available when tramp_alias is called, use the extra register to avoid the 4K limit of the 12 bit immediate.
--- arch/arm64/kernel/entry.S | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
arch/arm64/kernel/entry.S +8 -5
@@ -124,9 +124,12 @@ .org .Lventry_start\@ + 128 // Did we overflow the ventry slot? .endm - .macro tramp_alias, dst, sym + .macro tramp_alias, dst, sym, tmp mov_q \dst, TRAMP_VALIAS - add \dst, \dst, #(\sym - .entry.tramp.text) + adr_l \tmp, \sym + add \dst, \dst, \tmp + adr_l \tmp, .entry.tramp.text + sub \dst, \dst, \tmp .endm // This macro corrupts x0-x3. It is the caller's duty
@@ -377,10 +380,10 @@ alternative_else_nop_endif #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 bne 5f msr far_el1, x29 - tramp_alias x30, tramp_exit_native + tramp_alias x30, tramp_exit_native, x29 br x30 5: - tramp_alias x30, tramp_exit_compat + tramp_alias x30, tramp_exit_compat, x29 br x30 #endif .else
@@ -1362,7 +1365,7 @@ alternative_if_not ARM64_UNMAP_KERNEL_AT_EL0 alternative_else_nop_endif #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 - tramp_alias dst=x5, sym=__sdei_asm_exit_trampoline + tramp_alias dst=x5, sym=__sdei_asm_exit_trampoline, tmp=x3 br x5 #endif ENDPROC(__sdei_asm_handler)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 12/43 arm64: entry: Dont assume tramp_vectors is the start of the vectors
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit ed50da7764535f1e24432ded289974f2bf2b0c5a upstream.
The tramp_ventry macro uses tramp_vectors as the address of the vectors when calculating which ventry in the 'full fat' vectors to branch to.
While there is one set of tramp_vectors, this will be true. Adding multiple sets of vectors will break this assumption.
Move the generation of the vectors to a macro, and pass the start of the vectors as an argument to tramp_ventry.
--- arch/arm64/kernel/entry.S | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
arch/arm64/kernel/entry.S +15 -13
@@ -1069,7 +1069,7 @@ alternative_else_nop_endif sub \dst, \dst, PAGE_SIZE .endm - .macro tramp_ventry, regsize = 64 + .macro tramp_ventry, vector_start, regsize .align 7 1: .if \regsize == 64
@@ -1092,10 +1092,10 @@ alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003 ldr x30, =vectors #endif alternative_if_not ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM - prfm plil1strm, [x30, #(1b - tramp_vectors)] + prfm plil1strm, [x30, #(1b - \vector_start)] alternative_else_nop_endif msr vbar_el1, x30 - add x30, x30, #(1b - tramp_vectors + 4) + add x30, x30, #(1b - \vector_start + 4) isb ret .org 1b + 128 // Did we overflow the ventry slot?
@@ -1114,19 +1114,21 @@ alternative_else_nop_endif sb .endm - .align 11 -ENTRY(tramp_vectors) + .macro generate_tramp_vector +.Lvector_start\@: .space 0x400 - tramp_ventry - tramp_ventry - tramp_ventry - tramp_ventry + .rept 4 + tramp_ventry .Lvector_start\@, 64 + .endr + .rept 4 + tramp_ventry .Lvector_start\@, 32 + .endr + .endm - tramp_ventry 32 - tramp_ventry 32 - tramp_ventry 32 - tramp_ventry 32 + .align 11 +ENTRY(tramp_vectors) + generate_tramp_vector END(tramp_vectors) ENTRY(tramp_exit_native)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 13/43 arm64: entry: Move trampoline macros out of ifdefd section
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit 13d7a08352a83ef2252aeb464a5e08dfc06b5dfd upstream.
The macros for building the kpti trampoline are all behind CONFIG_UNMAP_KERNEL_AT_EL0, and in a region that outputs to the .entry.tramp.text section.
Move the macros out so they can be used to generate other kinds of trampoline. Only the symbols need to be guarded by CONFIG_UNMAP_KERNEL_AT_EL0 and appear in the .entry.tramp.text section.
--- arch/arm64/kernel/entry.S | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
arch/arm64/kernel/entry.S +5 -6
@@ -1025,12 +1025,6 @@ ENDPROC(el0_svc) .popsection // .entry.text -#ifdef CONFIG_UNMAP_KERNEL_AT_EL0 -/* - * Exception vectors trampoline. - */ - .pushsection ".entry.tramp.text", "ax" - // Move from tramp_pg_dir to swapper_pg_dir .macro tramp_map_kernel, tmp mrs \tmp, ttbr1_el1
@@ -1126,6 +1120,11 @@ alternative_else_nop_endif .endr .endm +#ifdef CONFIG_UNMAP_KERNEL_AT_EL0 +/* + * Exception vectors trampoline. + */ + .pushsection ".entry.tramp.text", "ax" .align 11 ENTRY(tramp_vectors) generate_tramp_vector
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 14/43 arm64: entry: Make the kpti trampolines kpti sequence optional
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit c47e4d04ba0f1ea17353d85d45f611277507e07a upstream.
Spectre-BHB needs to add sequences to the vectors. Having one global set of vectors is a problem for big/little systems where the sequence is costly on cpus that are not vulnerable.
Making the vectors per-cpu in the style of KVM's bh_harden_hyp_vecs requires the vectors to be generated by macros.
Make the kpti re-mapping of the kernel optional, so the macros can be used without kpti.
--- arch/arm64/kernel/entry.S | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
arch/arm64/kernel/entry.S +12 -6
@@ -1063,9 +1063,10 @@ alternative_else_nop_endif sub \dst, \dst, PAGE_SIZE .endm - .macro tramp_ventry, vector_start, regsize + .macro tramp_ventry, vector_start, regsize, kpti .align 7 1: + .if \kpti == 1 .if \regsize == 64 msr tpidrro_el0, x30 // Restored in kernel_ventry .endif
@@ -1088,9 +1089,14 @@ alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003 alternative_if_not ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM prfm plil1strm, [x30, #(1b - \vector_start)] alternative_else_nop_endif + msr vbar_el1, x30 - add x30, x30, #(1b - \vector_start + 4) isb + .else + ldr x30, =vectors + .endif // \kpti == 1 + + add x30, x30, #(1b - \vector_start + 4) ret .org 1b + 128 // Did we overflow the ventry slot? .endm
@@ -1108,15 +1114,15 @@ alternative_else_nop_endif sb .endm - .macro generate_tramp_vector + .macro generate_tramp_vector, kpti .Lvector_start\@: .space 0x400 .rept 4 - tramp_ventry .Lvector_start\@, 64 + tramp_ventry .Lvector_start\@, 64, \kpti .endr .rept 4 - tramp_ventry .Lvector_start\@, 32 + tramp_ventry .Lvector_start\@, 32, \kpti .endr .endm
@@ -1127,7 +1133,7 @@ alternative_else_nop_endif .pushsection ".entry.tramp.text", "ax" .align 11 ENTRY(tramp_vectors) - generate_tramp_vector + generate_tramp_vector kpti=1 END(tramp_vectors) ENTRY(tramp_exit_native)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 15/43 arm64: entry: Allow the trampoline text to occupy multiple pages
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit a9c406e6462ff14956d690de7bbe5131a5677dc9 upstream.
Adding a second set of vectors to .entry.tramp.text will make it larger than a single 4K page.
Allow the trampoline text to occupy up to three pages by adding two more fixmap slots. Previous changes to tramp_valias allowed it to reach beyond a single page.
--- arch/arm64/include/asm/fixmap.h | 6 ++++-- arch/arm64/include/asm/sections.h | 5 +++++ arch/arm64/kernel/entry.S | 2 +- arch/arm64/kernel/vmlinux.lds.S | 2 +- arch/arm64/mm/mmu.c | 12 +++++++++--- 5 files changed, 20 insertions(+), 7 deletions(-)
arch/arm64/include/asm/fixmap.h +4 -2
@@ -63,9 +63,11 @@ enum fixed_addresses {#endif /* CONFIG_ACPI_APEI_GHES */ #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 -FIX_ENTRY_TRAMP_TEXT , +FIX_ENTRY_TRAMP_TEXT3 , +FIX_ENTRY_TRAMP_TEXT2 , +FIX_ENTRY_TRAMP_TEXT1 ,FIX_ENTRY_TRAMP_DATA , -#define TRAMP_VALIAS (__fix_to_virt(FIX_ENTRY_TRAMP_TEXT)) +#define TRAMP_VALIAS (__fix_to_virt(FIX_ENTRY_TRAMP_TEXT1))#endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */ __end_of_permanent_fixed_addresses,
arch/arm64/include/asm/sections.h +5 -0
@@ -20,4 +20,9 @@ extern char __irqentry_text_start[], __irqentry_text_end[];extern char __mmuoff_data_start[], __mmuoff_data_end[];extern char __entry_tramp_text_start[], __entry_tramp_text_end[]; +static inline size_t entry_tramp_text_size (void ) +{ +return __entry_tramp_text_end - __entry_tramp_text_start; +} +#endif /* __ASM_SECTIONS_H */
arch/arm64/kernel/entry.S +1 -1
@@ -1059,7 +1059,7 @@ alternative_else_nop_endif .endm .macro tramp_data_page dst - adr \dst, .entry.tramp.text + adr_l \dst, .entry.tramp.text sub \dst, \dst, PAGE_SIZE .endm
arch/arm64/kernel/vmlinux.lds.S +1 -1
@@ -276,7 +276,7 @@ ASSERT(__hibernate_exit_text_end - (__hibernate_exit_text_start & ~(SZ_4K - 1)) <= SZ_4K, "Hibernate exit text too big or misaligned") #endif #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 -ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == PAGE_SIZE, +ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) <= 3*PAGE_SIZE, "Entry trampoline text too big") #endif /*
arch/arm64/mm/mmu.c +9 -3
@@ -583,6 +583,8 @@ early_param("rodata", parse_rodata);#ifdef CONFIG_UNMAP_KERNEL_AT_EL0 static int __init map_entry_trampoline (void ) { +int i; +pgprot_t prot = rodata_enabled ?PAGE_KERNEL_ROX :PAGE_KERNEL_EXEC ;phys_addr_t pa_start =__pa_symbol (__entry_tramp_text_start);
@@ -591,11 +593,15 @@ static int __init map_entry_trampoline(void)/* Map only the text into the trampoline page table */ memset (tramp_pg_dir,0 ,PGD_SIZE ); -__create_pgd_mapping (tramp_pg_dir, pa_start,TRAMP_VALIAS ,PAGE_SIZE , - prot, __pgd_pgtable_alloc,0 ); +__create_pgd_mapping (tramp_pg_dir, pa_start,TRAMP_VALIAS , +entry_tramp_text_size (), prot, + __pgd_pgtable_alloc,NO_BLOCK_MAPPINGS );/* Map both the text and data into the kernel page table */ -__set_fixmap (FIX_ENTRY_TRAMP_TEXT , pa_start, prot); +for (i =0 ; i <DIV_ROUND_UP (entry_tramp_text_size (),PAGE_SIZE ); i++) +__set_fixmap (FIX_ENTRY_TRAMP_TEXT1 - i, + pa_start + i *PAGE_SIZE , prot); +if (IS_ENABLED (CONFIG_RANDOMIZE_BASE )) {extern char __entry_tramp_data_start[];
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 16/43 arm64: entry: Add non-kpti __bp_harden_el1_vectors for mitigations
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit aff65393fa1401e034656e349abd655cfe272de0 upstream.
kpti is an optional feature, for systems not using kpti a set of vectors for the spectre-bhb mitigations is needed.
Add another set of vectors, __bp_harden_el1_vectors, that will be used if a mitigation is needed and kpti is not in use.
The EL1 ventries are repeated verbatim as there is no additional work needed for entry from EL1.
--- arch/arm64/kernel/entry.S | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
arch/arm64/kernel/entry.S +34 -1
@@ -1066,10 +1066,11 @@ alternative_else_nop_endif .macro tramp_ventry, vector_start, regsize, kpti .align 7 1: - .if \kpti == 1 .if \regsize == 64 msr tpidrro_el0, x30 // Restored in kernel_ventry .endif + + .if \kpti == 1 /* * Defend against branch aliasing attacks by pushing a dummy * entry onto the return stack and using a RET instruction to
@@ -1156,6 +1157,38 @@ __entry_tramp_data_start: #endif /* CONFIG_RANDOMIZE_BASE */ #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */ +/* + * Exception vectors for spectre mitigations on entry from EL1 when + * kpti is not in use. + */ + .macro generate_el1_vector +.Lvector_start\@: + kernel_ventry 1, sync_invalid // Synchronous EL1t + kernel_ventry 1, irq_invalid // IRQ EL1t + kernel_ventry 1, fiq_invalid // FIQ EL1t + kernel_ventry 1, error_invalid // Error EL1t + + kernel_ventry 1, sync // Synchronous EL1h + kernel_ventry 1, irq // IRQ EL1h + kernel_ventry 1, fiq_invalid // FIQ EL1h + kernel_ventry 1, error // Error EL1h + + .rept 4 + tramp_ventry .Lvector_start\@, 64, kpti=0 + .endr + .rept 4 + tramp_ventry .Lvector_start\@, 32, kpti=0 + .endr + .endm + + .pushsection ".entry.text", "ax" + .align 11 +SYM_CODE_START(__bp_harden_el1_vectors) + generate_el1_vector +SYM_CODE_END(__bp_harden_el1_vectors) + .popsection + + /* * Register switch for AArch64. The callee-saved registers need to be saved * and restored. On entry:
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 17/43 arm64: entry: Add vectors that have the bhb mitigation sequences
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit ba2689234be92024e5635d30fe744f4853ad97db upstream.
Some CPUs affected by Spectre-BHB need a sequence of branches, or a firmware call to be run before any indirect branch. This needs to go in the vectors. No CPU needs both.
While this can be patched in, it would run on all CPUs as there is a single set of vectors. If only one part of a big/little combination is affected, the unaffected CPUs have to run the mitigation too.
Create extra vectors that include the sequence. Subsequent patches will allow affected CPUs to select this set of vectors. Later patches will modify the loop count to match what the CPU requires.
--- arch/arm64/include/asm/assembler.h | 24 ++++++++++++++ arch/arm64/include/asm/vectors.h | 34 +++++++++++++++++++ arch/arm64/kernel/entry.S | 53 +++++++++++++++++++++++++----- include/linux/arm-smccc.h | 5 +++ 4 files changed, 107 insertions(+), 9 deletions(-) create mode 100644 arch/arm64/include/asm/vectors.h
arch/arm64/include/asm/assembler.h +24 -0
@@ -757,4 +757,28 @@ USER(\label, ic ivau, \tmp2) // invalidate I line PoU .Lyield_out_\@ : .endm + .macro __mitigate_spectre_bhb_loop tmp +#ifdef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY + mov \tmp, #32 +.Lspectre_bhb_loop\@: + b . + 4 + subs \tmp, \tmp, #1 + b.ne .Lspectre_bhb_loop\@ + sb +#endif /* CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY */ + .endm + + /* Save/restores x0-x3 to the stack */ + .macro __mitigate_spectre_bhb_fw +#ifdef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY + stp x0, x1, [sp, #-16]! + stp x2, x3, [sp, #-16]! + mov w0, #ARM_SMCCC_ARCH_WORKAROUND_3 +alternative_cb smccc_patch_fw_mitigation_conduit + nop // Patched to SMC/HVC #0 +alternative_cb_end + ldp x2, x3, [sp], #16 + ldp x0, x1, [sp], #16 +#endif /* CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY */ + .endm #endif /* __ASM_ASSEMBLER_H */
arch/arm64/include/asm/vectors.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright (C) 2022 ARM Ltd. +*/ +#ifndef __ASM_VECTORS_H +#define __ASM_VECTORS_H + +/* +* Note: the order of this enum corresponds to two arrays in entry.S: +* tramp_vecs and __bp_harden_el1_vectors. By default the canonical +* 'full fat' vectors are used directly. +*/ +enum arm64_bp_harden_el1_vectors { +#ifdef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY +/* +* Perform the BHB loop mitigation, before branching to the canonical +* vectors. +*/ +EL1_VECTOR_BHB_LOOP , + +/* +* Make the SMC call for firmware mitigation, before branching to the +* canonical vectors. +*/ +EL1_VECTOR_BHB_FW , +#endif /* CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY */ + +/* +* Remap the kernel before branching to the canonical vectors. +*/ +EL1_VECTOR_KPTI , +}; + +#endif /* __ASM_VECTORS_H */
arch/arm64/kernel/entry.S +44 -9
119 lines not on this page · raw message
include/linux/arm-smccc.h +5 -0
@@ -76,6 +76,11 @@ ARM_SMCCC_SMC_32, \ 0, 0x7fff) +#define ARM_SMCCC_ARCH_WORKAROUND_3 \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_SMC_32, \ + 0, 0x3fff) +#define SMCCC_ARCH_WORKAROUND_RET_UNAFFECTED 1#ifndef __ASSEMBLY__
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 18/43 arm64: entry: Add macro for reading symbol addresses from the trampoline
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit b28a8eebe81c186fdb1a0078263b30576c8e1f42 upstream.
The trampoline code needs to use the address of symbols in the wider kernel, e.g. vectors. PC-relative addressing wouldn't work as the trampoline code doesn't run at the address the linker expected.
tramp_ventry uses a literal pool, unless CONFIG_RANDOMIZE_BASE is set, in which case it uses the data page as a literal pool because the data page can be unmapped when running in user-space, which is required for CPUs vulnerable to meltdown.
Pull this logic out as a macro, instead of adding a third copy of it.
--- arch/arm64/kernel/entry.S | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-)
arch/arm64/kernel/entry.S +16 -19
@@ -1063,6 +1063,15 @@ alternative_else_nop_endif sub \dst, \dst, PAGE_SIZE .endm + .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
@@ -1093,13 +1102,8 @@ 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 alternative_if_not ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM prfm plil1strm, [x30, #(1b - \vector_start)] alternative_else_nop_endif
@@ -1183,7 +1187,12 @@ END(tramp_exit_compat) .align PAGE_SHIFT .globl __entry_tramp_data_start __entry_tramp_data_start: +__entry_tramp_data_vectors: .quad vectors +#ifdef CONFIG_ARM_SDE_INTERFACE +__entry_tramp_data___sdei_asm_trampoline_next_handler: + .quad __sdei_asm_handler +#endif /* CONFIG_ARM_SDE_INTERFACE */ .popsection // .rodata #endif /* CONFIG_RANDOMIZE_BASE */ #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */
@@ -1310,13 +1319,7 @@ ENTRY(__sdei_asm_entry_trampoline) */ 1: str x4, [x1, #(SDEI_EVENT_INTREGS + S_ORIG_ADDR_LIMIT)] -#ifdef CONFIG_RANDOMIZE_BASE - tramp_data_page x4 - add x4, x4, #:lo12:__sdei_asm_trampoline_next_handler - ldr x4, [x4] -#else - ldr x4, =__sdei_asm_handler -#endif + tramp_data_read_var x4, __sdei_asm_trampoline_next_handler br x4 ENDPROC(__sdei_asm_entry_trampoline) NOKPROBE(__sdei_asm_entry_trampoline)
@@ -1339,12 +1342,6 @@ ENDPROC(__sdei_asm_exit_trampoline) NOKPROBE(__sdei_asm_exit_trampoline) .ltorg .popsection // .entry.tramp.text -#ifdef CONFIG_RANDOMIZE_BASE -.pushsection ".rodata", "a" -__sdei_asm_trampoline_next_handler: - .quad __sdei_asm_handler -.popsection // .rodata -#endif /* CONFIG_RANDOMIZE_BASE */ #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */ /*
Signature · 1 line
2.34.1
Re: [PATCH 5.4 18/43] arm64: entry: Add macro for reading symbol addresses from the trampoline
Quoted 13 lines · Greg Kroah-Hartman
From: James Morse <[email protected]>
commit
b28a8eebe81c186fdb1a0078263b30576c8e1f42upstream.The trampoline code needs to use the address of symbols in the wider kernel, e.g. vectors. PC-relative addressing wouldn't work as the trampoline code doesn't run at the address the linker expected.
tramp_ventryuses a literal pool, unlessCONFIG_RANDOMIZE_BASEis set, in which case it uses the data page as a literal pool because the data page can be unmapped when running in user-space, which is required for CPUs vulnerable to meltdown.
Quoted 6 lines
Pull this logic out as a macro, instead of adding a third copy of it.
Reviewed-by Catalin Marinas <[email protected]>Signed-off-by James Morse <[email protected]>Signed-off-by Sasha Levin <[email protected]>
This commit causes a linking failure with CONFIG_ARM_SDE_INTERFACE=y enabled in the kernel:
LD .tmp_vmlinux.kallsyms1
/local/users/fainelli/buildroot/output/arm64/host/bin/aarch64-linux-ld:arch/arm64/kernel/entry.o: in function `__sdei_asm_exit_trampoline':
/local/users/fainelli/buildroot/output/arm64/build/linux-custom/arch/arm64/kernel/entry.S:1352:
undefined reference to `__sdei_asm_trampoline_next_handler'
make[2]: *** [Makefile:1100: vmlinux] Error 1
make[1]: *** [package/pkg-generic.mk:295:
/local/users/fainelli/buildroot/output/arm64/build/linux-custom/.stamp_built] Error 2
make: *** [Makefile:27: _all] Error 2
Quoted 81 lines
--- arch/arm64/kernel/entry.S | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-)arch/arm64/kernel/entry.S +16
-19@@ -1063,6 +1063,15 @@ alternative_else_nop_endif sub \dst, \dst, PAGE_SIZE .endm + .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@@ -1093,13 +1102,8 @@ 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 alternative_if_not ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM prfm plil1strm, [x30, #(1b - \vector_start)] alternative_else_nop_endif@@ -1183,7 +1187,12 @@ END(tramp_exit_compat) .align PAGE_SHIFT .globl __entry_tramp_data_start __entry_tramp_data_start: +__entry_tramp_data_vectors: .quad vectors +#ifdef CONFIG_ARM_SDE_INTERFACE +__entry_tramp_data___sdei_asm_trampoline_next_handler: + .quad __sdei_asm_handler +#endif /* CONFIG_ARM_SDE_INTERFACE */ .popsection // .rodata #endif /* CONFIG_RANDOMIZE_BASE */ #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */@@ -1310,13 +1319,7 @@ ENTRY(__sdei_asm_entry_trampoline) */ 1: str x4, [x1, #(SDEI_EVENT_INTREGS + S_ORIG_ADDR_LIMIT)] -#ifdef CONFIG_RANDOMIZE_BASE - tramp_data_page x4 - add x4, x4, #:lo12:__sdei_asm_trampoline_next_handler - ldr x4, [x4] -#else - ldr x4, =__sdei_asm_handler -#endif + tramp_data_read_var x4, __sdei_asm_trampoline_next_handler br x4 ENDPROC(__sdei_asm_entry_trampoline) NOKPROBE(__sdei_asm_entry_trampoline)@@ -1339,12 +1342,6 @@ ENDPROC(__sdei_asm_exit_trampoline) NOKPROBE(__sdei_asm_exit_trampoline) .ltorg .popsection // .entry.tramp.text -#ifdef CONFIG_RANDOMIZE_BASE -.pushsection ".rodata", "a" -__sdei_asm_trampoline_next_handler: - .quad __sdei_asm_handler -.popsection // .rodata -#endif /* CONFIG_RANDOMIZE_BASE */ #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */ /*
Signature · 1 line
Florian
Re: [PATCH 5.4 18/43] arm64: entry: Add macro for reading symbol addresses from the trampoline
Hi Florian,
Quoted 24 lines · Florian Fainelli
Quoted 13 lines · Greg Kroah-Hartman
From: James Morse <[email protected]>
commit
b28a8eebe81c186fdb1a0078263b30576c8e1f42upstream.The trampoline code needs to use the address of symbols in the wider kernel, e.g. vectors. PC-relative addressing wouldn't work as the trampoline code doesn't run at the address the linker expected.
tramp_ventryuses a literal pool, unlessCONFIG_RANDOMIZE_BASEis set, in which case it uses the data page as a literal pool because the data page can be unmapped when running in user-space, which is required for CPUs vulnerable to meltdown.Quoted 6 lines
Pull this logic out as a macro, instead of adding a third copy of it.
Reviewed-by Catalin Marinas <[email protected]>Signed-off-by James Morse <[email protected]>Signed-off-by Sasha Levin <[email protected]>This commit causes a linking failure with
CONFIG_ARM_SDE_INTERFACE=yenabled in the kernel:
Quoted 10 lines
LD .tmp_vmlinux.kallsyms1
/local/users/fainelli/buildroot/output/arm64/host/bin/aarch64-linux-ld:arch/arm64/kernel/entry.o: in function `__sdei_asm_exit_trampoline':
/local/users/fainelli/buildroot/output/arm64/build/linux-custom/arch/arm64/kernel/entry.S:1352:
undefined reference to `__sdei_asm_trampoline_next_handler'
make[2]: *** [Makefile:1100: vmlinux] Error 1
make[1]: *** [package/pkg-generic.mk:295:
/local/users/fainelli/buildroot/output/arm64/build/linux-custom/.stamp_built] Error 2
make: *** [Makefile:27:_all] Error 2
... and with CONFIG_RANDOMIZE_BASE turned off, which is why allyesconfig didn't catch it. This is because I kept the next_handler bit of the label when it conflicted, which isn't needed because the __entry_tramp bit added by the macro serves the same purpose.
The below diff fixes it:
----------%<----------
arch/arm64/kernel/entry.S +2 -2
@@ -1190,7 +1190,7 @@ __entry_tramp_data_start: __entry_tramp_data_vectors: .quad vectors #ifdef CONFIG_ARM_SDE_INTERFACE -__entry_tramp_data___sdei_asm_trampoline_next_handler: +__entry_tramp_data___sdei_asm_handler: .quad __sdei_asm_handler #endif /* CONFIG_ARM_SDE_INTERFACE */ .popsection // .rodata
@@ -1319,7 +1319,7 @@ ENTRY(__sdei_asm_entry_trampoline) */ 1: str x4, [x1, #(SDEI_EVENT_INTREGS + S_ORIG_ADDR_LIMIT)] - tramp_data_read_var x4, __sdei_asm_trampoline_next_handler + tramp_data_read_var x4, __sdei_asm_handler br x4 ENDPROC(__sdei_asm_entry_trampoline) NOKPROBE(__sdei_asm_entry_trampoline)
----------%<----------
Good news - this didn't happen with v5.10.
I don't see this in v5.4.185 yet.
Greg/Sasha, what is least work for you?:
A new version of this patch,
A fixup on top of the series,
Reposting the series with this fixed.
Thanks for catching this!
James
Greg Kroah-Hartman
maintainerRe: [PATCH 5.4 18/43] arm64: entry: Add macro for reading symbol addresses from the trampoline
Quoted 67 lines · James Morse
Hi Florian,
Quoted 24 lines · Florian Fainelli
Quoted 13 lines · Greg Kroah-Hartman
From: James Morse <[email protected]>
commit
b28a8eebe81c186fdb1a0078263b30576c8e1f42upstream.The trampoline code needs to use the address of symbols in the wider kernel, e.g. vectors. PC-relative addressing wouldn't work as the trampoline code doesn't run at the address the linker expected.
tramp_ventryuses a literal pool, unlessCONFIG_RANDOMIZE_BASEis set, in which case it uses the data page as a literal pool because the data page can be unmapped when running in user-space, which is required for CPUs vulnerable to meltdown.Quoted 6 lines
Pull this logic out as a macro, instead of adding a third copy of it.
Reviewed-by Catalin Marinas <[email protected]>Signed-off-by James Morse <[email protected]>Signed-off-by Sasha Levin <[email protected]>This commit causes a linking failure with
CONFIG_ARM_SDE_INTERFACE=yenabled in the kernel:Quoted 10 lines
LD .tmp_vmlinux.kallsyms1
/local/users/fainelli/buildroot/output/arm64/host/bin/aarch64-linux-ld:arch/arm64/kernel/entry.o: in function `__sdei_asm_exit_trampoline':
/local/users/fainelli/buildroot/output/arm64/build/linux-custom/arch/arm64/kernel/entry.S:1352:
undefined reference to `__sdei_asm_trampoline_next_handler'
make[2]: *** [Makefile:1100: vmlinux] Error 1
make[1]: *** [package/pkg-generic.mk:295:
/local/users/fainelli/buildroot/output/arm64/build/linux-custom/.stamp_built] Error 2
make: *** [Makefile:27:_all] Error 2... and with
CONFIG_RANDOMIZE_BASEturned off, which is why allyesconfig didn't catch it. This is because I kept thenext_handlerbit of the label when it conflicted, which isn't needed because the__entry_trampbit added by the macro serves the same purpose.The below diff fixes it:
----------%<----------arch/arm64/kernel/entry.S +2
-3@@ -1190,7 +1190,7 @@ __entry_tramp_data_start: __entry_tramp_data_vectors: .quad vectors #ifdef CONFIG_ARM_SDE_INTERFACE -__entry_tramp_data___sdei_asm_trampoline_next_handler: +__entry_tramp_data___sdei_asm_handler: .quad __sdei_asm_handler #endif /* CONFIG_ARM_SDE_INTERFACE */ .popsection // .rodata@@ -1319,7 +1319,7 @@ ENTRY(__sdei_asm_entry_trampoline) */ 1: str x4, [x1, #(SDEI_EVENT_INTREGS + S_ORIG_ADDR_LIMIT)] - tramp_data_read_var x4, __sdei_asm_trampoline_next_handler + tramp_data_read_var x4, __sdei_asm_handler br x4 ENDPROC(__sdei_asm_entry_trampoline) NOKPROBE(__sdei_asm_entry_trampoline) ----------%<----------
Quoted 8 lines
Good news - this didn't happen with v5.10.
I don't see this in v5.4.185 yet.
Greg/Sasha, what is least work for you?:
A new version of this patch,
A fixup on top of the series,
Reposting the series with this fixed.
Let me merge this into this commit.
thanks!
greg k-h
Greg Kroah-Hartman
maintainerRe: [PATCH 5.4 18/43] arm64: entry: Add macro for reading symbol addresses from the trampoline
Quoted 70 lines · Greg Kroah-Hartman
Quoted 69 lines · James Morse
Hi Florian,
Quoted 24 lines · Florian Fainelli
Quoted 13 lines · Greg Kroah-Hartman
From: James Morse <[email protected]>
commit
b28a8eebe81c186fdb1a0078263b30576c8e1f42upstream.The trampoline code needs to use the address of symbols in the wider kernel, e.g. vectors. PC-relative addressing wouldn't work as the trampoline code doesn't run at the address the linker expected.
tramp_ventryuses a literal pool, unlessCONFIG_RANDOMIZE_BASEis set, in which case it uses the data page as a literal pool because the data page can be unmapped when running in user-space, which is required for CPUs vulnerable to meltdown.Quoted 6 lines
Pull this logic out as a macro, instead of adding a third copy of it.
Reviewed-by Catalin Marinas <[email protected]>Signed-off-by James Morse <[email protected]>Signed-off-by Sasha Levin <[email protected]>This commit causes a linking failure with
CONFIG_ARM_SDE_INTERFACE=yenabled in the kernel:Quoted 10 lines
LD .tmp_vmlinux.kallsyms1
/local/users/fainelli/buildroot/output/arm64/host/bin/aarch64-linux-ld:arch/arm64/kernel/entry.o: in function `__sdei_asm_exit_trampoline':
/local/users/fainelli/buildroot/output/arm64/build/linux-custom/arch/arm64/kernel/entry.S:1352:
undefined reference to `__sdei_asm_trampoline_next_handler'
make[2]: *** [Makefile:1100: vmlinux] Error 1
make[1]: *** [package/pkg-generic.mk:295:
/local/users/fainelli/buildroot/output/arm64/build/linux-custom/.stamp_built] Error 2
make: *** [Makefile:27:_all] Error 2... and with
CONFIG_RANDOMIZE_BASEturned off, which is why allyesconfig didn't catch it. This is because I kept thenext_handlerbit of the label when it conflicted, which isn't needed because the__entry_trampbit added by the macro serves the same purpose.The below diff fixes it:
----------%<----------arch/arm64/kernel/entry.S +2
-3@@ -1190,7 +1190,7 @@ __entry_tramp_data_start: __entry_tramp_data_vectors: .quad vectors #ifdef CONFIG_ARM_SDE_INTERFACE -__entry_tramp_data___sdei_asm_trampoline_next_handler: +__entry_tramp_data___sdei_asm_handler: .quad __sdei_asm_handler #endif /* CONFIG_ARM_SDE_INTERFACE */ .popsection // .rodata@@ -1319,7 +1319,7 @@ ENTRY(__sdei_asm_entry_trampoline) */ 1: str x4, [x1, #(SDEI_EVENT_INTREGS + S_ORIG_ADDR_LIMIT)] - tramp_data_read_var x4, __sdei_asm_trampoline_next_handler + tramp_data_read_var x4, __sdei_asm_handler br x4 ENDPROC(__sdei_asm_entry_trampoline) NOKPROBE(__sdei_asm_entry_trampoline) ----------%<----------Good news - this didn't happen with v5.10.
Quoted 8 lines
Quoted 6 lines
I don't see this in v5.4.185 yet.
Greg/Sasha, what is least work for you?:
A new version of this patch,
A fixup on top of the series,
Reposting the series with this fixed.Let me merge this into this commit.
Well I would if it would actually apply :(
Can you send a version that isn't whitespace corrupted?
thanks,
greg k-h
fixup for [PATCH 5.4 18/43] arm64 entry: Add macro for reading symbol address from the trampoline
__sdei_asm_trampoline_next_handler shouldn't have its own name as the tramp_data_read_var takes the symbol name, and generates the name for the value in the data page if CONFIG_RANDOMIZE_BASE is clear.
This means when CONFIG_RANDOMIZE_BASE is clear, this code won't compile as __sdei_asm_trampoline_next_handler doesn't exist.
Use the proper name, and let the macro do its thing.
--- arch/arm64/kernel/entry.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/entry.S +2 -2
@@ -1190,7 +1190,7 @@ __entry_tramp_data_start: __entry_tramp_data_vectors: .quad vectors #ifdef CONFIG_ARM_SDE_INTERFACE -__entry_tramp_data___sdei_asm_trampoline_next_handler: +__entry_tramp_data___sdei_asm_handler: .quad __sdei_asm_handler #endif /* CONFIG_ARM_SDE_INTERFACE */ .popsection // .rodata
@@ -1319,7 +1319,7 @@ ENTRY(__sdei_asm_entry_trampoline) */ 1: str x4, [x1, #(SDEI_EVENT_INTREGS + S_ORIG_ADDR_LIMIT)] - tramp_data_read_var x4, __sdei_asm_trampoline_next_handler + tramp_data_read_var x4, __sdei_asm_handler br x4 ENDPROC(__sdei_asm_entry_trampoline) NOKPROBE(__sdei_asm_entry_trampoline)
Signature · 1 line
2.30.2
Greg Kroah-Hartman
maintainerRe: fixup for [PATCH 5.4 18/43] arm64 entry: Add macro for reading symbol address from the trampoline
Quoted 41 lines · James Morse
__sdei_asm_trampoline_next_handlershouldn't have its own name as thetramp_data_read_vartakes the symbol name, and generates the name for the value in the data page ifCONFIG_RANDOMIZE_BASEis clear.This means when
CONFIG_RANDOMIZE_BASEis clear, this code won't compile as__sdei_asm_trampoline_next_handlerdoesn't exist.Use the proper name, and let the macro do its thing.
Reported-by Florian Fainelli <[email protected]>Tested-by Florian Fainelli <[email protected]>Signed-off-by James Morse <[email protected]>--- arch/arm64/kernel/entry.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm64/kernel/entry.S +2
-2@@ -1190,7 +1190,7 @@ __entry_tramp_data_start: __entry_tramp_data_vectors: .quad vectors #ifdef CONFIG_ARM_SDE_INTERFACE -__entry_tramp_data___sdei_asm_trampoline_next_handler: +__entry_tramp_data___sdei_asm_handler: .quad __sdei_asm_handler #endif /* CONFIG_ARM_SDE_INTERFACE */ .popsection // .rodata@@ -1319,7 +1319,7 @@ ENTRY(__sdei_asm_entry_trampoline) */ 1: str x4, [x1, #(SDEI_EVENT_INTREGS + S_ORIG_ADDR_LIMIT)] - tramp_data_read_var x4, __sdei_asm_trampoline_next_handler + tramp_data_read_var x4, __sdei_asm_handler br x4 ENDPROC(__sdei_asm_entry_trampoline) NOKPROBE(__sdei_asm_entry_trampoline)Signature · 1 line
2.30.2
Thanks, now queued up.
greg k-h
Florian Fainelli
Tested-byRe: [PATCH 5.4 18/43] arm64: entry: Add macro for reading symbol addresses from the trampoline
In reply to James MorseQuoted 37 lines · James Morse
Hi Florian,
Quoted 34 lines · Florian Fainelli
Quoted 13 lines · Greg Kroah-Hartman
From: James Morse <[email protected]>
commit
b28a8eebe81c186fdb1a0078263b30576c8e1f42upstream.The trampoline code needs to use the address of symbols in the wider kernel, e.g. vectors. PC-relative addressing wouldn't work as the trampoline code doesn't run at the address the linker expected.
tramp_ventryuses a literal pool, unlessCONFIG_RANDOMIZE_BASEis set, in which case it uses the data page as a literal pool because the data page can be unmapped when running in user-space, which is required for CPUs vulnerable to meltdown.Quoted 6 lines
Pull this logic out as a macro, instead of adding a third copy of it.
Reviewed-by Catalin Marinas <[email protected]>Signed-off-by James Morse <[email protected]>Signed-off-by Sasha Levin <[email protected]>This commit causes a linking failure with
CONFIG_ARM_SDE_INTERFACE=yenabled in the kernel:LD .tmp_vmlinux.kallsyms1 /local/users/fainelli/buildroot/output/arm64/host/bin/aarch64-linux-ld:
arch/arm64/kernel/entry.o: in function `__sdei_asm_exit_trampoline':
/local/users/fainelli/buildroot/output/arm64/build/linux-custom/arch/arm64/kernel/entry.S:1352:undefined reference to `__sdei_asm_trampoline_next_handler' make[2]: *** [Makefile:1100: vmlinux] Error 1
make[1]: *** [package/pkg-generic.mk:295:
/local/users/fainelli/buildroot/output/arm64/build/linux-custom/.stamp_built]
Quoted 4 lines
Quoted 2 lines
Error 2
make: *** [Makefile:27:_all] Error 2... and with
CONFIG_RANDOMIZE_BASEturned off, which is why allyesconfig didn't catch it.
Yes that is correct CONFIG_RANDOMIZE_BASE is turned off in the configuration file I used.
Quoted 29 lines
This is because I kept the
next_handlerbit of the label when it conflicted, which isn't needed because the__entry_trampbit added by the macro serves the same purpose.The below diff fixes it:
----------%<----------arch/arm64/kernel/entry.S +2
-3@@ -1190,7 +1190,7 @@ __entry_tramp_data_start: __entry_tramp_data_vectors: .quad vectors #ifdef CONFIG_ARM_SDE_INTERFACE -__entry_tramp_data___sdei_asm_trampoline_next_handler: +__entry_tramp_data___sdei_asm_handler: .quad __sdei_asm_handler #endif /* CONFIG_ARM_SDE_INTERFACE */ .popsection // .rodata@@ -1319,7 +1319,7 @@ ENTRY(__sdei_asm_entry_trampoline) */ 1: str x4, [x1, #(SDEI_EVENT_INTREGS + S_ORIG_ADDR_LIMIT)] - tramp_data_read_var x4, __sdei_asm_trampoline_next_handler + tramp_data_read_var x4, __sdei_asm_handler br x4 ENDPROC(__sdei_asm_entry_trampoline) NOKPROBE(__sdei_asm_entry_trampoline) ----------%<----------
Quoted 8 lines
Good news - this didn't happen with v5.10.
I don't see this in v5.4.185 yet.
Greg/Sasha, what is least work for you?:
A new version of this patch,
A fixup on top of the series,
Reposting the series with this fixed.
FWIW, applying your patch on top of the entire 5.4.186-rc1 series will fail with some rejects so that would require you to fixup the patch instead, and then I suppose the whole -rc1 now becomes an -rc2?
Quoted 3 lines
Thanks for catching this!
Thanks for the quick turnaround:
Signature · 1 line
Florian
Greg Kroah-Hartman
maintainerPATCH 19/43 arm64: Add percpu vectors for EL1
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit bd09128d16fac3c34b80bd6a29088ac632e8ce09 upstream.
The Spectre-BHB workaround adds a firmware call to the vectors. This is needed on some CPUs, but not others. To avoid the unaffected CPU in a big/little pair from making the firmware call, create per cpu vectors.
The per-cpu vectors only apply when returning from EL0.
Systems using KPTI can use the canonical 'full-fat' vectors directly at EL1, the trampoline exit code will switch to this_cpu_vector on exit to EL0. Systems not using KPTI should always use this_cpu_vector.
this_cpu_vector will point at a vector in tramp_vecs or __bp_harden_el1_vectors, depending on whether KPTI is in use.
--- arch/arm64/include/asm/mmu.h | 2 +- arch/arm64/include/asm/vectors.h | 27 +++++++++++++++++++++++++++ arch/arm64/kernel/cpufeature.c | 11 +++++++++++ arch/arm64/kernel/entry.S | 16 ++++++++++------ arch/arm64/kvm/hyp/switch.c | 8 ++++++-- 5 files changed, 55 insertions(+), 9 deletions(-)
arch/arm64/include/asm/mmu.h +1 -1
@@ -29,7 +29,7 @@ typedef struct {*/ #define ASID (mm) ((mm)->context.id.counter & 0xffff) -static inline bool arm64_kernel_unmapped_at_el0 (void ) +static __always_inline bool arm64_kernel_unmapped_at_el0(void) {return IS_ENABLED (CONFIG_UNMAP_KERNEL_AT_EL0 ) &&cpus_have_const_cap (ARM64_UNMAP_KERNEL_AT_EL0 );
arch/arm64/include/asm/vectors.h +27 -0
@@ -5,6 +5,15 @@#ifndef __ASM_VECTORS_H#define __ASM_VECTORS_H +#include <linux/bug.h> +#include <linux/percpu.h> + +#include <asm/fixmap.h> + +extern char vectors[]; +extern char tramp_vectors[]; +extern char __bp_harden_el1_vectors[]; +/* * Note: the order of this enum corresponds to two arrays in entry.S: * tramp_vecs and __bp_harden_el1_vectors. By default the canonical
@@ -31,4 +40,22 @@ enum arm64_bp_harden_el1_vectors { EL1_VECTOR_KPTI, }; +/* The vectors to use on return from EL0. e.g. to remap the kernel */ +DECLARE_PER_CPU_READ_MOSTLY(const char *, this_cpu_vector); + +#ifndef CONFIG_UNMAP_KERNEL_AT_EL0 +#define TRAMP_VALIAS 0 +#endif + +static inline const char * +arm64_get_bp_hardening_vector (enum arm64_bp_harden_el1_vectors slot) +{ +if (arm64_kernel_unmapped_at_el0 ()) +return (char *)TRAMP_VALIAS +SZ_2K * slot; + +WARN_ON_ONCE (slot ==EL1_VECTOR_KPTI ); + +return __bp_harden_el1_vectors +SZ_2K * slot; +} +#endif /* __ASM_VECTORS_H */
arch/arm64/kernel/cpufeature.c +11 -0
@@ -10,11 +10,13 @@#include <linux/bsearch.h> #include <linux/cpumask.h> #include <linux/crash_dump.h> +#include <linux/percpu.h> #include <linux/sort.h> #include <linux/stop_machine.h> #include <linux/types.h> #include <linux/mm.h> #include <linux/cpu.h> +#include <asm/cpu.h> #include <asm/cpufeature.h> #include <asm/cpu_ops.h>
@@ -23,6 +25,7 @@#include <asm/processor.h> #include <asm/sysreg.h> #include <asm/traps.h> +#include <asm/vectors.h> #include <asm/virt.h> /* Kernel representation of AT_HWCAP and AT_HWCAP2 */
@@ -45,6 +48,8 @@ static struct arm64_cpu_capabilities const __ro_after_init *cpu_hwcaps_ptrs[ARM6/* Need also bit for ARM64_CB_PATCH */ DECLARE_BITMAP (boot_capabilities,ARM64_NPATCHABLE ); +DEFINE_PER_CPU_READ_MOSTLY(const char *, this_cpu_vector) = vectors; +/* * Flag to indicate if we have computed the system wide * capabilities based on the boot time active CPUs. This
@@ -1047,6 +1052,12 @@ kpti_install_ng_mappings(const struct arm64_cpu_capabilities *__unused)static bool kpti_applied = false;int cpu =smp_processor_id (); +if (__this_cpu_read (this_cpu_vector) == vectors) { +const char *v =arm64_get_bp_hardening_vector (EL1_VECTOR_KPTI ); + +__this_cpu_write (this_cpu_vector, v); + } +/* * We don't need to rewrite the page-tables if either we've done * it already or we have KASLR enabled and therefore have not
arch/arm64/kernel/entry.S +10 -6
@@ -60,7 +60,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
@@ -75,7 +74,6 @@ .endif .Lskip_tramp_vectors_cleanup\@: .endif -#endif sub sp, sp, #S_FRAME_SIZE #ifdef CONFIG_VMAP_STACK
@@ -1129,10 +1127,14 @@ alternative_else_nop_endif .endm .macro tramp_exit, regsize = 64 - adr x30, tramp_vectors -#ifdef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY - add x30, x30, SZ_4K -#endif + 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
@@ -1193,6 +1195,8 @@ __entry_tramp_data_vectors: __entry_tramp_data___sdei_asm_trampoline_next_handler: .quad __sdei_asm_handler #endif /* CONFIG_ARM_SDE_INTERFACE */ +__entry_tramp_data_this_cpu_vector: + .quad this_cpu_vector .popsection // .rodata #endif /* CONFIG_RANDOMIZE_BASE */ #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */
arch/arm64/kvm/hyp/switch.c +6 -2
@@ -25,6 +25,7 @@#include <asm/debug-monitors.h> #include <asm/processor.h> #include <asm/thread_info.h> +#include <asm/vectors.h> extern struct exception_table_entry __start___kvm_ex_table;extern struct exception_table_entry __stop___kvm_ex_table;
@@ -152,7 +153,7 @@ static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu)static void deactivate_traps_vhe (void ) { -extern char vectors[];/* kernel exception vectors */ +const char *host_vectors = vectors;write_sysreg (HCR_HOST_VHE_FLAGS , hcr_el2);/*
@@ -163,7 +164,10 @@ static void deactivate_traps_vhe(void) asm(ALTERNATIVE("nop", "isb", ARM64_WORKAROUND_1165522));write_sysreg (CPACR_EL1_DEFAULT , cpacr_el1); -write_sysreg (vectors, vbar_el1); + +if (!arm64_kernel_unmapped_at_el0 ()) + host_vectors =__this_cpu_read (this_cpu_vector); +write_sysreg (host_vectors, vbar_el1); }NOKPROBE_SYMBOL (deactivate_traps_vhe);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 20/43 arm64: proton-pack: Report Spectre-BHB vulnerabilities as part of Spectre-v2
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit dee435be76f4117410bbd90573a881fd33488f37 upstream.
Speculation attacks against some high-performance processors can make use of branch history to influence future speculation as part of a spectre-v2 attack. This is not mitigated by CSV2, meaning CPUs that previously reported 'Not affected' are now moderately mitigated by CSV2.
Update the value in /sys/devices/system/cpu/vulnerabilities/spectre_v2 to also show the state of the BHB mitigation.
--- arch/arm64/include/asm/cpufeature.h | 9 +++++++ arch/arm64/kernel/cpu_errata.c | 41 ++++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 4 deletions(-)
arch/arm64/include/asm/cpufeature.h +9 -0
@@ -639,6 +639,15 @@ static inline int arm64_get_ssbd_state(void)void arm64_set_ssbd_mitigation (bool state); +/* Watch out, ordering is important here. */ +enum mitigation_state { +SPECTRE_UNAFFECTED , +SPECTRE_MITIGATED , +SPECTRE_VULNERABLE , +}; + +enum mitigation_state arm64_get_spectre_bhb_state (void ); +extern int do_emulate_mrs (struct pt_regs *regs,u32 sys_reg,u32 rt);static inline u32 id_aa64mmfr0_parange_to_phys_shift (int parange)
arch/arm64/kernel/cpu_errata.c +37 -4
55 lines not on this page · raw message
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 21/43 KVM: arm64: Add templates for BHB mitigation sequences
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
KVM writes the Spectre-v2 mitigation template at the beginning of each vector when a CPU requires a specific sequence to run.
Because the template is copied, it can not be modified by the alternatives at runtime.
Add templates for calling ARCH_WORKAROUND_3 and one for each value of K in the brancy-loop. Instead of adding dummy functions for 'fn', which would disable the Spectre-v2 mitigation, add template_start to indicate that a template (and which one) is in use. Finally add a copy of install_bp_hardening_cb() that is able to install these.
--- arch/arm64/include/asm/cpucaps.h | 3 +- arch/arm64/include/asm/kvm_mmu.h | 6 ++- arch/arm64/include/asm/mmu.h | 6 +++ arch/arm64/kernel/cpu_errata.c | 65 +++++++++++++++++++++++++++++++- arch/arm64/kvm/hyp/hyp-entry.S | 54 ++++++++++++++++++++++++++ 5 files changed, 130 insertions(+), 4 deletions(-)
arch/arm64/include/asm/cpucaps.h +2 -1
@@ -55,7 +55,8 @@#define ARM64_WORKAROUND_CAVIUM_TX2_219_TVM 45#define ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM 46#define ARM64_WORKAROUND_1542419 47 +#define ARM64_SPECTRE_BHB 48 -#define ARM64_NCAPS 48 +#define ARM64_NCAPS 49#endif /* __ASM_CPUCAPS_H */
arch/arm64/include/asm/kvm_mmu.h +4 -2
@@ -478,7 +478,8 @@ static inline void *kvm_get_hyp_vector(void)void *vect =kern_hyp_va (kvm_ksym_ref (__kvm_hyp_vector));int slot =-1 ; -if (cpus_have_const_cap (ARM64_HARDEN_BRANCH_PREDICTOR ) && data->fn) { +if ((cpus_have_const_cap (ARM64_HARDEN_BRANCH_PREDICTOR ) || +cpus_have_const_cap (ARM64_SPECTRE_BHB )) && data->template_start) { vect =kern_hyp_va (kvm_ksym_ref (__bp_harden_hyp_vecs_start)); slot = data->hyp_vectors_slot; }
@@ -507,7 +508,8 @@ static inline int kvm_map_vectors(void)* !HBP + HEL2 -> allocate one vector slot and use exec mapping * HBP + HEL2 -> use hardened vertors and use exec mapping */ -if (cpus_have_const_cap (ARM64_HARDEN_BRANCH_PREDICTOR )) { +if (cpus_have_const_cap (ARM64_HARDEN_BRANCH_PREDICTOR ) || +cpus_have_const_cap (ARM64_SPECTRE_BHB )) { __kvm_bp_vect_base =kvm_ksym_ref (__bp_harden_hyp_vecs_start); __kvm_bp_vect_base =kern_hyp_va (__kvm_bp_vect_base); }
arch/arm64/include/asm/mmu.h +6 -0
@@ -82,6 +82,12 @@ typedef void (*bp_hardening_cb_t)(void);struct bp_hardening_data {int hyp_vectors_slot;bp_hardening_cb_t fn; + +/* +* template_start is only used by the BHB mitigation to identify the +* hyp_vectors_slot sequence. +*/ +const char *template_start; }; #if (defined(CONFIG_HARDEN_BRANCH_PREDICTOR) || \
arch/arm64/kernel/cpu_errata.c +64 -1
90 lines not on this page · raw message
arch/arm64/kvm/hyp/hyp-entry.S +54 -0
58 lines not on this page · raw message
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 22/43 arm64: Mitigate spectre style branch history side channels
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit 558c303c9734af5a813739cd284879227f7297d2 upstream.
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 or invalidates the branch history.
The sequence of branches is added to the vectors, and should appear before the first indirect branch. For systems using KPTI the sequence is added to the kpti trampoline where it has a free register as the exit from the trampoline is via a 'ret'. For systems not using KPTI, the same register tricks are used to free up a register in the vectors.
For the firmware call, arch-workaround-3 clobbers 4 registers, so there is no choice but to save them to the EL1 stack. This only happens for entry from EL0, so if we take an exception due to the stack access, it will not become re-entrant.
For KVM, the existing branch-predictor-hardening vectors are used. When a spectre version of these vectors is in use, the firmware call is sufficient to mitigate against Spectre-BHB. For the non-spectre versions, the sequence of branches is added to the indirect vector.
[ modified for stable, moved code to cpu_errata.c removed bitmap of
mitigations, use kvm template infrastructure ]
--- arch/arm64/Kconfig | 9 + arch/arm64/include/asm/assembler.h | 6 +- arch/arm64/include/asm/cpufeature.h | 18 ++ arch/arm64/include/asm/cputype.h | 8 + arch/arm64/include/asm/sysreg.h | 1 + arch/arm64/include/asm/vectors.h | 5 + arch/arm64/kernel/cpu_errata.c | 269 +++++++++++++++++++++++++++- arch/arm64/kvm/hyp/hyp-entry.S | 4 + 8 files changed, 316 insertions(+), 4 deletions(-)
arch/arm64/Kconfig +9 -0
@@ -1139,6 +1139,15 @@ config ARM64_SSBD If unsure, say Y. +config MITIGATE_SPECTRE_BRANCH_HISTORY + bool "Mitigate Spectre style attacks against branch history" if EXPERT + default y + 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. + config RODATA_FULL_DEFAULT_ENABLED bool "Apply r/o permissions of VM areas also to their linear aliases" default y
arch/arm64/include/asm/assembler.h +4 -2
@@ -759,7 +759,9 @@ USER(\label, ic ivau, \tmp2) // invalidate I line PoU .macro __mitigate_spectre_bhb_loop tmp#ifdef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY - mov \tmp, #32 +alternative_cb spectre_bhb_patch_loop_iter + mov \tmp, #32 // Patched to correct the immediate +alternative_cb_end .Lspectre_bhb_loop\@: b . + 4 subs \tmp, \tmp, #1
@@ -774,7 +776,7 @@ USER(\label, ic ivau, \tmp2) // invalidate I line PoU stp x0, x1, [sp, #-16]! stp x2, x3, [sp, #-16]! mov w0, #ARM_SMCCC_ARCH_WORKAROUND_3 -alternative_cb smccc_patch_fw_mitigation_conduit +alternative_cb arm64_update_smccc_conduit nop // Patched to SMC/HVC #0 alternative_cb_end ldp x2, x3, [sp], #16
arch/arm64/include/asm/cpufeature.h +18 -0
@@ -508,6 +508,21 @@ static inline bool cpu_supports_mixed_endian_el0(void)return id_aa64mmfr0_mixed_endian_el0 (read_cpuid (ID_AA64MMFR0_EL1 )); } +static inline bool supports_csv2p3 (int scope) +{ +u64 pfr0; +u8 csv2_val; + +if (scope ==SCOPE_LOCAL_CPU ) + pfr0 =read_sysreg_s (SYS_ID_AA64PFR0_EL1 ); +else + pfr0 =read_sanitised_ftr_reg (SYS_ID_AA64PFR0_EL1 ); + + csv2_val =cpuid_feature_extract_unsigned_field (pfr0, +ID_AA64PFR0_CSV2_SHIFT ); +return csv2_val ==3 ; +} +static inline bool system_supports_32bit_el0 (void ) {return cpus_have_const_cap (ARM64_HAS_32BIT_EL0 );
@@ -647,6 +662,9 @@ enum mitigation_state { };enum mitigation_state arm64_get_spectre_bhb_state (void ); +bool is_spectre_bhb_affected (const struct arm64_cpu_capabilities *entry,int scope); +u8 spectre_bhb_loop_affected (int scope); +void spectre_bhb_enable_mitigation (const struct arm64_cpu_capabilities *__unused);extern int do_emulate_mrs (struct pt_regs *regs,u32 sys_reg,u32 rt);
arch/arm64/include/asm/cputype.h +8 -0
@@ -72,9 +72,13 @@#define ARM_CPU_PART_CORTEX_A76 0xD0B#define ARM_CPU_PART_NEOVERSE_N1 0xD0C#define ARM_CPU_PART_CORTEX_A77 0xD0D +#define ARM_CPU_PART_NEOVERSE_V1 0xD40 +#define ARM_CPU_PART_CORTEX_A78 0xD41 +#define ARM_CPU_PART_CORTEX_X1 0xD44#define ARM_CPU_PART_CORTEX_A710 0xD47#define ARM_CPU_PART_CORTEX_X2 0xD48#define ARM_CPU_PART_NEOVERSE_N2 0xD49 +#define ARM_CPU_PART_CORTEX_A78C 0xD4B#define APM_CPU_PART_POTENZA 0x000
@@ -107,9 +111,13 @@#define MIDR_CORTEX_A76 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A76)#define MIDR_NEOVERSE_N1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N1)#define MIDR_CORTEX_A77 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A77) +#define MIDR_NEOVERSE_V1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_V1) +#define MIDR_CORTEX_A78 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A78) +#define MIDR_CORTEX_X1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X1)#define MIDR_CORTEX_A710 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A710)#define MIDR_CORTEX_X2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_X2)#define MIDR_NEOVERSE_N2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N2) +#define MIDR_CORTEX_A78C MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A78C)#define MIDR_THUNDERX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX)#define MIDR_THUNDERX_81XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_81XX)#define MIDR_THUNDERX_83XX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX_83XX)
arch/arm64/include/asm/sysreg.h +1 -0
@@ -661,6 +661,7 @@#endif /* id_aa64mmfr1 */ +#define ID_AA64MMFR1_ECBHB_SHIFT 60#define ID_AA64MMFR1_PAN_SHIFT 20#define ID_AA64MMFR1_LOR_SHIFT 16#define ID_AA64MMFR1_HPD_SHIFT 12
arch/arm64/include/asm/vectors.h +5 -0
@@ -40,6 +40,11 @@ enum arm64_bp_harden_el1_vectors { EL1_VECTOR_KPTI, }; +#ifndef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY +#define EL1_VECTOR_BHB_LOOP -1 +#define EL1_VECTOR_BHB_FW -1 +#endif /* !CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY */ +/* The vectors to use on return from EL0. e.g. to remap the kernel */ DECLARE_PER_CPU_READ_MOSTLY(const char *, this_cpu_vector);
arch/arm64/kernel/cpu_errata.c +267 -2
303 lines not on this page · raw message
arch/arm64/kvm/hyp/hyp-entry.S +4 -0
@@ -113,6 +113,10 @@ el1_hvc_guest: /* ARM_SMCCC_ARCH_WORKAROUND_2 handling */ eor w1, w1, #(ARM_SMCCC_ARCH_WORKAROUND_1 ^ \ ARM_SMCCC_ARCH_WORKAROUND_2) + cbz w1, wa_epilogue + + eor w1, w1, #(ARM_SMCCC_ARCH_WORKAROUND_2 ^ \ + ARM_SMCCC_ARCH_WORKAROUND_3) cbnz w1, el1_trap #ifdef CONFIG_ARM64_SSBD
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 23/43 KVM: arm64: Allow SMCCC_ARCH_WORKAROUND_3 to be discovered and migrated
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit a5905d6af492ee6a4a2205f0d550b3f931b03d03 upstream.
KVM allows the guest to discover whether the ARCH_WORKAROUND SMCCC are implemented, and to preserve that state during migration through its firmware register interface.
Add the necessary boiler plate for SMCCC_ARCH_WORKAROUND_3.
--- arch/arm/include/asm/kvm_host.h | 7 +++++++ arch/arm/include/uapi/asm/kvm.h | 6 ++++++ arch/arm64/include/asm/kvm_host.h | 5 +++++ arch/arm64/include/uapi/asm/kvm.h | 5 +++++ virt/kvm/arm/psci.c | 34 ++++++++++++++++++++++++++++--- 5 files changed, 54 insertions(+), 3 deletions(-)
arch/arm/include/asm/kvm_host.h +7 -0
@@ -15,6 +15,7 @@#include <asm/kvm_asm.h> #include <asm/kvm_mmio.h> #include <asm/fpstate.h> +#include <asm/spectre.h> #include <kvm/arm_arch_timer.h> #define __KVM_HAVE_ARCH_INTC_INITIALIZED
@@ -424,4 +425,10 @@ static inline bool kvm_arm_vcpu_is_finalized(struct kvm_vcpu *vcpu)#define kvm_arm_vcpu_loaded (vcpu) (false) +static inline int kvm_arm_get_spectre_bhb_state (void ) +{ +/* 32bit guests don't need firmware for this */ +return SPECTRE_VULNERABLE ;/* aka SMCCC_RET_NOT_SUPPORTED */ +} +#endif /* __ARM_KVM_HOST_H__ */
arch/arm/include/uapi/asm/kvm.h +6 -0
@@ -227,6 +227,12 @@ struct kvm_vcpu_events {#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_REQUIRED 3#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_ENABLED (1U << 4) +#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3 KVM_REG_ARM_FW_REG(3) +/* Higher values mean better protection. */ +#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3_NOT_AVAIL 0 +#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3_AVAIL 1 +#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3_NOT_REQUIRED 2 +/* Device Control API: ARM VGIC */ #define KVM_DEV_ARM_VGIC_GRP_ADDR 0#define KVM_DEV_ARM_VGIC_GRP_DIST_REGS 1
arch/arm64/include/asm/kvm_host.h +5 -0
@@ -684,4 +684,9 @@ bool kvm_arm_vcpu_is_finalized(struct kvm_vcpu *vcpu);#define kvm_arm_vcpu_loaded (vcpu) ((vcpu)->arch.sysregs_loaded_on_cpu) +static inline enum mitigation_state kvm_arm_get_spectre_bhb_state (void ) +{ +return arm64_get_spectre_bhb_state (); +} +#endif /* __ARM64_KVM_HOST_H__ */
arch/arm64/include/uapi/asm/kvm.h +5 -0
@@ -240,6 +240,11 @@ struct kvm_vcpu_events {#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_REQUIRED 3#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_ENABLED (1U << 4) +#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3 KVM_REG_ARM_FW_REG(3) +#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3_NOT_AVAIL 0 +#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3_AVAIL 1 +#define KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3_NOT_REQUIRED 2 +/* SVE registers */ #define KVM_REG_ARM64_SVE (0x15 << KVM_REG_ARM_COPROC_SHIFT)
virt/kvm/arm/psci.c +31 -3
@@ -426,6 +426,18 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)break ; }break ; +case ARM_SMCCC_ARCH_WORKAROUND_3 : +switch (kvm_arm_get_spectre_bhb_state ()) { +case SPECTRE_VULNERABLE : +break ; +case SPECTRE_MITIGATED : + val =SMCCC_RET_SUCCESS ; +break ; +case SPECTRE_UNAFFECTED : + val =SMCCC_ARCH_WORKAROUND_RET_UNAFFECTED ; +break ; + } +break ; }break ;default :
@@ -438,7 +450,7 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)int kvm_arm_get_fw_num_regs (struct kvm_vcpu *vcpu) { -return 3 ;/* PSCI version and two workaround registers */ +return 4 ;/* PSCI version and three workaround registers */ }int kvm_arm_copy_fw_reg_indices (struct kvm_vcpu *vcpu,u64 __user *uindices)
@@ -452,6 +464,9 @@ int kvm_arm_copy_fw_reg_indices(struct kvm_vcpu *vcpu, u64 __user *uindices)if (put_user (KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2 , uindices++))return -EFAULT ; +if (put_user (KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3 , uindices++)) +return -EFAULT ; +return 0 ; }
@@ -486,9 +501,20 @@ static int get_kernel_wa_level(u64 regid)return KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_NOT_REQUIRED ;case KVM_SSBD_UNKNOWN :default : -return KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_UNKNOWN ; +break ; } - } +return KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2_UNKNOWN ; +case KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3 : +switch (kvm_arm_get_spectre_bhb_state ()) { +case SPECTRE_VULNERABLE : +return KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3_NOT_AVAIL ; +case SPECTRE_MITIGATED : +return KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3_AVAIL ; +case SPECTRE_UNAFFECTED : +return KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3_NOT_REQUIRED ; + } +return KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3_NOT_AVAIL ; + }return -EINVAL ; }
@@ -503,6 +529,7 @@ int kvm_arm_get_fw_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) val =kvm_psci_version (vcpu, vcpu->kvm);break ;case KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1 : +case KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3 : val =get_kernel_wa_level (reg->id) &KVM_REG_FEATURE_LEVEL_MASK ;break ;case KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_2 :
@@ -555,6 +582,7 @@ int kvm_arm_set_fw_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg) }case KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_1 : +case KVM_REG_ARM_SMCCC_ARCH_WORKAROUND_3 :if (val & ~KVM_REG_FEATURE_LEVEL_MASK )return -EINVAL ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 24/43 arm64: Use the clearbhb instruction in mitigations
In reply to Greg Kroah-HartmanFrom: James Morse <[email protected]>
commit 228a26b912287934789023b4132ba76065d9491c upstream.
Future CPUs may implement a clearbhb instruction that is sufficient to mitigate SpectreBHB. CPUs that implement this instruction, but not CSV2.3 must be affected by Spectre-BHB.
Add support to use this instruction as the BHB mitigation on CPUs that support it. The instruction is in the hint space, so it will be treated by a NOP as older CPUs.
[ modified for stable: Use a KVM vector template instead of alternatives,
removed bitmap of mitigations ]
--- arch/arm64/include/asm/assembler.h | 7 +++++++ arch/arm64/include/asm/cpufeature.h | 13 +++++++++++++ arch/arm64/include/asm/sysreg.h | 1 + arch/arm64/include/asm/vectors.h | 7 +++++++ arch/arm64/kernel/cpu_errata.c | 14 ++++++++++++++ arch/arm64/kernel/cpufeature.c | 1 + arch/arm64/kernel/entry.S | 8 ++++++++ arch/arm64/kvm/hyp/hyp-entry.S | 6 ++++++ 8 files changed, 57 insertions(+)
arch/arm64/include/asm/assembler.h +7 -0
@@ -110,6 +110,13 @@ hint #20 .endm +/* +* Clear Branch History instruction +*/ + .macro clearbhb + hint #22 + .endm +/* * Speculation barrier */
arch/arm64/include/asm/cpufeature.h +13 -0
@@ -523,6 +523,19 @@ static inline bool supports_csv2p3(int scope)return csv2_val ==3 ; } +static inline bool supports_clearbhb (int scope) +{ +u64 isar2; + +if (scope ==SCOPE_LOCAL_CPU ) + isar2 =read_sysreg_s (SYS_ID_AA64ISAR2_EL1 ); +else + isar2 =read_sanitised_ftr_reg (SYS_ID_AA64ISAR2_EL1 ); + +return cpuid_feature_extract_unsigned_field (isar2, +ID_AA64ISAR2_CLEARBHB_SHIFT ); +} +static inline bool system_supports_32bit_el0 (void ) {return cpus_have_const_cap (ARM64_HAS_32BIT_EL0 );
arch/arm64/include/asm/sysreg.h +1 -0
@@ -577,6 +577,7 @@#define ID_AA64ISAR1_GPI_IMP_DEF 0x1/* id_aa64isar2 */ +#define ID_AA64ISAR2_CLEARBHB_SHIFT 28#define ID_AA64ISAR2_RPRES_SHIFT 4#define ID_AA64ISAR2_WFXT_SHIFT 0
arch/arm64/include/asm/vectors.h +7 -0
@@ -32,6 +32,12 @@ enum arm64_bp_harden_el1_vectors {* canonical vectors. */ EL1_VECTOR_BHB_FW , + +/* +* Use the ClearBHB instruction, before branching to the canonical +* vectors. +*/ + EL1_VECTOR_BHB_CLEAR_INSN, #endif /* CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY *//*
@@ -43,6 +49,7 @@ enum arm64_bp_harden_el1_vectors {#ifndef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY #define EL1_VECTOR_BHB_LOOP -1#define EL1_VECTOR_BHB_FW -1 +#define EL1_VECTOR_BHB_CLEAR_INSN -1#endif /* !CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY */ /* The vectors to use on return from EL0. e.g. to remap the kernel */
arch/arm64/kernel/cpu_errata.c +14 -0
@@ -125,6 +125,8 @@ extern char __spectre_bhb_loop_k24_start[];extern char __spectre_bhb_loop_k24_end[];extern char __spectre_bhb_loop_k32_start[];extern char __spectre_bhb_loop_k32_end[]; +extern char __spectre_bhb_clearbhb_start[]; +extern char __spectre_bhb_clearbhb_end[];static void __copy_hyp_vect_bpi (int slot,const char *hyp_vecs_start,const char *hyp_vecs_end)
@@ -1086,6 +1088,7 @@ static void update_mitigation_state(enum mitigation_state *oldp,* - Mitigated by a branchy loop a CPU specific number of times, and listed * in our "loop mitigated list". * - Mitigated in software by the firmware Spectre v2 call. +* - Has the ClearBHB instruction to perform the mitigation. * - Has the 'Exception Clears Branch History Buffer' (ECBHB) feature, so no * software mitigation in the vectors is needed. * - Has CSV2.3, so is unaffected.
@@ -1226,6 +1229,9 @@ bool is_spectre_bhb_affected(const struct arm64_cpu_capabilities *entry,if (supports_csv2p3 (scope))return false; +if (supports_clearbhb (scope)) +return true; +if (spectre_bhb_loop_affected (scope))return true;
@@ -1266,6 +1272,8 @@ static const char *kvm_bhb_get_vecs_end(const char *start)return __spectre_bhb_loop_k24_end; else if (start == __spectre_bhb_loop_k32_start) return __spectre_bhb_loop_k32_end; + else if (start == __spectre_bhb_clearbhb_start) + return __spectre_bhb_clearbhb_end;return NULL ; }
@@ -1305,6 +1313,7 @@ static void kvm_setup_bhb_slot(const char *hyp_vecs_start)#define __spectre_bhb_loop_k8_start NULL#define __spectre_bhb_loop_k24_start NULL#define __spectre_bhb_loop_k32_start NULL +#define __spectre_bhb_clearbhb_start NULLstatic void kvm_setup_bhb_slot (const char *hyp_vecs_start) { }#endif
@@ -1323,6 +1332,11 @@ void spectre_bhb_enable_mitigation(const struct arm64_cpu_capabilities *entry) }else if (cpu_mitigations_off ()) {pr_info_once ("spectre-bhb mitigation disabled by command line option\n" ); }else if (supports_ecbhb (SCOPE_LOCAL_CPU )) { + state =SPECTRE_MITIGATED ; + }else if (supports_clearbhb (SCOPE_LOCAL_CPU )) { +kvm_setup_bhb_slot (__spectre_bhb_clearbhb_start); +this_cpu_set_vectors (EL1_VECTOR_BHB_CLEAR_INSN ); + state =SPECTRE_MITIGATED ; }else if (spectre_bhb_loop_affected (SCOPE_LOCAL_CPU )) {switch (spectre_bhb_loop_affected (SCOPE_SYSTEM )) {
arch/arm64/kernel/cpufeature.c +1 -0
@@ -156,6 +156,7 @@ static const struct arm64_ftr_bits ftr_id_aa64isar1[] = { };static const struct arm64_ftr_bits ftr_id_aa64isar2[] = { +ARM64_FTR_BITS (FTR_HIDDEN ,FTR_STRICT ,FTR_HIGHER_SAFE ,ID_AA64ISAR2_CLEARBHB_SHIFT ,4 ,0 ),ARM64_FTR_END , };
arch/arm64/kernel/entry.S +8 -0
@@ -1074,6 +1074,7 @@ alternative_else_nop_endif #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
@@ -1090,6 +1091,11 @@ alternative_else_nop_endif __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
@@ -1170,6 +1176,7 @@ ENTRY(tramp_vectors) #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)
@@ -1232,6 +1239,7 @@ SYM_CODE_START(__bp_harden_el1_vectors) #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 */ SYM_CODE_END(__bp_harden_el1_vectors) .popsection
arch/arm64/kvm/hyp/hyp-entry.S +6 -0
@@ -405,4 +405,10 @@ ENTRY(__spectre_bhb_loop_k32_start) ldp x0, x1, [sp, #(8 * 0)] add sp, sp, #(8 * 2) ENTRY(__spectre_bhb_loop_k32_end) + +ENTRY(__spectre_bhb_clearbhb_start) + esb + clearbhb + isb +ENTRY(__spectre_bhb_clearbhb_end) #endif
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 25/43 xfrm: Check if_id in xfrm_migrate
In reply to Greg Kroah-HartmanFrom: Yan Yan <[email protected]>
[ Upstream commit c1aca3080e382886e2e58e809787441984a2f89b ]
This patch enables distinguishing SAs and SPs based on if_id during the xfrm_migrate flow. This ensures support for xfrm interfaces throughout the SA/SP lifecycle.
When there are multiple existing SPs with the same direction, the same xfrm_selector and different endpoint addresses, xfrm_migrate might fail with ENODATA.
Specifically, the code path for performing xfrm_migrate is:
Stage 1: find policy to migrate with
xfrm_migrate_policy_find(sel, dir, type, net)
Stage 2: find and update state(s) with
xfrm_migrate_state_find(mp, net)
Stage 3: update endpoint address(es) of template(s) with
xfrm_policy_migrate(pol, m, num_migrate)
Currently "Stage 1" always returns the first xfrm_policy that matches, and "Stage 3" looks for the xfrm_tmpl that matches the old endpoint address. Thus if there are multiple xfrm_policy with same selector, direction, type and net, "Stage 1" might rertun a wrong xfrm_policy and "Stage 3" will fail with ENODATA because it cannot find a xfrm_tmpl with the matching endpoint address.
The fix is to allow userspace to pass an if_id and add if_id to the matching rule in Stage 1 and Stage 2 since if_id is a unique ID for xfrm_policy and xfrm_state. For compatibility, if_id will only be checked if the attribute is set.
Tested with additions to Android's kernel unit test suite:
https://android-review.googlesource.com/c/kernel/tests/+/1668886
--- include/net/xfrm.h | 5 +++-- net/key/af_key.c | 2 +- net/xfrm/xfrm_policy.c | 14 ++++++++------ net/xfrm/xfrm_state.c | 7 ++++++- net/xfrm/xfrm_user.c | 6 +++++- 5 files changed, 23 insertions(+), 11 deletions(-)
include/net/xfrm.h +3 -2
@@ -1663,14 +1663,15 @@ int km_migrate(const struct xfrm_selector *sel, u8 dir, u8 type, const struct xfrm_migrate *m, int num_bundles, const struct xfrm_kmaddress *k, const struct xfrm_encap_tmpl *encap); -struct xfrm_state *xfrm_migrate_state_find (struct xfrm_migrate *m,struct net *net); +struct xfrm_state *xfrm_migrate_state_find (struct xfrm_migrate *m,struct net *net, +u32 if_id);struct xfrm_state *xfrm_state_migrate (struct xfrm_state *x,struct xfrm_migrate *m,struct xfrm_encap_tmpl *encap);int xfrm_migrate (const struct xfrm_selector *sel,u8 dir,u8 type,struct xfrm_migrate *m,int num_bundles,struct xfrm_kmaddress *k,struct net *net, -struct xfrm_encap_tmpl *encap); +struct xfrm_encap_tmpl *encap,u32 if_id);#endif int km_new_mapping (struct xfrm_state *x,xfrm_address_t *ipaddr,__be16 sport);
net/key/af_key.c +1 -1
@@ -2627,7 +2627,7 @@ static int pfkey_migrate(struct sock *sk, struct sk_buff *skb, }return xfrm_migrate (&sel, dir,XFRM_POLICY_TYPE_MAIN , m, i, - kma ? &k :NULL , net,NULL ); + kma ? &k :NULL , net,NULL ,0 ); out:return err;
net/xfrm/xfrm_policy.c +8 -6
@@ -4271,7 +4271,7 @@ static bool xfrm_migrate_selector_match(const struct xfrm_selector *sel_cmp, }static struct xfrm_policy *xfrm_migrate_policy_find (const struct xfrm_selector *sel, -u8 dir,u8 type,struct net *net) +u8 dir,u8 type,struct net *net,u32 if_id) {struct xfrm_policy *pol, *ret =NULL ;struct hlist_head *chain;
@@ -4280,7 +4280,8 @@ static struct xfrm_policy *xfrm_migrate_policy_find(const struct xfrm_selector *spin_lock_bh (&net->xfrm.xfrm_policy_lock); chain =policy_hash_direct (net, &sel->daddr, &sel->saddr, sel->family, dir);hlist_for_each_entry (pol, chain, bydst) { -if (xfrm_migrate_selector_match (sel, &pol->selector) && +if ((if_id ==0 || pol->if_id == if_id) && +xfrm_migrate_selector_match (sel, &pol->selector) && pol->type == type) { ret = pol; priority = ret->priority;
@@ -4292,7 +4293,8 @@ static struct xfrm_policy *xfrm_migrate_policy_find(const struct xfrm_selector *if ((pol->priority >= priority) && ret)break ; -if (xfrm_migrate_selector_match (sel, &pol->selector) && +if ((if_id ==0 || pol->if_id == if_id) && +xfrm_migrate_selector_match (sel, &pol->selector) && pol->type == type) { ret = pol;break ;
@@ -4408,7 +4410,7 @@ static int xfrm_migrate_check(const struct xfrm_migrate *m, int num_migrate)int xfrm_migrate (const struct xfrm_selector *sel,u8 dir,u8 type,struct xfrm_migrate *m,int num_migrate,struct xfrm_kmaddress *k,struct net *net, -struct xfrm_encap_tmpl *encap) +struct xfrm_encap_tmpl *encap,u32 if_id) {int i, err, nx_cur =0 , nx_new =0 ;struct xfrm_policy *pol =NULL ;
@@ -4427,14 +4429,14 @@ int xfrm_migrate(const struct xfrm_selector *sel, u8 dir, u8 type, }/* Stage 1 - find policy */ -if ((pol =xfrm_migrate_policy_find (sel, dir, type, net)) ==NULL ) { +if ((pol =xfrm_migrate_policy_find (sel, dir, type, net, if_id)) ==NULL ) { err = -ENOENT ; goto out; }/* Stage 2 - find and update state(s) */ for (i =0 , mp = m; i < num_migrate; i++, mp++) { -if ((x =xfrm_migrate_state_find (mp, net))) { +if ((x =xfrm_migrate_state_find (mp, net, if_id))) { x_cur[nx_cur] = x; nx_cur++; xc =xfrm_state_migrate (x, mp, encap);
net/xfrm/xfrm_state.c +6 -1
@@ -1563,7 +1563,8 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,return NULL ; } -struct xfrm_state *xfrm_migrate_state_find (struct xfrm_migrate *m,struct net *net) +struct xfrm_state *xfrm_migrate_state_find (struct xfrm_migrate *m,struct net *net, +u32 if_id) {unsigned int h;struct xfrm_state *x =NULL ;
@@ -1579,6 +1580,8 @@ struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *ncontinue ;if (m->reqid && x->props.reqid != m->reqid)continue ; +if (if_id !=0 && x->if_id != if_id) +continue ;if (!xfrm_addr_equal (&x->id.daddr, &m->old_daddr, m->old_family) || !xfrm_addr_equal(&x->props.saddr, &m->old_saddr,
@@ -1594,6 +1597,8 @@ struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *nif (x->props.mode != m->mode || x->id.proto != m->proto)continue ; +if (if_id !=0 && x->if_id != if_id) +continue ;if (!xfrm_addr_equal (&x->id.daddr, &m->old_daddr, m->old_family) || !xfrm_addr_equal(&x->props.saddr, &m->old_saddr,
net/xfrm/xfrm_user.c +5 -1
@@ -2374,6 +2374,7 @@ static int xfrm_do_migrate(struct sk_buff *skb, struct nlmsghdr *nlh,int n =0 ;struct net *net =sock_net (skb->sk);struct xfrm_encap_tmpl *encap =NULL ; +u32 if_id =0 ;if (attrs[XFRMA_MIGRATE ] ==NULL )return -EINVAL ;
@@ -2398,7 +2399,10 @@ static int xfrm_do_migrate(struct sk_buff *skb, struct nlmsghdr *nlh,return 0 ; } - err =xfrm_migrate (&pi->sel, pi->dir, type, m, n, kmp, net, encap); +if (attrs[XFRMA_IF_ID ]) + if_id =nla_get_u32 (attrs[XFRMA_IF_ID ]); + + err =xfrm_migrate (&pi->sel, pi->dir, type, m, n, kmp, net, encap, if_id);kfree (encap);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 26/43 xfrm: Fix xfrm migrate issues when address family changes
In reply to Greg Kroah-HartmanFrom: Yan Yan <[email protected]>
[ Upstream commit e03c3bba351f99ad932e8f06baa9da1afc418e02 ]
xfrm_migrate cannot handle address family change of an xfrm_state. The symptons are the xfrm_state will be migrated to a wrong address, and sending as well as receiving packets wil be broken.
This commit fixes it by breaking the original xfrm_state_clone method into two steps so as to update the props.family before running xfrm_init_state. As the result, xfrm_state's inner mode, outer mode, type and IP header length in xfrm_state_migrate can be updated with the new address family.
Tested with additions to Android's kernel unit test suite:
https://android-review.googlesource.com/c/kernel/tests/+/1885354
--- net/xfrm/xfrm_state.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/xfrm/xfrm_state.c +5 -3
@@ -1539,9 +1539,6 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig,memcpy (&x->mark, &orig->mark,sizeof (x->mark));memcpy (&x->props.smark, &orig->props.smark,sizeof (x->props.smark)); -if (xfrm_init_state (x) <0 ) - goto error; - x->props.flags = orig->props.flags; x->props.extra_flags = orig->props.extra_flags;
@@ -1625,6 +1622,11 @@ struct xfrm_state *xfrm_state_migrate(struct xfrm_state *x,if (!xc)return NULL ; + xc->props.family = m->new_family; + +if (xfrm_init_state (xc) <0 ) + goto error; +memcpy (&xc->id.daddr, &m->new_daddr,sizeof (xc->id.daddr));memcpy (&xc->props.saddr, &m->new_saddr,sizeof (xc->props.saddr));
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 27/43 arm64: dts: rockchip: fix rk3399-puma eMMC HS400 signal integrity
In reply to Greg Kroah-HartmanFrom: Jakob Unterwurzacher <[email protected]>
[ Upstream commit 62966cbdda8a92f82d966a45aa671e788b2006f7 ]
There are signal integrity issues running the eMMC at 200MHz on Puma RK3399-Q7.
Similar to the work-around found for RK3399 Gru boards, lowering the frequency to 100MHz made the eMMC much more stable, so let's lower the frequency to 100MHz.
It might be possible to run at 150MHz as on RK3399 Gru boards but only 100MHz was extensively tested.
--- arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi +6 -0
@@ -467,6 +467,12 @@ }; &sdhci { + /* + * Signal integrity isn't great at 200MHz but 100MHz has proven stable + * enough. + */ + max-frequency = <100000000>; + bus-width = <8>; mmc-hs400-1_8v; mmc-hs400-enhanced-strobe;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 28/43 arm64: dts: rockchip: reorder rk3399 hdmi clocks
In reply to Greg Kroah-HartmanFrom: Sascha Hauer <[email protected]>
[ Upstream commit 2e8a8b5955a000cc655f7e368670518cbb77fe58 ]
The binding specifies the clock order to "cec", "grf", "vpll". Reorder the clocks accordingly.
--- arch/arm64/boot/dts/rockchip/rk3399.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/rockchip/rk3399.dtsi +3 -3
@@ -1746,10 +1746,10 @@ interrupts = <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH 0>; clocks = <&cru PCLK_HDMI_CTRL>, <&cru SCLK_HDMI_SFR>, - <&cru PLL_VPLL>, + <&cru SCLK_HDMI_CEC>, <&cru PCLK_VIO_GRF>, - <&cru SCLK_HDMI_CEC>; - clock-names = "iahb", "isfr", "vpll", "grf", "cec"; + <&cru PLL_VPLL>; + clock-names = "iahb", "isfr", "cec", "grf", "vpll"; power-domains = <&power RK3399_PD_HDCP>; reg-io-width = <4>; rockchip,grf = <&grf>;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 29/43 arm64: dts: agilex: use the compatible "intel,socfpga-agilex-hsotg"
In reply to Greg Kroah-HartmanFrom: Dinh Nguyen <[email protected]>
[ Upstream commit 268a491aebc25e6dc7c618903b09ac3a2e8af530 ]
The DWC2 USB controller on the Agilex platform does not support clock gating, so use the chip specific "intel,socfpga-agilex-hsotg" compatible.
--- arch/arm64/boot/dts/intel/socfpga_agilex.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/intel/socfpga_agilex.dtsi +2 -2
@@ -369,7 +369,7 @@ }; usb0: usb@ffb00000 { - compatible = "snps,dwc2"; + compatible = "intel,socfpga-agilex-hsotg", "snps,dwc2"; reg = <0xffb00000 0x40000>; interrupts = <0 93 4>; phys = <&usbphy0>;
@@ -381,7 +381,7 @@ }; usb1: usb@ffb40000 { - compatible = "snps,dwc2"; + compatible = "intel,socfpga-agilex-hsotg", "snps,dwc2"; reg = <0xffb40000 0x40000>; interrupts = <0 94 4>; phys = <&usbphy0>;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 30/43 ARM: dts: rockchip: reorder rk322x hmdi clocks
In reply to Greg Kroah-HartmanFrom: Sascha Hauer <[email protected]>
[ Upstream commit be4e65bdffab5f588044325117df77dad7e9c45a ]
The binding specifies the clock order to "iahb", "isfr", "cec". Reorder the clocks accordingly.
--- arch/arm/boot/dts/rk322x.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/boot/dts/rk322x.dtsi +2 -2
@@ -635,8 +635,8 @@ interrupts = <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>; assigned-clocks = <&cru SCLK_HDMI_PHY>; assigned-clock-parents = <&hdmi_phy>; - clocks = <&cru SCLK_HDMI_HDCP>, <&cru PCLK_HDMI_CTRL>, <&cru SCLK_HDMI_CEC>; - clock-names = "isfr", "iahb", "cec"; + clocks = <&cru PCLK_HDMI_CTRL>, <&cru SCLK_HDMI_HDCP>, <&cru SCLK_HDMI_CEC>; + clock-names = "iahb", "isfr", "cec"; pinctrl-names = "default"; pinctrl-0 = <&hdmii2c_xfer &hdmi_hpd &hdmi_cec>; resets = <&cru SRST_HDMI_P>;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 31/43 ARM: dts: rockchip: fix a typo on rk3288 crypto-controller
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
[ Upstream commit 3916c3619599a3970d3e6f98fb430b7c46266ada ]
crypto-controller had a typo, fix it.
In the same time, rename it to just crypto
--- arch/arm/boot/dts/rk3288.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/rk3288.dtsi +1 -1
@@ -975,7 +975,7 @@ status = "disabled"; }; - crypto: cypto-controller@ff8a0000 { + crypto: crypto@ff8a0000 { compatible = "rockchip,rk3288-crypto"; reg = <0x0 0xff8a0000 0x0 0x4000>; interrupts = <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 32/43 mac80211: refuse aggregations sessions before authorized
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit a6bce78262f5dd4b50510f0aa47f3995f7b185f3 ]
If an MFP station isn't authorized, the receiver will (or at least should) drop the action frame since it's a robust management frame, but if we're not authorized we haven't installed keys yet. Refuse attempts to start a session as they'd just time out.
--- net/mac80211/agg-tx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
net/mac80211/agg-tx.c +9 -1
@@ -9,7 +9,7 @@* Copyright 2007, Michael Wu <[email protected]> * Copyright 2007-2010, Intel Corporation * Copyright(c) 2015-2017 Intel Deutschland GmbH -* Copyright (C) 2018 - 2021 Intel Corporation +* Copyright (C) 2018 - 2022 Intel Corporation */ #include <linux/ieee80211.h>
@@ -615,6 +615,14 @@ int ieee80211_start_tx_ba_session(struct ieee80211_sta *pubsta, u16 tid,return -EINVAL ; } +if (test_sta_flag (sta,WLAN_STA_MFP ) && + !test_sta_flag (sta,WLAN_STA_AUTHORIZED )) { +ht_dbg (sdata, +"MFP STA not authorized - deny BA session request %pM tid %d\n" , + sta->sta.addr, tid); +return -EINVAL ; + } +/* * 802.11n-2009 11.5.1.1: If the initiating STA is an HT STA, is a * member of an IBSS, and has no other existing Block Ack agreement
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 33/43 MIPS: smp: fill in sibling and core maps earlier
In reply to Greg Kroah-HartmanFrom: Alexander Lobakin <[email protected]>
[ Upstream commit f2703def339c793674010cc9f01bfe4980231808 ]
After enabling CONFIG_SCHED_CORE (landed during 5.14 cycle), 2-core 2-thread-per-core interAptiv (CPS-driven) started emitting the following:
[ 0.025698] CPU1 revision is: 0001a120 (MIPS interAptiv (multi)) [ 0.048183] ------------[ cut here ]------------ [ 0.048187] WARNING: CPU: 1 PID: 0 at kernel/sched/core.c:6025 sched_core_cpu_starting+0x198/0x240 [ 0.048220] Modules linked in: [ 0.048233] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 5.17.0-rc3+ #35 b7b319f24073fd9a3c2aa7ad15fb7993eec0b26f [ 0.048247] Stack : 817f0000 00000004 327804c8 810eb050 00000000 00000004 00000000 c314fdd1 [ 0.048278] 830cbd64 819c0000 81800000 817f0000 83070bf4 00000001 830cbd08 00000000 [ 0.048307] 00000000 00000000 815fcbc4 00000000 00000000 00000000 00000000 00000000 [ 0.048334] 00000000 00000000 00000000 00000000 817f0000 00000000 00000000 817f6f34 [ 0.048361] 817f0000 818a3c00 817f0000 00000004 00000000 00000000 4dc33260 0018c933 [ 0.048389] ... [ 0.048396] Call Trace: [ 0.048399] [<8105a7bc>] show_stack+0x3c/0x140 [ 0.048424] [<8131c2a0>] dump_stack_lvl+0x60/0x80 [ 0.048440] [<8108b5c0>] __warn+0xc0/0xf4 [ 0.048454] [<8108b658>] warn_slowpath_fmt+0x64/0x10c [ 0.048467] [<810bd418>] sched_core_cpu_starting+0x198/0x240 [ 0.048483] [<810c6514>] sched_cpu_starting+0x14/0x80 [ 0.048497] [<8108c0f8>] cpuhp_invoke_callback_range+0x78/0x140 [ 0.048510] [<8108d914>] notify_cpu_starting+0x94/0x140 [ 0.048523] [<8106593c>] start_secondary+0xbc/0x280 [ 0.048539] [ 0.048543] ---[ end trace 0000000000000000 ]--- [ 0.048636] Synchronize counters for CPU 1: done.
...for each but CPU 0/boot.
Basic debug printks right before the mentioned line say:
[ 0.048170] CPU: 1, smt_mask:
So smt_mask, which is sibling mask obviously, is empty when entering the function.
This is critical, as sched_core_cpu_starting() calculates core-scheduling parameters only once per CPU start, and it's crucial to have all the parameters filled in at that moment (at least it uses cpu_smt_mask() which in fact is &cpu_sibling_map[cpu] on MIPS).
A bit of debugging led me to that set_cpu_sibling_map() performing the actual map calculation, was being invocated after notify_cpu_start(), and exactly the latter function starts CPU HP callback round (sched_core_cpu_starting() is basically a CPU HP callback).
While the flow is same on ARM64 (maps after the notifier, although before calling set_cpu_online()), x86 started calculating sibling maps earlier than starting the CPU HP callbacks in Linux 4.14 (see
[0] for the reference). Neither me nor my brief tests couldn't find any potential caveats in calculating the maps right after performing delay calibration, but the WARN splat is now gone.
The very same debug prints now yield exactly what I expected from them:
[ 0.048433] CPU: 1, smt_mask: 0-1
[0] https://git.kernel.org/pub/scm/linux/kernel/git/mips/linux.git/commit/?id=76ce7cfe35ef
--- arch/mips/kernel/smp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/mips/kernel/smp.c +3 -3
@@ -361,6 +361,9 @@ asmlinkage void start_secondary(void) cpu =smp_processor_id (); cpu_data[cpu].udelay_val = loops_per_jiffy; +set_cpu_sibling_map (cpu); +set_cpu_core_map (cpu); +cpumask_set_cpu (cpu, &cpu_coherent_mask);notify_cpu_starting (cpu);
@@ -372,9 +375,6 @@ asmlinkage void start_secondary(void)/* The CPU is running and counters synchronised, now mark it online */ set_cpu_online (cpu, true); -set_cpu_sibling_map (cpu); -set_cpu_core_map (cpu); -calculate_cpu_foreign_map ();/*
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 34/43 ARM: 9178/1: fix unmet dependency on BITREVERSE for HAVE_ARCH_BITREVERSE
In reply to Greg Kroah-HartmanFrom: Julian Braha <[email protected]>
[ Upstream commit 11c57c3ba94da74c3446924260e34e0b1950b5d7 ]
Resending this to properly add it to the patch tracker - thanks for letting me know, Arnd :)
When ARM is enabled, and BITREVERSE is disabled,Kbuild gives the following warning:
WARNING: unmet direct dependencies detected for HAVE_ARCH_BITREVERSE
Depends on [n]: BITREVERSE [=n]
Selected by [y]:
- ARM [=y] && (CPU_32v7M [=n] || CPU_32v7 [=y]) && !CPU_32v6 [=n]
This is because ARM selects HAVE_ARCH_BITREVERSE
without selecting BITREVERSE, despiteHAVE_ARCH_BITREVERSE depending on BITREVERSE.
This unmet dependency bug was found by Kismet,
a static analysis tool for Kconfig. Please advise if this is not the appropriate solution.
--- lib/Kconfig | 1 - 1 file changed, 1 deletion(-)
lib/Kconfig +0 -1
@@ -42,7 +42,6 @@ config BITREVERSE config HAVE_ARCH_BITREVERSE bool default n - depends on BITREVERSE help This option enables the use of hardware bit-reversal instructions on architectures which support such operations.
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 35/43 can: rcar_canfd: rcar_canfd_channel_probe(): register the CAN device when fully ready
In reply to Greg Kroah-HartmanFrom: Lad Prabhakar <[email protected]>
[ Upstream commit c5048a7b2c23ab589f3476a783bd586b663eda5b ]
Register the CAN device only when all the necessary initialization is completed. This patch makes sure all the data structures and locks are initialized before registering the CAN device.
--- drivers/net/can/rcar/rcar_canfd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/can/rcar/rcar_canfd.c +3 -3
@@ -1598,15 +1598,15 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch,netif_napi_add (ndev, &priv->napi, rcar_canfd_rx_poll,RCANFD_NAPI_WEIGHT ); +spin_lock_init (&priv->tx_lock); +devm_can_led_init (ndev); + gpriv->ch[priv->channel] = priv; err =register_candev (ndev);if (err) {dev_err (&pdev->dev,"register_candev() failed, error %d\n" , err); goto fail_candev; } -spin_lock_init (&priv->tx_lock); -devm_can_led_init (ndev); - gpriv->ch[priv->channel] = priv;dev_info (&pdev->dev,"device registered (channel %u)\n" , priv->channel);return 0 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 36/43 atm: firestream: check the return value of ioremap() in fs_init()
In reply to Greg Kroah-HartmanFrom: Jia-Ju Bai <[email protected]>
[ Upstream commit d4e26aaea7f82ba884dcb4acfe689406bc092dc3 ]
The function ioremap() in fs_init() can fail, so its return value should be checked.
--- drivers/atm/firestream.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/atm/firestream.c +2 -0
@@ -1677,6 +1677,8 @@ static int fs_init(struct fs_dev *dev) dev->hw_base =pci_resource_start (pci_dev,0 ); dev->base =ioremap (dev->hw_base,0x1000 ); +if (!dev->base) +return 1 ;reset_chip (dev);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 37/43 iwlwifi: dont advertise TWT support
In reply to Greg Kroah-HartmanFrom: Golan Ben Ami <[email protected]>
[ Upstream commit 1db5fcbba2631277b78d7f8aff99c9607d29f6d8 ]
Some APs misbehave when TWT is used and cause our firmware to crash. We don't know a reasonable way to detect and work around this problem in the FW yet. To prevent these crashes, disable TWT in the driver by stopping to advertise TWT support.
--- drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c | 3 +-- drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 1 - 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c +1 -2
@@ -519,8 +519,7 @@ static struct ieee80211_sband_iftype_data iwl_he_capa[] = { .has_he = true, .he_cap_elem = { .mac_cap_info[0 ] = -IEEE80211_HE_MAC_CAP0_HTC_HE | - IEEE80211_HE_MAC_CAP0_TWT_REQ, + IEEE80211_HE_MAC_CAP0_HTC_HE, .mac_cap_info[1 ] =IEEE80211_HE_MAC_CAP1_TF_MAC_PAD_DUR_16US | IEEE80211_HE_MAC_CAP1_MULTI_TID_AGG_RX_QOS_8,
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +0 -1
@@ -343,7 +343,6 @@ const static u8 he_if_types_ext_capa_sta[] = { [0] = WLAN_EXT_CAPA1_EXT_CHANNEL_SWITCHING, [2] = WLAN_EXT_CAPA3_MULTI_BSSID_SUPPORT, [7] = WLAN_EXT_CAPA8_OPMODE_NOTIF, - [9] = WLAN_EXT_CAPA10_TWT_REQUESTER_SUPPORT, };const static struct wiphy_iftype_ext_capab he_iftypes_ext_capa[] = {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 38/43 drm/vrr: Set VRR capable prop only if it is attached to connector
In reply to Greg Kroah-HartmanFrom: Manasi Navare <[email protected]>
[ Upstream commit 62929726ef0ec72cbbe9440c5d125d4278b99894 ]
VRR capable property is not attached by default to the connector It is attached only if VRR is supported.
So if the driver tries to call drm core set prop function without it being attached that causes NULL dereference.
--- drivers/gpu/drm/drm_connector.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/drm_connector.c +3 -0
@@ -1984,6 +1984,9 @@ EXPORT_SYMBOL(drm_connector_attach_max_bpc_property);void drm_connector_set_vrr_capable_property (struct drm_connector *connector,bool capable) { +if (!connector->vrr_capable_property) +return ; +drm_object_property_set_value (&connector->base, connector->vrr_capable_property, capable);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 39/43 nl80211: Update bss channel on channel switch for P2P_CLIENT
In reply to Greg Kroah-HartmanFrom: Sreeramya Soratkal <[email protected]>
[ Upstream commit e50b88c4f076242358b66ddb67482b96947438f2 ]
The wdev channel information is updated post channel switch only for the station mode and not for the other modes. Due to this, the P2P client still points to the old value though it moved to the new channel when the channel change is induced from the P2P GO.
Update the bss channel after CSA channel switch completion for P2P client interface as well.
--- net/wireless/nl80211.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/wireless/nl80211.c +2 -1
@@ -16314,7 +16314,8 @@ void cfg80211_ch_switch_notify(struct net_device *dev, wdev->chandef = *chandef; wdev->preset_chandef = *chandef; -if (wdev->iftype ==NL80211_IFTYPE_STATION && +if ((wdev->iftype ==NL80211_IFTYPE_STATION || + wdev->iftype ==NL80211_IFTYPE_P2P_CLIENT ) && !WARN_ON (!wdev->current_bss))cfg80211_update_assoc_bss_entry (wdev, chandef->chan);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 40/43 tcp: make tcp_read_sock() more robust
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit e3d5ea2c011ecb16fb94c56a659364e6b30fac94 ]
If recv_actor() returns an incorrect value, tcp_read_sock() might loop forever.
Instead, issue a one time warning and make sure to make progress.
--- net/ipv4/tcp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/ipv4/tcp.c +6 -4
@@ -1652,11 +1652,13 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,if (!copied) copied = used;break ; - }else if (used <= len) { - seq += used; - copied += used; - offset += used; } +if (WARN_ON_ONCE (used > len)) + used = len; + seq += used; + copied += used; + offset += used; +/* If recv_actor drops the lock (e.g. TCP splice * receive) the skb pointer might be invalid when * getting here: tcp_collapse might have deleted it
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 41/43 sfc: extend the locking on mcdi->seqno
In reply to Greg Kroah-HartmanFrom: Niels Dossche <[email protected]>
[ Upstream commit f1fb205efb0ccca55626fd4ef38570dd16b44719 ]
seqno could be read as a stale value outside of the lock. The lock is already acquired to protect the modification of seqno against a possible race condition. Place the reading of this value also inside this locking to protect it against a possible race condition.
--- drivers/net/ethernet/sfc/mcdi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/sfc/mcdi.c +1 -1
@@ -163,9 +163,9 @@ static void efx_mcdi_send_request(struct efx_nic *efx, unsigned cmd,/* Serialise with efx_mcdi_ev_cpl() and efx_mcdi_ev_death() */ spin_lock_bh (&mcdi->iface_lock); ++mcdi->seqno; + seqno = mcdi->seqno &SEQ_MASK ;spin_unlock_bh (&mcdi->iface_lock); - seqno = mcdi->seqno &SEQ_MASK ; xflags =0 ;if (mcdi->mode ==MCDI_MODE_EVENTS ) xflags |=MCDI_HEADER_XFLAGS_EVREQ ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 42/43 bnx2: Fix an error message
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 8ccffe9ac3239e549beaa0a9d5e1a1eac94e866c ]
Fix an error message and report the correct failing function.
--- drivers/net/ethernet/broadcom/bnx2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnx2.c +1 -1
@@ -8231,7 +8231,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev) rc =pci_set_consistent_dma_mask (pdev, persist_dma_mask);if (rc) {dev_err (&pdev->dev, -"pci_set_consistent_dma_mask failed, aborting\n" ); +"dma_set_coherent_mask failed, aborting\n" ); goto err_out_unmap; } }else if ((rc =pci_set_dma_mask (pdev,DMA_BIT_MASK (32 ))) !=0 ) {
Signature · 1 line
2.34.1
Re: [PATCH 5.4 42/43] bnx2: Fix an error message
Hi,
this one should be removed,
The message is correct in 5.4.
Le 17/03/2022 à 13:45, Greg Kroah-Hartman a écrit :
Quoted 26 lines
From: Christophe JAILLET <[email protected]>
[ Upstream commit
8ccffe9ac3239e549beaa0a9d5e1a1eac94e866c]Fix an error message and report the correct failing function.
Signed-off-by Christophe JAILLET <[email protected]>Signed-off-by David S. Miller <[email protected]>Signed-off-by Sasha Levin <[email protected]>--- drivers/net/ethernet/broadcom/bnx2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/broadcom/bnx2.c +1
-1@@ -8231,7 +8231,7 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev) rc =pci_set_consistent_dma_mask (pdev, persist_dma_mask);if (rc) {dev_err (&pdev->dev, -"pci_set_consistent_dma_mask failed, aborting\n" ); +"dma_set_coherent_mask failed, aborting\n" ); goto err_out_unmap; } }else if ((rc =pci_set_dma_mask (pdev,DMA_BIT_MASK (32 ))) !=0 ) {
Greg Kroah-Hartman
maintainerPATCH 43/43 kselftest/vm: fix tests build with old libc
In reply to Greg Kroah-HartmanFrom: Chengming Zhou <[email protected]>
[ Upstream commit b773827e361952b3f53ac6fa4c4e39ccd632102e ]
The error message when I build vm tests on debian10 (GLIBC 2.28):
userfaultfd.c: In function `userfaultfd_pagemap_test':
userfaultfd.c:1393:37: error: MADV_PAGEOUT' undeclared (first use in this function); did you mean MADV_RANDOM'?
if (madvise(area_dst, test_pgsize, MADV_PAGEOUT))
^~~~~~~~~~~~ MADV_RANDOM
This patch includes these newer definitions from UAPI linux/mman.h, is useful to fix tests build on systems without these definitions in glibc sys/mman.h.
--- tools/testing/selftests/vm/userfaultfd.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/vm/userfaultfd.c +1 -0
@@ -46,6 +46,7 @@#include <signal.h> #include <poll.h> #include <string.h> +#include <linux/mman.h> #include <sys/mman.h> #include <sys/syscall.h> #include <sys/ioctl.h>
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.186 release. There are 43 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 19 Mar 2022 12:45:16 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.186-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
There is a build failure with SDEI enable that was reported to the patch author in response to patch #18 in this series:
/local/users/fainelli/buildroot/output/arm64/host/bin/aarch64-linux-ld:arch/arm64/kernel/entry.o: in function `__sdei_asm_exit_trampoline':
/local/users/fainelli/buildroot/output/arm64/build/linux-custom/arch/arm64/kernel/entry.S:1352:
undefined reference to `__sdei_asm_trampoline_next_handler'
make[2]: *** [Makefile:1100: vmlinux] Error 1
Signature · 1 line
Florian
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.186 release. There are 43 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 19 Mar 2022 12:45:16 +0000. Anything received after that time might be too late.
Build results:
total: 159 pass: 159 fail: 0 Qemu test results: total: 449 pass: 449 fail: 0
Guenter
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.186 release. There are 43 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 19 Mar 2022 12:45:16 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.186-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
## Build
* kernel: 5.4.186-rc1
* git: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
* git branch: linux-5.4.y
* git commit: 4eb765392859512cee9488eb5831d73f5b47b4ac
* git describe: v5.4.185-44-g4eb765392859
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-5.4.y/build/v5.4.185-44-g4eb765392859
## Test Regressions (compared to v5.4.185)
No test regressions found.
## Metric Regressions (compared to v5.4.185)
No metric regressions found.
## Test Fixes (compared to v5.4.185)
No test fixes found.
## Metric Fixes (compared to v5.4.185)
No metric fixes found.
## Test result summary
total: 92947, pass: 76842, fail: 1135, skip: 13484, xfail: 1486
## Build Summary
* arc: 10 total, 10 passed, 0 failed
* arm: 290 total, 290 passed, 0 failed
* arm64: 40 total, 34 passed, 6 failed
* dragonboard-410c: 1 total, 1 passed, 0 failed
* hi6220-hikey: 1 total, 1 passed, 0 failed
* i386: 20 total, 20 passed, 0 failed
* juno-r2: 1 total, 1 passed, 0 failed
* mips: 37 total, 37 passed, 0 failed
* parisc: 12 total, 12 passed, 0 failed
* powerpc: 60 total, 49 passed, 11 failed
* riscv: 27 total, 27 passed, 0 failed
* s390: 12 total, 12 passed, 0 failed
* sh: 24 total, 24 passed, 0 failed
* sparc: 12 total, 12 passed, 0 failed
* x15: 1 total, 1 passed, 0 failed
* x86: 1 total, 1 passed, 0 failed
* x86_64: 40 total, 40 passed, 0 failed
## Test suites summary
* fwts
* igt-gpu-tools
* kselftest-android
* kselftest-arm64
* kselftest-bpf
* kselftest-breakpoints
* kselftest-capabilities
* kselftest-cgroup
* kselftest-clone3
* kselftest-core
* kselftest-cpu-hotplug
* kselftest-cpufreq
* kselftest-drivers
* kselftest-efivarfs
* kselftest-filesystems
* kselftest-firmware
* kselftest-fpu
* kselftest-futex
* kselftest-gpio
* kselftest-intel_pstate
* kselftest-ipc
* kselftest-ir
* kselftest-kcmp
* kselftest-kexec
* kselftest-kvm
* kselftest-lib
* kselftest-livepatch
* kselftest-membarrier
* kselftest-memfd
* kselftest-memory-hotplug
* kselftest-mincore
* kselftest-mount
* kselftest-mqueue
* kselftest-net
* kselftest-netfilter
* kselftest-nsfs
* kselftest-openat2
* kselftest-pid_namespace
* kselftest-pidfd
* kselftest-proc
* kselftest-pstore
* kselftest-ptrace
* kselftest-rseq
* kselftest-rtc
* kselftest-seccomp
* kselftest-sigaltstack
* kselftest-size
* kselftest-splice
* kselftest-static_keys
* kselftest-sync
* kselftest-sysctl
* kselftest-tc-testing
* kselftest-timens
* kselftest-timers
* kselftest-tmpfs
* kselftest-tpm2
* kselftest-user
* kselftest-vm
* kselftest-x86
* kselftest-zram
* kvm-unit-tests
* libgpiod
* libhugetlbfs
* linux-log-parser
* ltp-cap_bounds-tests
* ltp-commands-tests
* ltp-containers-tests
* ltp-controllers-tests
* ltp-cpuhotplug-tests
* ltp-crypto-tests
* ltp-cve-tests
* ltp-dio-tests
* ltp-fcntl-locktests-tests
* ltp-filecaps-tests
* ltp-fs-tests
* ltp-fs_bind-tests
* ltp-fs_perms_simple-tests
* ltp-fsx-tests
* ltp-hugetlb-tests
* ltp-io-tests
* ltp-ipc-tests
* ltp-math-tests
* ltp-mm-tests
* ltp-nptl-tests
* ltp-open-posix-tests
* ltp-pty-tests
* ltp-sched-tests
* ltp-securebits-tests
* ltp-syscalls-tests
* ltp-tracing-tests
* network-basic-tests
* packetdrill
* perf
* perf/Zstd-perf.data-compression
* rcutorture
* ssuite
* v4l2-compliance
* vdso
--
Linaro LKFT
https://lkft.linaro.org
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.186 release. There are 43 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 19 Mar 2022 12:45:16 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.186-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.4.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v5.4:
10 builds: 10 pass, 0 fail
26 boots: 26 pass, 0 fail
59 tests: 59 pass, 0 failLinux version: 5.4.186-rc1-g4eb765392859
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra20-ventana,
tegra210-p2371-2180, tegra210-p3450-0000,
tegra30-cardhu-a04Jon
Hi Greg,
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.4.186 release. There are 43 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sat, 19 Mar 2022 12:45:16 +0000. Anything received after that time might be too late.
Build test:
mips (gcc version 11.2.1 20220301): 65 configs -> no new failure arm (gcc version 11.2.1 20220301): 107 configs -> no new failure arm64 (gcc version 11.2.1 20220301): 2 configs -> no failure x86_64 (gcc version 11.2.1 20220301): 4 configs -> no failure
Boot test:x86_64: Booted on my test laptop. No regression.x86_64: Booted on qemu. No regression. [1]
[1]. https://openqa.qa.codethink.co.uk/tests/902
--
Regards
Sudip