]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
accel/kvm: check for KVM_CAP_MULTI_ADDRESS_SPACE on vm
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 11 Oct 2024 08:39:58 +0000 (10:39 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 17 Oct 2024 17:41:30 +0000 (19:41 +0200)
KVM_CAP_MULTI_ADDRESS_SPACE used to be a global capability, but with the
introduction of AMD SEV-SNP confidential VMs, the number of address spaces
can vary by VM type.

Query the extension on the VM level instead of on the KVM level.

Inspired by an analogous patch by Tom Dohrmann.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
accel/kvm/kvm-all.c

index 99746436bfa660944d626fd4fcddfe4c9da06239..d985486a053a616f5c66f596e5e4c77c6a8c2a8d 100644 (file)
@@ -2618,12 +2618,6 @@ static int kvm_init(MachineState *ms)
         s->nr_slots_max = KVM_MEMSLOTS_NR_MAX_DEFAULT;
     }
 
-    s->nr_as = kvm_check_extension(s, KVM_CAP_MULTI_ADDRESS_SPACE);
-    if (s->nr_as <= 1) {
-        s->nr_as = 1;
-    }
-    s->as = g_new0(struct KVMAs, s->nr_as);
-
     type = find_kvm_machine_type(ms);
     if (type < 0) {
         ret = -EINVAL;
@@ -2637,6 +2631,12 @@ static int kvm_init(MachineState *ms)
 
     s->vmfd = ret;
 
+    s->nr_as = kvm_vm_check_extension(s, KVM_CAP_MULTI_ADDRESS_SPACE);
+    if (s->nr_as <= 1) {
+        s->nr_as = 1;
+    }
+    s->as = g_new0(struct KVMAs, s->nr_as);
+
     /* check the vcpu limits */
     soft_vcpus_limit = kvm_recommended_vcpus(s);
     hard_vcpus_limit = kvm_max_vcpus(s);