Skip to content

Commit 6e52aab

Browse files
brooniectmarinas
authored andcommitted
arm64: kvm: Modernize annotation for __bp_harden_hyp_vecs
We have recently introduced new macros for annotating assembly symbols for things that aren't C functions, SYM_CODE_START() and SYM_CODE_END(), in an effort to clarify and simplify our annotations of assembly files. Using these for __bp_harden_hyp_vecs is more involved than for most symbols as this symbol is annotated quite unusually as rather than just have the explicit symbol we define _start and _end symbols which we then use to compute the length. This does not play at all nicely with the new style macros. Since the size of the vectors is a known constant which won't vary the simplest thing to do is simply to drop the separate _start and _end symbols and just use a #define for the size. Signed-off-by: Mark Brown <[email protected]> Signed-off-by: Catalin Marinas <[email protected]> Acked-by: Marc Zyngier <[email protected]>
1 parent 617a2f3 commit 6e52aab

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

arch/arm64/include/asm/kvm_mmu.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ static inline void *kvm_get_hyp_vector(void)
480480
int slot = -1;
481481

482482
if (cpus_have_const_cap(ARM64_HARDEN_BRANCH_PREDICTOR) && data->fn) {
483-
vect = kern_hyp_va(kvm_ksym_ref(__bp_harden_hyp_vecs_start));
483+
vect = kern_hyp_va(kvm_ksym_ref(__bp_harden_hyp_vecs));
484484
slot = data->hyp_vectors_slot;
485485
}
486486

@@ -509,14 +509,13 @@ static inline int kvm_map_vectors(void)
509509
* HBP + HEL2 -> use hardened vertors and use exec mapping
510510
*/
511511
if (cpus_have_const_cap(ARM64_HARDEN_BRANCH_PREDICTOR)) {
512-
__kvm_bp_vect_base = kvm_ksym_ref(__bp_harden_hyp_vecs_start);
512+
__kvm_bp_vect_base = kvm_ksym_ref(__bp_harden_hyp_vecs);
513513
__kvm_bp_vect_base = kern_hyp_va(__kvm_bp_vect_base);
514514
}
515515

516516
if (cpus_have_const_cap(ARM64_HARDEN_EL2_VECTORS)) {
517-
phys_addr_t vect_pa = __pa_symbol(__bp_harden_hyp_vecs_start);
518-
unsigned long size = (__bp_harden_hyp_vecs_end -
519-
__bp_harden_hyp_vecs_start);
517+
phys_addr_t vect_pa = __pa_symbol(__bp_harden_hyp_vecs);
518+
unsigned long size = __BP_HARDEN_HYP_VECS_SZ;
520519

521520
/*
522521
* Always allocate a spare vector slot, as we don't

arch/arm64/include/asm/mmu.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define TTBR_ASID_MASK (UL(0xffff) << 48)
1414

1515
#define BP_HARDEN_EL2_SLOTS 4
16+
#define __BP_HARDEN_HYP_VECS_SZ (BP_HARDEN_EL2_SLOTS * SZ_2K)
1617

1718
#ifndef __ASSEMBLY__
1819

@@ -45,7 +46,8 @@ struct bp_hardening_data {
4546

4647
#if (defined(CONFIG_HARDEN_BRANCH_PREDICTOR) || \
4748
defined(CONFIG_HARDEN_EL2_VECTORS))
48-
extern char __bp_harden_hyp_vecs_start[], __bp_harden_hyp_vecs_end[];
49+
50+
extern char __bp_harden_hyp_vecs[];
4951
extern atomic_t arm64_el2_vector_last_slot;
5052
#endif /* CONFIG_HARDEN_BRANCH_PREDICTOR || CONFIG_HARDEN_EL2_VECTORS */
5153

arch/arm64/kernel/cpu_errata.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ extern char __smccc_workaround_1_smc_end[];
119119
static void __copy_hyp_vect_bpi(int slot, const char *hyp_vecs_start,
120120
const char *hyp_vecs_end)
121121
{
122-
void *dst = lm_alias(__bp_harden_hyp_vecs_start + slot * SZ_2K);
122+
void *dst = lm_alias(__bp_harden_hyp_vecs + slot * SZ_2K);
123123
int i;
124124

125125
for (i = 0; i < SZ_2K; i += 0x80)

arch/arm64/kvm/hyp/hyp-entry.S

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,13 @@ alternative_cb_end
312312
.endm
313313

314314
.align 11
315-
ENTRY(__bp_harden_hyp_vecs_start)
315+
SYM_CODE_START(__bp_harden_hyp_vecs)
316316
.rept BP_HARDEN_EL2_SLOTS
317317
generate_vectors
318318
.endr
319-
ENTRY(__bp_harden_hyp_vecs_end)
319+
1: .org __bp_harden_hyp_vecs + __BP_HARDEN_HYP_VECS_SZ
320+
.org 1b
321+
SYM_CODE_END(__bp_harden_hyp_vecs)
320322

321323
.popsection
322324

0 commit comments

Comments
 (0)