Skip to content

Commit d30d9ee

Browse files
Freax13bonzini
authored andcommitted
KVM: x86: Only advertise KVM_CAP_READONLY_MEM when supported by VM
Until recently, KVM_CAP_READONLY_MEM was unconditionally supported on x86, but this is no longer the case for SEV-ES and SEV-SNP VMs. When KVM_CHECK_EXTENSION is invoked on a VM, only advertise KVM_CAP_READONLY_MEM when it's actually supported. Fixes: 66155de ("KVM: x86: Disallow read-only memslots for SEV-ES and SEV-SNP (and TDX)") Cc: Sean Christopherson <seanjc@google.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Michael Roth <michael.roth@amd.com> Signed-off-by: Tom Dohrmann <erbse.13@gmx.de> Message-ID: <20240902144219.3716974-1-erbse.13@gmx.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 1ae9959 commit d30d9ee

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/x86/kvm/x86.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4656,7 +4656,6 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
46564656
case KVM_CAP_ASYNC_PF_INT:
46574657
case KVM_CAP_GET_TSC_KHZ:
46584658
case KVM_CAP_KVMCLOCK_CTRL:
4659-
case KVM_CAP_READONLY_MEM:
46604659
case KVM_CAP_IOAPIC_POLARITY_IGNORED:
46614660
case KVM_CAP_TSC_DEADLINE_TIMER:
46624661
case KVM_CAP_DISABLE_QUIRKS:
@@ -4815,6 +4814,8 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
48154814
case KVM_CAP_VM_TYPES:
48164815
r = kvm_caps.supported_vm_types;
48174816
break;
4817+
case KVM_CAP_READONLY_MEM:
4818+
r = kvm ? kvm_arch_has_readonly_mem(kvm) : 1;
48184819
default:
48194820
break;
48204821
}

0 commit comments

Comments
 (0)