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

[PATCH v19 1/3] xen/arm: check read handler behavior


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Tue, 15 Apr 2025 12:54:00 -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=/Jg9hhUpjJaodqTmnAIJsJFxnkbZD6cQdRZdDLYzRtU=; b=j08cXc9rvwuNSputnqOkytMhO4aPXBJWTRNqTix5Cbv/yAsWd4nmpRlGZrlWsskg7RCPgL2jFB9mpES20tUNXJzwVxgLVUnkt5lkLLZJLu/YvI499V2szO0DNIViAMkNprqy9TI9kM2Be4ff6zll2if81+XAwyecpNWDNaXyY5B7SzLioNBM7jM7oNeQKGqmKtEshoqQmNLryyB1Jz2fd9WaJtTNq0X/GxrL2ZFjADc6nV92je1PKyyNv77mmLT/e6Kc6qK+jhlUL/aUwGm7VG7xJJsS9+AFlJl0Ht1UJ+r37RYA81hiC8OY/ffCWx4cn9OYMEpY1p+Rbh4XOEhN4Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=syZ23NTL6y4I0x9XqAvnJPcm5dkHWvlTlK/Rx5vAyKAZ7VpCbj7QCsRDfTXkkNTGpqjd5JNzHCh37FUuIu5hNlIFrcNUTv5xebLh5DSFm6tmv4ksxrSjU2vp0/1IY9RH/eBuoicqzd2IP0OT31uWQfCLKTQ86u6AXDkKIpyOAKIHYwP9IKABxX4wPWht3fxpJtW37hgpvyQqruTn5hL/EpkAU3pVzy4adpsCeju2tdD5vKHPcTYerCUf8F81rQ1SrwJ0Cf+r+ebSNytySxbZ9wgCyUZ6xrWaoGl5SCWKze5Hhc7NWQYf6gXT0emChb+6bSbNQAIViswW9a/ssI2fVQ==
  • 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>, Julien Grall <jgrall@xxxxxxxxxx>
  • Delivery-date: Tue, 15 Apr 2025 16:54:31 +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>
Acked-by: Julien Grall <jgrall@xxxxxxxxxx>
---
There's no need to wait for the rest of the series to commit this patch.

v18->v19:
* add Julien's A-b
* s/GENMASK_ULL/GENMASK/

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..5a4b0e8f25c6 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((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®.