Skip to content

Commit 0cc3cb2

Browse files
committed
KVM: Disallow all flags for KVM-internal memslots
Disallow all flags for KVM-internal memslots as all existing flags require some amount of userspace interaction to have any meaning. In addition to guarding against KVM goofs, explicitly disallowing dirty logging of KVM- internal memslots will (hopefully) allow exempting KVM-internal memslots from the KVM_MEM_MAX_NR_PAGES limit, which appears to exist purely because the dirty bitmap operations use a 32-bit index. Cc: Xiaoyao Li <xiaoyao.li@intel.com> Cc: Claudio Imbrenda <imbrenda@linux.ibm.com> Cc: Christian Borntraeger <borntraeger@de.ibm.com> Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com> Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Acked-by: Christoph Schlameuss <schlameuss@linux.ibm.com> Link: https://lore.kernel.org/r/20250111002022.1230573-6-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 344315e commit 0cc3cb2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

virt/kvm/kvm_main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,6 +2057,9 @@ int kvm_set_internal_memslot(struct kvm *kvm,
20572057
if (WARN_ON_ONCE(mem->slot < KVM_USER_MEM_SLOTS))
20582058
return -EINVAL;
20592059

2060+
if (WARN_ON_ONCE(mem->flags))
2061+
return -EINVAL;
2062+
20602063
return kvm_set_memory_region(kvm, mem);
20612064
}
20622065
EXPORT_SYMBOL_GPL(kvm_set_internal_memslot);

0 commit comments

Comments
 (0)