ANDROID: KVM: arm64: Fix for do not allow memslot changes after first VM run under pKVM

Move the check for protected VMs up to ensure that we don't miss
a KVM_MR_DELETE.

Bug: 231684412
Change-Id: Ia5cecc13232e8c430f2a1747a3cebd7e7bd5e348
Signed-off-by: Fuad Tabba <tabba@google.com>
This commit is contained in:
Fuad Tabba
2022-05-06 10:28:06 +00:00
parent b9b94e2aca
commit c607c61848

View File

@@ -1853,10 +1853,6 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
hva_t reg_end = hva + mem->memory_size;
int ret = 0;
if (change != KVM_MR_CREATE && change != KVM_MR_MOVE &&
change != KVM_MR_FLAGS_ONLY)
return 0;
/* In protected mode, cannot modify memslots once a VM has run. */
if (is_protected_kvm_enabled() &&
(change == KVM_MR_DELETE || change == KVM_MR_MOVE) &&
@@ -1864,6 +1860,10 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm,
return -EPERM;
}
if (change != KVM_MR_CREATE && change != KVM_MR_MOVE &&
change != KVM_MR_FLAGS_ONLY)
return 0;
/*
* Prevent userspace from creating a memory region outside of the IPA
* space addressable by the KVM guest IPA space.