Skip to contentSkip to conversation

accel/kvm: check for KVM_CAP_READONLY_MEM on VM

PATCH In review Paolo Bonzini 2 participants 2 messages Oct 11, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 accel/kvm: check for KVM_CAP_READONLY_MEM on VM

From: Tom Dohrmann <[email protected]>

KVM_CAP_READONLY_MEM used to be a global capability, but with the introduction of AMD SEV-SNP confidential VMs, this extension is not always available on all VM types [1,2].

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

[1] https://patchwork.kernel.org/project/kvm/patch/[email protected]/
[2] https://patchwork.kernel.org/project/kvm/patch/[email protected]/

---
 accel/kvm/kvm-all.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
accel/kvm/kvm-all.c +1 -1
index 482c5b24cf6..801cff16a5a 100644
@@ -2683,7 +2683,7 @@ static int kvm_init(MachineState *ms)
     }
 
     kvm_readonly_mem_allowed =
-        (kvm_check_extension(s, KVM_CAP_READONLY_MEM) > 0);
+        (kvm_vm_check_extension(s, KVM_CAP_READONLY_MEM) > 0);
 
     kvm_resamplefds_allowed =
         (kvm_check_extension(s, KVM_CAP_IRQFD_RESAMPLE) > 0);
Signature · 1 line
2.46.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines

KVM_CAP_READONLY_MEM used to be a global capability, but with the introduction of AMD SEV-SNP confidential VMs, this extension is not always available on all VM types [1,2].

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

Quoted 7 lines

[1] https://patchwork.kernel.org/project/kvm/patch/[email protected]/
[2] https://patchwork.kernel.org/project/kvm/patch/[email protected]/

Quoted 17 lines
---
  accel/kvm/kvm-all.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
accel/kvm/kvm-all.c +1 -1
index 482c5b24cf6..801cff16a5a 100644
@@ -2683,7 +2683,7 @@ static int kvm_init(MachineState *ms)
      }
 
      kvm_readonly_mem_allowed =
-        (kvm_check_extension(s, KVM_CAP_READONLY_MEM) > 0);
+        (kvm_vm_check_extension(s, KVM_CAP_READONLY_MEM) > 0);
 
      kvm_resamplefds_allowed =
          (kvm_check_extension(s, KVM_CAP_IRQFD_RESAMPLE) > 0);