]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
KVM: Forbid the use of tagged userspace addresses for memslots
authorMarc Zyngier <maz@kernel.org>
Thu, 21 Jan 2021 12:08:15 +0000 (12:08 +0000)
committerMarc Zyngier <maz@kernel.org>
Thu, 21 Jan 2021 14:17:36 +0000 (14:17 +0000)
The use of a tagged address could be pretty confusing for the
whole memslot infrastructure as well as the MMU notifiers.

Forbid it altogether, as it never quite worked the first place.

Cc: stable@vger.kernel.org
Reported-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Documentation/virt/kvm/api.rst
virt/kvm/kvm_main.c

index 4e5316ed10e90b70076b25e0463a38c9cf14f593..c347b7083abf4640db2eae3a8c27378a07c4dacc 100644 (file)
@@ -1269,6 +1269,9 @@ field userspace_addr, which must point at user addressable memory for
 the entire memory slot size.  Any object may back this memory, including
 anonymous memory, ordinary files, and hugetlbfs.
 
+On architectures that support a form of address tagging, userspace_addr must
+be an untagged address.
+
 It is recommended that the lower 21 bits of guest_phys_addr and userspace_addr
 be identical.  This allows large pages in the guest to be backed by large
 pages in the host.
index 2541a17ff1c45394e5de176ac52669b4785f5420..a9abaf5f8e53c832e02bc06f5176a2efa3157432 100644 (file)
@@ -1290,6 +1290,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
                return -EINVAL;
        /* We can read the guest memory with __xxx_user() later on. */
        if ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
+           (mem->userspace_addr != untagged_addr(mem->userspace_addr)) ||
             !access_ok((void __user *)(unsigned long)mem->userspace_addr,
                        mem->memory_size))
                return -EINVAL;