diff mbox series

[v2,1/3] xen/arm64: Fix incorrect DIRECTMAP_SIZE calculation

Message ID 20230117114332.25863-2-michal.orzel@amd.com (mailing list archive)
State New, archived
Headers show
Series xen/arm: Frametable hardening and config.h cleanup | expand

Commit Message

Michal Orzel Jan. 17, 2023, 11:43 a.m. UTC
The direct mapped area occupies L0 slots from 256 to 265 included
(i.e. 10 slots), resulting in 5TB (512GB * 10) of virtual address space.
However, due to incorrect slot subtraction (we take 9 slots into account)
we set DIRECTMAP_SIZE to 4.5TB instead. Fix it.

Note that we only support up to 2TB of physical memory so this is
a latent issue.

Fixes: 5263507b1b4a ("xen: arm: Use a direct mapping of RAM on arm64")
Signed-off-by: Michal Orzel <michal.orzel@amd.com>
---
Changes in v2:
 - update commit msg making it clear that this is a latent issue 
---
 xen/arch/arm/include/asm/config.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Julien Grall Jan. 17, 2023, 1:51 p.m. UTC | #1
Hi Michal,

On 17/01/2023 11:43, Michal Orzel wrote:
> The direct mapped area occupies L0 slots from 256 to 265 included
> (i.e. 10 slots), resulting in 5TB (512GB * 10) of virtual address space.
> However, due to incorrect slot subtraction (we take 9 slots into account)
> we set DIRECTMAP_SIZE to 4.5TB instead. Fix it.
> 
> Note that we only support up to 2TB of physical memory so this is
> a latent issue.
> 
> Fixes: 5263507b1b4a ("xen: arm: Use a direct mapping of RAM on arm64")
> Signed-off-by: Michal Orzel <michal.orzel@amd.com>

Reviewed-by: Julien Grall <jgrall@amazon.com>

Cheers,
diff mbox series

Patch

diff --git a/xen/arch/arm/include/asm/config.h b/xen/arch/arm/include/asm/config.h
index 0fefed1b8aa9..16213c8b677f 100644
--- a/xen/arch/arm/include/asm/config.h
+++ b/xen/arch/arm/include/asm/config.h
@@ -157,7 +157,7 @@ 
 #define FRAMETABLE_NR          (FRAMETABLE_SIZE / sizeof(*frame_table))
 
 #define DIRECTMAP_VIRT_START   SLOT0(256)
-#define DIRECTMAP_SIZE         (SLOT0_ENTRY_SIZE * (265-256))
+#define DIRECTMAP_SIZE         (SLOT0_ENTRY_SIZE * (266 - 256))
 #define DIRECTMAP_VIRT_END     (DIRECTMAP_VIRT_START + DIRECTMAP_SIZE - 1)
 
 #define XENHEAP_VIRT_START     directmap_virt_start