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

[PATCH v2 2/4] xen/arm: guest_walk: refuse an address outside both halves of the range


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stefano Stabellini <stefano.stabellini@xxxxxxx>
  • Date: Tue, 17 Nov 2026 16:59:01 -0800
  • 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=zGJszfWfoSqr3opBXAHz7+BtojPST/zZUmtV8ooETSs=; b=ZVZG4Mrz4tPxgcYwkVUei05iD68ZNhj3Hs1I2XMAGxYEZUJQBJFVQ/F8I7s7hzPzR/5E2b/5zYHu7k3xo1h0nA7fccjMl5hir00uyFcS/xP1vBLfA28VQpkV1REwX0pcsWVrcOW7qra8vYMowyGRax6HPsOx8DefH7ZQQw2wMCppvdZSiz1Kf5Z0U0nh3luxwfDWnuioa4N8NZuwHNp+b03MEnXLSafaShdf5ZhQ8HyqAMaPLHT6oo4zVLS7xV8bf81W1Ewt1qAhabuo0vrCMQnDaWPGQa9Wiq3YiP3AktyCSpLydnPzWRCe/9+lZUPthLkpHznlS/k2Ce+Ri5cvxA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ljwgnYNZR0jBp19UHuGdrRRUhrzZffq+7XY45gcGHY1kYrfltuHDkFigaaw45ZiSHYTTyCThYIIizYtYFIsUZV+1LMCyfmZdn2dyYNiec3/FI6IDhqIPs7ZPbllO7YTVrcjZ51nUtM7pF85roqvt/l+e/txDzLZaF4GMPfielH6MHqWVKGqRwTViox0io4d6aq7rdPF7jbTZx0vpFsJJZBUxopZYHkiwqQ5SDLOCkHFEp3J5iZgdaEm2YvpRpZpBlKaZKmqv1wJbt/vOcGbuKLglel41VLZhxJtK1BE2TIO3Sglv+io52MoYLoCmt2H1L5/Yv8rEtwHSuWNU0O73Gg==
  • 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: <stefano.stabellini@xxxxxxx>, Julien Grall <julien@xxxxxxx>, "Bertrand Marquis" <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Wed, 18 Nov 2026 00:59:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The bits of an input address from its top bit (bit 63, or bit 55 with
the top byte ignored) down to the input address size must be all 0 for
TTBR0 and all 1 for TTBR1, else the walk faults (ARM DDI 0487 M.d
D8.2.4, AArch64.VAIsOutOfRange()). guest_walk_ld() chose the base from
the top bit alone and translated such an address. Refuse it before
reading any table.

Fixes: 7d623b358a45 ("arm/mem_access: Add long-descriptor based gpt")
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx>
---
Cc: Julien Grall <julien@xxxxxxx>
Cc: Bertrand Marquis <bertrand.marquis@xxxxxxx>
Cc: Michal Orzel <michal.orzel@xxxxxxx>
Cc: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>

Changes in v2:
- Cite ARM DDI 0487 M.d (D8.2.4, AArch64.VAIsOutOfRange()) instead of
  A.k, in the commit message and the comment.
- Move the Cc list after ---.
---
 xen/arch/arm/guest_walk.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/xen/arch/arm/guest_walk.c b/xen/arch/arm/guest_walk.c
index 151b837541..8c73ceb04d 100644
--- a/xen/arch/arm/guest_walk.c
+++ b/xen/arch/arm/guest_walk.c
@@ -408,6 +408,15 @@ static bool guest_walk_ld(const struct vcpu *v,
         if ( (input_size > TCR_EL1_IPS_48_BIT_VAL) ||
              (input_size < TCR_EL1_IPS_MIN_VAL) )
             return false;
+
+        /*
+         * The bits of the GVA from the top bit down to the input size must
+         * all be 0 for TTBR0 and all 1 for TTBR1, or the translation faults
+         * (ARM DDI 0487 M.d D8.2.4, AArch64.VAIsOutOfRange()).
+         */
+        mask = GENMASK_ULL(topbit, input_size);
+        if ( (gva & mask) != ((gva & BIT(topbit, ULL)) ? mask : 0) )
+            return false;
     }
     else
     {
-- 
2.47.3




 


Rackspace

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