Skip to content

Commit 26e89dc

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: Add kvm_has_s1poe() helper
Just like we have kvm_has_s1pie(), add its S1POE counterpart, making the code slightly more readable. Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent f757553 commit 26e89dc

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,4 +1525,7 @@ void kvm_set_vm_id_reg(struct kvm *kvm, u32 reg, u64 val);
15251525
#define kvm_has_s1pie(k) \
15261526
(kvm_has_feat((k), ID_AA64MMFR3_EL1, S1PIE, IMP))
15271527

1528+
#define kvm_has_s1poe(k) \
1529+
(kvm_has_feat((k), ID_AA64MMFR3_EL1, S1POE, IMP))
1530+
15281531
#endif /* __ARM64_KVM_HOST_H__ */

arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static inline bool ctxt_has_s1poe(struct kvm_cpu_context *ctxt)
8080
return false;
8181

8282
vcpu = ctxt_to_vcpu(ctxt);
83-
return kvm_has_feat(kern_hyp_va(vcpu->kvm), ID_AA64MMFR3_EL1, S1POE, IMP);
83+
return kvm_has_s1poe(kern_hyp_va(vcpu->kvm));
8484
}
8585

8686
static inline void __sysreg_save_el1_state(struct kvm_cpu_context *ctxt)

arch/arm64/kvm/nested.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ int kvm_init_nv_sysregs(struct kvm *kvm)
11071107
res0 |= HFGxTR_EL2_nRCWMASK_EL1;
11081108
if (!kvm_has_s1pie(kvm))
11091109
res0 |= (HFGxTR_EL2_nPIRE0_EL1 | HFGxTR_EL2_nPIR_EL1);
1110-
if (!kvm_has_feat(kvm, ID_AA64MMFR3_EL1, S1POE, IMP))
1110+
if (!kvm_has_s1poe(kvm))
11111111
res0 |= (HFGxTR_EL2_nPOR_EL0 | HFGxTR_EL2_nPOR_EL1);
11121112
if (!kvm_has_feat(kvm, ID_AA64MMFR3_EL1, S2POE, IMP))
11131113
res0 |= HFGxTR_EL2_nS2POR_EL1;
@@ -1217,7 +1217,7 @@ int kvm_init_nv_sysregs(struct kvm *kvm)
12171217
res0 |= TCR2_EL2_PTTWI | TCR2_EL2_PnCH;
12181218
if (!kvm_has_feat(kvm, ID_AA64MMFR3_EL1, AIE, IMP))
12191219
res0 |= TCR2_EL2_AIE;
1220-
if (!kvm_has_feat(kvm, ID_AA64MMFR3_EL1, S1POE, IMP))
1220+
if (!kvm_has_s1poe(kvm))
12211221
res0 |= TCR2_EL2_POE | TCR2_EL2_E0POE;
12221222
if (!kvm_has_s1pie(kvm))
12231223
res0 |= TCR2_EL2_PIE;

arch/arm64/kvm/sys_regs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2323,7 +2323,7 @@ static bool access_zcr_el2(struct kvm_vcpu *vcpu,
23232323
static unsigned int s1poe_visibility(const struct kvm_vcpu *vcpu,
23242324
const struct sys_reg_desc *rd)
23252325
{
2326-
if (kvm_has_feat(vcpu->kvm, ID_AA64MMFR3_EL1, S1POE, IMP))
2326+
if (kvm_has_s1poe(vcpu->kvm))
23272327
return 0;
23282328

23292329
return REG_HIDDEN;
@@ -4862,7 +4862,7 @@ void kvm_calculate_traps(struct kvm_vcpu *vcpu)
48624862
kvm->arch.fgu[HFGxTR_GROUP] |= (HFGxTR_EL2_nPIRE0_EL1 |
48634863
HFGxTR_EL2_nPIR_EL1);
48644864

4865-
if (!kvm_has_feat(kvm, ID_AA64MMFR3_EL1, S1POE, IMP))
4865+
if (!kvm_has_s1poe(kvm))
48664866
kvm->arch.fgu[HFGxTR_GROUP] |= (HFGxTR_EL2_nPOR_EL1 |
48674867
HFGxTR_EL2_nPOR_EL0);
48684868

0 commit comments

Comments
 (0)