From owner-freebsd-xen@freebsd.org Thu Apr 21 13:44:03 2016 Return-Path: Delivered-To: freebsd-xen@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A3ACDB178B0 for ; Thu, 21 Apr 2016 13:44:03 +0000 (UTC) (envelope-from sstabellini@kernel.org) Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8A2041EB4 for ; Thu, 21 Apr 2016 13:44:03 +0000 (UTC) (envelope-from sstabellini@kernel.org) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3627B2026F; Thu, 21 Apr 2016 13:34:36 +0000 (UTC) Received: from [10.0.0.5] (107.238.189.80.dyn.plus.net [80.189.238.107]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8A4592025A; Thu, 21 Apr 2016 13:34:34 +0000 (UTC) Date: Thu, 21 Apr 2016 14:34:25 +0100 (BST) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-X260 To: freebsd-xen@freebsd.org cc: xen-devel@lists.xenproject.org, sstabellini@kernel.org, roger.pau@citrix.com Subject: [PATCH] xen/x86: don't lose event interrupts Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP X-BeenThere: freebsd-xen@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Discussion of the freebsd port to xen - implementation and usage List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Apr 2016 13:44:03 -0000 xen/x86: don't lose event interrupts On slow platforms with unreliable TSC, such as QEMU emulated machines, it is possible for the FreeBSD kernel to request the next event in the past. In that case, in the current implementation of xentimer_vcpu_start_timer, we simply return -ETIME. To be precise Xen returns -ETIME and we pass it on. As a consequence we need to loop around to function to make sure that the timer is properly set. Instead it is better to always ask the hypervisor for a timer event, even if the timeout is past. To do that, remove the VCPU_SSHOTTMR_future flag. Signed-off-by: Stefano Stabellini diff --git a/sys/dev/xen/timer/timer.c b/sys/dev/xen/timer/timer.c index 53aff0a..db9b19b 100644 --- a/sys/dev/xen/timer/timer.c +++ b/sys/dev/xen/timer/timer.c @@ -267,7 +267,8 @@ xentimer_vcpu_start_timer(int vcpu, uint64_t next_time) struct vcpu_set_singleshot_timer single; single.timeout_abs_ns = next_time; - single.flags = VCPU_SSHOTTMR_future; + /* Get an event anyway, even if the timeout is already expired */ + single.flags = 0; return (HYPERVISOR_vcpu_op(VCPUOP_set_singleshot_timer, vcpu, &single)); }