[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] xen/arm: traps: Fix sign extension logic in sign_extend()
- To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Michal Orzel <michal.orzel@xxxxxxx>
- Date: Wed, 18 Nov 2026 09:37:42 +0100
- 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=367FIxPIRRoWf+05E1+aWh6DlYSYbZJLLc7xNjyra3A=; b=j2XPAN5grAp/TYBKHM+QJ3EBdTz4vaYLIAWvCBKuuhujezSRSTxePZrblw0TczMMTJUDvHA9UEBXFlhnqBL5P5WtHRJlcSXMiEPuWqhJNPpdmsaHGD8w96bHSiB9ZKhsVxCCrTVmVR/NhAKYrQaxJD8lc5UPfSAOnv7IwXO5OWqZQeYL4fYYDy+NF/45uKopbhVGZF7UA+M7c9y5FJs3eMxET0egTdq0WNs7i08jl9dvZQhaXN9MeHvQayXQpJ8p1++hBdT+iSYEk/j/VXX/bgRqo0WKT9cA+Zc/lm5k7R+eI+usCy3Jpzn3W0U8tAwFwUbkFY/UfY7LYBrnXyJoHw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IXwlgijQUhkCFTMNiwLd3EqokkZ5zi4xj4qC5YSuKjY9oa6SnwE3PQCJtZpmyRRM8AgY4lUsvWjOTDSrIXRooijvbCGHgzlqgLW4sPKrHRt6Jd8ha8J7vk6JEd8H9Hg2/DW3NM/mwSLe/m6EIc0IwgoI8/VMvaLOORxVcfC9iXFDgGVDu8lCYJasVb07tOeM3ClsoMPEs2GIVGOUxq9L1dsqW5tQR72AYbfdvkn79HA+Y3zAOs4Y9AHCu5IZs9dTWEnKxM4euWBbIfI9KzubXPxiSHbkCSR5RjBbLZO3kQCx4N9UwQZrJpkpdMRCYPVSSyvfhSwwTomboYwsqh914Q==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
- Cc: Michal Orzel <michal.orzel@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
- Delivery-date: Wed, 18 Nov 2026 08:38:06 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
At the moment, we always sign extend to the full register width, i.e.
64-bit on Arm64, even though for byte and half-word accesses the
destination can also be a W (32-bit) register (LDRSB Wt, LDRSH Wt). In
that case, the architecture requires bits [63:32] of Xt to be zero, but
a subsequent use of Xt by the guest sees them set to ones. Fix it.
Fixes: ac0ca6895b65 ("xen/arm: io: Support sign-extension for every read
access")
Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
---
xen/arch/arm/include/asm/traps.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/xen/arch/arm/include/asm/traps.h b/xen/arch/arm/include/asm/traps.h
index 3b40afe26259..c5b6ff5b788b 100644
--- a/xen/arch/arm/include/asm/traps.h
+++ b/xen/arch/arm/include/asm/traps.h
@@ -111,6 +111,12 @@ static inline register_t sign_extend(const struct hsr_dabt
dabt, register_t r)
*/
BUILD_BUG_ON(sizeof(register_t) != sizeof(unsigned long));
r |= (~0UL) << size;
+
+#ifdef CONFIG_ARM_64
+ /* When loading to W register we should only sign extend to 32-bit */
+ if ( !dabt.sf )
+ r = (uint32_t)r;
+#endif
}
return r;
--
2.43.0
|