Skip to content

Commit 4db61fe

Browse files
brooniectmarinas
authored andcommitted
arm64: kvm: Modernize __smccc_workaround_1_smc_start annotations
In an effort to clarify and simplify the annotation of assembly functions in the kernel new macros have been introduced. These replace ENTRY and ENDPROC with separate annotations for standard C callable functions, data and code with different calling conventions. Using these for __smccc_workaround_1_smc is more involved than for most symbols as this symbol is annotated quite unusually, 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. Instead define a constant for the size of the function and use that in both the C code and for .org based size checks in the assembly code. Signed-off-by: Mark Brown <[email protected]> Signed-off-by: Catalin Marinas <[email protected]> Acked-by: Marc Zyngier <[email protected]>
1 parent 6e52aab commit 4db61fe

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

arch/arm64/include/asm/kvm_asm.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
*/
3737
#define KVM_VECTOR_PREAMBLE (2 * AARCH64_INSN_SIZE)
3838

39+
#define __SMCCC_WORKAROUND_1_SMC_SZ 36
40+
3941
#ifndef __ASSEMBLY__
4042

4143
#include <linux/mm.h>
@@ -75,6 +77,8 @@ extern void __vgic_v3_init_lrs(void);
7577

7678
extern u32 __kvm_get_mdcr_el2(void);
7779

80+
extern char __smccc_workaround_1_smc[__SMCCC_WORKAROUND_1_SMC_SZ];
81+
7882
/* Home-grown __this_cpu_{ptr,read} variants that always work at HYP */
7983
#define __hyp_this_cpu_ptr(sym) \
8084
({ \

arch/arm64/kernel/cpu_errata.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <asm/cpu.h>
1212
#include <asm/cputype.h>
1313
#include <asm/cpufeature.h>
14+
#include <asm/kvm_asm.h>
1415
#include <asm/smp_plat.h>
1516

1617
static bool __maybe_unused
@@ -113,9 +114,6 @@ atomic_t arm64_el2_vector_last_slot = ATOMIC_INIT(-1);
113114
DEFINE_PER_CPU_READ_MOSTLY(struct bp_hardening_data, bp_hardening_data);
114115

115116
#ifdef CONFIG_KVM_INDIRECT_VECTORS
116-
extern char __smccc_workaround_1_smc_start[];
117-
extern char __smccc_workaround_1_smc_end[];
118-
119117
static void __copy_hyp_vect_bpi(int slot, const char *hyp_vecs_start,
120118
const char *hyp_vecs_end)
121119
{
@@ -163,9 +161,6 @@ static void install_bp_hardening_cb(bp_hardening_cb_t fn,
163161
raw_spin_unlock(&bp_lock);
164162
}
165163
#else
166-
#define __smccc_workaround_1_smc_start NULL
167-
#define __smccc_workaround_1_smc_end NULL
168-
169164
static void install_bp_hardening_cb(bp_hardening_cb_t fn,
170165
const char *hyp_vecs_start,
171166
const char *hyp_vecs_end)
@@ -239,11 +234,14 @@ static int detect_harden_bp_fw(void)
239234
smccc_end = NULL;
240235
break;
241236

237+
#if IS_ENABLED(CONFIG_KVM_ARM_HOST)
242238
case SMCCC_CONDUIT_SMC:
243239
cb = call_smc_arch_workaround_1;
244-
smccc_start = __smccc_workaround_1_smc_start;
245-
smccc_end = __smccc_workaround_1_smc_end;
240+
smccc_start = __smccc_workaround_1_smc;
241+
smccc_end = __smccc_workaround_1_smc +
242+
__SMCCC_WORKAROUND_1_SMC_SZ;
246243
break;
244+
#endif
247245

248246
default:
249247
return -1;

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ SYM_CODE_END(__bp_harden_hyp_vecs)
322322

323323
.popsection
324324

325-
ENTRY(__smccc_workaround_1_smc_start)
325+
SYM_CODE_START(__smccc_workaround_1_smc)
326326
esb
327327
sub sp, sp, #(8 * 4)
328328
stp x2, x3, [sp, #(8 * 0)]
@@ -332,5 +332,7 @@ ENTRY(__smccc_workaround_1_smc_start)
332332
ldp x2, x3, [sp, #(8 * 0)]
333333
ldp x0, x1, [sp, #(8 * 2)]
334334
add sp, sp, #(8 * 4)
335-
ENTRY(__smccc_workaround_1_smc_end)
335+
1: .org __smccc_workaround_1_smc + __SMCCC_WORKAROUND_1_SMC_SZ
336+
.org 1b
337+
SYM_CODE_END(__smccc_workaround_1_smc)
336338
#endif

0 commit comments

Comments
 (0)