From patchwork Sat Apr 16 01:23:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 8860791 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2B699BF29F for ; Sat, 16 Apr 2016 01:26:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5D78120279 for ; Sat, 16 Apr 2016 01:26:02 +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 7AB8D2026F for ; Sat, 16 Apr 2016 01:26:01 +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 1arEx8-0004jc-LO; Sat, 16 Apr 2016 01:23:14 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1arEx7-0004jW-Tj for xen-devel@lists.xenproject.org; Sat, 16 Apr 2016 01:23:14 +0000 Received: from [193.109.254.147] by server-8.bemta-14.messagelabs.com id 99/EF-03512-10491175; Sat, 16 Apr 2016 01:23:13 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRWlGSWpSXmKPExsVybKJshy7DFMF wgx+PVC2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxpM2+zFNznrNi+7CFbA+Ncji5GLg4hgamM Elf2/WaHcL4yStzs3sXYxcjJwSKgLbGldQ8TiM0mYCjx98kmti5GDg4JIHvJZw6QsIiAksS9V ZOZQHqZBZoZJd53dbGAJIQFTCXerTjLClLPK+AlceJFIkhYVEBX4tC/P2wgNq+AoMTJmU/Ayp kFtCSWT98GZksIZEjM65nDCmF7SSy6cQnKVpO4em4T8wRG/llI2mchaV/AyLSKUaM4tagstUj X0EwvqSgzPaMkNzEzR9fQ0EQvN7W4ODE9NScxqVgvOT93EyMw3OoZGBh3MH497XmIUZKDSUmU t7NAMFyILyk/pTIjsTgjvqg0J7X4EKMMB4eSBG/tJKCcYFFqempFWmYOMPBh0hIcPEoivJ4ga d7igsTc4sx0iNQpRkUpcd4akIQASCKjNA+uDRZtlxhlpYR5GRkYGIR4ClKLcjNLUOVfMYpzMC oJ8/aATOHJzCuBm/4KaDET0OKyd7wgi0sSEVJSDYytve9cJUz+7/mxc7Lutkf7nabGcPcbFC9 NMonfmOzNYrbwbs6qpZVn1+S+UN1lf+H/N7dnZ3Z8/b5j0pMfbF5rJ2qtU+7LF9399Z3m7Q3d 02Sl6jMZ/acHJFucjPyybX9wzVchkc96ev6nhB3irArens/dt+5iiu8Flqksb4sv2ve/N5Qo8 ihQYinOSDTUYi4qTgQAAkNRqbECAAA= X-Env-Sender: sstabellini@kernel.org X-Msg-Ref: server-8.tower-27.messagelabs.com!1460769791!32127904!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 52785 invoked from network); 16 Apr 2016 01:23:12 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.136) by server-8.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 16 Apr 2016 01:23:12 -0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BCF062026C; Sat, 16 Apr 2016 01:23:09 +0000 (UTC) Received: from [10.1.10.56] (unknown [96.82.76.110]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8CB9F20259; Sat, 16 Apr 2016 01:23:08 +0000 (UTC) Date: Fri, 15 Apr 2016 18:23:00 -0700 (PDT) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-X260 To: xen-devel@lists.xenproject.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: jgross@suse.com, boris.ostrovsky@oracle.com, sstabellini@kernel.org, linux-kernel@vger.kernel.org, david.vrabel@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 On slow platforms with unreliable TSC, such as QEMU emulated machines, it is possible for the kernel to request the next event in the past. In that case, in the current implementation of xen_vcpuop_clockevent, we simply return -ETIME. To be precise the Xen returns -ETIME and we pass it on. However the result of this is a missed event, which simply causes the kernel to hang. Instead it is better to always ask the hypervisor for a timer event, even if the timeout is in the past. That way there are no lost interrupts and the kernel survives. To do that, remove the VCPU_SSHOTTMR_future flag. Signed-off-by: Stefano Stabellini Acked-by: Juergen Gross diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c index a0a4e55..6deba5b 100644 --- a/arch/x86/xen/time.c +++ b/arch/x86/xen/time.c @@ -290,11 +290,11 @@ static int xen_vcpuop_set_next_event(unsigned long delta, WARN_ON(!clockevent_state_oneshot(evt)); single.timeout_abs_ns = get_abs_timeout(delta); - single.flags = VCPU_SSHOTTMR_future; + /* Get an event anyway, even if the timeout is already expired */ + single.flags = 0; ret = HYPERVISOR_vcpu_op(VCPUOP_set_singleshot_timer, cpu, &single); - - BUG_ON(ret != 0 && ret != -ETIME); + BUG_ON(ret != 0); return ret; }