Skip to content

Commit ee3a9a0

Browse files
Marc Zyngieroupton
authored andcommitted
KVM: arm64: Add a composite EL2 visibility helper
We are starting to have a bunch of visibility helpers checking for EL2 + something else, and we are going to add more. Simplify things somehow by introducing a helper that implement extractly that by taking a visibility helper as a parameter, and convert the existing ones to that. Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 364c081 commit ee3a9a0

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,16 +2303,18 @@ static u64 reset_hcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r)
23032303
return __vcpu_sys_reg(vcpu, r->reg) = val;
23042304
}
23052305

2306+
static unsigned int __el2_visibility(const struct kvm_vcpu *vcpu,
2307+
const struct sys_reg_desc *rd,
2308+
unsigned int (*fn)(const struct kvm_vcpu *,
2309+
const struct sys_reg_desc *))
2310+
{
2311+
return el2_visibility(vcpu, rd) ?: fn(vcpu, rd);
2312+
}
2313+
23062314
static unsigned int sve_el2_visibility(const struct kvm_vcpu *vcpu,
23072315
const struct sys_reg_desc *rd)
23082316
{
2309-
unsigned int r;
2310-
2311-
r = el2_visibility(vcpu, rd);
2312-
if (r)
2313-
return r;
2314-
2315-
return sve_visibility(vcpu, rd);
2317+
return __el2_visibility(vcpu, rd, sve_visibility);
23162318
}
23172319

23182320
static bool access_zcr_el2(struct kvm_vcpu *vcpu,

0 commit comments

Comments
 (0)