aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2024-10-11 10:39:58 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2024-10-17 19:41:30 +0200
commit586d708c1e3e5e29a0b3c05c347290aed9478854 (patch)
tree222e9776af6c0a9fe20d7f68be249ce63dfaf3bd
parent60de433d4cb17211dbea5c1e6b74d476dec16370 (diff)
downloadqemu-586d708c1e3e5e29a0b3c05c347290aed9478854.zip
qemu-586d708c1e3e5e29a0b3c05c347290aed9478854.tar.gz
qemu-586d708c1e3e5e29a0b3c05c347290aed9478854.tar.bz2
accel/kvm: check for KVM_CAP_MEMORY_ATTRIBUTES on vm
The exact set of available memory attributes can vary by VM. In the future it might vary depending on enabled capabilities, too. Query the extension on the VM level instead of on the KVM level, and only after architecture-specific initialization. Inspired by an analogous patch by Tom Dohrmann. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--accel/kvm/kvm-all.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index d985486..801cff1 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -2604,12 +2604,6 @@ static int kvm_init(MachineState *ms)
goto err;
}
- kvm_supported_memory_attributes = kvm_check_extension(s, KVM_CAP_MEMORY_ATTRIBUTES);
- kvm_guest_memfd_supported =
- kvm_check_extension(s, KVM_CAP_GUEST_MEMFD) &&
- kvm_check_extension(s, KVM_CAP_USER_MEMORY2) &&
- (kvm_supported_memory_attributes & KVM_MEMORY_ATTRIBUTE_PRIVATE);
-
kvm_immediate_exit = kvm_check_extension(s, KVM_CAP_IMMEDIATE_EXIT);
s->nr_slots_max = kvm_check_extension(s, KVM_CAP_NR_MEMSLOTS);
@@ -2723,6 +2717,12 @@ static int kvm_init(MachineState *ms)
goto err;
}
+ kvm_supported_memory_attributes = kvm_vm_check_extension(s, KVM_CAP_MEMORY_ATTRIBUTES);
+ kvm_guest_memfd_supported =
+ kvm_check_extension(s, KVM_CAP_GUEST_MEMFD) &&
+ kvm_check_extension(s, KVM_CAP_USER_MEMORY2) &&
+ (kvm_supported_memory_attributes & KVM_MEMORY_ATTRIBUTE_PRIVATE);
+
if (s->kernel_irqchip_split == ON_OFF_AUTO_AUTO) {
s->kernel_irqchip_split = mc->default_kernel_irqchip_split ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF;
}