From patchwork Wed Feb 19 11:01:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 11391253 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA5F817EF for ; Wed, 19 Feb 2020 11:03:10 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A0B3F24658 for ; Wed, 19 Feb 2020 11:03:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A0B3F24658 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j4N6p-0008WP-W8; Wed, 19 Feb 2020 11:01:39 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j4N6n-0008Vf-SG for xen-devel@lists.xenproject.org; Wed, 19 Feb 2020 11:01:37 +0000 X-Inumbo-ID: 31f49152-5307-11ea-bc8e-bc764e2007e4 Received: from Galois.linutronix.de (unknown [2a0a:51c0:0:12e:550::1]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 31f49152-5307-11ea-bc8e-bc764e2007e4; Wed, 19 Feb 2020 11:01:36 +0000 (UTC) Received: from [5.158.153.52] (helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1j4N6k-0002oa-27; Wed, 19 Feb 2020 12:01:34 +0100 Received: by nanos.tec.linutronix.de (Postfix, from userid 1000) id BB84F103A05; Wed, 19 Feb 2020 12:01:33 +0100 (CET) From: Thomas Gleixner To: LKML Date: Wed, 19 Feb 2020 12:01:33 +0100 Message-ID: <87tv3mq1rm.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] xen: Enable interrupts when calling _cond_resched() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , xen-devel@lists.xenproject.org, Boris Ostrovsky , x86@kernel.org, Stefano Stabellini Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" xen_maybe_preempt_hcall() is called from the exception entry point xen_do_hypervisor_callback with interrupts disabled. _cond_resched() evades the might_sleep() check in cond_resched() which would have caught that and schedule_debug() unfortunately lacks a check for irqs_disabled(). Enable interrupts around the call and use cond_resched() to catch future issues. Fixes: fdfd811ddde3 ("x86/xen: allow privcmd hypercalls to be preempted") Signed-off-by: Thomas Gleixner --- drivers/xen/preempt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/xen/preempt.c +++ b/drivers/xen/preempt.c @@ -33,8 +33,10 @@ asmlinkage __visible void xen_maybe_pree * cpu. */ __this_cpu_write(xen_in_preemptible_hcall, false); - _cond_resched(); + local_irq_enable(); + cond_resched(); __this_cpu_write(xen_in_preemptible_hcall, true); + local_irq_disable(); } } #endif /* CONFIG_PREEMPTION */