From patchwork Tue Sep 12 00:37:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 9948247 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 228496038F for ; Tue, 12 Sep 2017 00:41:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1428C28D31 for ; Tue, 12 Sep 2017 00:41:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05E2C28D33; Tue, 12 Sep 2017 00:41:12 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID 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 1F81D28D52 for ; Tue, 12 Sep 2017 00:41:05 +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 1drZDI-0000mg-7r; Tue, 12 Sep 2017 00:38:04 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drZDH-0000hb-L8 for xen-devel@lists.xenproject.org; Tue, 12 Sep 2017 00:38:03 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id BB/FF-03093-B6C27B95; Tue, 12 Sep 2017 00:38:03 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOIsWRWlGSWpSXmKPExsVyMfTOYd1Mne2 RBjsuGFp83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBkLPt9iKuiSq7j6bQZjA+MF8S5GLg4hgRmM Ev3bHzODOCwCH1gk+rZcYwNxJASmsUo8bjjM0sXICeTESfR19TJD2GkS298th7KrJFbfmwdWI ySgJLFl8mNGiLEHmSQWLDoKViQsoCcx+dttRhCbTUBf4unaa0BxDqBmN4lP17hA6kUE2hklZl /5xQpSwyxgKNH69igbRG+ExLnpG8DiLAKqEtsPLwVbxitgJdF5/gcTxBHyEhN7p4HN5wSK//4 xjxXiIEuJjgVXmCYwCi9gZFjFqFGcWlSWWqRrbKSXVJSZnlGSm5iZo2toYKaXm1pcnJiempOY VKyXnJ+7iREYpAxAsIPx9LrAQ4ySHExKory/hbdHCvEl5adUZiQWZ8QXleakFh9ilOHgUJLgv asNlBMsSk1PrUjLzAHGC0xagoNHSYQ3SwsozVtckJhbnJkOkTrFaM9x4c6lP0wcxzZdBpIH9t wCkh037/5hEmLJy89LlRLnLQKZKgDSllGaBzcUFt+XGGWlhHkZgc4U4ilILcrNLEGVf8UozsG oJMx7B2QKT2ZeCdzuV0BnMQGdxXNpC8hZJYkIKakGRiPBJQ+70k5N7/lSwrX0i31ym4CUr0JI +Tw2t/2rvG6W1NYr3r+qs0ZMW5HZb2XE/GqLybsEjhupFn5/MXPWagZryb3cT9ad3MX0wknD/ MsFlz8Hws4VqiSoLMvM/9PA2lDwYvWcK1eEcnf+ap47Weej8XvmWZsCJzxQsFl+9efkeV8mHh Z6YKDEUpyRaKjFXFScCAA6bxJC6gIAAA== X-Env-Sender: ketuzsezr@gmail.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1505176681!93037845!1 X-Originating-IP: [209.85.220.195] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64225 invoked from network); 12 Sep 2017 00:38:01 -0000 Received: from mail-qk0-f195.google.com (HELO mail-qk0-f195.google.com) (209.85.220.195) by server-10.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 12 Sep 2017 00:38:01 -0000 Received: by mail-qk0-f195.google.com with SMTP id o77so6381006qke.2 for ; Mon, 11 Sep 2017 17:38:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=8iyJuXv74BZJgQ+5v26qIlpe8fLdg8abyMwjP78O+ek=; b=N9kacStBErYOcGgzEfHnDnYmJSEzuiTYxhR/Zbz4v+WArkzNtnZ2bA9v7h8EoMjAMa RBpcH+lzgvOZzR4K5g/euSha0XLD8q5lZLtZHcZgGxV4dWa3OZ93iuVAvz4oq29K24vv 47RqbbDUODO/2G/xskX8Pgc6zPxS2OLXDuDWhFu6bHzENRvyUWSiqqqRy3C9lysie8pL 1gifZLlgMYDTtE21XlVrDDri042kQN8pISRb/Y7DpdDtD7e173qeIgvnqlGdz70jA2TS /1l3sdUXMffGxe+YD130q9NWkFov6SSWeDAWhXkgzh5h662MOXBeucDzWN3t67GEt/il YXSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=8iyJuXv74BZJgQ+5v26qIlpe8fLdg8abyMwjP78O+ek=; b=aiL1w8jJZO4DAAHHD6o1GRjpHrsc01EwCM0sQcUJm74oYIzVRtv9xDY39CkkC9sFUp MluSVIjEsCfQGbzWsY1bReNQQxlo8C5mPfrf+15pfaDta9eoXTTyUIoPZK++xschhc68 xrkEXoVp3f7ljZqFFKmFNPUQrQbf58FA9N1GZSdsGgUY3nI/HgwNS/Rh2gCHol/drABc zuUe98hXBQ6ntbWhuVEkjEqggCIJi5ABCUyPnu9An0OUwf+UX+6weYChFryACyaLF/ZW RNKafBmSeWOP7EDt8s+RYUy4Ia4dEY+PA5aSAK2CYw+TasMJ18+iZyWgVZx9GkJXLUpP xTDA== X-Gm-Message-State: AHPjjUgajeYXJxPgHrXvMdiyz8+dCVRLcPZP7MxuuczWCPt5GtgL6M3e zcIJzseFD9XXnzT9 X-Google-Smtp-Source: AOwi7QBbTjrXT8rPlyQpcEp8r1VmHSSAe+SVMkT+uxEpcVv0CcUQnQBP5TN/Vgj4UYhWLXcUojf7YA== X-Received: by 10.55.215.211 with SMTP id t80mr11270456qkt.30.1505176680425; Mon, 11 Sep 2017 17:38:00 -0700 (PDT) Received: from localhost.localdomain (209-6-200-48.s4398.c3-0.smr-ubr2.sbo-smr.ma.cable.rcncustomer.com. [209.6.200.48]) by smtp.gmail.com with ESMTPSA id z75sm6771034qkb.71.2017.09.11.17.37.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Sep 2017 17:37:59 -0700 (PDT) From: Konrad Rzeszutek Wilk X-Google-Original-From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, ross.lagerwall@citrix.com, konrad.wilk@oracle.com, julien.grall@arm.com, sstabellini@kernel.org Date: Mon, 11 Sep 2017 20:37:22 -0400 Message-Id: <20170912003726.368-14-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170912003726.368-1-konrad.wilk@oracle.com> References: <20170912003726.368-1-konrad.wilk@oracle.com> Cc: andrew.cooper3@citrix.com, jbeulich@suse.com Subject: [Xen-devel] [PATCH v3 13/17] livepatch: Expand spin_debug_disable in [apply|revert]_payload 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Under ARM64 the vmap calls were all done with IRQs disabled which didn't trip the spinlock debug check (as seen on x86): livepatch.c:1330: livepatch: xen_hello_world: timeout is 30000000ns livepatch.c:1437: livepatch: xen_hello_world: CPU3 - IPIing the other 3 CPUs Applying xen_hello_world... (XEN) livepatch: xen_hello_world: Applying 1 functions Xen BUG at spinlock.c:47 ..snip.. [] spinlock.c#check_lock+0x3e/0x44 [] _spin_lock+0x11/0x4a [] __vmap+0x78/0x381 [] livepatch.c#livepatch_quiesce+0xc4/0x1bf [] livepatch.c#apply_payload+0x3a/0x102 [] check_for_livepatch_work+0x1f3/0x390 [] domain.c#continue_idle_domain+0x1b/0x22 But are definitly the case on x86 - so we expand the scope of the spin_debug_disable. Signed-off-by: Konrad Rzeszutek Wilk --- xen/common/livepatch.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c index 93083cda1a..2f5ee1ae75 100644 --- a/xen/common/livepatch.c +++ b/xen/common/livepatch.c @@ -1154,22 +1154,22 @@ static int apply_payload(struct payload *data) printk(XENLOG_INFO LIVEPATCH "%s: Applying %u functions\n", data->name, data->nfuncs); + /* + * Since we are running with IRQs disabled and the hooks may call common + * code - which expects certain spinlocks to run with IRQs enabled - we + * temporarily disable the spin locks IRQ state checks. + */ + spin_debug_disable(); rc = livepatch_quiesce(data->funcs, data->nfuncs); if ( rc ) { + spin_debug_enable(); printk(XENLOG_ERR LIVEPATCH "%s: unable to quiesce!\n", data->name); return rc; } - /* - * Since we are running with IRQs disabled and the hooks may call common - * code - which expects certain spinlocks to run with IRQs enabled - we - * temporarily disable the spin locks IRQ state checks. - */ - spin_debug_disable(); for ( i = 0; i < data->n_load_funcs; i++ ) data->load_funcs[i](); - spin_debug_enable(); ASSERT(!local_irq_is_enabled()); @@ -1177,6 +1177,7 @@ static int apply_payload(struct payload *data) arch_livepatch_apply(&data->funcs[i]); livepatch_revive(); + spin_debug_enable(); /* * We need RCU variant (which has barriers) in case we crash here. @@ -1195,9 +1196,16 @@ static int revert_payload(struct payload *data) printk(XENLOG_INFO LIVEPATCH "%s: Reverting\n", data->name); + /* + * Since we are running with IRQs disabled and the hooks may call common + * code - which expects certain spinlocks to run with IRQs enabled - we + * temporarily disable the spin locks IRQ state checks. + */ + spin_debug_disable(); rc = livepatch_quiesce(data->funcs, data->nfuncs); if ( rc ) { + spin_debug_enable(); printk(XENLOG_ERR LIVEPATCH "%s: unable to quiesce!\n", data->name); return rc; } @@ -1205,19 +1213,13 @@ static int revert_payload(struct payload *data) for ( i = 0; i < data->nfuncs; i++ ) livepatch_revert(&data->funcs[i]); - /* - * Since we are running with IRQs disabled and the hooks may call common - * code - which expects certain spinlocks to run with IRQs enabled - we - * temporarily disable the spin locks IRQ state checks. - */ - spin_debug_disable(); for ( i = 0; i < data->n_unload_funcs; i++ ) data->unload_funcs[i](); - spin_debug_enable(); ASSERT(!local_irq_is_enabled()); livepatch_revive(); + spin_debug_enable(); /* * We need RCU variant (which has barriers) in case we crash here.