* [PATCH] i386/xen: Ignore VCPU_SSHOTTMR_future flag in set_singleshot_timer()
@ 2023-08-23 11:58 David Woodhouse
2023-08-25 10:02 ` Paul Durrant
0 siblings, 1 reply; 2+ messages in thread
From: David Woodhouse @ 2023-08-23 11:58 UTC (permalink / raw)
To: qemu-devel
Cc: Paul Durrant, Paolo Bonzini, Marcelo Tosatti, kvm,
Roger Pau Monné, Jan Beulich
[-- Attachment #1: Type: text/plain, Size: 3204 bytes --]
From: David Woodhouse <dwmw@amazon.co.uk>
Upstream Xen now ignores this flag¹, since the only guest kernel ever to
use it was buggy.
¹ https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=19c6cbd909
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
We do take an argument to emulate a specific Xen version, and
*theoretically* we could ignore the VCPU_SSHOTTMR_future flag only if
we're emulating Xen 4.17 or newer? But I don't think it's worth doing
that (and QEMU won't be the only instance of Xen emulation or even real
older Xen versions patched to ignore the flag).
target/i386/kvm/xen-emu.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/target/i386/kvm/xen-emu.c b/target/i386/kvm/xen-emu.c
index b307c75713..3810dc7d70 100644
--- a/target/i386/kvm/xen-emu.c
+++ b/target/i386/kvm/xen-emu.c
@@ -1070,17 +1070,13 @@ static int vcpuop_stop_periodic_timer(CPUState *target)
* Must always be called with xen_timers_lock held.
*/
static int do_set_singleshot_timer(CPUState *cs, uint64_t timeout_abs,
- bool future, bool linux_wa)
+ bool linux_wa)
{
CPUX86State *env = &X86_CPU(cs)->env;
int64_t now = kvm_get_current_ns();
int64_t qemu_now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
int64_t delta = timeout_abs - now;
- if (future && timeout_abs < now) {
- return -ETIME;
- }
-
if (linux_wa && unlikely((int64_t)timeout_abs < 0 ||
(delta > 0 && (uint32_t)(delta >> 50) != 0))) {
/*
@@ -1122,9 +1118,13 @@ static int vcpuop_set_singleshot_timer(CPUState *cs, uint64_t arg)
}
QEMU_LOCK_GUARD(&X86_CPU(cs)->env.xen_timers_lock);
- return do_set_singleshot_timer(cs, sst.timeout_abs_ns,
- !!(sst.flags & VCPU_SSHOTTMR_future),
- false);
+
+ /*
+ * We ignore the VCPU_SSHOTTMR_future flag, just as Xen now does.
+ * The only guest that ever used it, got it wrong.
+ * https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=19c6cbd909
+ */
+ return do_set_singleshot_timer(cs, sst.timeout_abs_ns, false);
}
static int vcpuop_stop_singleshot_timer(CPUState *cs)
@@ -1149,7 +1149,7 @@ static bool kvm_xen_hcall_set_timer_op(struct kvm_xen_exit *exit, X86CPU *cpu,
err = vcpuop_stop_singleshot_timer(CPU(cpu));
} else {
QEMU_LOCK_GUARD(&X86_CPU(cpu)->env.xen_timers_lock);
- err = do_set_singleshot_timer(CPU(cpu), timeout, false, true);
+ err = do_set_singleshot_timer(CPU(cpu), timeout, true);
}
exit->u.hcall.result = err;
return true;
@@ -1837,7 +1837,7 @@ int kvm_put_xen_state(CPUState *cs)
QEMU_LOCK_GUARD(&env->xen_timers_lock);
if (env->xen_singleshot_timer_ns) {
ret = do_set_singleshot_timer(cs, env->xen_singleshot_timer_ns,
- false, false);
+ false);
if (ret < 0) {
return ret;
}
--
2.34.1
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] i386/xen: Ignore VCPU_SSHOTTMR_future flag in set_singleshot_timer()
2023-08-23 11:58 [PATCH] i386/xen: Ignore VCPU_SSHOTTMR_future flag in set_singleshot_timer() David Woodhouse
@ 2023-08-25 10:02 ` Paul Durrant
0 siblings, 0 replies; 2+ messages in thread
From: Paul Durrant @ 2023-08-25 10:02 UTC (permalink / raw)
To: David Woodhouse, qemu-devel
Cc: Paolo Bonzini, Marcelo Tosatti, kvm, Roger Pau Monné,
Jan Beulich
On 23/08/2023 12:58, David Woodhouse wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
>
> Upstream Xen now ignores this flag¹, since the only guest kernel ever to
> use it was buggy.
>
> ¹ https://xenbits.xen.org/gitweb/?p=xen.git;a=commitdiff;h=19c6cbd909
>
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> ---
> We do take an argument to emulate a specific Xen version, and
> *theoretically* we could ignore the VCPU_SSHOTTMR_future flag only if
> we're emulating Xen 4.17 or newer? But I don't think it's worth doing
> that (and QEMU won't be the only instance of Xen emulation or even real
> older Xen versions patched to ignore the flag).
>
> target/i386/kvm/xen-emu.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
Reviewed-by: Paul Durrant <paul@xen.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-25 10:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-23 11:58 [PATCH] i386/xen: Ignore VCPU_SSHOTTMR_future flag in set_singleshot_timer() David Woodhouse
2023-08-25 10:02 ` Paul Durrant
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).