Skip to content

Commit e5ecedc

Browse files
Marc Zyngierwilldeacon
authored andcommitted
arm64/sysreg: Get rid of CPACR_ELx SysregFields
There is no such thing as CPACR_ELx in the architecture. What we have is CPACR_EL1, for which CPTR_EL12 is an accessor. Rename CPACR_ELx_* to CPACR_EL1_*, and fix the bit of code using these names. Reviewed-by: Mark Brown <[email protected]> Acked-by: Mark Rutland <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 233fc36 commit e5ecedc

File tree

13 files changed

+47
-53
lines changed

13 files changed

+47
-53
lines changed

arch/arm64/include/asm/el2_setup.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
/* Coprocessor traps */
155155
.macro __init_el2_cptr
156156
__check_hvhe .LnVHE_\@, x1
157-
mov x0, #CPACR_ELx_FPEN
157+
mov x0, #CPACR_EL1_FPEN
158158
msr cpacr_el1, x0
159159
b .Lskip_set_cptr_\@
160160
.LnVHE_\@:
@@ -332,7 +332,7 @@
332332

333333
// (h)VHE case
334334
mrs x0, cpacr_el1 // Disable SVE traps
335-
orr x0, x0, #CPACR_ELx_ZEN
335+
orr x0, x0, #CPACR_EL1_ZEN
336336
msr cpacr_el1, x0
337337
b .Lskip_set_cptr_\@
338338

@@ -353,7 +353,7 @@
353353

354354
// (h)VHE case
355355
mrs x0, cpacr_el1 // Disable SME traps
356-
orr x0, x0, #CPACR_ELx_SMEN
356+
orr x0, x0, #CPACR_EL1_SMEN
357357
msr cpacr_el1, x0
358358
b .Lskip_set_cptr_sme_\@
359359

arch/arm64/include/asm/kvm_arm.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,6 @@
391391
ECN(SOFTSTP_CUR), ECN(WATCHPT_LOW), ECN(WATCHPT_CUR), \
392392
ECN(BKPT32), ECN(VECTOR32), ECN(BRK64), ECN(ERET)
393393

394-
#define CPACR_EL1_TTA (1 << 28)
395-
396394
#define kvm_mode_names \
397395
{ PSR_MODE_EL0t, "EL0t" }, \
398396
{ PSR_MODE_EL1t, "EL1t" }, \

arch/arm64/include/asm/kvm_emulate.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -556,13 +556,13 @@ static __always_inline void kvm_incr_pc(struct kvm_vcpu *vcpu)
556556
({ \
557557
u64 cptr = 0; \
558558
\
559-
if ((set) & CPACR_ELx_FPEN) \
559+
if ((set) & CPACR_EL1_FPEN) \
560560
cptr |= CPTR_EL2_TFP; \
561-
if ((set) & CPACR_ELx_ZEN) \
561+
if ((set) & CPACR_EL1_ZEN) \
562562
cptr |= CPTR_EL2_TZ; \
563-
if ((set) & CPACR_ELx_SMEN) \
563+
if ((set) & CPACR_EL1_SMEN) \
564564
cptr |= CPTR_EL2_TSM; \
565-
if ((clr) & CPACR_ELx_TTA) \
565+
if ((clr) & CPACR_EL1_TTA) \
566566
cptr |= CPTR_EL2_TTA; \
567567
if ((clr) & CPTR_EL2_TAM) \
568568
cptr |= CPTR_EL2_TAM; \
@@ -576,13 +576,13 @@ static __always_inline void kvm_incr_pc(struct kvm_vcpu *vcpu)
576576
({ \
577577
u64 cptr = 0; \
578578
\
579-
if ((clr) & CPACR_ELx_FPEN) \
579+
if ((clr) & CPACR_EL1_FPEN) \
580580
cptr |= CPTR_EL2_TFP; \
581-
if ((clr) & CPACR_ELx_ZEN) \
581+
if ((clr) & CPACR_EL1_ZEN) \
582582
cptr |= CPTR_EL2_TZ; \
583-
if ((clr) & CPACR_ELx_SMEN) \
583+
if ((clr) & CPACR_EL1_SMEN) \
584584
cptr |= CPTR_EL2_TSM; \
585-
if ((set) & CPACR_ELx_TTA) \
585+
if ((set) & CPACR_EL1_TTA) \
586586
cptr |= CPTR_EL2_TTA; \
587587
if ((set) & CPTR_EL2_TAM) \
588588
cptr |= CPTR_EL2_TAM; \
@@ -595,13 +595,13 @@ static __always_inline void kvm_incr_pc(struct kvm_vcpu *vcpu)
595595
#define cpacr_clear_set(clr, set) \
596596
do { \
597597
BUILD_BUG_ON((set) & CPTR_VHE_EL2_RES0); \
598-
BUILD_BUG_ON((clr) & CPACR_ELx_E0POE); \
599-
__build_check_all_or_none((clr), CPACR_ELx_FPEN); \
600-
__build_check_all_or_none((set), CPACR_ELx_FPEN); \
601-
__build_check_all_or_none((clr), CPACR_ELx_ZEN); \
602-
__build_check_all_or_none((set), CPACR_ELx_ZEN); \
603-
__build_check_all_or_none((clr), CPACR_ELx_SMEN); \
604-
__build_check_all_or_none((set), CPACR_ELx_SMEN); \
598+
BUILD_BUG_ON((clr) & CPACR_EL1_E0POE); \
599+
__build_check_all_or_none((clr), CPACR_EL1_FPEN); \
600+
__build_check_all_or_none((set), CPACR_EL1_FPEN); \
601+
__build_check_all_or_none((clr), CPACR_EL1_ZEN); \
602+
__build_check_all_or_none((set), CPACR_EL1_ZEN); \
603+
__build_check_all_or_none((clr), CPACR_EL1_SMEN); \
604+
__build_check_all_or_none((set), CPACR_EL1_SMEN); \
605605
\
606606
if (has_vhe() || has_hvhe()) \
607607
sysreg_clear_set(cpacr_el1, clr, set); \
@@ -624,16 +624,16 @@ static __always_inline u64 kvm_get_reset_cptr_el2(struct kvm_vcpu *vcpu)
624624
u64 val;
625625

626626
if (has_vhe()) {
627-
val = (CPACR_ELx_FPEN | CPACR_EL1_ZEN_EL1EN);
627+
val = (CPACR_EL1_FPEN | CPACR_EL1_ZEN_EL1EN);
628628
if (cpus_have_final_cap(ARM64_SME))
629629
val |= CPACR_EL1_SMEN_EL1EN;
630630
} else if (has_hvhe()) {
631-
val = CPACR_ELx_FPEN;
631+
val = CPACR_EL1_FPEN;
632632

633633
if (!vcpu_has_sve(vcpu) || !guest_owns_fp_regs())
634-
val |= CPACR_ELx_ZEN;
634+
val |= CPACR_EL1_ZEN;
635635
if (cpus_have_final_cap(ARM64_SME))
636-
val |= CPACR_ELx_SMEN;
636+
val |= CPACR_EL1_SMEN;
637637
} else {
638638
val = CPTR_NVHE_EL2_RES1;
639639

@@ -685,7 +685,7 @@ static inline bool ____cptr_xen_trap_enabled(const struct kvm_vcpu *vcpu,
685685
#define __guest_hyp_cptr_xen_trap_enabled(vcpu, xen) \
686686
(!vcpu_has_nv(vcpu) ? false : \
687687
____cptr_xen_trap_enabled(vcpu, \
688-
SYS_FIELD_GET(CPACR_ELx, xen, \
688+
SYS_FIELD_GET(CPACR_EL1, xen, \
689689
vcpu_sanitised_cptr_el2(vcpu))))
690690

691691
static inline bool guest_hyp_fpsimd_traps_enabled(const struct kvm_vcpu *vcpu)

arch/arm64/include/asm/kvm_nested.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ static inline u64 translate_tcr_el2_to_tcr_el1(u64 tcr)
3333

3434
static inline u64 translate_cptr_el2_to_cpacr_el1(u64 cptr_el2)
3535
{
36-
u64 cpacr_el1 = CPACR_ELx_RES1;
36+
u64 cpacr_el1 = CPACR_EL1_RES1;
3737

3838
if (cptr_el2 & CPTR_EL2_TTA)
39-
cpacr_el1 |= CPACR_ELx_TTA;
39+
cpacr_el1 |= CPACR_EL1_TTA;
4040
if (!(cptr_el2 & CPTR_EL2_TFP))
41-
cpacr_el1 |= CPACR_ELx_FPEN;
41+
cpacr_el1 |= CPACR_EL1_FPEN;
4242
if (!(cptr_el2 & CPTR_EL2_TZ))
43-
cpacr_el1 |= CPACR_ELx_ZEN;
43+
cpacr_el1 |= CPACR_EL1_ZEN;
4444

4545
cpacr_el1 |= cptr_el2 & (CPTR_EL2_TCPAC | CPTR_EL2_TAM);
4646

arch/arm64/kernel/cpufeature.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2376,7 +2376,7 @@ static void cpu_enable_mops(const struct arm64_cpu_capabilities *__unused)
23762376
static void cpu_enable_poe(const struct arm64_cpu_capabilities *__unused)
23772377
{
23782378
sysreg_clear_set(REG_TCR2_EL1, 0, TCR2_EL1_E0POE);
2379-
sysreg_clear_set(CPACR_EL1, 0, CPACR_ELx_E0POE);
2379+
sysreg_clear_set(CPACR_EL1, 0, CPACR_EL1_E0POE);
23802380
}
23812381
#endif
23822382

arch/arm64/kvm/emulate-nested.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ static enum trap_behaviour check_cptr_tta(struct kvm_vcpu *vcpu)
494494
if (!vcpu_el2_e2h_is_set(vcpu))
495495
val = translate_cptr_el2_to_cpacr_el1(val);
496496

497-
if (val & CPACR_ELx_TTA)
497+
if (val & CPACR_EL1_TTA)
498498
return BEHAVE_FORWARD_RW;
499499

500500
return BEHAVE_HANDLE_LOCALLY;

arch/arm64/kvm/fpsimd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu)
169169
if (has_vhe() && system_supports_sme()) {
170170
/* Also restore EL0 state seen on entry */
171171
if (vcpu_get_flag(vcpu, HOST_SME_ENABLED))
172-
sysreg_clear_set(CPACR_EL1, 0, CPACR_ELx_SMEN);
172+
sysreg_clear_set(CPACR_EL1, 0, CPACR_EL1_SMEN);
173173
else
174174
sysreg_clear_set(CPACR_EL1,
175175
CPACR_EL1_SMEN_EL0EN,

arch/arm64/kvm/hyp/include/hyp/switch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,9 @@ static bool kvm_hyp_handle_fpsimd(struct kvm_vcpu *vcpu, u64 *exit_code)
419419

420420
/* First disable enough traps to allow us to update the registers */
421421
if (sve_guest || (is_protected_kvm_enabled() && system_supports_sve()))
422-
cpacr_clear_set(0, CPACR_ELx_FPEN | CPACR_ELx_ZEN);
422+
cpacr_clear_set(0, CPACR_EL1_FPEN | CPACR_EL1_ZEN);
423423
else
424-
cpacr_clear_set(0, CPACR_ELx_FPEN);
424+
cpacr_clear_set(0, CPACR_EL1_FPEN);
425425
isb();
426426

427427
/* Write out the host state if it's in the registers */

arch/arm64/kvm/hyp/nvhe/hyp-main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static void fpsimd_sve_sync(struct kvm_vcpu *vcpu)
6868
if (!guest_owns_fp_regs())
6969
return;
7070

71-
cpacr_clear_set(0, CPACR_ELx_FPEN | CPACR_ELx_ZEN);
71+
cpacr_clear_set(0, CPACR_EL1_FPEN | CPACR_EL1_ZEN);
7272
isb();
7373

7474
if (vcpu_has_sve(vcpu))
@@ -481,7 +481,7 @@ void handle_trap(struct kvm_cpu_context *host_ctxt)
481481
handle_host_smc(host_ctxt);
482482
break;
483483
case ESR_ELx_EC_SVE:
484-
cpacr_clear_set(0, CPACR_ELx_ZEN);
484+
cpacr_clear_set(0, CPACR_EL1_ZEN);
485485
isb();
486486
sve_cond_update_zcr_vq(sve_vq_from_vl(kvm_host_sve_max_vl) - 1,
487487
SYS_ZCR_EL2);

arch/arm64/kvm/hyp/nvhe/pkvm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static void pvm_init_traps_aa64pfr0(struct kvm_vcpu *vcpu)
6868
/* Trap SVE */
6969
if (!FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR0_EL1_SVE), feature_ids)) {
7070
if (has_hvhe())
71-
cptr_clear |= CPACR_ELx_ZEN;
71+
cptr_clear |= CPACR_EL1_ZEN;
7272
else
7373
cptr_set |= CPTR_EL2_TZ;
7474
}

0 commit comments

Comments
 (0)