Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp445112pxb; Thu, 26 Aug 2021 06:48:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8/xwMqpZkUeBLhaMdLIJPK3WWVk2Y4Fc2pC03hAnsZAEcy807gNyCXzJXHq7hxHaanMQ0 X-Received: by 2002:a05:6402:270d:: with SMTP id y13mr4346313edd.304.1629985695930; Thu, 26 Aug 2021 06:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629985695; cv=none; d=google.com; s=arc-20160816; b=JYLzn68tz1zXlhIC8AWaxyFR/OldwtLZiQCg6vs7q2GUXuisLghkRVRnI6+PozRRHC VIZRfNRzPCV4s3p4c+HiwpE6SjBQWcMG+/eJMTQvRIExP1x3PdvkPfQdrFsYH9XfGotN I1SnKY5M/rc7vaBYensMkvHhDPqfxD6JQBI4biiA8zIt6qlCE6ZcySAniUfBk96ZqJ2h 2o9n0w9cG0wuw93K6U8lsduyETIivz3cANLpqXyWtLyVduZz+rLxEO13afn2BwJyq1Nn Ev1u54s2P81Zpt7XlaX5Zogl6uWHAmQS5UPAf/iFkI2xT4td83hzl1e+1hPaO+48Nwn7 0gcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=WXkphgSznvbe0cwinig1Log1T5d//3hovaBCb47o4oA=; b=ZIHbCWl1dKOwlCqdE9+6k12bKpG8XMQZhiM1XdQ2OF8H/j7WNViPpxlnsfEg7zG6ZR 6qTA+UU0NGHLIUgAWIuDTGOschMqeko4Fv01c10eVb64M8kGj+W0csLSk1T4C7b3Jvh8 1jmDClJhRlvoUlNYSfbNg8iQbXzpDZbo0QKWgoYLRHdQx+zeh3EMc4gyKcTHKjSD9eDK hiTuu+Ly08nm2D7MkgBbolgnPsFrChFMskkvHtJNNzPiBHtKefODoqLUwwJUWi36LDCr PfYeQWKA1Gd/0H2H2LzuBJaG9S3Rka7awBWevl6YDJpQi9aaRJDeQj4H5p9YRZLep6ws CfOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=v5BfsVUM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c9si3178297edt.514.2021.08.26.06.47.23; Thu, 26 Aug 2021 06:48:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=v5BfsVUM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242687AbhHZNpC (ORCPT + 99 others); Thu, 26 Aug 2021 09:45:02 -0400 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:48773 "EHLO wout1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237433AbhHZNpC (ORCPT ); Thu, 26 Aug 2021 09:45:02 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id E976B320091E; Thu, 26 Aug 2021 09:44:12 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 26 Aug 2021 09:44:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=WXkphg Sznvbe0cwinig1Log1T5d//3hovaBCb47o4oA=; b=v5BfsVUM1wAk/pHl5RGehs NUC7chBUMMZZ3qSXN/EF4YmzrildowrB8+xsW+ElYfd0lxvcnlybMP8EN9wybGQh t36rqG/KMHpcZi3+9Ts53VPwJgVi7Aqh3dvcSco999mjBnRJ/ps0c0wKQ7XJCOzp mSi6W7Y2NcUZV3TZ8BY5U39833R+z+s+t1evcJq6O7P6ylmeboglqhnCeT20dLUl oueq/zwOIkvBNr/1Ui0p0N/FHcAn4xNg3fXkSqGI5QSSS57pmzz1r+EFNzoxrzxN R3y2hWakKPfaiRKPgbL6kkO7jQ2uSBwEo3k+ez2jUZRo2AiQnk1i2kjFSmYZzxeQ == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudduuddgieeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffogggtohfgsehtkeertdertdejnecuhfhrohhmpeforghrvghk ucforghrtgiihihkohifshhkihdqifpkrhgvtghkihcuoehmrghrmhgrrhgvkhesihhnvh hishhisghlvghthhhinhhgshhlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpeetgeet keeukeffhfejueeludehtedtkeeuiedtgffgtdfhveefueeiiefhudehgeenucevlhhush htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrghrmhgrrhgvkhes ihhnvhhishhisghlvghthhhinhhgshhlrggsrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 26 Aug 2021 09:44:10 -0400 (EDT) From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , stable@vger.kernel.org, xen-devel@lists.xenproject.org, Bjorn Helgaas , Marc Zyngier , Thomas Gleixner , linux-pci@vger.kernel.org (open list:PCI SUBSYSTEM) Subject: [PATCH] PCI/MSI: skip masking MSI on Xen PV Date: Thu, 26 Aug 2021 15:43:37 +0200 Message-Id: <20210826134337.134767-1-marmarek@invisiblethingslab.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Organization: Invisible Things Lab Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When running as Xen PV guest, masking MSI is a responsibility of the hypervisor. Guest has no write access to relevant BAR at all - when it tries to, it results in a crash like this: BUG: unable to handle page fault for address: ffffc9004069100c #PF: supervisor write access in kernel mode #PF: error_code(0x0003) - permissions violation PGD 18f1c067 P4D 18f1c067 PUD 4dbd067 PMD 4fba067 PTE 80100000febd4075 Oops: 0003 [#1] SMP NOPTI CPU: 0 PID: 234 Comm: kworker/0:2 Tainted: G W 5.14.0-rc7-1.fc32.qubes.x86_64 #15 Workqueue: events work_for_cpu_fn RIP: e030:__pci_enable_msix_range.part.0+0x26b/0x5f0 Code: 2f 96 ff 48 89 44 24 28 48 89 c7 48 85 c0 0f 84 f6 01 00 00 45 0f b7 f6 48 8d 40 0c ba 01 00 00 00 49 c1 e6 04 4a 8d 4c 37 1c <89> 10 48 83 c0 10 48 39 c1 75 f5 41 0f b6 44 24 6a 84 c0 0f 84 48 RSP: e02b:ffffc9004018bd50 EFLAGS: 00010212 RAX: ffffc9004069100c RBX: ffff88800ed412f8 RCX: ffffc9004069105c RDX: 0000000000000001 RSI: 00000000000febd4 RDI: ffffc90040691000 RBP: 0000000000000003 R08: 0000000000000000 R09: 00000000febd404f R10: 0000000000007ff0 R11: ffff88800ee8ae40 R12: ffff88800ed41000 R13: 0000000000000000 R14: 0000000000000040 R15: 00000000feba0000 FS: 0000000000000000(0000) GS:ffff888018400000(0000) knlGS:0000000000000000 CS: e030 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffff8000007f5ea0 CR3: 0000000012f6a000 CR4: 0000000000000660 Call Trace: e1000e_set_interrupt_capability+0xbf/0xd0 [e1000e] e1000_probe+0x41f/0xdb0 [e1000e] local_pci_probe+0x42/0x80 (...) There is pci_msi_ignore_mask variable for bypassing MSI masking on Xen PV, but msix_mask_all() missed checking it. Add the check there too. Fixes: 7d5ec3d36123 ("PCI/MSI: Mask all unused MSI-X entries") Cc: stable@vger.kernel.org Signed-off-by: Marek Marczykowski-Górecki --- Cc: xen-devel@lists.xenproject.org --- drivers/pci/msi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index e5e75331b415..3a9f4f8ad8f9 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -776,6 +776,9 @@ static void msix_mask_all(void __iomem *base, int tsize) u32 ctrl = PCI_MSIX_ENTRY_CTRL_MASKBIT; int i; + if (pci_msi_ignore_mask) + return; + for (i = 0; i < tsize; i++, base += PCI_MSIX_ENTRY_SIZE) writel(ctrl, base + PCI_MSIX_ENTRY_VECTOR_CTRL); } -- 2.31.1