]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
i386/xen: handle PV timers in hypervisor
authorJoao Martins <joao.m.martins@oracle.com>
Wed, 24 Oct 2018 10:38:47 +0000 (06:38 -0400)
committerJoao Martins <joao.m.martins@oracle.com>
Tue, 19 Feb 2019 14:00:57 +0000 (09:00 -0500)
This tells the hypervisor that PV timers will be handled in hypervisor,
and as such we won't receive userspace exits for oneshot modes.

Also introduce 'xen-pvclock' to toggle kvmclock usage. This cpu
feature controls whether version hypercall exposes the
XENFEAT_hvm_safe_pvclock bit.

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

index b1911d49f3d5f5636b9d645cba6369d2bcb0ab59..afe27d0ed352cafd8c202e89b9cca599df6e9015 100644 (file)
@@ -5810,6 +5810,7 @@ static Property x86_cpu_properties[] = {
     DEFINE_PROP_BOOL("legacy-cache", X86CPU, legacy_cache, true),
     DEFINE_PROP_BOOL("xen", X86CPU, xen, false),
     DEFINE_PROP_BOOL("xen-vapic", X86CPU, xen_vapic, false),
+    DEFINE_PROP_BOOL("xen-pvclock", X86CPU, xen_pvclock, true),
     DEFINE_PROP_UINT32("xen-major-version", X86CPU, xen_major_version, 3),
     DEFINE_PROP_UINT32("xen-minor-version", X86CPU, xen_minor_version, 2),
 
index 687b2b887962cdb7fcf587f43810ce2e6aaa361d..3e0644b239440292c8cc3d6b28d1033f27d84cc0 100644 (file)
@@ -1488,6 +1488,7 @@ struct X86CPU {
 
     bool xen;
     bool xen_vapic;
+    bool xen_pvclock;
     uint32_t xen_major_version;
     uint32_t xen_minor_version;
 };
index c20fa5629d3b9e056d85014c3057497a4f056ce0..2ee2bc3a0cff66bf78cae12853d10bd30dd79a20 100644 (file)
@@ -180,6 +180,11 @@ static int kvm_xen_hcall_xen_version(struct kvm_xen_exit *exit, X86CPU *cpu,
              */
             fi->submap = (1U << XENFEAT_auto_translated_physmap) |
                          (1U << XENFEAT_hvm_callback_vector);
+
+            if (cpu->xen_pvclock) {
+                fi->submap |= (1U << XENFEAT_hvm_safe_pvclock);
+            }
+
             break;
          }
     }
index e058a9aba2c0aeb32f7909d1e5474d1cf50659ed..fab8fb27fc7223adb198686f27afc21ac9c6d704 100644 (file)
@@ -330,6 +330,11 @@ int kvm_xen_evtchn_bind_virq(X86CPU *cpu, void *arg)
 
     kvm_xen_run_on_cpu(dest, xen_vcpu_set_evtchn, evtchn);
 
+    /* We want to offload timers where possible */
+    if (evtchn->virq == VIRQ_TIMER) {
+        kvm_set_xen_event(dest->kvm_state, evtchn, NULL);
+    }
+
     out->port = evtchn->port;
 
     return 0;