:p
atchew
Login
The latest Xen fails to boot on ADLink AVA platform. Alexey Klimov root caused the issue is related with the commit 1c78d76b67 ("xen/arm64: mm: Introduce helpers to prepare/enable/disable"). This is because on ADLink AVA platform, it loads Xen hypervisor to the address above 2TB and hence causes Xen panic: (XEN) MODULE[0]: 00000807f6df0000 - 00000807f6f3e000 Xen (XEN) MODULE[1]: 00000807f8054000 - 00000807f8056000 Device Tree (XEN) MODULE[2]: 00000000fa834000 - 00000000fc5de1d5 Ramdisk (XEN) MODULE[3]: 00000000fc5df000 - 00000000ffb3f810 Kernel To fix this issue, this series is to enlarge identity map space to 127 TiB and tested on Telechips Dolphin5 platform. Changes from v1: - Rebased on staging branch (Bertrand); - Added Alexey Klimov tested tag for patch 01 (Alexey). - Corrected the printing log with dynamically calculation ID map size. Leo Yan (2): xen/arm: Add macro XEN_VM_MAPPING xen/arm: Enlarge identity map space to 127TiB xen/arch/arm/arm64/mm.c | 12 ++++++++---- xen/arch/arm/include/asm/config.h | 22 ++++++++++++---------- xen/arch/arm/mm.c | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-) -- 2.39.2
Xen maps the virtual memory space starting from L0 slot 4, so it's open coded for macros with the offset '4'. For more readable, add a new macro XEN_VM_MAPPING which defines the start slot for Xen virtual memory mapping, and all virtual memory regions are defined based on it. Signed-off-by: Leo Yan <leo.yan@linaro.org> Tested-by: Alexey Klimov <alexey.klimov@linaro.org> --- xen/arch/arm/include/asm/config.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/include/asm/config.h b/xen/arch/arm/include/asm/config.h index XXXXXXX..XXXXXXX 100644 --- a/xen/arch/arm/include/asm/config.h +++ b/xen/arch/arm/include/asm/config.h @@ -XXX,XX +XXX,XX @@ #define XEN_VIRT_START _AT(vaddr_t, MB(2)) #else +#define IDENTITY_MAPPING_AREA_NR_L0 4 +#define XEN_VM_MAPPING SLOT0(IDENTITY_MAPPING_AREA_NR_L0) + #define SLOT0_ENTRY_BITS 39 #define SLOT0(slot) (_AT(vaddr_t,slot) << SLOT0_ENTRY_BITS) #define SLOT0_ENTRY_SIZE SLOT0(1) -#define XEN_VIRT_START (SLOT0(4) + _AT(vaddr_t, MB(2))) +#define XEN_VIRT_START (XEN_VM_MAPPING + _AT(vaddr_t, MB(2))) #endif /* @@ -XXX,XX +XXX,XX @@ #else /* ARM_64 */ -#define IDENTITY_MAPPING_AREA_NR_L0 4 - -#define VMAP_VIRT_START (SLOT0(4) + GB(1)) +#define VMAP_VIRT_START (XEN_VM_MAPPING + GB(1)) #define VMAP_VIRT_SIZE GB(1) -#define FRAMETABLE_VIRT_START (SLOT0(4) + GB(32)) +#define FRAMETABLE_VIRT_START (XEN_VM_MAPPING + GB(32)) #define FRAMETABLE_SIZE GB(32) #define FRAMETABLE_NR (FRAMETABLE_SIZE / sizeof(*frame_table)) -- 2.39.2
On some platforms, the memory regions could be: (XEN) MODULE[0]: 00000807f6df0000 - 00000807f6f3e000 Xen (XEN) MODULE[1]: 00000807f8054000 - 00000807f8056000 Device Tree (XEN) MODULE[2]: 00000000fa834000 - 00000000fc5de1d5 Ramdisk (XEN) MODULE[3]: 00000000fc5df000 - 00000000ffb3f810 Kernel In this case, the Xen binary is loaded above 2TiB. 2TiB is the maximum identity map space supported by Xen, thus it fails to boot up due to the out of the range. This patch introduces several macros to present the zeroth page table's slot numbers for easier readable. Based on the defined macros, it enlarges identity map space to 127TiB, which can support the memory space [0x0 .. 0x00007eff_ffff_ffff] so has flexibility for various platforms. Fixes: 1c78d76b67 ("xen/arm64: mm: Introduce helpers to prepare/enable/disable") Reported-by: Alexey Klimov <alexey.klimov@linaro.org> Signed-off-by: Leo Yan <leo.yan@linaro.org> --- xen/arch/arm/arm64/mm.c | 12 ++++++++---- xen/arch/arm/include/asm/config.h | 15 ++++++++------- xen/arch/arm/mm.c | 2 +- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/xen/arch/arm/arm64/mm.c b/xen/arch/arm/arm64/mm.c index XXXXXXX..XXXXXXX 100644 --- a/xen/arch/arm/arm64/mm.c +++ b/xen/arch/arm/arm64/mm.c @@ -XXX,XX +XXX,XX @@ static void __init prepare_boot_identity_mapping(void) clear_page(boot_second_id); clear_page(boot_third_id); - if ( id_offsets[0] >= IDENTITY_MAPPING_AREA_NR_L0 ) - panic("Cannot handle ID mapping above 2TB\n"); + if ( id_offsets[0] >= XEN_IDENTITY_MAP_L0_END ) + /* 1TiB occupies 2 slots in zeroeth table */ + panic("Cannot handle ID mapping above %dTiB\n", + XEN_IDENTITY_MAP_L0_END>>1); /* Link first ID table */ pte = mfn_to_xen_entry(virt_to_mfn(boot_first_id), MT_NORMAL); @@ -XXX,XX +XXX,XX @@ static void __init prepare_runtime_identity_mapping(void) lpae_t pte; DECLARE_OFFSETS(id_offsets, id_addr); - if ( id_offsets[0] >= IDENTITY_MAPPING_AREA_NR_L0 ) - panic("Cannot handle ID mapping above 2TB\n"); + if ( id_offsets[0] >= XEN_IDENTITY_MAP_L0_END ) + /* 1TiB occupies 2 slots in zeroeth table */ + panic("Cannot handle ID mapping above %dTiB\n", + XEN_IDENTITY_MAP_L0_END>>1); /* Link first ID table */ pte = pte_of_xenaddr((vaddr_t)xen_first_id); diff --git a/xen/arch/arm/include/asm/config.h b/xen/arch/arm/include/asm/config.h index XXXXXXX..XXXXXXX 100644 --- a/xen/arch/arm/include/asm/config.h +++ b/xen/arch/arm/include/asm/config.h @@ -XXX,XX +XXX,XX @@ * 2G - 4G Domheap: on-demand-mapped * * ARM64 layout: - * 0x0000000000000000 - 0x000001ffffffffff (2TB, L0 slots [0..3]) + * 0x0000000000000000 - 0x00007effffffffff (127TB, L0 slots [0..253]) * * Reserved to identity map Xen * - * 0x0000020000000000 - 0x0000027fffffffff (512GB, L0 slot [4]) + * 0x000007f000000000 - 0x00007fffffffffff (1TB, L0 slot [254..255]) * (Relative offsets) * 0 - 2M Unmapped * 2M - 10M Xen text, data, bss @@ -XXX,XX +XXX,XX @@ * * 32G - 64G Frametable: 56 bytes per page for 2TB of RAM * - * 0x0000028000000000 - 0x00007fffffffffff (125TB, L0 slots [5..255]) - * Unused - * * 0x0000800000000000 - 0x000084ffffffffff (5TB, L0 slots [256..265]) * 1:1 mapping of RAM * @@ -XXX,XX +XXX,XX @@ #define XEN_VIRT_START _AT(vaddr_t, MB(2)) #else -#define IDENTITY_MAPPING_AREA_NR_L0 4 -#define XEN_VM_MAPPING SLOT0(IDENTITY_MAPPING_AREA_NR_L0) +#define XEN_IDENTITY_MAP_L0_START 0 +#define XEN_IDENTITY_MAP_L0_NUM 254 +#define XEN_IDENTITY_MAP_L0_END (XEN_IDENTITY_MAP_L0_START + \ + XEN_IDENTITY_MAP_L0_NUM) +#define XEN_VM_MAP_L0_START (XEN_IDENTITY_MAP_L0_END) +#define XEN_VM_MAPPING SLOT0(XEN_VM_MAP_L0_START) #define SLOT0_ENTRY_BITS 39 #define SLOT0(slot) (_AT(vaddr_t,slot) << SLOT0_ENTRY_BITS) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index XXXXXXX..XXXXXXX 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -XXX,XX +XXX,XX @@ static void __init __maybe_unused build_assertions(void) * with it. */ #define CHECK_OVERLAP_WITH_IDMAP(virt) \ - BUILD_BUG_ON(zeroeth_table_offset(virt) < IDENTITY_MAPPING_AREA_NR_L0) + BUILD_BUG_ON(zeroeth_table_offset(virt) < XEN_IDENTITY_MAP_L0_END) CHECK_OVERLAP_WITH_IDMAP(XEN_VIRT_START); CHECK_OVERLAP_WITH_IDMAP(VMAP_VIRT_START); -- 2.39.2
The latest Xen fails to boot on ADLink AVA platform. Alexey Klimov root caused the issue is related with the commit 1c78d76b67 ("xen/arm64: mm: Introduce helpers to prepare/enable/disable"). This is because on ADLink AVA platform, it loads Xen hypervisor to the address above 8TB and hence causes Xen panic (see patch 02 for details). To fix this issue, this series is to enlarge identity map space to 127 TiB and tested on AVA platform. Changes from v2: - Kept macro naming IDENTITY_MAPPING_AREA_NR_L0 and removed introduced macros (Julien Grall). - Minor improvement for coding style (Julien Grall). - Added platform's detail in the patch 02 commit log (Julien Grall). Changes from v1: - Rebased on staging branch (Bertrand); - Added Alexey Klimov tested tag for patch 01 (Alexey). - Corrected the printing log with dynamically calculation ID map size. Leo Yan (2): xen/arm: Add macro XEN_VM_MAPPING xen/arm: Enlarge identity map space to 127TB xen/arch/arm/arm64/mm.c | 6 ++++-- xen/arch/arm/include/asm/mmu/layout.h | 17 +++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) -- 2.34.1
Xen maps the virtual memory space starting from L0 slot 4, so it's open coded for macros with the offset '4'. For more readable, add a new macro XEN_VM_MAPPING which defines the start slot for Xen virtual memory mapping, and all virtual memory regions are defined based on it. Signed-off-by: Leo Yan <leo.yan@linaro.org> --- xen/arch/arm/include/asm/mmu/layout.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/include/asm/mmu/layout.h b/xen/arch/arm/include/asm/mmu/layout.h index XXXXXXX..XXXXXXX 100644 --- a/xen/arch/arm/include/asm/mmu/layout.h +++ b/xen/arch/arm/include/asm/mmu/layout.h @@ -XXX,XX +XXX,XX @@ #define XEN_VIRT_START _AT(vaddr_t, MB(2)) #else +#define IDENTITY_MAPPING_AREA_NR_L0 4 +#define XEN_VM_MAPPING SLOT0(IDENTITY_MAPPING_AREA_NR_L0) + #define SLOT0_ENTRY_BITS 39 #define SLOT0(slot) (_AT(vaddr_t,slot) << SLOT0_ENTRY_BITS) #define SLOT0_ENTRY_SIZE SLOT0(1) -#define XEN_VIRT_START (SLOT0(4) + _AT(vaddr_t, MB(2))) +#define XEN_VIRT_START (XEN_VM_MAPPING + _AT(vaddr_t, MB(2))) #endif /* @@ -XXX,XX +XXX,XX @@ #else /* ARM_64 */ -#define IDENTITY_MAPPING_AREA_NR_L0 4 - -#define VMAP_VIRT_START (SLOT0(4) + GB(1)) +#define VMAP_VIRT_START (XEN_VM_MAPPING + GB(1)) #define VMAP_VIRT_SIZE GB(1) -#define FRAMETABLE_VIRT_START (SLOT0(4) + GB(32)) +#define FRAMETABLE_VIRT_START (XEN_VM_MAPPING + GB(32)) #define FRAMETABLE_SIZE GB(32) #define FRAMETABLE_NR (FRAMETABLE_SIZE / sizeof(*frame_table)) -- 2.34.1
On ADLink AVA platform (Ampere Altra SoC with 32 Arm Neoverse N1 cores), the physical memory regions are: DRAM memory regions: Node[0] Region[0]: 0x000080000000 - 0x0000ffffffff Node[0] Region[1]: 0x080000000000 - 0x08007fffffff Node[0] Region[2]: 0x080100000000 - 0x0807ffffffff The UEFI loads Xen hypervisor and DTB into the high memory, the kernel and ramdisk images are loaded into the low memory space: (XEN) MODULE[0]: 00000807f6df0000 - 00000807f6f3e000 Xen (XEN) MODULE[1]: 00000807f8054000 - 00000807f8056000 Device Tree (XEN) MODULE[2]: 00000000fa834000 - 00000000fc5de1d5 Ramdisk (XEN) MODULE[3]: 00000000fc5df000 - 00000000ffb3f810 Kernel In this case, the Xen binary is loaded above 8TB, which exceeds the maximum supported identity map space of 2TB in Xen. Consequently, the system fails to boot. This patch enlarges identity map space to 127TB, allowing module loading within the range of [0x0 .. 0x00007eff_ffff_ffff]. Note, despite this expansion of the identity map to 127TB, the frame table still only supports 2TB. The reason is the frame table is data structure for the page management, which does not require coverage of the memory layout gaps (refer to pfn_pdx_hole_setup() for Xen removing the biggest gap from memory regions). Thus, 2TB of memory support remains sufficient for most use cases. Fixes: 1c78d76b67 ("xen/arm64: mm: Introduce helpers to prepare/enable/disable") Reported-by: Alexey Klimov <alexey.klimov@linaro.org> Signed-off-by: Leo Yan <leo.yan@linaro.org> --- xen/arch/arm/arm64/mm.c | 6 ++++-- xen/arch/arm/include/asm/mmu/layout.h | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/arm64/mm.c b/xen/arch/arm/arm64/mm.c index XXXXXXX..XXXXXXX 100644 --- a/xen/arch/arm/arm64/mm.c +++ b/xen/arch/arm/arm64/mm.c @@ -XXX,XX +XXX,XX @@ static void __init prepare_boot_identity_mapping(void) clear_page(boot_third_id); if ( id_offsets[0] >= IDENTITY_MAPPING_AREA_NR_L0 ) - panic("Cannot handle ID mapping above 2TB\n"); + panic("Cannot handle ID mapping above %uTB\n", + IDENTITY_MAPPING_AREA_NR_L0 >> 1); /* Link first ID table */ pte = mfn_to_xen_entry(virt_to_mfn(boot_first_id), MT_NORMAL); @@ -XXX,XX +XXX,XX @@ static void __init prepare_runtime_identity_mapping(void) DECLARE_OFFSETS(id_offsets, id_addr); if ( id_offsets[0] >= IDENTITY_MAPPING_AREA_NR_L0 ) - panic("Cannot handle ID mapping above 2TB\n"); + panic("Cannot handle ID mapping above %uTB\n", + IDENTITY_MAPPING_AREA_NR_L0 >> 1); /* Link first ID table */ pte = pte_of_xenaddr((vaddr_t)xen_first_id); diff --git a/xen/arch/arm/include/asm/mmu/layout.h b/xen/arch/arm/include/asm/mmu/layout.h index XXXXXXX..XXXXXXX 100644 --- a/xen/arch/arm/include/asm/mmu/layout.h +++ b/xen/arch/arm/include/asm/mmu/layout.h @@ -XXX,XX +XXX,XX @@ * 2G - 4G Domheap: on-demand-mapped * * ARM64 layout: - * 0x0000000000000000 - 0x000001ffffffffff (2TB, L0 slots [0..3]) + * 0x0000000000000000 - 0x00007effffffffff (127TB, L0 slots [0..253]) * * Reserved to identity map Xen * - * 0x0000020000000000 - 0x0000027fffffffff (512GB, L0 slot [4]) + * 0x00007f0000000000 - 0x00007f7fffffffff (512GB, L0 slot [254]) * (Relative offsets) * 0 - 2M Unmapped * 2M - 10M Xen text, data, bss @@ -XXX,XX +XXX,XX @@ * * 32G - 64G Frametable: 56 bytes per page for 2TB of RAM * - * 0x0000028000000000 - 0x00007fffffffffff (125TB, L0 slots [5..255]) + * 0x00007f8000000000 - 0x00007fffffffffff (512GB, L0 slots [255]) * Unused * * 0x0000800000000000 - 0x000084ffffffffff (5TB, L0 slots [256..265]) @@ -XXX,XX +XXX,XX @@ #define XEN_VIRT_START _AT(vaddr_t, MB(2)) #else -#define IDENTITY_MAPPING_AREA_NR_L0 4 +#define IDENTITY_MAPPING_AREA_NR_L0 254 #define XEN_VM_MAPPING SLOT0(IDENTITY_MAPPING_AREA_NR_L0) #define SLOT0_ENTRY_BITS 39 -- 2.34.1