From: Joao Martins Date: Wed, 24 Oct 2018 10:38:47 +0000 (-0400) Subject: i386/xen: handle PV timers in hypervisor X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=46b7d0b454b6adceef33be53d82df80eba17b436;p=users%2Fdwmw2%2Fqemu.git i386/xen: handle PV timers in hypervisor 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 --- diff --git a/target/i386/cpu.c b/target/i386/cpu.c index b1911d49f3..afe27d0ed3 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -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), diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 687b2b8879..3e0644b239 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1488,6 +1488,7 @@ struct X86CPU { bool xen; bool xen_vapic; + bool xen_pvclock; uint32_t xen_major_version; uint32_t xen_minor_version; }; diff --git a/target/i386/xen.c b/target/i386/xen.c index c20fa5629d..2ee2bc3a0c 100644 --- a/target/i386/xen.c +++ b/target/i386/xen.c @@ -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; } } diff --git a/target/i386/xen_evtchn.c b/target/i386/xen_evtchn.c index e058a9aba2..fab8fb27fc 100644 --- a/target/i386/xen_evtchn.c +++ b/target/i386/xen_evtchn.c @@ -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;