[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v12 15/15] arm/vpci: honor access size when returning an error


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Tue, 9 Jan 2024 16:51:30 -0500
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=UMvnpYtMsr+XyhV7s4jn4yVI4a71Jl58SaqRvfzmz4E=; b=hRWeCL1gZ0UXku6fhKw/+XUNShm+4f7ma7DxypjnuBXoOCeMc1yLMu+73qcWlXRYyPWU6l0QPmUyjhki4fWnBg/DiUsGrHTjd7CojEotcuu4a0onAZS3+spp7hY/6VZPK9UBHLxtS0vcpjRr2UYcw4ktmVtN5x53qkRquOl3JS1Hgf2+e7NFM0UapX+zFv4tFKe3VwZrwSGcR6z+vHnwfqHV/tTm6PQbdeuNYf/vli5eETPi2C8HScSi9JWWq98FWkiCRUbiKMxmWJFUUO8nemOPATiBt/TBD1mZCEWQ2NbHwDzG9I0RYMjh9uNHFaI5SvPg8fpiVnkiDuLDlnO26w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bd5HjMCqvBekugTEjrpyaS6ANo2q8gssnhqrzxYZxmFlWRCEHJBc7FfqAoGQouZS+8YGbe+udzCB/Efj80Z5XWap3xN8eswlPxV7YQL79HOMTIdcyVSDBRKifs3Ru9sbNJlipjqqsbeP4ZfVAN3X6MW6d+1ams1yTYyxDEWmDiyvSV8hkW4e8nbYFgm3uongglvJmqInL66P8ukH1nZgn/DrO3eZzI5/vo/VqG0zRtd4MjISlnTjOIdljmzhb7ih0G/0DQ2x9pA6D75MXK9OGfvi33Bm53o0E3Rx4PjDegjdMO5FRoEKFqh4WG7xU/6QS0GxCMrCodnu9+WEJ90CbQ==
  • Cc: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Volodymyr Babchuk" <volodymyr_babchuk@xxxxxxxx>, Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Delivery-date: Tue, 09 Jan 2024 21:55:27 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>

Guest can try to read config space using different access sizes: 8,
16, 32, 64 bits. We need to take this into account when we are
returning an error back to MMIO handler, otherwise it is possible to
provide more data than requested: i.e. guest issues LDRB instruction
to read one byte, but we are writing 0xFFFFFFFFFFFFFFFF in the target
register.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
---
 xen/arch/arm/vpci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/vpci.c b/xen/arch/arm/vpci.c
index b6ef440f17b0..05a479096ef7 100644
--- a/xen/arch/arm/vpci.c
+++ b/xen/arch/arm/vpci.c
@@ -42,6 +42,8 @@ static int vpci_mmio_read(struct vcpu *v, mmio_info_t *info,
 {
     struct pci_host_bridge *bridge = p;
     pci_sbdf_t sbdf;
+    const uint8_t access_size = (1 << info->dabt.size) * 8;
+    const uint64_t access_mask = GENMASK_ULL(access_size - 1, 0);
     /* data is needed to prevent a pointer cast on 32bit */
     unsigned long data;
 
@@ -49,7 +51,7 @@ static int vpci_mmio_read(struct vcpu *v, mmio_info_t *info,
 
     if ( !vpci_sbdf_from_gpa(v->domain, bridge, info->gpa, &sbdf) )
     {
-        *r = ~0UL;
+        *r = access_mask;
         return 1;
     }
 
@@ -60,7 +62,7 @@ static int vpci_mmio_read(struct vcpu *v, mmio_info_t *info,
         return 1;
     }
 
-    *r = ~0UL;
+    *r = access_mask;
 
     return 0;
 }
-- 
2.43.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.