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

[PATCH v18 2/2] xen/arm: check read handler behavior


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Tue, 25 Mar 2025 13:27:26 -0400
  • 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=arcselector10001; 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=J9DOB8WC9KWKSLTBEGC4wKPk/MvEmQT8Ry5fkhruHXQ=; b=ptwdiZk/vVAMpd+avE8R43Tm3LZoF/fZXWygN5vH+/EYjQGS7yBu2NQsTCuGEDHgzslgDv8h85I5Ks4IWxGaCXNsihGsrJGfciHWvSMosMZ+Dodh/BejIdxmJwQWtnf3agPgpjZrwsRUiqgu2nAbBh1fr1D5CS8ZtgfKNMPs1sEkP7S9H8tHwMgei/d8giTO4GI39w6v1wp1Eppf71dtIf+mEnCjP/XutSnSCdllGtHPb7FHjpSIJ2PbT3TYTyJxy/vRd5m8abBDmXivasOvrEeWdRxgIFJe8j15nSmMUpVbi4sM1gbVRLVVcVQEtzp0bFAqOMTsWsw45UbJRK7Rjg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hRhU2CYPoPfGmsqQRbwGPcQGbFL5Po+P8n6WqmJuXoU826fUJXYRGC9H10cIjIGJIwxImkzA0cZ4lPzVcZwITUVaYPAUUxPEA0m2FAYDo66JAC8+rPUTUTW5lfuijVcOXTMBS5fTdwhfAV+YVtUBcgFRSx1V2sQXjSMh2FO2hOJGfSgC4sB76P6SjVKwLiBnhn1au8y2ZBTlHVaqM3j0AymcelP1jMeNTdIGrldfkY68U1ZI7GJQf/v8y4CFl2hvS/RDqCWjm/PpwiaprxYV6SBrteb69afxoAt1ZMDvR6DJDYQZmJMR7YRJNIOh61Sll+GWG7IrjSLqs0h0y87l9g==
  • Cc: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Tue, 25 Mar 2025 17:27:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

We expect mmio read handlers to leave the bits above the access size
zeroed. Add an ASSERT to check this aspect of read handler behavior.

Suggested-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
---
v17->v18:
* no change

v16->v17:
* new patch

See 
https://lore.kernel.org/xen-devel/bc6660ef-59f1-4514-9792-067d987e3fbc@xxxxxxx/

Also see 7db7bd0f319f ("arm/vpci: honor access size when returning an error")

Also see xen/arch/arm/ioreq.c:handle_ioserv()
---
 xen/arch/arm/io.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c
index 653428e16c1f..68b5dca70026 100644
--- a/xen/arch/arm/io.c
+++ b/xen/arch/arm/io.c
@@ -37,6 +37,8 @@ static enum io_state handle_read(const struct mmio_handler 
*handler,
     if ( !handler->ops->read(v, info, &r, handler->priv) )
         return IO_ABORT;
 
+    ASSERT((r & ~GENMASK_ULL((1U << info->dabt.size) * 8 - 1, 0)) == 0);
+
     r = sign_extend(dabt, r);
 
     set_user_reg(regs, dabt.reg, r);
-- 
2.49.0




 


Rackspace

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