Re: [RFC PATCH 12/16] KVM: arm64/sve: Context switch the SVE registers

Dave Martin
2018-08-08T08:23:41Z

On Tue, Aug 07, 2018 at 09:43:38PM +0200, Christoffer Dall wrote:
> On Tue, Aug 07, 2018 at 12:15:26PM +0100, Dave Martin wrote:
> > On Mon, Aug 06, 2018 at 03:19:10PM +0200, Christoffer Dall wrote:

[...]

> > > nit: this may also be folded nicely into a static bool
> > > __trap_fpsimd_sve_access() check.
> >
> > It wouldn't hurt to make this look less fiddly, certainly.
> >
> > Can you elaborate on precisely what you had in mind?
>
> sure:
>
> static bool __hyp_text __trap_is_fpsimd_sve_access(struct kvm_vcpu *vcpu)
> {
> /*
> * Can we support SVE without FPSIMD? If not, this can be
> * simplified by reversing the condition.
> */
> if (system_supports_fpsimd() &&
> kvm_vcpu_trap_get_class(vcpu) == ESR_ELx_EC_FP_ASIMD)
> return true;
>
> if (guest_has_sve && kvm_vcpu_trap_get_class(vcpu) == ESR_ELx_EC_SVE)
> return true;
>
> return false;
> }
>
>
> static bool __hyp_text fixup_guest_exit(struct kvm_vcpu *vcpu, u64 *exit_code)
> {
> [...]
> if (__trap_is_fpsimd_sve_access(vcpu))
> return __hyp_switch_fpsimd(vcpu, guest_has_sve);
> [...]
> }
>
> Of course not even compile-tested or anything like that.

Sure, I can do something along these line. The conditions are indeed a
bit unwieldy today.

Cheers
---Dave