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

[xen staging] xen/arm: guest_walk: refuse a block descriptor where the granule has none



commit a7f4d07ff6a84b2c44d172ce1fe4896d1722532d
Author:     Stefano Stabellini <stefano.stabellini@xxxxxxx>
AuthorDate: Wed Nov 18 01:59:00 2026 +0100
Commit:     Michal Orzel <michal.orzel@xxxxxxx>
CommitDate: Thu Nov 19 08:18:28 2026 +0100

    xen/arm: guest_walk: refuse a block descriptor where the granule has none
    
    guest_walk_ld() accepted a block descriptor at any level. No granule has
    level 0 blocks, and the 16KB and 64KB granules have no level 1 blocks
    (ARM DDI 0487 M.d D8.3.1.2): the translation table walk makes such an
    entry a Translation fault (AArch64.BlockDescSupported()). Refuse it.
    
    The check is only valid without 52-bit support (FEAT_LPA, FEAT_LPA2).
    Note in get_ipa_output_size() that 52-bit support requires updating it.
    
    Fixes: 7d623b358a45 ("arm/mem_access: Add long-descriptor based gpt")
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx>
    Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
    Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
---
 xen/arch/arm/guest_walk.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/guest_walk.c b/xen/arch/arm/guest_walk.c
index 7da3df886a..8c73ceb04d 100644
--- a/xen/arch/arm/guest_walk.c
+++ b/xen/arch/arm/guest_walk.c
@@ -201,7 +201,8 @@ static int get_ipa_output_size(struct domain *d, register_t 
tcr,
          * Return an error on reserved IPA output-sizes and if the IPA
          * output-size is 52bit.
          *
-         * XXX: 52 bit output-size is not supported yet.
+         * XXX: 52 bit output-size is not supported yet. Supporting it also
+         * requires updating the block descriptor check in guest_walk_ld().
          */
         if ( ips > TCR_EL1_IPS_48_BIT )
             return -EFAULT;
@@ -542,6 +543,17 @@ static bool guest_walk_ld(const struct vcpu *v,
     if ( !lpae_is_valid(pte) || !lpae_is_mapping(pte, level) )
         return false;
 
+    /*
+     * A block descriptor is only supported at level 1 and level 2 with the
+     * 4KB granule, and only at level 2 with the 16KB and 64KB granules (ARM
+     * DDI 0487 M.d D8.3.1.2). The block encoding at any other level generates
+     * a Translation fault (AArch64.BlockDescSupported()).
+     *
+     * This is only valid without 52-bit support (FEAT_LPA, FEAT_LPA2).
+     */
+    if ( level == 0 || (level == 1 && gran != GRANULE_SIZE_INDEX_4K) )
+        return false;
+
     /* Make sure that the lower bits of the PTE's base address are zero. */
     mask = GENMASK_ULL(47, grainsizes[gran]);
     *ipa = (pfn_to_paddr(pte.walk.base) & mask) |
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

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