From patchwork Thu Apr 21 13:34:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 8900841 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2B5819F457 for ; Thu, 21 Apr 2016 13:36:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 568D2202DD for ; Thu, 21 Apr 2016 13:36:46 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7B8DD20295 for ; Thu, 21 Apr 2016 13:36:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1atEkr-0003HH-5K; Thu, 21 Apr 2016 13:34:49 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1atEkq-0003HA-Mv for xen-devel@lists.xenproject.org; Thu, 21 Apr 2016 13:34:48 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 85/41-18833-8F6D8175; Thu, 21 Apr 2016 13:34:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNIsWRWlGSWpSXmKPExsVybKJsh+73axL hBrMfK1h83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBm7lr5hLljCWbGkZyFLA+Nz9i5GLg4hgamM Ej2nJrBAOJ1MEt3L21i7GDk5WAS0JS7Oa2IDsdkEDCX+PtkEZHNwSADZSz5zgIRFBKQltt95z woSZhYIldi8SQEkLCxgKvFuxVmwMK+At8TzA4wgYVEBXYlD//6ADeQVEJQ4OfMJC4jNLKAlsX z6NjBbQiBDYl7PHFYI20ti0Y1LULaaxNVzm5gnMPLPQtI+C0n7AkamVYzqxalFZalFusZ6SUW Z6RkluYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiBgcYABDsYO/45HWKU5GBSEuWN3CMRLsSX lJ9SmZFYnBFfVJqTWnyIUYaDQ0mC99FVoJxgUWp6akVaZg4w5GHSEhw8SiK8N0HSvMUFibnFm ekQqVOMilLivEdBEgIgiYzSPLg2WJxdYpSVEuZlBDpEiKcgtSg3swRV/hWjOAejkjDvKZApPJ l5JXDTXwEtZgJazH9XFGRxSSJCSqqBUVL+Heud1p13EvMdDk11+tp17rDYRvs5dhqy7pO7Pum +tTrucHzLEYmrIS8Fr2WVp4qVfd0scJ5He7OCTPsxa/7SrHLhu9rLTpVVnLF6fIOhM2TpyneK nb5/bnFdEF5inJRe4Dd9xsf2syqlKwTX7D/14XH7jr1Gf98sFFswZfclP577jOtqLJRYijMSD bWYi4oTAYTWetmuAgAA X-Env-Sender: sstabellini@kernel.org X-Msg-Ref: server-6.tower-21.messagelabs.com!1461245684!10581178!1 X-Originating-IP: [198.145.29.136] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 63554 invoked from network); 21 Apr 2016 13:34:47 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.136) by server-6.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 21 Apr 2016 13:34:47 -0000 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 Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable 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 Cc: xen-devel@lists.xenproject.org, sstabellini@kernel.org, roger.pau@citrix.com Subject: [Xen-devel] [PATCH] xen/x86: don't lose event interrupts X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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)); }