Message ID | 20230526221712.317287-1-oliver.upton@linux.dev (mailing list archive) |
---|---|
Headers | show |
Series | arm64: Handle PSCI calls in userspace | expand |
Hi Oliver, On Fri, May 26, 2023 at 10:16:51PM +0000, Oliver Upton wrote: > The 6.4 kernel picks up support for a generalized SMCCC filter, allowing > userspace to select hypercall ranges that should be forwarded to > userspace. This is a shameless attempt of making future SMCCC interfaces > the responsibility of userspace :) > > As a starting point, let's move PSCI up into userspace. KVM already > leans on userspace for handling calls that have a system-wide effect. > > Tested on linux-next with a 64 vCPU VM. Additionally, I took a stab at > running kvm-unit-test's psci test, which passes. I applied these patches to kvmtool and tested 6.4, however they don't work with an SVE enabled kernel/device. # ./lkvm run -c 2 -m 4 -k psci.flat INFO: psci: PSCI version 1.0 PASS: psci: invalid-function PASS: psci: affinity-info-on PASS: psci: affinity-info-off Error: KVM_ARM_VCPU_FINALIZE: Operation not permitted Fatal: Unable to configure requested vcpu features `kvm_cpu__configure_features` in kvmtool is failing because Linux returns an error if SVE was already finalised (arch/arm64/kvm/reset.c): ``` int kvm_arm_vcpu_finalize(struct kvm_vcpu *vcpu, int feature) { switch (feature) { case KVM_ARM_VCPU_SVE: if (!vcpu_has_sve(vcpu)) return -EINVAL; if (kvm_arm_vcpu_sve_finalized(vcpu)) return -EPERM; // <---- returns here return kvm_vcpu_finalize_sve(vcpu); } return -EINVAL; } ``` It's not immediately obvious to me why finalising SVE twice is an error. Changing that to `return 0;` gets the test passing, but not sure if there are other implications. I also booted with `arm64.nosve` and the test passed. Thanks, Joey
Hey Joey, Thanks for the review and taking the patches for a spin. On Wed, Jun 14, 2023 at 01:05:03PM +0100, Joey Gouly wrote: > `kvm_cpu__configure_features` in kvmtool is failing because Linux returns an > error if SVE was already finalised (arch/arm64/kvm/reset.c): > > ``` > int kvm_arm_vcpu_finalize(struct kvm_vcpu *vcpu, int feature) > { > switch (feature) { > case KVM_ARM_VCPU_SVE: > if (!vcpu_has_sve(vcpu)) > return -EINVAL; > > if (kvm_arm_vcpu_sve_finalized(vcpu)) > return -EPERM; // <---- returns here > > return kvm_vcpu_finalize_sve(vcpu); > } > > return -EINVAL; > } > ``` > > It's not immediately obvious to me why finalising SVE twice is an error. > Changing that to `return 0;` gets the test passing, but not sure if there > are other implications. This is utterly mindless on my part, apologies. The SVE feature shouldn't be finalised (again). I'll probably drop patch 8 altogether and replace its usage with a direct call to KVM_ARM_VCPU_INIT.