Skip to content

Commit a59a2ed

Browse files
David BrazdilMarc Zyngier
authored andcommitted
KVM: arm64: Substitute RANDOMIZE_BASE for HARDEN_EL2_VECTORS
The HARDEN_EL2_VECTORS config maps vectors at a fixed location on cores which are susceptible to Spector variant 3a (A57, A72) to prevent defeating hyp layout randomization by leaking the value of VBAR_EL2. Since this feature is only applicable when EL2 layout randomization is enabled, unify both behind the same RANDOMIZE_BASE Kconfig. Majority of code remains conditional on a capability selected for the affected cores. Signed-off-by: David Brazdil <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 24f69c0 commit a59a2ed

File tree

4 files changed

+5
-23
lines changed

4 files changed

+5
-23
lines changed

arch/arm64/Kconfig

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,22 +1182,6 @@ config HARDEN_BRANCH_PREDICTOR
11821182

11831183
If unsure, say Y.
11841184

1185-
config HARDEN_EL2_VECTORS
1186-
bool "Harden EL2 vector mapping against system register leak" if EXPERT
1187-
default y
1188-
help
1189-
Speculation attacks against some high-performance processors can
1190-
be used to leak privileged information such as the vector base
1191-
register, resulting in a potential defeat of the EL2 layout
1192-
randomization.
1193-
1194-
This config option will map the vectors to a fixed location,
1195-
independent of the EL2 code mapping, so that revealing VBAR_EL2
1196-
to an attacker does not give away any extra information. This
1197-
only gets enabled on affected CPUs.
1198-
1199-
If unsure, say Y.
1200-
12011185
config ARM64_SSBD
12021186
bool "Speculative Store Bypass Disable" if EXPERT
12031187
default y

arch/arm64/include/asm/mmu.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ struct bp_hardening_data {
4242
bp_hardening_cb_t fn;
4343
};
4444

45-
#if (defined(CONFIG_HARDEN_BRANCH_PREDICTOR) || \
46-
defined(CONFIG_HARDEN_EL2_VECTORS))
47-
45+
#ifdef CONFIG_KVM_INDIRECT_VECTORS
4846
extern char __bp_harden_hyp_vecs[];
4947
extern atomic_t arm64_el2_vector_last_slot;
50-
#endif /* CONFIG_HARDEN_BRANCH_PREDICTOR || CONFIG_HARDEN_EL2_VECTORS */
48+
#endif
5149

5250
#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
5351
DECLARE_PER_CPU_READ_MOSTLY(struct bp_hardening_data, bp_hardening_data);

arch/arm64/kernel/cpu_errata.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ has_neoverse_n1_erratum_1542419(const struct arm64_cpu_capabilities *entry,
635635
return is_midr_in_range(midr, &range) && has_dic;
636636
}
637637

638-
#if defined(CONFIG_HARDEN_EL2_VECTORS)
638+
#ifdef CONFIG_RANDOMIZE_BASE
639639

640640
static const struct midr_range ca57_a72[] = {
641641
MIDR_ALL_VERSIONS(MIDR_CORTEX_A57),
@@ -880,7 +880,7 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
880880
.type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
881881
.matches = check_branch_predictor,
882882
},
883-
#ifdef CONFIG_HARDEN_EL2_VECTORS
883+
#ifdef CONFIG_RANDOMIZE_BASE
884884
{
885885
.desc = "EL2 vector hardening",
886886
.capability = ARM64_HARDEN_EL2_VECTORS,

arch/arm64/kvm/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ config KVM_ARM_PMU
5858
virtual machines.
5959

6060
config KVM_INDIRECT_VECTORS
61-
def_bool HARDEN_BRANCH_PREDICTOR || HARDEN_EL2_VECTORS
61+
def_bool HARDEN_BRANCH_PREDICTOR || RANDOMIZE_BASE
6262

6363
endif # KVM
6464

0 commit comments

Comments
 (0)