[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v5 4/7] xen/arm: static memory initialization
On Tue, 24 Aug 2021, Penny Zheng wrote: > This patch introduces static memory initialization, during system boot up. > > The new function init_staticmem_pages is responsible for static memory > initialization. > > Helper free_staticmem_pages is the equivalent of free_heap_pages, to free > nr_mfns pages of static memory. > > This commit also introduces new CONFIG_STATIC_MEMORY to wrap all ^ a ^ option > static-allocation-related codes. ^ code > Put asynchronous scrubbing for pages of static memory in TODO list. > > Signed-off-by: Penny Zheng <penny.zheng@xxxxxxx> > --- > v5 change: > - make CONFIG_STATIC_MEMORY user selectable and gated by UNSUPPORTED. > - wrap all static-allocation-related codes with CONFIG_STATIC_MEMORY > even in arm-specific file. > - make bank_start/bank_end type of mfn_t, and rename bank_size to > bank_pages. > --- > xen/arch/arm/setup.c | 31 +++++++++++++++++++++++++++++++ > xen/common/Kconfig | 17 +++++++++++++++++ > xen/common/page_alloc.c | 22 +++++++++++++++++++++- > xen/include/xen/mm.h | 6 ++++++ > 4 files changed, 75 insertions(+), 1 deletion(-) > > diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c > index 63a908e325..44aca9f1b9 100644 > --- a/xen/arch/arm/setup.c > +++ b/xen/arch/arm/setup.c > @@ -609,6 +609,29 @@ static void __init init_pdx(void) > } > } > > +#ifdef CONFIG_STATIC_MEMORY > +/* Static memory initialization */ > +static void __init init_staticmem_pages(void) > +{ > + unsigned int bank; > + > + for ( bank = 0 ; bank < bootinfo.reserved_mem.nr_banks; bank++ ) > + { > + if ( bootinfo.reserved_mem.bank[bank].xen_domain ) > + { > + mfn_t bank_start = > _mfn(PFN_UP(bootinfo.reserved_mem.bank[bank].start)); > + unsigned long bank_pages = > PFN_DOWN(bootinfo.reserved_mem.bank[bank].size); > + mfn_t bank_end = mfn_add(bank_start, bank_pages); > + > + if ( mfn_x(bank_end) <= mfn_x(bank_start) ) > + return; > + > + free_staticmem_pages(mfn_to_page(bank_start), bank_pages, false); > + } > + } > +} > +#endif > + > #ifdef CONFIG_ARM_32 > static void __init setup_mm(void) > { > @@ -736,6 +759,10 @@ static void __init setup_mm(void) > /* Add xenheap memory that was not already added to the boot allocator. > */ > init_xenheap_pages(mfn_to_maddr(xenheap_mfn_start), > mfn_to_maddr(xenheap_mfn_end)); > + > +#ifdef CONFIG_STATIC_MEMORY > + init_staticmem_pages(); > +#endif > } > #else /* CONFIG_ARM_64 */ > static void __init setup_mm(void) > @@ -789,6 +816,10 @@ static void __init setup_mm(void) > > setup_frametable_mappings(ram_start, ram_end); > max_page = PFN_DOWN(ram_end); > + > +#ifdef CONFIG_STATIC_MEMORY > + init_staticmem_pages(); > +#endif > } > #endif > > diff --git a/xen/common/Kconfig b/xen/common/Kconfig > index 0ddd18e11a..514a2c9022 100644 > --- a/xen/common/Kconfig > +++ b/xen/common/Kconfig > @@ -67,6 +67,23 @@ config MEM_ACCESS > config NEEDS_LIBELF > bool > > +config STATIC_MEMORY > + bool "Static Allocation Support (UNSUPPORTED)" if UNSUPPORTED > + depends on ARM > + ---help--- > + Static Allocation refers to system or sub-system(domains) for > + which memory areas are pre-defined by configuration using physical > + address ranges. > + > + Those pre-defined memory, -- Static Memory, as parts of RAM reserved > + during system boot-up, shall never go to heap allocator or boot > + allocator for any use. > + > + When enabled, memory can be statically allocated to a domain using > + the property "xen,static-mem" defined in the domain configuration. > + > + If unsure, say Y. I share Jan's comment about indentation, the kconfig message and the little spurious change below. Aside from those, this patch looks fine to me.
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |