ANDROID: KVM: arm64: Only unpin a vCPU SVE state if set

This avoid unpinning NULL state.

Bug: 256125458
Signed-off-by: Fuad Tabba <tabba@google.com>
Change-Id: I9d346e0705a69b69704fd30ab09635548763229e
This commit is contained in:
Fuad Tabba
2022-10-28 13:29:38 +01:00
parent d6b5e9db8c
commit 379be12c0f

View File

@@ -373,15 +373,14 @@ 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;
void *sve_state = shadow_vcpu->arch.sve_state;
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))
if (!sve_state)
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);