i386/sev: Enable KVM_HC_MAP_GPA_RANGE hcall for SNP guests
authorMichael Roth <michael.roth@amd.com>
Thu, 30 May 2024 11:16:43 +0000 (06:16 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 5 Jun 2024 09:01:06 +0000 (11:01 +0200)
KVM will forward GHCB page-state change requests to userspace in the
form of KVM_HC_MAP_GPA_RANGE, so make sure the hypercall handling is
enabled for SNP guests.

Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Pankaj Gupta <pankaj.gupta@amd.com>
Message-ID: <20240530111643.1091816-32-pankaj.gupta@amd.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/sev.c

index eaf5fc6c6b5d8ae749a500f978dcc849979d643d..abb63062ac678d02d8bdf8ab7564bbf026ac999f 100644 (file)
@@ -14,6 +14,7 @@
 #include "qemu/osdep.h"
 
 #include <linux/kvm.h>
+#include <linux/kvm_para.h>
 #include <linux/psp-sev.h>
 
 #include <sys/ioctl.h>
@@ -758,6 +759,10 @@ sev_snp_launch_start(SevCommonState *sev_common)
     trace_kvm_sev_snp_launch_start(start->policy,
                                    sev_snp_guest->guest_visible_workarounds);
 
+    if (!kvm_enable_hypercall(BIT_ULL(KVM_HC_MAP_GPA_RANGE))) {
+            return 1;
+    }
+
     rc = sev_ioctl(sev_common->sev_fd, KVM_SEV_SNP_LAUNCH_START,
                    start, &fw_error);
     if (rc < 0) {