diff options
author | Sean Christopherson <[email protected]> | 2024-07-26 16:51:11 -0700 |
---|---|---|
committer | Marc Zyngier <[email protected]> | 2024-08-13 19:29:17 +0100 |
commit | e0b7de4fd18c47ebd47ec0dd1af6503d4071b943 (patch) | |
tree | 7dad5048ca6526b1be6825d26bfc0fcfdfd544df | |
parent | ae41d7dbaeb4f79134136cd65ad7015cf9ccf78a (diff) |
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: f0376edb1ddc ("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]>
-rw-r--r-- | arch/arm64/kvm/guest.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index e1f0ff08836a..962f985977c2 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -1045,6 +1045,11 @@ int kvm_vm_ioctl_mte_copy_tags(struct kvm *kvm, mutex_lock(&kvm->slots_lock); + if (write && atomic_read(&kvm->nr_memslots_dirty_logging)) { + ret = -EBUSY; + goto out; + } + while (length > 0) { kvm_pfn_t pfn = gfn_to_pfn_prot(kvm, gfn, write, NULL); void *maddr; |