Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2087562rwb; Sat, 19 Nov 2022 08:42:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Dw+nuW/KqRDu6tAufFB98XuR8eJeo1FIqZIKujnmyzSpD7EVUAL0aPZhx2v8PAjNFvWwo X-Received: by 2002:a63:4285:0:b0:477:15c8:cd8a with SMTP id p127-20020a634285000000b0047715c8cd8amr10014112pga.595.1668876171819; Sat, 19 Nov 2022 08:42:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668876171; cv=none; d=google.com; s=arc-20160816; b=BPWT403yv5AYu+Ul/FkKBX4wvOiX5j7gFareF5HpU+7xh/j4W3hDTNA13jrjufdcVf 0sK7zhYE3jGJRcwqEY7n4rBsPd3fVcqWGA+SyGRIjRlMcwalq5lcUUtvW1pKh2eL4LUo 5VjvcoRxOFgg7B1kFt0utqgQywkOhIbQIsZmAH/zeK3S/R0K7Q4FrVfZ8qyVB89NukBN T//4G/033AouaRLX8094CY+qUg1XRybtIGfqEOIaOuH0atSHROwTdlMW7L3SfUwfTQ0+ U77Lg/ImxBzF4z3mt/DVtA66v6O7hEl5BWN7D0NBGMMImA5AUNy7HMbaYv9HkSdau2a2 mHuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=k1JAkdVKYVaYxy7kpC5w8PdLHIgc/yfPIYL5UkOFoDY=; b=yQqARIdHVofwftdKAKhFDuKlEG4s2B8NjGcTvzpKD+GozvEhogxAjxjeg/kp+GNrhO j94Ck6aRCdZwRprLeo643OCrl2gSlTp8kUi9B+1GK6uzelYn8U5BpFnTnFtjxgSIkICW 0NfDfq2YzTp2uWay3SE2vzBwmOMLOcAuzK1JRG9D6KJMEnFdSmZVNtB3J+N9I2QonS4c qX7KTX8IqMb+2V/Wp6zjHNRH9YzqddwB+AoyHghdHk009M4jfhz8Caqm6scevFQBzSr4 7GCmw2+R0tjDwOkwxg/JwrKlpwC91O+tFyqAALP341UIjQR4lsQPmmk2hSHzyLP87L0t qIpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@invisiblethingslab.com header.s=fm1 header.b=UFfepIQk; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=lJcopc9O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nu16-20020a17090b1b1000b002121890521csi11861396pjb.119.2022.11.19.08.42.39; Sat, 19 Nov 2022 08:42:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@invisiblethingslab.com header.s=fm1 header.b=UFfepIQk; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=lJcopc9O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233780AbiKSQdt (ORCPT + 90 others); Sat, 19 Nov 2022 11:33:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231865AbiKSQdr (ORCPT ); Sat, 19 Nov 2022 11:33:47 -0500 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26ED113CD3 for ; Sat, 19 Nov 2022 08:33:43 -0800 (PST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 039975C0049; Sat, 19 Nov 2022 11:33:41 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sat, 19 Nov 2022 11:33:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= invisiblethingslab.com; h=cc:cc:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1668875620; x= 1668962020; bh=k1JAkdVKYVaYxy7kpC5w8PdLHIgc/yfPIYL5UkOFoDY=; b=U FfepIQkuRItQ+/RiE97orM1O6zNvi/VRaBRkKEf7rZY/eNrkBFpNjDdIeMa8resL voWC3eqP7CwW31vto5TEet10oPB1Lt6Y67vEe8AynLgPhIaBTzxIHTCuChFPeXdj OeWnoqFOwvt/uYeZWGpPuHEEnVOmqTsalJUGbRyhGqmt37jWK9ux/CE3v3rwfySN 2POOHBjhRHSfCY5qsB3WW7SCN25M5FqkinuzfD9D+XfYoAAx37WHW9cYWQMpfD3R pnbNkS2s6dxTdswawuohCdzRvwzKuoJAxgEw3TVO5vFbiMZgwSU4WRNuBHjKucFr MuYvlHWErGT0xCGqzyIYA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1668875620; x=1668962020; bh=k1JAkdVKYVaYxy7kpC5w8PdLHIgc /yfPIYL5UkOFoDY=; b=lJcopc9Opa+b6cHyTKQiOD7+nX2mwT03Ph9BbVVZuT5I 9VP8a5u0d3AeJOBBREXjFugQusX0JMrdM/Rt2rzsEVqWXRbmNMcoiSUZy3/Eb2tQ Krk1TUa95At6+S2CJ1wZJQtCffQFB1GktV2vTOvxhlCNrBmKSNwUExOaJRLMASuj S0NDX4atxmBdozpETZMlV7vQA5W/wWZG+Gx7zPrc2rtIab/YFP+pD1wAPcRRD359 lWu0kzBk6NVJz/nyhFWUhrYvW2Y8zGbO4cDKQDeG/sBh1vCD7NtFv2bupzobkIK+ teN1qvBEEDHJneZmbGkOJAjMchPfd/+BHd558a+gBQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrhedvgdeludcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehgtderredttdejnecuhfhrohhmpeforghrvghk ucforghrtgiihihkohifshhkihdqifpkrhgvtghkihcuoehmrghrmhgrrhgvkhesihhnvh hishhisghlvghthhhinhhgshhlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpeeukeet teeggffgkeduheetgeeileejjeeiiefhjeegvefhtefggfetueetteeuteenucffohhmrg hinhepghhithhhuhgsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghm pehmrghilhhfrhhomhepmhgrrhhmrghrvghksehinhhvihhsihgslhgvthhhihhnghhslh grsgdrtghomh X-ME-Proxy: Feedback-ID: i1568416f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 19 Nov 2022 11:33:39 -0500 (EST) Date: Sat, 19 Nov 2022 17:33:36 +0100 From: Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= To: Jason Andryuk Cc: linux-kernel@vger.kernel.org, Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Jan Beulich , "moderated list:XEN HYPERVISOR INTERFACE" Subject: Re: [PATCH v3] xen-pciback: Consider INTx disabled when MSI/MSI-X is enabled Message-ID: References: <20221118154931.1928298-1-marmarek@invisiblethingslab.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="sCWikLql3O/b4frL" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --sCWikLql3O/b4frL Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Date: Sat, 19 Nov 2022 17:33:36 +0100 From: Marek =?utf-8?Q?Marczykowski-G=C3=B3recki?= To: Jason Andryuk Cc: linux-kernel@vger.kernel.org, Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Jan Beulich , "moderated list:XEN HYPERVISOR INTERFACE" Subject: Re: [PATCH v3] xen-pciback: Consider INTx disabled when MSI/MSI-X is enabled On Sat, Nov 19, 2022 at 09:36:54AM -0500, Jason Andryuk wrote: > Hi, Marek, >=20 > On Fri, Nov 18, 2022 at 4:46 PM Marek Marczykowski-G=C3=B3recki > wrote: > > > > On Fri, Nov 18, 2022 at 03:46:47PM -0500, Jason Andryuk wrote: > > > I was trying to test your xen-pciback v3 patch, and I am having > > > assignment fail consistently now. It is actually failing to > > > quarantine to domIO in the first place, which matches the failure from > > > the other day (when I more carefully read through the logs). It now > > > consistently fails to quarantine on every boot unlike the other day > > > where it happened once. > > > > Does this include the very first assignment too, or only after domain > > reboot? If the latter, maybe some cleanup missed clearing MASKALL? >=20 > It's the quarantine during dom0 boot that fails. Later assignment > during VM boot fails. I tried warm reboots and cold boots and it > happened both times. >=20 > I also modified my initrd to halt in there and checked the config > space. MASKALL wasn't set at that time. I need to double check - > MASKALL may have been unset after dom0 booted in that case. >=20 > I'll test more to figure when and how MASKALL is getting set. >=20 > > FWIW, the patch applied to Qubes > > (https://github.com/QubesOS/qubes-linux-kernel/pull/680) seems to work > > fine (the full test run is still in progress, but I see some green marks > > already). >=20 > Does Qubes quarantine devices explicitly, or are they in dom0 and > libvirt/libxl just assigns them when a domain boots? We do quarantine them explicitly, still in initramfs. > > > I added some printks and it 's getting -EBUSY from pdev_msix_assign() > > > which means pci_reset_msix_state() is failing: > > > if ( pci_conf_read16(pdev->sbdf, msix_control_reg(pos)) & > > > PCI_MSIX_FLAGS_MASKALL ) > > > return -EBUSY; > > > > > > # lspci -vv -s 14.3 > > > ... > > > Capabilities: [80] MSI-X: Enable- Count=3D16 Masked+ > > > Vector table: BAR=3D0 offset=3D00002000 > > > PBA: BAR=3D0 offset=3D00003000 > > > > > > So it looks like MASKALL is set and prevents assignment. > > > > > > setpci -s 00:14.3 82.W=3Df > > > cleared that out for me and I could assign the device. > > > > > > My dom0 boots, it runs flask-label-pci for a set of PCI devices > > > (including iwlwifi), then xl pci-assignable-add for all PCI devices > > > which will be passed through, then a little later it boots the > > > associated domains. Dom0 does not have a driver for iwlwifi. > > > > > > I'll have to investigate more to see how MASKALL is getting set. This > > > had not been an issue before your recent patches. > > > > I guess before the patches nothing set anything in MSI-X capability, > > because it was hidden... >=20 > Well, stubdom hasn't even booted when, so it would be the Xen or > pciback change to modify MASKALL? Weird... > > Anyway, to support my cleanup hypothesis, I tried to destroy a > > PCI-having domain, and it left MSI-X enabled (at least according to the > > config space). MASKALL was _not_ set, but I haven't checked masking of > > individual vectors. TBH, I'm not sure what should be responsible for the > > MSI-X cleanup after guest destroy. Should it be Xen? Qemu? Pciback? > > Pciback calls PHYSDEVOP_{prepare,release}_msix only when > > binding/unbinding from the device (so - xl pci-assignable-{add,remove}), > > so this isn't the right place. >=20 > I need to review all this code to give a meaningful response. Would > xen-pciback set MASKALL when it binds a device? That happens before > xl pci-assignable-add tries to quarantine (assign to to domIO). I don't see pciback doing that. And also, my patches shouldn't change behaviour of pciback when binding to a device (so, if it would be doing that, it would happen before my patches too). Maybe that's an interaction with some other patches? > > Should that be in Xen, in deassign_device() (part of > > DOMCTL_deassign_device)? >=20 > It seems to me that Xen needs to ultimately disable the device. That's my intuition too. --=20 Best Regards, Marek Marczykowski-G=C3=B3recki Invisible Things Lab --sCWikLql3O/b4frL Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEhrpukzGPukRmQqkK24/THMrX1ywFAmN5BWAACgkQ24/THMrX 1yyF0Af/aYMmZvYJ1q+GwXf5MPWXWaBIlU/0TQMqLyNv6+JNpsplksGAxarsFwMr 4sXcwivdu7fslA6RfvbZ6L5hV5opwAGyg76i3PZsQo35ezsdcVIGAqNt3Uj+4LE7 rzPwn+7b6yaKLjVPybqvN6n0/sLpO7d5E4ZpPy6/Ww89DAUFwhIS5hDDnnmrc3QO UQkQ5HpykQNx7Iq9cOdZabbSzS1ms0bS9pj8GzCPmJY3Lgu/q2aPkqMvpuJ+TwpQ oDKPzNK/BPoAVaEWf5bzFcybMf3ZiaQS4E6sauKxausfkh4Sn+hCeoqJVKreBUvQ 8Jksic/ya73VURI5MVCfaHH33g1wTw== =wgKy -----END PGP SIGNATURE----- --sCWikLql3O/b4frL--