Skip to content

Commit d071cef

Browse files
broonieMarc Zyngier
authored andcommitted
KVM: arm64: Restructure check for SVE support in FP trap handler
We share the same handler for general floating point and SVE traps with a check to make sure we don't handle any SVE traps if the system doesn't have SVE support. Since we will be adding SME support and wishing to handle that along with other FP related traps rewrite the check to be more scalable and a bit clearer too, ensuring we don't misidentify SME traps as SVE ones. Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20221214-kvm-arm64-sme-context-switch-v2-2-57ba0082e9ff@kernel.org
1 parent 4c181e3 commit d071cef

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,17 @@ static bool kvm_hyp_handle_fpsimd(struct kvm_vcpu *vcpu, u64 *exit_code)
176176
sve_guest = vcpu_has_sve(vcpu);
177177
esr_ec = kvm_vcpu_trap_get_class(vcpu);
178178

179-
/* Don't handle SVE traps for non-SVE vcpus here: */
180-
if (!sve_guest && esr_ec != ESR_ELx_EC_FP_ASIMD)
179+
/* Only handle traps the vCPU can support here: */
180+
switch (esr_ec) {
181+
case ESR_ELx_EC_FP_ASIMD:
182+
break;
183+
case ESR_ELx_EC_SVE:
184+
if (!sve_guest)
185+
return false;
186+
break;
187+
default:
181188
return false;
189+
}
182190

183191
/* Valid trap. Switch the context: */
184192

0 commit comments

Comments
 (0)