Skip to content

Commit 3bb72d8

Browse files
brooniewilldeacon
authored andcommitted
arm64: Always use individual bits in CPACR floating point enables
CPACR_EL1 has several bitfields for controlling traps for floating point features to EL1, each of which has a separate bits for EL0 and EL1. Marc Zyngier noted that we are not consistent in our use of defines to manipulate these, sometimes using a define covering the whole field and sometimes using defines for the individual bits. Make this consistent by expanding the whole field defines where they are used (currently only in the KVM code) and deleting them so that no further uses can be introduced. Suggested-by: Marc Zyngier <[email protected]> Signed-off-by: Mark Brown <[email protected]> Acked-by: Catalin Marinas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 879358f commit 3bb72d8

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

arch/arm64/include/asm/kvm_arm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@
356356
ECN(BKPT32), ECN(VECTOR32), ECN(BRK64)
357357

358358
#define CPACR_EL1_TTA (1 << 28)
359-
#define CPACR_EL1_DEFAULT (CPACR_EL1_FPEN | CPACR_EL1_ZEN_EL1EN)
359+
#define CPACR_EL1_DEFAULT (CPACR_EL1_FPEN_EL0EN | CPACR_EL1_FPEN_EL1EN |\
360+
CPACR_EL1_ZEN_EL1EN)
360361

361362
#endif /* __ARM64_KVM_ARM_H__ */

arch/arm64/include/asm/sysreg.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,11 +1099,9 @@
10991099

11001100
#define CPACR_EL1_FPEN_EL1EN (BIT(20)) /* enable EL1 access */
11011101
#define CPACR_EL1_FPEN_EL0EN (BIT(21)) /* enable EL0 access, if EL1EN set */
1102-
#define CPACR_EL1_FPEN (CPACR_EL1_FPEN_EL1EN | CPACR_EL1_FPEN_EL0EN)
11031102

11041103
#define CPACR_EL1_ZEN_EL1EN (BIT(16)) /* enable EL1 access */
11051104
#define CPACR_EL1_ZEN_EL0EN (BIT(17)) /* enable EL0 access, if EL1EN set */
1106-
#define CPACR_EL1_ZEN (CPACR_EL1_ZEN_EL1EN | CPACR_EL1_ZEN_EL0EN)
11071105

11081106
/* TCR EL1 Bit Definitions */
11091107
#define SYS_TCR_EL1_TCMA1 (BIT(58))

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

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

175175
/* Valid trap. Switch the context: */
176176
if (has_vhe()) {
177-
reg = CPACR_EL1_FPEN;
177+
reg = CPACR_EL1_FPEN_EL0EN | CPACR_EL1_FPEN_EL1EN;
178178
if (sve_guest)
179-
reg |= CPACR_EL1_ZEN;
179+
reg |= CPACR_EL1_ZEN_EL0EN | CPACR_EL1_ZEN_EL1EN;
180180

181181
sysreg_clear_set(cpacr_el1, 0, reg);
182182
} else {

arch/arm64/kvm/hyp/vhe/switch.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static void __activate_traps(struct kvm_vcpu *vcpu)
3838

3939
val = read_sysreg(cpacr_el1);
4040
val |= CPACR_EL1_TTA;
41-
val &= ~CPACR_EL1_ZEN;
41+
val &= ~(CPACR_EL1_ZEN_EL0EN | CPACR_EL1_ZEN_EL1EN);
4242

4343
/*
4444
* With VHE (HCR.E2H == 1), accesses to CPACR_EL1 are routed to
@@ -53,9 +53,9 @@ static void __activate_traps(struct kvm_vcpu *vcpu)
5353

5454
if (update_fp_enabled(vcpu)) {
5555
if (vcpu_has_sve(vcpu))
56-
val |= CPACR_EL1_ZEN;
56+
val |= CPACR_EL1_ZEN_EL0EN | CPACR_EL1_ZEN_EL1EN;
5757
} else {
58-
val &= ~CPACR_EL1_FPEN;
58+
val &= ~(CPACR_EL1_FPEN_EL0EN | CPACR_EL1_FPEN_EL1EN);
5959
__activate_traps_fpsimd32(vcpu);
6060
}
6161

0 commit comments

Comments
 (0)