Skip to content

Commit e0b7de4

Browse files
sean-jcMarc Zyngier
authored andcommitted
KVM: arm64: Disallow copying MTE to guest memory while KVM is dirty logging
Disallow copying MTE tags to guest memory while KVM is dirty logging, as writing guest memory without marking the gfn as dirty in the memslot could result in userspace failing to migrate the updated page. Ideally (maybe?), KVM would simply mark the gfn as dirty, but there is no vCPU to work with, and presumably the only use case for copy MTE tags _to_ the guest is when restoring state on the target. Fixes: f0376ed ("KVM: arm64: Add ioctl to fetch/store tags in a guest") Signed-off-by: Sean Christopherson <[email protected]> Reviewed-by: Steven Price <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent ae41d7d commit e0b7de4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

arch/arm64/kvm/guest.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,11 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm,
10451045

10461046
mutex_lock(&kvm->slots_lock);
10471047

1048+
if (write && atomic_read(&kvm->nr_memslots_dirty_logging)) {
1049+
ret = -EBUSY;
1050+
goto out;
1051+
}
1052+
10481053
while (length > 0) {
10491054
kvm_pfn_t pfn = gfn_to_pfn_prot(kvm, gfn, write, NULL);
10501055
void *maddr;

0 commit comments

Comments
 (0)