]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
KVM: x86/xen: Add KVM_XEN_INVALID_GPA and KVM_XEN_INVALID_GFN to uapi
authorDavid Woodhouse <dwmw@amazon.co.uk>
Mon, 26 Dec 2022 12:03:19 +0000 (12:03 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 27 Dec 2022 11:01:49 +0000 (06:01 -0500)
These are (uint64_t)-1 magic values are a userspace ABI, allowing the
shared info pages and other enlightenments to be disabled. This isn't
a Xen ABI because Xen doesn't let the guest turn these off except with
the full SHUTDOWN_soft_reset mechanism. Under KVM, the userspace VMM is
expected to handle soft reset, and tear down the kernel parts of the
enlightenments accordingly.

Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Message-Id: <20221226120320.1125390-5-dwmw2@infradead.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/xen.c
include/uapi/linux/kvm.h

index bddbe5ac5cfa2d23f7d9c6d5801a1c119d0fcdf7..b178f40bd863c2c56115b8c56fdd6bf870ec7741 100644 (file)
@@ -41,7 +41,7 @@ static int kvm_xen_shared_info_init(struct kvm *kvm, gfn_t gfn)
        int ret = 0;
        int idx = srcu_read_lock(&kvm->srcu);
 
-       if (gfn == GPA_INVALID) {
+       if (gfn == KVM_XEN_INVALID_GFN) {
                kvm_gpc_deactivate(gpc);
                goto out;
        }
@@ -659,7 +659,7 @@ int kvm_xen_hvm_get_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data)
                if (kvm->arch.xen.shinfo_cache.active)
                        data->u.shared_info.gfn = gpa_to_gfn(kvm->arch.xen.shinfo_cache.gpa);
                else
-                       data->u.shared_info.gfn = GPA_INVALID;
+                       data->u.shared_info.gfn = KVM_XEN_INVALID_GFN;
                r = 0;
                break;
 
@@ -705,7 +705,7 @@ int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
                BUILD_BUG_ON(offsetof(struct vcpu_info, time) !=
                             offsetof(struct compat_vcpu_info, time));
 
-               if (data->u.gpa == GPA_INVALID) {
+               if (data->u.gpa == KVM_XEN_INVALID_GPA) {
                        kvm_gpc_deactivate(&vcpu->arch.xen.vcpu_info_cache);
                        r = 0;
                        break;
@@ -719,7 +719,7 @@ int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
                break;
 
        case KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO:
-               if (data->u.gpa == GPA_INVALID) {
+               if (data->u.gpa == KVM_XEN_INVALID_GPA) {
                        kvm_gpc_deactivate(&vcpu->arch.xen.vcpu_time_info_cache);
                        r = 0;
                        break;
@@ -739,7 +739,7 @@ int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
                        r = -EOPNOTSUPP;
                        break;
                }
-               if (data->u.gpa == GPA_INVALID) {
+               if (data->u.gpa == KVM_XEN_INVALID_GPA) {
                        r = 0;
                deactivate_out:
                        kvm_gpc_deactivate(&vcpu->arch.xen.runstate_cache);
@@ -937,7 +937,7 @@ int kvm_xen_vcpu_get_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
                if (vcpu->arch.xen.vcpu_info_cache.active)
                        data->u.gpa = vcpu->arch.xen.vcpu_info_cache.gpa;
                else
-                       data->u.gpa = GPA_INVALID;
+                       data->u.gpa = KVM_XEN_INVALID_GPA;
                r = 0;
                break;
 
@@ -945,7 +945,7 @@ int kvm_xen_vcpu_get_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data)
                if (vcpu->arch.xen.vcpu_time_info_cache.active)
                        data->u.gpa = vcpu->arch.xen.vcpu_time_info_cache.gpa;
                else
-                       data->u.gpa = GPA_INVALID;
+                       data->u.gpa = KVM_XEN_INVALID_GPA;
                r = 0;
                break;
 
index 20522d4ba1e0d8b058876d93fd9dd554910f6263..55155e262646e5fc48b6317054b07b1c15aad02a 100644 (file)
@@ -1767,6 +1767,7 @@ struct kvm_xen_hvm_attr {
                __u8 runstate_update_flag;
                struct {
                        __u64 gfn;
+#define KVM_XEN_INVALID_GFN ((__u64)-1)
                } shared_info;
                struct {
                        __u32 send_port;
@@ -1798,6 +1799,7 @@ struct kvm_xen_hvm_attr {
        } u;
 };
 
+
 /* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_SHARED_INFO */
 #define KVM_XEN_ATTR_TYPE_LONG_MODE            0x0
 #define KVM_XEN_ATTR_TYPE_SHARED_INFO          0x1
@@ -1823,6 +1825,7 @@ struct kvm_xen_vcpu_attr {
        __u16 pad[3];
        union {
                __u64 gpa;
+#define KVM_XEN_INVALID_GPA ((__u64)-1)
                __u64 pad[8];
                struct {
                        __u64 state;