[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] vpci/msix: restore PBA access length and alignment restrictions
- To: xen-devel@xxxxxxxxxxxxxxxxxxxx
- From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Date: Wed, 29 Mar 2023 12:18:10 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GBcikQid1EDsNKVmlhoAesovXe8SAQfNny1rvck7MW4=; b=TyzBoTPpJLj3nfCkblAAUY66i4P5J/JX5Qovwqne8VjrGY1nVAvn2mLsBaGOgNDG6LxFrPr3RmFqnny9P6MrtKlmU5h+flP5x654QmGxKCRQpkfRzts0wSUYAPLWwTQfzRvskvZwxeHtL3bgAuNGoFiw+b16eAHS1we6h0kZzHA5WJ5EfKcwQ3DBWwW062X17uMiU8Y4HqBKs5ULL5jPw75BX2Un5lj58btXEuCy+cSiWvFK59a09RRsGxnu9w9a/8b1frwRNy7hRKvVZuDMILB9p0OK9SEIFtZbHrcocd6XVYVArnWL8rJ01Lh6OHP9uC3C2+gsgj1c12glxhNohQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A2IaZAR5vPZAk/isGePCrxrxNs0Kn6y9ikSt2Q89VMyv8c/UrAr8HljfVLEv8GdPSGe+lhNTHlbo9zAL+NWrlYp5osggMFJu6YItD9kWOw8jtq/Xnu6Ya1QJ7BWhg6XWImU0hoVh4zmf/OceCr+3CnT8I17nnXBiFY4A91hTeFtZ1kiMr6WwIol5j1uINIvL1I3ueDcMHR238+gX6GI4UkBXKH9ZcsIX6arIzIFrhrrkY1N1Hx/BuydUb60gqpwVJ8QSxvFa+Wl2rOPUTP5hgYJkzUrKSQbZhcRieMlo7E7SNcVpczh5GJL0fkrYJbVpy8bMIWbHi4Y51PpI29tNPQ==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: jbeulich@xxxxxxxx, Roger Pau Monne <roger.pau@xxxxxxxxxx>
- Delivery-date: Wed, 29 Mar 2023 10:21:56 +0000
- Ironport-data: A9a23:9JUsM6oJSSfGGex5NXgzlXeoO0leBmIKZBIvgKrLsJaIsI4StFCzt garIBnUb/uKMDf2LdgkaYjkpBlU7Z+Ay9ZiS1Y5rH0zQSwb+JuZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbKCYWYpA1c/Ek/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKm06WNwUmAWP6gR5weFzShNVfrzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXAB4yTACYi767+bCQZMA8nvw9J/jBJoxK7xmMzRmBZRonabbqZvySoPV+g3I3jM0IGuvCb c0EbzYpdA7HfxBEJlYQDtQ5gfusgX78NTZfrTp5p4JuuzSVkFM3j+CraYKMEjCJbZw9ckKwv GXJ8n6/GhgHHNee1SCE4jSngeqncSbTAdpIRODnrKAz6LGV7jMLKx87CluwmP6o1FWbf/FzC WBI4xN7+MDe82TuFLERRSaQsHOC+xIRRddUO+k78x2WjLrZ5R6DAWoJRSIHb8Yp3Oc0TzE30 l6Cn/vyGCdi9raSTBqgGqy8qDqzPW0fKzAEbCpdFQ8duYC7+cc0kw7FSctlHOitlNrpFDrsw jeM6i8jm7EUis1N3KK+lbzavw+RSlHyZlZdzm3qsqiNtGuVuKbNi1SU1GXm
- Ironport-hdrordr: A9a23:Ash9VqBNegzMiDjlHejHsseALOsnbusQ8zAXPh9KJCC9I/bzqy nxpp8mPH/P5wr5lktQ++xoX5PwOU80lKQFmLX5WI3PYOCIghrNEGgP1+vfKl7balDDH5BmpM BdmsFFYbWfbGSS5fyKmjVQeOxQpeVvnprY5ts3mBxWPHpXguxbnnBE4kHxKDwGeCB2Qb4CUL aM7MtOoDStPVwRc8SAH3EAG8TTutHRk5riQBgeQzoq8hOHgz+E4KPzV0Hw5GZUbxp/hZMZtU TVmQ3w4auu99m91x/nzmfWq7hGhdf7zdNHJcqUzuwYMC/lhAqEbJloH5eCoDc2iuey70tCqq iFnz4Qe+BIr1/BdGC8phXgnyHmzTYV8nfnjXuVm2Hqr8DVTC8zT5Mpv/MRTjLpr24b+P1s2q NC2GyU87JREBP7hSz4o/zFTQtjmEaYqWcr1cQTk3tce40Db6I5l/1owGplVLM7WA7q4oEuF+ djSOna+fZtaFufK0vUu2F+qebcLEgbL1OjeAwvq8aV2z9ZkDRS1E0D3vESmX8G6dYUV4REz/ 6sCNUmqJh+CustKY5tDuYIRsW6TkbXRwjXDW6UKVP7UIkaJnP2rYLt6rld3pDnRHUx9upypH 39aiIZiYZrEHieSvFmnac7vywleV/NEwgEkaplltpEUr6VfsuZDcTMciFqryKamYRgPiTqYY fOBHtoOY6dEYKXI/cu4+TfYegmFZBMarxghv8LH3Szn+nsFqrG8sTmTde7HsucLd9jYBK0Pk c+
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Accesses to the PBA array have the same length and alignment
limitations as accesses to the MSI-X table:
"For all accesses to MSI-X Table and MSI-X PBA fields, software must
use aligned full DWORD or aligned full QWORD transactions; otherwise,
the result is undefined."
Introduce such length and alignment checks into the handling of PBA
accesses for vPCI. This was a mistake of mine for not reading the
specification correctly.
Note that accesses must now be aligned, and hence there's no longer a
need to check that the end of the access falls into the PBA region as
both the access and the region addresses must be aligned.
Fixes: b177892d2d ('vpci/msix: handle accesses adjacent to the MSI-X table')
Reported-by: Jan Beulich <jbeulich@xxxxxxxx>
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
xen/drivers/vpci/msix.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/xen/drivers/vpci/msix.c b/xen/drivers/vpci/msix.c
index 99dd249c15..25bde77586 100644
--- a/xen/drivers/vpci/msix.c
+++ b/xen/drivers/vpci/msix.c
@@ -278,6 +278,11 @@ static int adjacent_read(const struct domain *d, const
struct vpci_msix *msix,
if ( !adjacent_handle(msix, addr + len - 1) )
return X86EMUL_OKAY;
+ if ( VMSIX_ADDR_IN_RANGE(addr, vpci, VPCI_MSIX_PBA) &&
+ !access_allowed(msix->pdev, addr, len) )
+ /* PBA accesses must be aligned and 4 or 8 bytes in size. */
+ return X86EMUL_OKAY;
+
slot = get_slot(vpci, addr);
if ( slot >= ARRAY_SIZE(msix->table) )
return X86EMUL_OKAY;
@@ -419,9 +424,8 @@ static int adjacent_write(const struct domain *d, const
struct vpci_msix *msix,
* assumed to be equal or bigger (8 bytes) than the length of any access
* handled here.
*/
- if ( (VMSIX_ADDR_IN_RANGE(addr, vpci, VPCI_MSIX_PBA) ||
- VMSIX_ADDR_IN_RANGE(addr + len - 1, vpci, VPCI_MSIX_PBA)) &&
- !is_hardware_domain(d) )
+ if ( VMSIX_ADDR_IN_RANGE(addr, vpci, VPCI_MSIX_PBA) &&
+ (!access_allowed(msix->pdev, addr, len) || !is_hardware_domain(d)) )
/* Ignore writes to PBA for DomUs, it's undefined behavior. */
return X86EMUL_OKAY;
--
2.40.0
|