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

[PATCH v13 14/14] arm/vpci: honor access size when returning an error


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Fri, 2 Feb 2024 16:33:18 -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=GP/sADPnaw4TMrLkrvzS2aR+Na6StFaFDNxGi2x57hw=; b=DX6OsOgxQt9xx84rX1T8v1+ukzDYU5QSJ1OHkweUcF7y0I+SLELcJYvVnwYbsfCEMX2iZQfO+YnyJJr8fhkalCMcE4h7tLu8evOtddP6MwjGEFoCt/qIgYXm4rB/vjgALNj92KoZLFhUgDbraehnbWqANETDl2mMjMiYhWLSeJR4JCBRfdDvbR2xUHcnT9H96YEFpgYZA9yKaQ6V4of4FASD3FCNSknZVCVUO7HLgPELpBvsHNe7RZbWrXGy3c6v9UYwPqyzmjJuPlu8ikybEUGYSK+TTolkBx6Mj7hxMs3lK91gRYz8qq++qbgmyjyJBCQVKaRsGW5hqnGiIZ696A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VOwCokeJ+nAkYL5YQpg0yBcovVPhOFz8a3t2YyQCXNDgWZC+K+8Dr0k6eQU9WCr3yBFUlEgEJaHK9fLtMzw2de4XDyge8oc7GgqP58i6snvaHOmDZWakuAWHzVgkOzPuqQ64AeE3yJvKEDcEAtz2t5X0b9HLvyvonS/A3n0MfMiqPt9ERI2jdhtRrsBkh0vzjkHU8Ocz7DKJy0eJxkUKkSAWzGlLqxOuvLSD5l3iepdK+axqF4jLcD8LXWhwxJAyI170bi1OvbyFLwTGxkQK/1UZ8Yb5zdEHF7hcOj2LIKp2XFbeYSa7I2XeIPlC4ljktNDW4evQCOinuP/CpPLl9g==
  • 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: Fri, 02 Feb 2024 21:37:13 +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>
---
v9->10:
* New patch in v10.
---
 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 348ba0fbc860..aaf9d9120c3d 100644
--- a/xen/arch/arm/vpci.c
+++ b/xen/arch/arm/vpci.c
@@ -41,6 +41,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;
 
@@ -48,7 +50,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;
     }
 
@@ -59,7 +61,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®.