mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
xen/arm: make consider_modules() available for xen relocation
Cache coloring must physically relocate Xen in order to color the hypervisor
and consider_modules() is a key function that is needed to find a new
available physical address.
672d67f339 ("xen/arm: Split MMU-specific setup_mm() and related code out")
moved consider_modules() under arm32. Move it to mmu/setup.c and make it
non-static so that it can be used outside.
Signed-off-by: Carlo Nonato <carlo.nonato@minervasys.tech>
Reviewed-by: Michal Orzel <michal.orzel@amd.com>
This commit is contained in:
1 parent
0975bab5ea
commit
f376ff0e4f
3 files changed
+98
-94
No files matched your search
@@ -7,6 +7,7 @@
|
||||
#include <xen/param.h>
|
||||
#include <xen/pfn.h>
|
||||
#include <asm/fixmap.h>
|
||||
#include <asm/setup.h>
|
||||
#include <asm/static-memory.h>
|
||||
#include <asm/static-shmem.h>
|
||||
|
||||
@@ -31,100 +32,6 @@ static void __init setup_directmap_mappings(unsigned long base_mfn,
|
||||
directmap_virt_end = XENHEAP_VIRT_START + nr_mfns * PAGE_SIZE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the end address of the highest region in the range s..e
|
||||
* with required size and alignment that does not conflict with the
|
||||
* modules from first_mod to nr_modules.
|
||||
*
|
||||
* For non-recursive callers first_mod should normally be 0 (all
|
||||
* modules and Xen itself) or 1 (all modules but not Xen).
|
||||
*/
|
||||
static paddr_t __init consider_modules(paddr_t s, paddr_t e,
|
||||
uint32_t size, paddr_t align,
|
||||
int first_mod)
|
||||
{
|
||||
const struct membanks *reserved_mem = bootinfo_get_reserved_mem();
|
||||
#ifdef CONFIG_STATIC_SHM
|
||||
const struct membanks *shmem = bootinfo_get_shmem();
|
||||
#endif
|
||||
const struct bootmodules *mi = &bootinfo.modules;
|
||||
int i;
|
||||
int nr;
|
||||
|
||||
s = (s+align-1) & ~(align-1);
|
||||
e = e & ~(align-1);
|
||||
|
||||
if ( s > e || e - s < size )
|
||||
return 0;
|
||||
|
||||
/* First check the boot modules */
|
||||
for ( i = first_mod; i < mi->nr_mods; i++ )
|
||||
{
|
||||
paddr_t mod_s = mi->module[i].start;
|
||||
paddr_t mod_e = mod_s + mi->module[i].size;
|
||||
|
||||
if ( s < mod_e && mod_s < e )
|
||||
{
|
||||
mod_e = consider_modules(mod_e, e, size, align, i+1);
|
||||
if ( mod_e )
|
||||
return mod_e;
|
||||
|
||||
return consider_modules(s, mod_s, size, align, i+1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* i is the current bootmodule we are evaluating, across all
|
||||
* possible kinds of bootmodules.
|
||||
*
|
||||
* When retrieving the corresponding reserved-memory addresses, we
|
||||
* need to index the reserved_mem bank starting from 0, and only counting
|
||||
* the reserved-memory modules. Hence, we need to use i - nr.
|
||||
*/
|
||||
nr = mi->nr_mods;
|
||||
for ( ; i - nr < reserved_mem->nr_banks; i++ )
|
||||
{
|
||||
paddr_t r_s = reserved_mem->bank[i - nr].start;
|
||||
paddr_t r_e = r_s + reserved_mem->bank[i - nr].size;
|
||||
|
||||
if ( s < r_e && r_s < e )
|
||||
{
|
||||
r_e = consider_modules(r_e, e, size, align, i + 1);
|
||||
if ( r_e )
|
||||
return r_e;
|
||||
|
||||
return consider_modules(s, r_s, size, align, i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_STATIC_SHM
|
||||
nr += reserved_mem->nr_banks;
|
||||
for ( ; i - nr < shmem->nr_banks; i++ )
|
||||
{
|
||||
paddr_t r_s, r_e;
|
||||
|
||||
r_s = shmem->bank[i - nr].start;
|
||||
|
||||
/* Shared memory banks can contain INVALID_PADDR as start */
|
||||
if ( INVALID_PADDR == r_s )
|
||||
continue;
|
||||
|
||||
r_e = r_s + shmem->bank[i - nr].size;
|
||||
|
||||
if ( s < r_e && r_s < e )
|
||||
{
|
||||
r_e = consider_modules(r_e, e, size, align, i + 1);
|
||||
if ( r_e )
|
||||
return r_e;
|
||||
|
||||
return consider_modules(s, r_s, size, align, i + 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find a contiguous region that fits in the static heap region with
|
||||
* required size and alignment, and return the end address of the region
|
||||
|
||||
@@ -81,6 +81,9 @@ struct init_info
|
||||
unsigned int cpuid;
|
||||
};
|
||||
|
||||
paddr_t consider_modules(paddr_t s, paddr_t e, uint32_t size, paddr_t align,
|
||||
int first_mod);
|
||||
|
||||
#endif
|
||||
/*
|
||||
* Local variables:
|
||||
|
||||
@@ -222,6 +222,100 @@ static void xen_pt_enforce_wnx(void)
|
||||
flush_xen_tlb_local();
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the end address of the highest region in the range s..e
|
||||
* with required size and alignment that does not conflict with the
|
||||
* modules from first_mod to nr_modules.
|
||||
*
|
||||
* For non-recursive callers first_mod should normally be 0 (all
|
||||
* modules and Xen itself) or 1 (all modules but not Xen).
|
||||
*/
|
||||
paddr_t __init consider_modules(paddr_t s, paddr_t e,
|
||||
uint32_t size, paddr_t align,
|
||||
int first_mod)
|
||||
{
|
||||
const struct membanks *reserved_mem = bootinfo_get_reserved_mem();
|
||||
#ifdef CONFIG_STATIC_SHM
|
||||
const struct membanks *shmem = bootinfo_get_shmem();
|
||||
#endif
|
||||
const struct bootmodules *mi = &bootinfo.modules;
|
||||
int i;
|
||||
int nr;
|
||||
|
||||
s = (s+align-1) & ~(align-1);
|
||||
e = e & ~(align-1);
|
||||
|
||||
if ( s > e || e - s < size )
|
||||
return 0;
|
||||
|
||||
/* First check the boot modules */
|
||||
for ( i = first_mod; i < mi->nr_mods; i++ )
|
||||
{
|
||||
paddr_t mod_s = mi->module[i].start;
|
||||
paddr_t mod_e = mod_s + mi->module[i].size;
|
||||
|
||||
if ( s < mod_e && mod_s < e )
|
||||
{
|
||||
mod_e = consider_modules(mod_e, e, size, align, i+1);
|
||||
if ( mod_e )
|
||||
return mod_e;
|
||||
|
||||
return consider_modules(s, mod_s, size, align, i+1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* i is the current bootmodule we are evaluating, across all
|
||||
* possible kinds of bootmodules.
|
||||
*
|
||||
* When retrieving the corresponding reserved-memory addresses, we
|
||||
* need to index the reserved_mem bank starting from 0, and only counting
|
||||
* the reserved-memory modules. Hence, we need to use i - nr.
|
||||
*/
|
||||
nr = mi->nr_mods;
|
||||
for ( ; i - nr < reserved_mem->nr_banks; i++ )
|
||||
{
|
||||
paddr_t r_s = reserved_mem->bank[i - nr].start;
|
||||
paddr_t r_e = r_s + reserved_mem->bank[i - nr].size;
|
||||
|
||||
if ( s < r_e && r_s < e )
|
||||
{
|
||||
r_e = consider_modules(r_e, e, size, align, i + 1);
|
||||
if ( r_e )
|
||||
return r_e;
|
||||
|
||||
return consider_modules(s, r_s, size, align, i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_STATIC_SHM
|
||||
nr += reserved_mem->nr_banks;
|
||||
for ( ; i - nr < shmem->nr_banks; i++ )
|
||||
{
|
||||
paddr_t r_s, r_e;
|
||||
|
||||
r_s = shmem->bank[i - nr].start;
|
||||
|
||||
/* Shared memory banks can contain INVALID_PADDR as start */
|
||||
if ( INVALID_PADDR == r_s )
|
||||
continue;
|
||||
|
||||
r_e = r_s + shmem->bank[i - nr].size;
|
||||
|
||||
if ( s < r_e && r_s < e )
|
||||
{
|
||||
r_e = consider_modules(r_e, e, size, align, i + 1);
|
||||
if ( r_e )
|
||||
return r_e;
|
||||
|
||||
return consider_modules(s, r_s, size, align, i + 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
/*
|
||||
* Boot-time pagetable setup.
|
||||
* Changes here may need matching changes in head.S
|
||||
|
||||