From patchwork Fri Mar 24 17:58:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 9643543 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CB25A601E9 for ; Fri, 24 Mar 2017 18:04:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C14681FFC9 for ; Fri, 24 Mar 2017 18:04:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5B23269A3; Fri, 24 Mar 2017 18:04:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 251AE1FFC9 for ; Fri, 24 Mar 2017 18:04:48 +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 1crTX7-0003aY-0N; Fri, 24 Mar 2017 18:01:53 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1crTX6-0003aS-AG for xen-devel@lists.xenproject.org; Fri, 24 Mar 2017 18:01:52 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id E0/66-27545-F0F55D85; Fri, 24 Mar 2017 18:01:51 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeJIrShJLcpLzFFi42LpubySR5cv/mq EwZMJFhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bhp6uYCvrEKs7dn8DewLhYuIuRi0NIYCej xI/ejexdjBwcbAKmEjP+q3QxcnKICChIbO59xgpSwyzQzyKx+cljNpCEsECgxNub01lAbBYBV Yn29zNZQWxeASuJxv1HwGwJAXmJR5segdVzClhLXF37EywuBFTz9el1sF5RATGJg+/uM0H0Ck qcnPmEBeQGZgF1ifXzhCYw8s5CkpmFkFnAyLSKUb04tagstUjXVC+pKDM9oyQ3MTNH19DATC8 3tbg4MT01JzGpWC85P3cTIzBwGIBgB+P0y/6HGCU5mJREed22XYkQ4kvKT6nMSCzOiC8qzUkt PsQow8GhJMFbHns1QkiwKDU9tSItMwcYwjBpCQ4eJRHeQyBp3uKCxNzizHSI1ClGXY45s3e/Y RJiycvPS5US5w0DKRIAKcoozYMbAYunS4yyUsK8jEBHCfEUpBblZpagyr9iFOdgVBLmnQ8yhS czrwRu0yugI5iAjpi94QrIESWJCCmpBsZW/ttmBQ138//8VT2i+2K6xA/By+9MFKwncThrviy qT5z145Tz/W+RkQHyTRKfZnJuLdO3rHbh8L0Q9D5Qv/DdmVuxDvr24kvK3uSar1CLORKsHmix as6NdV99tMV+HbyzQHym07Ymt7qUS12VrtMTXlXrSvqVOCg78z/z3m3R1/Mv5dzl9UosxRmJh lrMRcWJAPD2PEaiAgAA X-Env-Sender: gregkh@linuxfoundation.org X-Msg-Ref: server-9.tower-27.messagelabs.com!1490378509!93690485!1 X-Originating-IP: [140.211.169.12] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31092 invoked from network); 24 Mar 2017 18:01:50 -0000 Received: from mail.linuxfoundation.org (HELO mail.linuxfoundation.org) (140.211.169.12) by server-9.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 24 Mar 2017 18:01:50 -0000 Received: from localhost (LFbn-1-12060-104.w90-92.abo.wanadoo.fr [90.92.122.104]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 34CF8BCC; Fri, 24 Mar 2017 18:01:48 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Date: Fri, 24 Mar 2017 18:58:50 +0100 Message-Id: <20170324151221.499557812@linuxfoundation.org> X-Mailer: git-send-email 2.12.1 In-Reply-To: <20170324151220.759111698@linuxfoundation.org> References: <20170324151220.759111698@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Cc: Juergen Gross , Peter Zijlstra , Greg Kroah-Hartman , stable@vger.kernel.org, Ingo Molnar , Ross Lagerwall , David Vrabel , xen-devel@lists.xenproject.org, Boris Ostrovsky , Sumit Semwal , Linus Torvalds , Thomas Gleixner Subject: [Xen-devel] [PATCH 4.4 11/30] xen/qspinlock: Dont kick CPU if IRQ is not initialized 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 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ross Lagerwall commit 707e59ba494372a90d245f18b0c78982caa88e48 upstream. The following commit: 1fb3a8b2cfb2 ("xen/spinlock: Fix locking path engaging too soon under PVHVM.") ... moved the initalization of the kicker interrupt until after native_cpu_up() is called. However, when using qspinlocks, a CPU may try to kick another CPU that is spinning (because it has not yet initialized its kicker interrupt), resulting in the following crash during boot: kernel BUG at /build/linux-Ay7j_C/linux-4.4.0/drivers/xen/events/events_base.c:1210! invalid opcode: 0000 [#1] SMP ... RIP: 0010:[] [] xen_send_IPI_one+0x59/0x60 ... Call Trace: [] xen_qlock_kick+0xe/0x10 [] __pv_queued_spin_unlock+0xb2/0xf0 [] ? __raw_callee_save___pv_queued_spin_unlock+0x11/0x20 [] ? check_tsc_warp+0x76/0x150 [] check_tsc_sync_source+0x96/0x160 [] native_cpu_up+0x3d8/0x9f0 [] xen_hvm_cpu_up+0x35/0x80 [] _cpu_up+0x13c/0x180 [] cpu_up+0x7a/0xa0 [] smp_init+0x7f/0x81 [] kernel_init_freeable+0xef/0x212 [] ? rest_init+0x80/0x80 [] kernel_init+0xe/0xe0 [] ret_from_fork+0x3f/0x70 [] ? rest_init+0x80/0x80 To fix this, only send the kick if the target CPU's interrupt has been initialized. This check isn't racy, because the target is waiting for the spinlock, so it won't have initialized the interrupt in the meantime. Signed-off-by: Ross Lagerwall Reviewed-by: Boris Ostrovsky Cc: David Vrabel Cc: Juergen Gross Cc: Konrad Rzeszutek Wilk Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Cc: xen-devel@lists.xenproject.org Signed-off-by: Ingo Molnar Cc: Sumit Semwal Signed-off-by: Greg Kroah-Hartman --- arch/x86/xen/spinlock.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/arch/x86/xen/spinlock.c +++ b/arch/x86/xen/spinlock.c @@ -27,6 +27,12 @@ static bool xen_pvspin = true; static void xen_qlock_kick(int cpu) { + int irq = per_cpu(lock_kicker_irq, cpu); + + /* Don't kick if the target's kicker interrupt is not initialized. */ + if (irq == -1) + return; + xen_send_IPI_one(cpu, XEN_SPIN_UNLOCK_VECTOR); }