]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
i386/xen: handle HVMOP_get_param
authorJoao Martins <joao.m.martins@oracle.com>
Fri, 28 Sep 2018 17:17:47 +0000 (13:17 -0400)
committerJoao Martins <joao.m.martins@oracle.com>
Tue, 19 Feb 2019 14:00:57 +0000 (09:00 -0500)
Which is used to fetch xenstore PFN and port to be used
by the guest. This is preallocated by the toolstack when
guest will just read those and use it straight away.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
target/i386/xen.c

index c342f6f3206485a7a796dec7c2c581d94765b6dc..959c4cf9fc55390ffd072de32b74e20ee25d8d09 100644 (file)
@@ -461,8 +461,50 @@ static int kvm_xen_hcall_evtchn_upcall_vector(struct kvm_xen_exit *exit,
     xcpu->cb.virq = err;
 
 out:
-    exit->u.hcall.result = err;
-    return err ? HCALL_ERR : 0;
+    return err;
+}
+
+static int handle_get_param(struct kvm_xen_exit *exit, X86CPU *cpu,
+                            uint64_t arg)
+{
+    CPUState *cs = CPU(cpu);
+    XenState *xen = cs->xen_state;
+    struct xen_hvm_param *hp;
+    int err;
+
+    hp = gva_to_hva(cs, arg);
+    if (!hp) {
+        err = -EFAULT;
+        goto out;
+    }
+
+    if (hp->domid != DOMID_SELF) {
+        err = -EINVAL;
+        goto out;
+    }
+
+    err = 0;
+    switch (hp->index) {
+    case HVM_PARAM_STORE_PFN:
+        if (X86_CPU(cs)->xen_xenbus) {
+            hp->value = xen->xenstore_pfn;
+        } else {
+            err = -ENOSYS;
+        }
+        break;
+    case HVM_PARAM_STORE_EVTCHN:
+        if (X86_CPU(cs)->xen_xenbus) {
+            hp->value = xen->xenstore_port;
+        } else {
+            err = -ENOSYS;
+        }
+        break;
+    default:
+        err = -ENOSYS;
+        break;
+    }
+out:
+    return err;
 }
 
 static int kvm_xen_hcall_hvm_op(struct kvm_xen_exit *exit, X86CPU *cpu,
@@ -478,6 +520,10 @@ static int kvm_xen_hcall_hvm_op(struct kvm_xen_exit *exit, X86CPU *cpu,
             ret = handle_set_param(exit, cpu, arg);
             break;
         }
+    case HVMOP_get_param: {
+            ret = handle_get_param(exit, cpu, arg);
+            break;
+        }
     }
 
     exit->u.hcall.result = ret;