mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-25 12:00:22 +09:00
ANDROID: KVM: arm64: pkvm: Track the SVE state in the shadow vcpu
When dealing with a guest with SVE enabled, we don't populate the shadow SVE state, nor pin the SVE state at S1 EL2. Fix both issues in one go. Bug: 227292021 Signed-off-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Marc Zyngier <mzyngier@google.com> Change-Id: I88dc7e9c84e5970ec2466a0aa98ad4e3c94711a0
This commit is contained in:
committed by
Marc Zyngier
parent
7cea3ceefb
commit
34469ce1b4
@@ -354,8 +354,19 @@ static void unpin_host_vcpus(struct shadow_vcpu_state *shadow_vcpus, int nr_vcpu
|
||||
|
||||
for (i = 0; i < nr_vcpus; i++) {
|
||||
struct kvm_vcpu *host_vcpu = shadow_vcpus[i].vcpu.arch.pkvm.host_vcpu;
|
||||
struct kvm_vcpu *shadow_vcpu = &shadow_vcpus[i].vcpu;
|
||||
size_t sve_state_size;
|
||||
void *sve_state;
|
||||
|
||||
hyp_unpin_shared_mem(host_vcpu, host_vcpu + 1);
|
||||
|
||||
if (!test_bit(KVM_ARM_VCPU_SVE, shadow_vcpu->arch.features))
|
||||
continue;
|
||||
|
||||
sve_state = shadow_vcpu->arch.sve_state;
|
||||
sve_state = kern_hyp_va(sve_state);
|
||||
sve_state_size = vcpu_sve_state_size(shadow_vcpu);
|
||||
hyp_unpin_shared_mem(sve_state, sve_state + sve_state_size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,6 +416,27 @@ static int init_shadow_structs(struct kvm *kvm, struct kvm_shadow_vm *vm,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (test_bit(KVM_ARM_VCPU_SVE, shadow_vcpu->arch.features)) {
|
||||
size_t sve_state_size;
|
||||
void *sve_state;
|
||||
|
||||
shadow_vcpu->arch.sve_state = READ_ONCE(host_vcpu->arch.sve_state);
|
||||
shadow_vcpu->arch.sve_max_vl = READ_ONCE(host_vcpu->arch.sve_max_vl);
|
||||
|
||||
sve_state = kern_hyp_va(shadow_vcpu->arch.sve_state);
|
||||
sve_state_size = vcpu_sve_state_size(shadow_vcpu);
|
||||
|
||||
if (!shadow_vcpu->arch.sve_state || !sve_state_size ||
|
||||
hyp_pin_shared_mem(sve_state,
|
||||
sve_state + sve_state_size)) {
|
||||
clear_bit(KVM_ARM_VCPU_SVE,
|
||||
shadow_vcpu->arch.features);
|
||||
shadow_vcpu->arch.sve_state = NULL;
|
||||
shadow_vcpu->arch.sve_max_vl = 0;
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
if (vm->arch.pkvm.enabled)
|
||||
pkvm_vcpu_init_traps(shadow_vcpu);
|
||||
kvm_reset_pvm_sys_regs(shadow_vcpu);
|
||||
|
||||
Reference in New Issue
Block a user