mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
xen/arm64: Panic if direct map is too small
Harden the code by panicing if direct map is too small for current memory layout taking into account possible PDX compression. Otherwise the assert is observed: Assertion '(mfn_to_pdx(maddr_to_mfn(ma)) - directmap_base_pdx) < (DIRECTMAP_SIZE >> PAGE_SHIFT)' failed at ./arch/arm/include/asm/mmu/mm.h:72 At the moment, we don't set max_pdx denoting maximum usable PDX which should be based on max_page. Consolidate setting of max_page and max_pdx in init_pdx() for both arm32 and arm64. max_pdx will be used in the future to set up frametable mappings respecting the PDX grouping. Signed-off-by: Michal Orzel <michal.orzel@amd.com> Reviewed-by: Hari Limaye <hari.limaye@arm.com> Tested-by: Hari Limaye <hari.limaye@arm.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
This commit is contained in:
1 parent
7fc5a47322
commit
9fc76a2e35
3 files changed
+8
-3
No files matched your search
@@ -190,7 +190,6 @@ void __init setup_mm(void)
|
||||
|
||||
/* Frame table covers all of RAM region, including holes */
|
||||
setup_frametable_mappings(ram_start, ram_end);
|
||||
max_page = PFN_DOWN(ram_end);
|
||||
|
||||
/*
|
||||
* The allocators may need to use map_domain_page() (such as for
|
||||
|
||||
@@ -224,6 +224,9 @@ static void __init setup_directmap_mappings(unsigned long base_mfn,
|
||||
*/
|
||||
directmap_virt_start = DIRECTMAP_VIRT_START +
|
||||
(base_mfn - mfn_gb) * PAGE_SIZE;
|
||||
|
||||
if ( (max_pdx - directmap_base_pdx) > (DIRECTMAP_SIZE >> PAGE_SHIFT) )
|
||||
panic("Direct map is too small\n");
|
||||
}
|
||||
|
||||
if ( base_mfn < mfn_x(directmap_mfn_start) )
|
||||
@@ -278,7 +281,6 @@ void __init setup_mm(void)
|
||||
directmap_mfn_end = maddr_to_mfn(ram_end);
|
||||
|
||||
setup_frametable_mappings(ram_start, ram_end);
|
||||
max_page = PFN_DOWN(ram_end);
|
||||
|
||||
init_staticmem_pages();
|
||||
init_sharedmem_pages();
|
||||
|
||||
@@ -254,7 +254,7 @@ static void __init relocate_fdt(const void **dtb_vaddr, size_t dtb_size)
|
||||
void __init init_pdx(void)
|
||||
{
|
||||
const struct membanks *mem = bootinfo_get_mem();
|
||||
paddr_t bank_start, bank_size, bank_end;
|
||||
paddr_t bank_start, bank_size, bank_end, ram_end = 0;
|
||||
|
||||
/*
|
||||
* Arm does not have any restrictions on the bits to compress. Pass 0 to
|
||||
@@ -290,10 +290,14 @@ void __init init_pdx(void)
|
||||
bank_start = mem->bank[bank].start;
|
||||
bank_size = mem->bank[bank].size;
|
||||
bank_end = bank_start + bank_size;
|
||||
ram_end = max(ram_end, bank_end);
|
||||
|
||||
set_pdx_range(paddr_to_pfn(bank_start),
|
||||
paddr_to_pfn(bank_end));
|
||||
}
|
||||
|
||||
max_page = PFN_DOWN(ram_end);
|
||||
max_pdx = pfn_to_pdx(max_page - 1) + 1;
|
||||
}
|
||||
|
||||
size_t __read_mostly dcache_line_bytes;
|
||||
|
||||