Static shared memory followup v2 - pt2
v4 cover Static shared memory followup v2 - pt2
This serie is a partial rework of this other serie:
https://patchwork.kernel.org/project/xen-devel/cover/[email protected]/
The original serie is addressing an issue of the static shared memory feature that impacts the memory footprint of other component when the feature is enabled, another issue impacts the device tree generation for the guests when the feature is enabled and used and the last one is a missing feature that is the option to have a static shared memory region that is not from the host address space.
This serie is handling some comment on the original serie and it is splitting the rework in two part, this first part is addressing the memory footprint issue and the device tree generation and currently is fully merged
(https://patchwork.kernel.org/project/xen-devel/cover/[email protected]/),
this serie is addressing the static shared memory allocation from the Xen heap.
Luca Fancellu (5):
xen/arm: Lookup bootinfo shm bank during the mapping xen/arm: Wrap shared memory mapping code in one function xen/arm: Parse xen,shared-mem when host phys address is not provided xen/arm: Rework heap page allocation outside allocate_bank_memory xen/arm: Implement the logic for static shared memory from Xen heap
Penny Zheng (2):
xen/p2m: put reference for level 2 superpage xen/docs: Describe static shared memory when host address is not
provided
docs/misc/arm/device-tree/booting.txt | 52 ++- xen/arch/arm/arm32/mmu/mm.c | 11 +- xen/arch/arm/dom0less-build.c | 4 +- xen/arch/arm/domain_build.c | 84 +++-- xen/arch/arm/include/asm/domain_build.h | 9 +- xen/arch/arm/mmu/p2m.c | 82 +++-- xen/arch/arm/setup.c | 14 +- xen/arch/arm/static-shmem.c | 432 +++++++++++++++++------- 8 files changed, 502 insertions(+), 186 deletions(-)
Signature · 1 line
2.34.1
PATCH v4 1/7 xen/arm: Lookup bootinfo shm bank during the mapping
The current static shared memory code is using bootinfo banks when it needs to find the number of borrowers, so every time assign_shared_memory is called, the bank is searched in the bootinfo.shmem structure.
There is nothing wrong with it, however the bank can be used also to retrieve the start address and size and also to pass less argument to assign_shared_memory. When retrieving the information from the bootinfo bank, it's also possible to move the checks on alignment to process_shm_node in the early stages.
So create a new function find_shm_bank_by_id() which takes a 'struct shared_meminfo' structure and the shared memory ID, to look for a bank with a matching ID, take the physical host address and size from the bank, pass the bank to assign_shared_memory() removing the now unnecessary arguments and finally remove the acquire_nr_borrower_domain() function since now the information can be extracted from the passed bank. Move the "xen,shm-id" parsing early in process_shm to bail out quickly in case of errors (unlikely), as said above, move the checks on alignment to process_shm_node.
Drawback of this change is that now the bootinfo are used also when the bank doesn't need to be allocated, however it will be convenient later to use it as an argument for assign_shared_memory when dealing with the use case where the Host physical address is not supplied by the user.
---
v3 changes:
- switch strncmp with strcmp in find_shm_bank_by_id, fix commit msg typo, add R-by Michal.
v2 changes:
- fix typo commit msg, renamed find_shm() to find_shm_bank_by_id(), swap region size check different from zero and size alignment, remove not necessary BUGON(). (Michal)
--- xen/arch/arm/static-shmem.c | 100 +++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 47 deletions(-)
xen/arch/arm/static-shmem.c +53 -47
@@ -19,29 +19,21 @@ static void __init __maybe_unused build_assertions(void) offsetof(struct shared_meminfo, bank))); } -static int __init acquire_nr_borrower_domain (struct domain *d, -paddr_t pbase,paddr_t psize, -unsigned long *nr_borrowers) +static const struct membank __init * +find_shm_bank_by_id (const struct membanks *shmem,const char *shm_id) { -const struct membanks *shmem =bootinfo_get_shmem ();unsigned int bank; -/* Iterate reserved memory to find requested shm bank. */ for ( bank =0 ; bank < shmem->nr_banks; bank++ ) { -paddr_t bank_start = shmem->bank[bank].start; -paddr_t bank_size = shmem->bank[bank].size; - -if ( (pbase == bank_start) && (psize == bank_size) ) +if (strcmp (shm_id, shmem->bank[bank].shmem_extra->shm_id) ==0 )break ; }if ( bank == shmem->nr_banks ) -return -ENOENT ; +return NULL ; - *nr_borrowers = shmem->bank[bank].shmem_extra->nr_shm_borrowers; - -return 0 ; +return &shmem->bank[bank]; }/*
@@ -103,14 +95,18 @@ static mfn_t __init acquire_shared_memory_bank(struct domain *d,return smfn; } -static int __init assign_shared_memory (struct domain *d, -paddr_t pbase,paddr_t psize, -paddr_t gbase) +static int __init assign_shared_memory (struct domain *d,paddr_t gbase, +const struct membank *shm_bank) {mfn_t smfn;int ret =0 ;unsigned long nr_pages, nr_borrowers, i;struct page_info *page; +paddr_t pbase, psize; + + pbase = shm_bank->start; + psize = shm_bank->size; + nr_borrowers = shm_bank->shmem_extra->nr_shm_borrowers;printk ("%pd: allocate static shared memory BANK %#" PRIpaddr"-%#" PRIpaddr".\n" , d, pbase, pbase + psize);
@@ -135,14 +131,6 @@ static int __init assign_shared_memory(struct domain *d, } } -/* -* Get the right amount of references per page, which is the number of -* borrower domains. -*/ - ret =acquire_nr_borrower_domain (d, pbase, psize, &nr_borrowers); -if ( ret ) -return ret; -/* * Instead of letting borrower domain get a page ref, we add as many * additional reference as the number of borrowers when the owner
@@ -199,6 +187,7 @@ int __init process_shm(struct domain *d, struct kernel_info *kinfo,dt_for_each_child_node (node, shm_node) { +const struct membank *boot_shm_bank;const struct dt_property *prop;const __be32 *cells;uint32_t addr_cells, size_cells;
@@ -212,6 +201,23 @@ int __init process_shm(struct domain *d, struct kernel_info *kinfo,if ( !dt_device_is_compatible (shm_node,"xen,domain-shared-memory-v1" ) )continue ; +if (dt_property_read_string (shm_node,"xen,shm-id" , &shm_id) ) + { +printk ("%pd: invalid \"xen,shm-id\" property" , d); +return -EINVAL ; + } +BUG_ON ((strlen (shm_id) <=0 ) || (strlen (shm_id) >=MAX_SHM_ID_LENGTH )); + + boot_shm_bank =find_shm_bank_by_id (bootinfo_get_shmem (), shm_id); +if ( !boot_shm_bank ) + { +printk ("%pd: static shared memory bank not found: '%s'" , d, shm_id); +return -ENOENT ; + } + + pbase = boot_shm_bank->start; + psize = boot_shm_bank->size; +/* * xen,shared-mem = <pbase, gbase, size>; * TODO: pbase is optional.
@@ -221,20 +227,7 @@ int __init process_shm(struct domain *d, struct kernel_info *kinfo, prop =dt_find_property (shm_node,"xen,shared-mem" ,NULL );BUG_ON (!prop); cells = (const __be32 *)prop->value; -device_tree_get_reg (&cells, addr_cells, addr_cells, &pbase, &gbase); - psize =dt_read_paddr (cells, size_cells); -if ( !IS_ALIGNED (pbase,PAGE_SIZE ) || !IS_ALIGNED (gbase,PAGE_SIZE ) ) - { -printk ("%pd: physical address 0x%" PRIpaddr", or guest address 0x%" PRIpaddr" is not suitably aligned.\n" , - d, pbase, gbase); -return -EINVAL ; - } -if ( !IS_ALIGNED (psize,PAGE_SIZE ) ) - { -printk ("%pd: size 0x%" PRIpaddr" is not suitably aligned\n" , - d, psize); -return -EINVAL ; - } + gbase =dt_read_paddr (cells + addr_cells, addr_cells);for ( i =0 ; i <PFN_DOWN (psize); i++ )if ( !mfn_valid (mfn_add (maddr_to_mfn (pbase), i)) )
@@ -251,13 +244,6 @@ int __init process_shm(struct domain *d, struct kernel_info *kinfo,if (dt_property_read_string (shm_node,"role" , &role_str) ==0 ) owner_dom_io = false; -if (dt_property_read_string (shm_node,"xen,shm-id" , &shm_id) ) - { -printk ("%pd: invalid \"xen,shm-id\" property" , d); -return -EINVAL ; - } -BUG_ON ((strlen (shm_id) <=0 ) || (strlen (shm_id) >=MAX_SHM_ID_LENGTH )); -/* * DOMID_IO is a fake domain and is not described in the Device-Tree. * Therefore when the owner of the shared region is DOMID_IO, we will
@@ -270,8 +256,8 @@ int __init process_shm(struct domain *d, struct kernel_info *kinfo,* We found the first borrower of the region, the owner was not * specified, so they should be assigned to dom_io. */ - ret =assign_shared_memory (owner_dom_io ? dom_io : d, - pbase, psize, gbase); + ret =assign_shared_memory (owner_dom_io ? dom_io : d, gbase, + boot_shm_bank);if ( ret )return ret; }
@@ -439,12 +425,32 @@ int __init process_shm_node(const void *fdt, int node, uint32_t address_cells,device_tree_get_reg (&cell, address_cells, address_cells, &paddr, &gaddr); size =dt_next_cell (size_cells, &cell); +if ( !IS_ALIGNED (paddr,PAGE_SIZE ) ) + { +printk ("fdt: physical address 0x%" PRIpaddr" is not suitably aligned.\n" , + paddr); +return -EINVAL ; + } + +if ( !IS_ALIGNED (gaddr,PAGE_SIZE ) ) + { +printk ("fdt: guest address 0x%" PRIpaddr" is not suitably aligned.\n" , + gaddr); +return -EINVAL ; + } +if ( !size ) {printk ("fdt: the size for static shared memory region can not be zero\n" );return -EINVAL ; } +if ( !IS_ALIGNED (size,PAGE_SIZE ) ) + { +printk ("fdt: size 0x%" PRIpaddr" is not suitably aligned\n" , size); +return -EINVAL ; + } + end = paddr + size;if ( end <= paddr ) {
Signature · 1 line
2.34.1
PATCH v4 2/7 xen/arm: Wrap shared memory mapping code in one function
In reply to Luca FancelluWrap the code and logic that is calling assign_shared_memory and map_regions_p2mt into a new function 'handle_shared_mem_bank', it will become useful later when the code will allow the user to don't pass the host physical address.
---
v3 changes:
- check return value of dt_property_read_string, add R-by Michal
v2 changes:
- add blank line, move owner_dom_io computation inside handle_shared_mem_bank in order to reduce args count, remove not needed BUGON(). (Michal)
--- xen/arch/arm/static-shmem.c | 86 +++++++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 33 deletions(-)
xen/arch/arm/static-shmem.c +53 -33
@@ -180,6 +180,53 @@ append_shm_bank_to_domain(struct kernel_info *kinfo, paddr_t start,return 0 ; } +static int __init handle_shared_mem_bank (struct domain *d,paddr_t gbase, +const char *role_str, +const struct membank *shm_bank) +{ +bool owner_dom_io = true; +paddr_t pbase, psize; +int ret; + + pbase = shm_bank->start; + psize = shm_bank->size; + +/* +* "role" property is optional and if it is defined explicitly, +* then the owner domain is not the default "dom_io" domain. +*/ +if ( role_str !=NULL ) + owner_dom_io = false; + +/* +* DOMID_IO is a fake domain and is not described in the Device-Tree. +* Therefore when the owner of the shared region is DOMID_IO, we will +* only find the borrowers. +*/ +if ( (owner_dom_io && !is_shm_allocated_to_domio (pbase)) || + (!owner_dom_io &&strcmp (role_str,"owner" ) ==0 ) ) + { +/* +* We found the first borrower of the region, the owner was not +* specified, so they should be assigned to dom_io. +*/ + ret =assign_shared_memory (owner_dom_io ? dom_io : d, gbase, shm_bank); +if ( ret ) +return ret; + } + +if ( owner_dom_io || (strcmp (role_str,"borrower" ) ==0 ) ) + { +/* Set up P2M foreign mapping for borrower domain. */ + ret =map_regions_p2mt (d,_gfn (PFN_UP (gbase)),PFN_DOWN (psize), +_mfn (PFN_UP (pbase)), p2m_map_foreign_rw); +if ( ret ) +return ret; + } + +return 0 ; +} +int __init process_shm (struct domain *d,struct kernel_info *kinfo,const struct dt_device_node *node) {
@@ -196,7 +243,6 @@ int __init process_shm(struct domain *d, struct kernel_info *kinfo,unsigned int i;const char *role_str;const char *shm_id; -bool owner_dom_io = true;if ( !dt_device_is_compatible (shm_node,"xen,domain-shared-memory-v1" ) )continue ;
@@ -237,39 +283,13 @@ int __init process_shm(struct domain *d, struct kernel_info *kinfo,return -EINVAL ; } -/* -* "role" property is optional and if it is defined explicitly, -* then the owner domain is not the default "dom_io" domain. -*/ -if (dt_property_read_string (shm_node,"role" , &role_str) ==0 ) - owner_dom_io = false; +/* "role" property is optional */ +if (dt_property_read_string (shm_node,"role" , &role_str) !=0 ) + role_str =NULL ; -/* -* DOMID_IO is a fake domain and is not described in the Device-Tree. -* Therefore when the owner of the shared region is DOMID_IO, we will -* only find the borrowers. -*/ -if ( (owner_dom_io && !is_shm_allocated_to_domio (pbase)) || - (!owner_dom_io &&strcmp (role_str,"owner" ) ==0 ) ) - { -/* -* We found the first borrower of the region, the owner was not -* specified, so they should be assigned to dom_io. -*/ - ret =assign_shared_memory (owner_dom_io ? dom_io : d, gbase, - boot_shm_bank); -if ( ret ) -return ret; - } - -if ( owner_dom_io || (strcmp (role_str,"borrower" ) ==0 ) ) - { -/* Set up P2M foreign mapping for borrower domain. */ - ret =map_regions_p2mt (d,_gfn (PFN_UP (gbase)),PFN_DOWN (psize), -_mfn (PFN_UP (pbase)), p2m_map_foreign_rw); -if ( ret ) -return ret; - } + ret =handle_shared_mem_bank (d, gbase, role_str, boot_shm_bank); +if ( ret ) +return ret;/* * Record static shared memory region info for later setting
Signature · 1 line
2.34.1
PATCH v4 3/7 xen/p2m: put reference for level 2 superpage
In reply to Luca FancelluFrom: Penny Zheng <[email protected]>
We are doing foreign memory mapping for static shared memory, and there is a great possibility that it could be super mapped. But today, p2m_put_l3_page could not handle superpages.
This commits implements a new function p2m_put_l2_superpage to handle 2MB superpages, specifically for helping put extra references for foreign superpages.
Modify relinquish_p2m_mapping as well to take into account preemption when type is foreign memory and order is above 9 (2MB).
Currently 1GB superpages are not handled because Xen is not preemptible and therefore some work is needed to handle such superpages, for which at some point Xen might end up freeing memory and therefore for such a big mapping it could end up in a very long operation.
---
v4 changes:
- optimised the path to call put_page() on the foreign mapping as
Julien suggested. Add a comment in p2m_put_l2_superpage to state
that any changes needs to take into account some change in the
relinquish code. (Julien)
v3 changes:
- Add reasoning why we don't support now 1GB superpage, remove level_order
variable from p2m_put_l2_superpage, update TODO comment inside
p2m_free_entry, use XEN_PT_LEVEL_ORDER(2) instead of value 9 inside
relinquish_p2m_mapping. (Michal)
v2:
- Do not handle 1GB super page as there might be some issue where
a lot of calls to put_page(...) might be issued which could lead
to free memory that is a long operation.
v1:
- patch from https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/
--- xen/arch/arm/mmu/p2m.c | 82 +++++++++++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 20 deletions(-)
xen/arch/arm/mmu/p2m.c +62 -20
@@ -753,34 +753,66 @@ static int p2m_mem_access_radix_set(struct p2m_domain *p2m, gfn_t gfn,return rc; } -/* -* Put any references on the single 4K page referenced by pte. -* TODO: Handle superpages, for now we only take special references for leaf -* pages (specifically foreign ones, which can't be super mapped today). -*/ -static void p2m_put_l3_page (const lpae_t pte) +static void p2m_put_foreign_page (struct page_info *pg) { -mfn_t mfn =lpae_get_mfn (pte); - -ASSERT (p2m_is_valid (pte)); -/* -* TODO: Handle other p2m types -* * It's safe to do the put_page here because page_alloc will * flush the TLBs if the page is reallocated before the end of * this loop. */ -if (p2m_is_foreign (pte.p2m.type) ) +put_page (pg); +} + +/* Put any references on the single 4K page referenced by mfn. */ +static void p2m_put_l3_page (mfn_t mfn,p2m_type_t type) +{ +/* TODO: Handle other p2m types */ +if (p2m_is_foreign (type) ) {ASSERT (mfn_valid (mfn)); -put_page (mfn_to_page (mfn)); +p2m_put_foreign_page (mfn_to_page (mfn)); }/* Detect the xenheap page and mark the stored GFN as invalid. */ -else if (p2m_is_ram (pte.p2m.type) &&is_xen_heap_mfn (mfn) ) +else if (p2m_is_ram (type) &&is_xen_heap_mfn (mfn) )page_set_xenheap_gfn (mfn_to_page (mfn),INVALID_GFN ); } +/* Put any references on the superpage referenced by mfn. */ +static void p2m_put_l2_superpage (mfn_t mfn,p2m_type_t type) +{ +struct page_info *pg; +unsigned int i; + +/* +* TODO: Handle other p2m types, but be aware that any changes to handle +* different types should require an update on the relinquish code to handle +* preemption. +*/ +if ( !p2m_is_foreign (type) ) +return ; + +ASSERT (mfn_valid (mfn)); + + pg =mfn_to_page (mfn); + +for ( i =0 ; i <XEN_PT_LPAE_ENTRIES ; i++, pg++ ) +p2m_put_foreign_page (pg); +} + +/* Put any references on the page referenced by pte. */ +static void p2m_put_page (const lpae_t pte,unsigned int level) +{ +mfn_t mfn =lpae_get_mfn (pte); + +ASSERT (p2m_is_valid (pte)); + +/* We have a second level 2M superpage */ +if (p2m_is_superpage (pte, level) && (level ==2 ) ) +return p2m_put_l2_superpage (mfn, pte.p2m.type); +else if ( level ==3 ) +return p2m_put_l3_page (mfn, pte.p2m.type); +} +/* Free lpae sub-tree behind an entry */ static void p2m_free_entry (struct p2m_domain *p2m,lpae_t entry,unsigned int level)
@@ -809,9 +841,16 @@ static void p2m_free_entry(struct p2m_domain *p2m,#endif p2m->stats.mappings[level]--; -/* Nothing to do if the entry is a super-page. */ -if ( level ==3 ) -p2m_put_l3_page (entry); +/* +* TODO: Currently we don't handle 1GB super-page, Xen is not +* preemptible and therefore some work is needed to handle such +* superpages, for which at some point Xen might end up freeing memory +* and therefore for such a big mapping it could end up in a very long +* operation. +*/ +if ( level >=2 ) +p2m_put_page (entry, level); +return ; }
@@ -1558,9 +1597,12 @@ int relinquish_p2m_mapping(struct domain *d) count++;/* -* Arbitrarily preempt every 512 iterations. +* Arbitrarily preempt every 512 iterations or when type is foreign +* mapping and the order is above 9 (2MB). */ -if ( !(count %512 ) &&hypercall_preempt_check () ) +if ( (!(count %512 ) || + (p2m_is_foreign (t) && (order >XEN_PT_LEVEL_ORDER (2 )))) && +hypercall_preempt_check () ) { rc = -ERESTART ;break ;
Signature · 1 line
2.34.1
Re: [PATCH v4 3/7] xen/p2m: put reference for level 2 superpage
Hi Luca,
Quoted 109 lines · Luca Fancellu
From: Penny Zheng <[email protected]>
We are doing foreign memory mapping for static shared memory, and there is a great possibility that it could be super mapped. But today,
p2m_put_l3_pagecould not handle superpages.This commits implements a new function
p2m_put_l2_superpageto handle 2MB superpages, specifically for helping put extra references for foreign superpages.Modify
relinquish_p2m_mappingas well to take into account preemption when type is foreign memory and order is above 9 (2MB).Currently 1GB superpages are not handled because Xen is not preemptible and therefore some work is needed to handle such superpages, for which at some point Xen might end up freeing memory and therefore for such a big mapping it could end up in a very long operation.
Signed-off-by Penny Zheng <[email protected]>Signed-off-by Luca Fancellu <[email protected]>---
v4 changes:
- optimised the path to callput_page()on the foreign mapping as
Julien suggested. Add a comment inp2m_put_l2_superpageto state
that any changes needs to take into account some change in the
relinquish code. (Julien)
v3 changes:
- Add reasoning why we don't support now 1GB superpage, removelevel_order
variable fromp2m_put_l2_superpage, update TODO comment inside
p2m_free_entry, useXEN_PT_LEVEL_ORDER(2)instead of value 9 inside
relinquish_p2m_mapping. (Michal)
v2:
- Do not handle 1GB super page as there might be some issue where
a lot of calls toput_page(...)might be issued which could lead
to free memory that is a long operation.
v1:
- patch from https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/--- xen/arch/arm/mmu/p2m.c | 82 +++++++++++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 20 deletions(-)xen/arch/arm/mmu/p2m.c +32
-15@@ -753,34 +753,66 @@ static int p2m_mem_access_radix_set(struct p2m_domain *p2m, gfn_t gfn,return rc; } -/* -* Put any references on the single 4K page referenced by pte. -* TODO: Handle superpages, for now we only take special references for leaf -* pages (specifically foreign ones, which can't be super mapped today). -*/ -static void p2m_put_l3_page (const lpae_t pte) +static void p2m_put_foreign_page (struct page_info *pg) { -mfn_t mfn =lpae_get_mfn (pte); - -ASSERT (p2m_is_valid (pte)); -/* -* TODO: Handle other p2m types -* * It's safe to do the put_page here because page_alloc will * flush the TLBs if the page is reallocated before the end of * this loop. */ -if (p2m_is_foreign (pte.p2m.type) ) +put_page (pg); +} + +/* Put any references on the single 4K page referenced by mfn. */ +static void p2m_put_l3_page (mfn_t mfn,p2m_type_t type) +{ +/* TODO: Handle other p2m types */ +if (p2m_is_foreign (type) ) {ASSERT (mfn_valid (mfn)); -put_page (mfn_to_page (mfn)); +p2m_put_foreign_page (mfn_to_page (mfn)); }/* Detect the xenheap page and mark the stored GFN as invalid. */ -else if (p2m_is_ram (pte.p2m.type) &&is_xen_heap_mfn (mfn) ) +else if (p2m_is_ram (type) &&is_xen_heap_mfn (mfn) )page_set_xenheap_gfn (mfn_to_page (mfn),INVALID_GFN ); } +/* Put any references on the superpage referenced by mfn. */ +static void p2m_put_l2_superpage (mfn_t mfn,p2m_type_t type) +{ +struct page_info *pg; +unsigned int i; + +/* +* TODO: Handle other p2m types, but be aware that any changes to handle +* different types should require an update on the relinquish code to handle +* preemption. +*/ +if ( !p2m_is_foreign (type) ) +return ; + +ASSERT (mfn_valid (mfn)); + + pg =mfn_to_page (mfn); + +for ( i =0 ; i <XEN_PT_LPAE_ENTRIES ; i++, pg++ ) +p2m_put_foreign_page (pg); +}
xen/arch/arm/mmu/p2m.c static int p2m_mem_access_radix_set(struct p2m_domain *p2m, gfn_t gfn, · line 810
Quoted 10 lines
xen/arch/arm/mmu/p2m.c +10
-0+ +/* Put any references on the page referenced by pte. */ +static void p2m_put_page (const lpae_t pte,unsigned int level) +{ +mfn_t mfn =lpae_get_mfn (pte); + +ASSERT (p2m_is_valid (pte)); + +/* We have a second level 2M superpage */ +if (p2m_is_superpage (pte, level) && (level ==2 ) )
AFAICT, p2m_put_page() can only be called if the pte points to a superpage or page:
if ( p2m_is_superpage(entry, level) || (level == 3) )
{
...
p2m_put_page()
}So do we actually need to check p2m_is_superpage()?
Quoted 13 lines
xen/arch/arm/mmu/p2m.c +5
-1+return p2m_put_l2_superpage (mfn, pte.p2m.type); + else if ( level == 3 ) + return p2m_put_l3_page(mfn, pte.p2m.type); +} + /* Free lpae sub-tree behind an entry */ static void p2m_free_entry(struct p2m_domain *p2m, lpae_t entry, unsigned int level)@@ -809,9 +841,16 @@ static void p2m_free_entry(struct p2m_domain *p2m,#endif p2m->stats.mappings[level]--; -/* Nothing to do if the entry is a super-page. */
xen/arch/arm/mmu/p2m.c static void p2m_free_entry(struct p2m_domain *p2m, · line 851
Quoted 10 lines
xen/arch/arm/mmu/p2m.c +8
-2-if ( level ==3 ) -p2m_put_l3_page (entry); +/* +* TODO: Currently we don't handle 1GB super-page, Xen is not +* preemptible and therefore some work is needed to handle such +* superpages, for which at some point Xen might end up freeing memory +* and therefore for such a big mapping it could end up in a very long +* operation. +*/ +if ( level >=2 )
The code in p2m_put_page() can properly handle level 1. So I would rather prefer if we remove this check (again in order to reduce the amount of work in the P2M code).
This TODO could be moved there.
xen/arch/arm/mmu/p2m.c int relinquish_p2m_mapping(struct domain *d) · line 1601
Quoted 12 lines
xen/arch/arm/mmu/p2m.c +4
-1+p2m_put_page (entry, level); +return ; }@@ -1558,9 +1597,12 @@ int relinquish_p2m_mapping(struct domain *d) count++;/* -* Arbitrarily preempt every 512 iterations. +* Arbitrarily preempt every 512 iterations or when type is foreign +* mapping and the order is above 9 (2MB).
Let's avoid mentioning 2MB. This is only valid when using 4KB pages.
This is also talking about a specific when the code below is not 4KB specific. I would rework anything after the 'or' to:
'we have a level-2 foreign mapping'
The rest of the LGTM to me but I don't feel confortable to do all those changes on commit. So this will want a respin.
For simplicity, you can only resend this patch.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v4 3/7] xen/p2m: put reference for level 2 superpage
Hi Julien,
Quoted 168 lines · Julien Grall
Hi Luca,
Quoted 101 lines · Luca Fancellu
From: Penny Zheng <[email protected]>
We are doing foreign memory mapping for static shared memory, and there is a great possibility that it could be super mapped. But today,p2m_put_l3_pagecould not handle superpages.
This commits implements a new functionp2m_put_l2_superpageto handle 2MB superpages, specifically for helping put extra references for foreign superpages.
Modifyrelinquish_p2m_mappingas well to take into account preemption when type is foreign memory and order is above 9 (2MB). Currently 1GB superpages are not handled because Xen is not preemptible and therefore some work is needed to handle such superpages, for which at some point Xen might end up freeing memory and therefore for such a big mapping it could end up in a very long operation.Signed-off-by Penny Zheng <[email protected]>Signed-off-by Luca Fancellu <[email protected]>---
v4 changes:
- optimised the path to callput_page()on the foreign mapping as
Julien suggested. Add a comment inp2m_put_l2_superpageto state
that any changes needs to take into account some change in the
relinquish code. (Julien)
v3 changes:
- Add reasoning why we don't support now 1GB superpage, removelevel_order
variable fromp2m_put_l2_superpage, update TODO comment inside
p2m_free_entry, useXEN_PT_LEVEL_ORDER(2)instead of value 9 inside
relinquish_p2m_mapping. (Michal)
v2:
- Do not handle 1GB super page as there might be some issue where
a lot of calls toput_page(...)might be issued which could lead
to free memory that is a long operation.
v1:
- patch from https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/--- xen/arch/arm/mmu/p2m.c | 82 +++++++++++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 20 deletions(-)xen/arch/arm/mmu/p2m.c +31
-14@@ -753,34 +753,66 @@ static int p2m_mem_access_radix_set(struct p2m_domain *p2m, gfn_t gfn,return rc; } -/* -* Put any references on the single 4K page referenced by pte. -* TODO: Handle superpages, for now we only take special references for leaf -* pages (specifically foreign ones, which can't be super mapped today). -*/ -static void p2m_put_l3_page(const lpae_t pte) +static void p2m_put_foreign_page(struct page_info *pg) { -mfn_t mfn =lpae_get_mfn (pte); - -ASSERT (p2m_is_valid (pte)); -/* -* TODO: Handle other p2m types -* * It's safe to do the put_page here because page_alloc will * flush the TLBs if the page is reallocated before the end of * this loop. */ -if (p2m_is_foreign (pte.p2m.type) ) +put_page (pg); +} + +/* Put any references on the single 4K page referenced by mfn. */ +static void p2m_put_l3_page (mfn_t mfn,p2m_type_t type) +{ +/* TODO: Handle other p2m types */ +if (p2m_is_foreign (type) ) {ASSERT (mfn_valid (mfn)); -put_page (mfn_to_page (mfn)); +p2m_put_foreign_page (mfn_to_page (mfn)); }/* Detect the xenheap page and mark the stored GFN as invalid. */ -else if (p2m_is_ram (pte.p2m.type) &&is_xen_heap_mfn (mfn) ) +else if (p2m_is_ram (type) &&is_xen_heap_mfn (mfn) )page_set_xenheap_gfn (mfn_to_page (mfn),INVALID_GFN ); } +/* Put any references on the superpage referenced by mfn. */ +static void p2m_put_l2_superpage(mfn_t mfn, p2m_type_t type) +{ +struct page_info *pg; +unsigned int i; + +/* +* TODO: Handle other p2m types, but be aware that any changes to handle +* different types should require an update on the relinquish code to handle +* preemption. +*/ +if ( !p2m_is_foreign (type) ) +return ; + +ASSERT (mfn_valid (mfn)); + + pg =mfn_to_page (mfn); + +for ( i =0 ; i <XEN_PT_LPAE_ENTRIES ; i++, pg++ ) +p2m_put_foreign_page (pg); +}xen/arch/arm/mmu/p2m.c static int p2m_mem_access_radix_set(struct p2m_domain *p2m, gfn_t gfn, · line 809
Quoted 10 lines
xen/arch/arm/mmu/p2m.c +10
-0+ +/* Put any references on the page referenced by pte. */ +static void p2m_put_page (const lpae_t pte,unsigned int level) +{ +mfn_t mfn =lpae_get_mfn (pte); + +ASSERT (p2m_is_valid (pte)); + +/* We have a second level 2M superpage */ +if (p2m_is_superpage (pte, level) && (level ==2 ) )AFAICT,
p2m_put_page()can only be called if the pte points to a superpage or page:if ( p2m_is_superpage(entry, level) || (level == 3) ) { ... p2m_put_page() }So do we actually need to check
p2m_is_superpage()?Quoted 12 lines
xen/arch/arm/mmu/p2m.c +5
-1+return p2m_put_l2_superpage (mfn, pte.p2m.type); + else if ( level == 3 ) + return p2m_put_l3_page(mfn, pte.p2m.type); +} + /* Free lpae sub-tree behind an entry */ static void p2m_free_entry(struct p2m_domain *p2m, lpae_t entry, unsigned int level)@@ -809,9 +841,16 @@ static void p2m_free_entry(struct p2m_domain *p2m,#endif p2m->stats.mappings[level]--; -/* Nothing to do if the entry is a super-page. */ xen/arch/arm/mmu/p2m.c static void p2m_free_entry(struct p2m_domain *p2m, · line 850
Quoted 10 lines
xen/arch/arm/mmu/p2m.c +8
-2-if ( level ==3 ) -p2m_put_l3_page (entry); +/* +* TODO: Currently we don't handle 1GB super-page, Xen is not +* preemptible and therefore some work is needed to handle such +* superpages, for which at some point Xen might end up freeing memory +* and therefore for such a big mapping it could end up in a very long +* operation. +*/ +if ( level >=2 )The code in
p2m_put_page()can properly handle level 1. So I would rather prefer if we remove this check (again in order to reduce the amount of work in the P2M code).This TODO could be moved there.
xen/arch/arm/mmu/p2m.c int relinquish_p2m_mapping(struct domain *d) · line 1601
Quoted 10 lines
xen/arch/arm/mmu/p2m.c +2
-0+p2m_put_page (entry, level); +return ; } @@ -1558,9 +1597,12 @@ int relinquish_p2m_mapping(struct domain *d) count++;/*xen/arch/arm/mmu/p2m.c +2
-1-* Arbitrarily preempt every 512 iterations. +* Arbitrarily preempt every 512 iterations or when type is foreign +* mapping and the order is above 9 (2MB). Let's avoid mentioning 2MB. This is only valid when using 4KB pages.
Quoted 7 lines
This is also talking about a specific when the code below is not 4KB specific. I would rework anything after the 'or' to:
'we have a level-2 foreign mapping'
The rest of the LGTM to me but I don't feel confortable to do all those changes on commit. So this will want a respin.
For simplicity, you can only resend this patch.
Thanks, I’ll address your comment and push the new patch asap.
Cheers,
Luca
PATCH v4 4/7 xen/arm: Parse xen,shared-mem when host phys address is not provided
In reply to Luca FancelluHandle the parsing of the 'xen,shared-mem' property when the host physical address is not provided, this commit is introducing the logic to parse it, but the functionality is still not implemented and will be part of future commits.
Rework the logic inside process_shm_node to check the shm_id before doing the other checks, because it ease the logic itself, add more comment on the logic.
Now when the host physical address is not provided, the value INVALID_PADDR is chosen to signal this condition and it is stored as start of the bank, due to that change also early_print_info_shmem and init_sharedmem_pages are changed, to not handle banks with start equal to INVALID_PADDR.
Another change is done inside meminfo_overlap_check, to skip banks that are starting with the start address INVALID_PADDR, that function is used to check banks from reserved memory, shared memory and ACPI and since the comment above the function states that wrapping around is not handled, it's unlikely for these bank to have the start address as INVALID_PADDR. Same change is done inside consider_modules, find_unallocated_memory and dt_unreserved_regions functions, in order to skip banks that starts with INVALID_PADDR from any computation.
The changes above holds because of this consideration.
---
v4 changes:
- Fix wrong condition for paddr_assigned (Michal)
v3 changes:
- fix typo in commit msg, add R-by Michal
v2 changes:
- fix comments, add parenthesis to some conditions, remove unneeded variables, remove else branch, increment counter in the for loop, skip INVALID_PADDR start banks from also consider_modules, find_unallocated_memory and dt_unreserved_regions. (Michal)
--- xen/arch/arm/arm32/mmu/mm.c | 11 +++- xen/arch/arm/domain_build.c | 5 ++ xen/arch/arm/setup.c | 14 +++- xen/arch/arm/static-shmem.c | 125 +++++++++++++++++++++++++----------- 4 files changed, 111 insertions(+), 44 deletions(-)
xen/arch/arm/arm32/mmu/mm.c +9 -2
@@ -101,8 +101,15 @@ static paddr_t __init consider_modules(paddr_t s, paddr_t e, nr += reserved_mem->nr_banks;for ( ; i - nr < shmem->nr_banks; i++ ) { -paddr_t r_s = shmem->bank[i - nr].start; -paddr_t r_e = r_s + shmem->bank[i - nr].size; +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 ) {
xen/arch/arm/domain_build.c +5 -0
@@ -927,6 +927,11 @@ static int __init find_unallocated_memory(const struct kernel_info *kinfo,for ( j =0 ; j < mem_banks[i]->nr_banks; j++ ) { start = mem_banks[i]->bank[j].start; + +/* Shared memory banks can contain INVALID_PADDR as start */ +if (INVALID_PADDR == start ) +continue ; + end = mem_banks[i]->bank[j].start + mem_banks[i]->bank[j].size; res =rangeset_remove_range (unalloc_mem,PFN_DOWN (start),PFN_DOWN (end -1 ));
xen/arch/arm/setup.c +11 -3
@@ -240,8 +240,15 @@ static void __init dt_unreserved_regions(paddr_t s, paddr_t e, offset = reserved_mem->nr_banks;for ( ; i - offset < shmem->nr_banks; i++ ) { -paddr_t r_s = shmem->bank[i - offset].start; -paddr_t r_e = r_s + shmem->bank[i - offset].size; +paddr_t r_s, r_e; + + r_s = shmem->bank[i - offset].start; + +/* Shared memory banks can contain INVALID_PADDR as start */ +if (INVALID_PADDR == r_s ) +continue ; + + r_e = r_s + shmem->bank[i - offset].size;if ( s < r_e && r_s < e ) {
@@ -272,7 +279,8 @@ static bool __init meminfo_overlap_check(const struct membanks *mem, bank_start = mem->bank[i].start; bank_end = bank_start + mem->bank[i].size; -if ( region_end <= bank_start || region_start >= bank_end ) +if (INVALID_PADDR == bank_start || region_end <= bank_start || + region_start >= bank_end )continue ;else {
xen/arch/arm/static-shmem.c +86 -39
189 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v4 5/7 xen/arm: Rework heap page allocation outside allocate_bank_memory
In reply to Luca FancelluThe function allocate_bank_memory allocates pages from the heap and maps them to the guest using guest_physmap_add_page.
As a preparation work to support static shared memory bank when the host physical address is not provided, Xen needs to allocate memory from the heap, so rework allocate_bank_memory moving out the page allocation in a new function called allocate_domheap_memory.
The function allocate_domheap_memory takes a callback function and a pointer to some extra information passed to the callback and this function will be called for every region, until a defined size is reached.
In order to keep allocate_bank_memory functionality, the callback passed to allocate_domheap_memory is a wrapper for guest_physmap_add_page.
Let allocate_domheap_memory be externally visible, in order to use it in the future from the static shared memory module.
Take the opportunity to change the signature of allocate_bank_memory and remove the 'struct domain' parameter, which can be retrieved from 'struct kernel_info'.
No functional changes is intended.
---
v3 changes:
- Add R-by Michal
v2:
- Reduced scope of pg var in allocate_domheap_memory, removed not necessary BUG_ON(), changed callback to return bool and fix comment. (Michal)
--- xen/arch/arm/dom0less-build.c | 4 +- xen/arch/arm/domain_build.c | 79 +++++++++++++++++-------- xen/arch/arm/include/asm/domain_build.h | 9 ++- 3 files changed, 62 insertions(+), 30 deletions(-)
xen/arch/arm/dom0less-build.c +2 -2
@@ -60,12 +60,12 @@ static void __init allocate_memory(struct domain *d, struct kernel_info *kinfo) mem->nr_banks =0 ; bank_size =MIN (GUEST_RAM0_SIZE , kinfo->unassigned_mem); -if ( !allocate_bank_memory (d, kinfo,gaddr_to_gfn (GUEST_RAM0_BASE ), +if ( !allocate_bank_memory (kinfo,gaddr_to_gfn (GUEST_RAM0_BASE ), bank_size) ) goto fail; bank_size =MIN (GUEST_RAM1_SIZE , kinfo->unassigned_mem); -if ( !allocate_bank_memory (d, kinfo,gaddr_to_gfn (GUEST_RAM1_BASE ), +if ( !allocate_bank_memory (kinfo,gaddr_to_gfn (GUEST_RAM1_BASE ), bank_size) ) goto fail;
xen/arch/arm/domain_build.c +54 -25
101 lines not on this page · raw message
xen/arch/arm/include/asm/domain_build.h +6 -3
@@ -5,9 +5,12 @@#include <asm/kernel.h> typedef __be32 gic_interrupt_t [3 ]; - -bool allocate_bank_memory (struct domain *d,struct kernel_info *kinfo, -gfn_t sgfn,paddr_t tot_size); +typedef bool (*alloc_domheap_mem_cb )(struct domain *d,struct page_info *pg, +unsigned int order,void *extra); +bool allocate_domheap_memory (struct domain *d,paddr_t tot_size, +alloc_domheap_mem_cb cb,void *extra); +bool allocate_bank_memory (struct kernel_info *kinfo,gfn_t sgfn, +paddr_t tot_size);int construct_domain (struct domain *d,struct kernel_info *kinfo);int domain_fdt_begin_node (void *fdt,const char *name,uint64_t unit);int make_chosen_node (const struct kernel_info *kinfo);
Signature · 1 line
2.34.1
PATCH v4 6/7 xen/arm: Implement the logic for static shared memory from Xen heap
In reply to Luca FancelluThis commit implements the logic to have the static shared memory banks from the Xen heap instead of having the host physical address passed from the user.
When the host physical address is not supplied, the physical memory is taken from the Xen heap using allocate_domheap_memory, the allocation needs to occur at the first handled DT node and the allocated banks need to be saved somewhere.
Introduce the 'shm_heap_banks' for that reason, a struct that will hold the banks allocated from the heap, its field bank[].shmem_extra will be used to point to the bootinfo shared memory banks .shmem_extra space, so that there is not further allocation of memory and every bank in shm_heap_banks can be safely identified by the shm_id to reconstruct its traceability and if it was allocated or not.
A search into 'shm_heap_banks' will reveal if the banks were allocated or not, in case the host address is not passed, and the callback given to allocate_domheap_memory will store the banks in the structure and map them to the current domain, to do that, some changes to acquire_shared_memory_bank are made to let it differentiate if the bank is from the heap and if it is, then assign_pages is called for every bank.
When the bank is already allocated, for every bank allocated with the corresponding shm_id, handle_shared_mem_bank is called and the mapping are done.
---
v4 changes:
- Add R-by Michal
v3 changes:
- reworded commit msg section, swap role_str and gbase in alloc_heap_pages_cb_extra to avoid padding hole in arm32, remove not needed printk, modify printk to print KB instead of KB, swap strncmp for strcmp, reduced memory footprint for shm_heap_banks. (Michal)
v2 changes:
- add static inline get_shmem_heap_banks(), given the changes to the struct membanks interface. Rebase changes due to removal of owner_dom_io arg from handle_shared_mem_bank.
Change save_map_heap_pages return type given the changes to the allocate_domheap_memory callback type.
--- xen/arch/arm/static-shmem.c | 187 ++++++++++++++++++++++++++++++------ 1 file changed, 155 insertions(+), 32 deletions(-)
xen/arch/arm/static-shmem.c +155 -32
@@ -9,6 +9,25 @@#include <asm/static-memory.h> #include <asm/static-shmem.h> +typedef struct { +struct domain *d; +const char *role_str; +paddr_t gbase; +struct shmem_membank_extra *bank_extra_info; +}alloc_heap_pages_cb_extra ; + +static struct { +struct membanks_hdr common; +struct membank bank[NR_SHMEM_BANKS ]; +} shm_heap_banks__initdata = { + .common.max_banks =NR_SHMEM_BANKS +}; + +static inline struct membanks *get_shmem_heap_banks (void ) +{ + return container_of(&shm_heap_banks.common, struct membanks, common); +} +static void __init __maybe_unused build_assertions (void ) {/*
@@ -63,7 +82,8 @@ static bool __init is_shm_allocated_to_domio(paddr_t pbase) }static mfn_t __init acquire_shared_memory_bank (struct domain *d, -paddr_t pbase,paddr_t psize) +paddr_t pbase,paddr_t psize, +bool bank_from_heap) {mfn_t smfn;unsigned long nr_pfns;
@@ -83,19 +103,31 @@ static mfn_t __init acquire_shared_memory_bank(struct domain *d, d->max_pages += nr_pfns; smfn =maddr_to_mfn (pbase); - res =acquire_domstatic_pages (d, smfn, nr_pfns,0 ); +if ( bank_from_heap ) +/* +* When host address is not provided, static shared memory is +* allocated from heap and shall be assigned to owner domain. +*/ + res =assign_pages (maddr_to_page (pbase), nr_pfns, d,0 ); +else + res =acquire_domstatic_pages (d, smfn, nr_pfns,0 ); +if ( res ) { -printk (XENLOG_ERR -"%pd: failed to acquire static memory: %d.\n" , d, res); - d->max_pages -= nr_pfns; -return INVALID_MFN ; +printk (XENLOG_ERR "%pd: failed to %s static memory: %d.\n" , d, + bank_from_heap ?"assign" :"acquire" , res); + goto fail; }return smfn; + + fail: + d->max_pages -= nr_pfns; +return INVALID_MFN ; }static int __init assign_shared_memory (struct domain *d,paddr_t gbase, +bool bank_from_heap,const struct membank *shm_bank) {mfn_t smfn;
@@ -108,10 +140,7 @@ static int __init assign_shared_memory(struct domain *d, paddr_t gbase, psize = shm_bank->size; nr_borrowers = shm_bank->shmem_extra->nr_shm_borrowers; -printk ("%pd: allocate static shared memory BANK %#" PRIpaddr"-%#" PRIpaddr".\n" , - d, pbase, pbase + psize); - - smfn =acquire_shared_memory_bank (d, pbase, psize); + smfn =acquire_shared_memory_bank (d, pbase, psize, bank_from_heap);if (mfn_eq (smfn,INVALID_MFN ) )return -EINVAL ;
@@ -182,6 +211,7 @@ append_shm_bank_to_domain(struct kernel_info *kinfo, paddr_t start,static int __init handle_shared_mem_bank (struct domain *d,paddr_t gbase,const char *role_str, +bool bank_from_heap,const struct membank *shm_bank) {bool owner_dom_io = true;
@@ -210,7 +240,8 @@ static int __init handle_shared_mem_bank(struct domain *d, paddr_t gbase,* We found the first borrower of the region, the owner was not * specified, so they should be assigned to dom_io. */ - ret =assign_shared_memory (owner_dom_io ? dom_io : d, gbase, shm_bank); + ret =assign_shared_memory (owner_dom_io ? dom_io : d, gbase, + bank_from_heap, shm_bank);if ( ret )return ret; }
@@ -227,6 +258,39 @@ static int __init handle_shared_mem_bank(struct domain *d, paddr_t gbase,return 0 ; } +static bool __init save_map_heap_pages (struct domain *d,struct page_info *pg, +unsigned int order,void *extra) +{ +alloc_heap_pages_cb_extra *b_extra = (alloc_heap_pages_cb_extra *)extra; +int idx = shm_heap_banks.common.nr_banks; +int ret = -ENOSPC ; + +BUG_ON (!b_extra); + +if ( idx < shm_heap_banks.common.max_banks ) + { + shm_heap_banks.bank[idx].start =page_to_maddr (pg); + shm_heap_banks.bank[idx].size = (1ULL << (PAGE_SHIFT + order)); + shm_heap_banks.bank[idx].shmem_extra = b_extra->bank_extra_info; + shm_heap_banks.common.nr_banks++; + + ret =handle_shared_mem_bank (b_extra->d, b_extra->gbase, + b_extra->role_str, true, + &shm_heap_banks.bank[idx]); +if ( !ret ) + { +/* Increment guest physical address for next mapping */ + b_extra->gbase += shm_heap_banks.bank[idx].size; +return true; + } + } + +printk ("Failed to allocate static shared memory from Xen heap: (%d)\n" , + ret); + +return false; +} +int __init process_shm (struct domain *d,struct kernel_info *kinfo,const struct dt_device_node *node) {
@@ -264,38 +328,97 @@ int __init process_shm(struct domain *d, struct kernel_info *kinfo, pbase = boot_shm_bank->start; psize = boot_shm_bank->size; -if (INVALID_PADDR == pbase ) - { -printk ("%pd: host physical address must be chosen by users at the moment" , d); -return -EINVAL ; - } +/* "role" property is optional */ +if (dt_property_read_string (shm_node,"role" , &role_str) !=0 ) + role_str =NULL ;/* -* xen,shared-mem = <pbase, gbase, size>; -* TODO: pbase is optional. +* xen,shared-mem = <[pbase,] gbase, size>; +* pbase is optional. */ addr_cells =dt_n_addr_cells (shm_node); size_cells =dt_n_size_cells (shm_node); prop =dt_find_property (shm_node,"xen,shared-mem" ,NULL );BUG_ON (!prop); cells = (const __be32 *)prop->value; - gbase =dt_read_paddr (cells + addr_cells, addr_cells); -for ( i =0 ; i <PFN_DOWN (psize); i++ ) -if ( !mfn_valid (mfn_add (maddr_to_mfn (pbase), i)) ) - { -printk ("%pd: invalid physical address 0x%" PRI_mfn"\n" , - d,mfn_x (mfn_add (maddr_to_mfn (pbase), i))); -return -EINVAL ; - } +if ( pbase !=INVALID_PADDR ) + { +/* guest phys address is after host phys address */ + gbase =dt_read_paddr (cells + addr_cells, addr_cells); + +for ( i =0 ; i <PFN_DOWN (psize); i++ ) +if ( !mfn_valid (mfn_add (maddr_to_mfn (pbase), i)) ) + { +printk ("%pd: invalid physical address 0x%" PRI_mfn"\n" , + d,mfn_x (mfn_add (maddr_to_mfn (pbase), i))); +return -EINVAL ; + } + +/* The host physical address is supplied by the user */ + ret =handle_shared_mem_bank (d, gbase, role_str, false, + boot_shm_bank); +if ( ret ) +return ret; + } +else + { +/* +* The host physical address is not supplied by the user, so it +* means that the banks needs to be allocated from the Xen heap, +* look into the already allocated banks from the heap. +*/ +const struct membank *alloc_bank = +find_shm_bank_by_id (get_shmem_heap_banks (), shm_id); -/* "role" property is optional */ -if (dt_property_read_string (shm_node,"role" , &role_str) !=0 ) - role_str =NULL ; +/* guest phys address is right at the beginning */ + gbase =dt_read_paddr (cells, addr_cells); - ret =handle_shared_mem_bank (d, gbase, role_str, boot_shm_bank); -if ( ret ) -return ret; +if ( !alloc_bank ) + { +alloc_heap_pages_cb_extra cb_arg = { d, role_str, gbase, + boot_shm_bank->shmem_extra }; + +/* shm_id identified bank is not yet allocated */ +if ( !allocate_domheap_memory (NULL , psize, save_map_heap_pages, + &cb_arg) ) + { +printk (XENLOG_ERR +"Failed to allocate (%" PRIpaddr"KB) pages as static shared memory from heap\n" , + psize >>10 ); +return -EINVAL ; + } + } +else + { +/* shm_id identified bank is already allocated */ +const struct membank *end_bank = + &shm_heap_banks.bank[shm_heap_banks.common.nr_banks]; +paddr_t gbase_bank = gbase; + +/* +* Static shared memory banks that are taken from the Xen heap +* are allocated sequentially in shm_heap_banks, so starting +* from the first bank found identified by shm_id, the code can +* just advance by one bank at the time until it reaches the end +* of the array or it finds another bank NOT identified by +* shm_id +*/ +for ( ; alloc_bank < end_bank; alloc_bank++ ) + { +if (strcmp (shm_id, alloc_bank->shmem_extra->shm_id) !=0 ) +break ; + + ret =handle_shared_mem_bank (d, gbase_bank, role_str, true, + alloc_bank); +if ( ret ) +return ret; + +/* Increment guest physical address for next mapping */ + gbase_bank += alloc_bank->size; + } + } + }/* * Record static shared memory region info for later setting
Signature · 1 line
2.34.1
PATCH v4 7/7 xen/docs: Describe static shared memory when host address is not provided
In reply to Luca FancelluFrom: Penny Zheng <[email protected]>
This commit describe the new scenario where host address is not provided in "xen,shared-mem" property and a new example is added to the page to explain in details.
Take the occasion to fix some typos in the page.
---
v2:
- Add Michal R-by
v1:
- patch from https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/
with some changes in the commit message.
--- docs/misc/arm/device-tree/booting.txt | 52 ++++++++++++++++++++------- 1 file changed, 39 insertions(+), 13 deletions(-)
docs/misc/arm/device-tree/booting.txt +39 -13
@@ -590,7 +590,7 @@ communication. An array takes a physical address, which is the base address of the shared memory region in host physical address space, a size, and a guest physical address, as the target address of the mapping. - e.g. xen,shared-mem = < [host physical address] [guest address] [size] > + e.g. xen,shared-mem = < [host physical address] [guest address] [size] >; It shall also meet the following criteria: 1) If the SHM ID matches with an existing region, the address range of the
@@ -601,8 +601,8 @@ communication. The number of cells for the host address (and size) is the same as the guest pseudo-physical address and they are inherited from the parent node. - Host physical address is optional, when missing Xen decides the location - (currently unimplemented). + Host physical address is optional, when missing Xen decides the location. + e.g. xen,shared-mem = < [guest address] [size] >; - role (Optional)
@@ -629,7 +629,7 @@ chosen { role = "owner"; xen,shm-id = "my-shared-mem-0"; xen,shared-mem = <0x10000000 0x10000000 0x10000000>; - } + }; domU1 { compatible = "xen,domain";
@@ -640,25 +640,36 @@ chosen { vpl011; /* - * shared memory region identified as 0x0(xen,shm-id = <0x0>) - * is shared between Dom0 and DomU1. + * shared memory region "my-shared-mem-0" is shared + * between Dom0 and DomU1. */ domU1-shared-mem@10000000 { compatible = "xen,domain-shared-memory-v1"; role = "borrower"; xen,shm-id = "my-shared-mem-0"; xen,shared-mem = <0x10000000 0x50000000 0x10000000>; - } + }; /* - * shared memory region identified as 0x1(xen,shm-id = <0x1>) - * is shared between DomU1 and DomU2. + * shared memory region "my-shared-mem-1" is shared between + * DomU1 and DomU2. */ domU1-shared-mem@50000000 { compatible = "xen,domain-shared-memory-v1"; xen,shm-id = "my-shared-mem-1"; xen,shared-mem = <0x50000000 0x60000000 0x20000000>; - } + }; + + /* + * shared memory region "my-shared-mem-2" is shared between + * DomU1 and DomU2. + */ + domU1-shared-mem-2 { + compatible = "xen,domain-shared-memory-v1"; + xen,shm-id = "my-shared-mem-2"; + role = "owner"; + xen,shared-mem = <0x80000000 0x20000000>; + }; ......
@@ -672,14 +683,21 @@ chosen { cpus = <1>; /* - * shared memory region identified as 0x1(xen,shm-id = <0x1>) - * is shared between domU1 and domU2. + * shared memory region "my-shared-mem-1" is shared between + * domU1 and domU2. */ domU2-shared-mem@50000000 { compatible = "xen,domain-shared-memory-v1"; xen,shm-id = "my-shared-mem-1"; xen,shared-mem = <0x50000000 0x70000000 0x20000000>; - } + }; + + domU2-shared-mem-2 { + compatible = "xen,domain-shared-memory-v1"; + xen,shm-id = "my-shared-mem-2"; + role = "borrower"; + xen,shared-mem = <0x90000000 0x20000000>; + }; ...... };
@@ -699,3 +717,11 @@ shared between DomU1 and DomU2. It will get mapped at 0x60000000 in DomU1 guest physical address space, and at 0x70000000 in DomU2 guest physical address space. DomU1 and DomU2 are both the borrower domain, the owner domain is the default owner domain DOMID_IO. + +For the static shared memory region "my-shared-mem-2", since host physical +address is not provided by user, Xen will automatically allocate 512MB +from heap as static shared memory to be shared between DomU1 and DomU2. +The automatically allocated static shared memory will get mapped at +0x80000000 in DomU1 guest physical address space, and at 0x90000000 in DomU2 +guest physical address space. DomU1 is explicitly defined as the owner domain, +and DomU2 is the borrower domain.
Signature · 1 line
2.34.1
+ Oleksii
Quoted 30 lines · Luca Fancellu
This serie is a partial rework of this other serie:
https://patchwork.kernel.org/project/xen-devel/cover/[email protected]/The original serie is addressing an issue of the static shared memory feature that impacts the memory footprint of other component when the feature is enabled, another issue impacts the device tree generation for the guests when the feature is enabled and used and the last one is a missing feature that is the option to have a static shared memory region that is not from the host address space.
This serie is handling some comment on the original serie and it is splitting the rework in two part, this first part is addressing the memory footprint issue and the device tree generation and currently is fully merged
(https://patchwork.kernel.org/project/xen-devel/cover/[email protected]/),
this serie is addressing the static shared memory allocation from the Xen heap.Luca Fancellu (5):
xen/arm: Lookup bootinfo shm bank during the mapping xen/arm: Wrap shared memory mapping code in one function xen/arm: Parse xen,shared-mem when host phys address is not provided xen/arm: Rework heap page allocation outsideallocate_bank_memoryxen/arm: Implement the logic for static shared memory from Xen heapPenny Zheng (2):
xen/p2m: put reference for level 2 superpage
xen/docs: Describe static shared memory when host address is not
provided
Quoted 14 lines
docs/misc/arm/device-tree/booting.txt | 52 ++- xen/arch/arm/arm32/mmu/mm.c | 11 +- xen/arch/arm/dom0less-build.c | 4 +- xen/arch/arm/domain_build.c | 84 +++-- xen/arch/arm/include/asm/domain_build.h | 9 +- xen/arch/arm/mmu/p2m.c | 82 +++-- xen/arch/arm/setup.c | 14 +- xen/arch/arm/static-shmem.c | 432 +++++++++++++++++------- 8 files changed, 502 insertions(+), 186 deletions(-)Signature · 1 line
2.34.1
Hi,
We would like this serie to be in Xen 4.19, there was a misunderstanding on our side because we thought that since the serie was sent before the last posting date, it could have been a candidate for merging in the new release, instead after speaking with Julien and Oleksii we are now aware that we need to provide a justification for its presence.
Pros to this serie is that we are closing the circle for static shared memory, allowing it to use memory from the host or from Xen, it is also a feature that is not enabled by default, so it should not cause too much disruption in case of any bugs that escaped the review, however we’ve tested many configurations for that with/without enabling the feature if that can be an additional value.
Cons: we are touching some common code related to p2m, but also there the impact should be minimal because the new code is subject to l2 foreign mapping (to be confirmed maybe from a p2m expert like Julien).
The comments on patch 3 of this serie are addressed by this patch:
https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/
And the serie is fully reviewed.
So our request is to allow this serie in 4.19, Oleksii, ARM maintainers, do you agree on that?
Cheers,
Luca
Hi,
Quoted 61 lines · Luca Fancellu
+ Oleksii
Quoted 40 lines · Luca Fancellu
This serie is a partial rework of this other serie:
https://patchwork.kernel.org/project/xen-devel/cover/[email protected]/The original serie is addressing an issue of the static shared memory feature that impacts the memory footprint of other component when the feature is enabled, another issue impacts the device tree generation for the guests when the feature is enabled and used and the last one is a missing feature that is the option to have a static shared memory region that is not from the host address space.
This serie is handling some comment on the original serie and it is splitting the rework in two part, this first part is addressing the memory footprint issue and the device tree generation and currently is fully merged
(https://patchwork.kernel.org/project/xen-devel/cover/[email protected]/),
this serie is addressing the static shared memory allocation from the Xen heap.Luca Fancellu (5):
xen/arm: Lookup bootinfo shm bank during the mapping xen/arm: Wrap shared memory mapping code in one function xen/arm: Parse xen,shared-mem when host phys address is not provided xen/arm: Rework heap page allocation outsideallocate_bank_memoryxen/arm: Implement the logic for static shared memory from Xen heapPenny Zheng (2):
xen/p2m: put reference for level 2 superpage
xen/docs: Describe static shared memory when host address is not
provideddocs/misc/arm/device-tree/booting.txt | 52 ++- xen/arch/arm/arm32/mmu/mm.c | 11 +- xen/arch/arm/dom0less-build.c | 4 +- xen/arch/arm/domain_build.c | 84 +++-- xen/arch/arm/include/asm/domain_build.h | 9 +- xen/arch/arm/mmu/p2m.c | 82 +++-- xen/arch/arm/setup.c | 14 +- xen/arch/arm/static-shmem.c | 432 +++++++++++++++++------- 8 files changed, 502 insertions(+), 186 deletions(-)Quoted 4 lines
--
2.34.1Hi,
We would like this serie to be in Xen 4.19, there was a misunderstanding on our side because we thought that since the serie was sent before the last posting date, it could have been a candidate for merging in the new release, instead after speaking with Julien and Oleksii we are now aware that we need to provide a justification for its presence.
Pros to this serie is that we are closing the circle for static shared memory, allowing it to use memory from the host or from Xen, it is also a feature that is not enabled by default, so it should not cause too much disruption in case of any bugs that escaped the review, however we’ve tested many configurations for that with/without enabling the feature if that can be an additional value.
Quoted 8 lines
Cons: we are touching some common code related to p2m, but also there the impact should be minimal because the new code is subject to l2 foreign mapping (to be confirmed maybe from a p2m expert like Julien).
The comments on patch 3 of this serie are addressed by this patch:
https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/
And the serie is fully reviewed.So our request is to allow this serie in 4.19, Oleksii, ARM maintainers, do you agree on that?
As a main reviewer of this series I'm ok to have this series in. It is nicely encapsulated and the feature itself is still in unsupported state. I don't foresee any issues with it.
~Michal
Hi,
Quoted 13 lines · Michal Orzel
Quoted 13 lines
We would like this serie to be in Xen 4.19, there was a misunderstanding on our side because we thought that since the serie was sent before the last posting date, it could have been a candidate for merging in the new release, instead after speaking with Julien and Oleksii we are now aware that we need to provide a justification for its presence.
Pros to this serie is that we are closing the circle for static shared memory, allowing it to use memory from the host or from Xen, it is also a feature that is not enabled by default, so it should not cause too much disruption in case of any bugs that escaped the review, however we’ve tested many configurations for that with/without enabling the feature if that can be an additional value.
Cons: we are touching some common code related to p2m, but also there the impact should be minimal because the new code is subject to l2 foreign mapping (to be confirmed maybe from a p2m expert like Julien).
Quoted 7 lines
Quoted 5 lines
The comments on patch 3 of this serie are addressed by this patch:
https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/
And the serie is fully reviewed.So our request is to allow this serie in 4.19, Oleksii, ARM maintainers, do you agree on that?
As a main reviewer of this series I'm ok to have this series in. It is nicely encapsulated and the feature itself is still in unsupported state. I don't foresee any issues with it.
There are changes in the p2m code and the memory allocation for boot domains. So is it really encapsulated?
For me there are two risks:
* p2m (already mentioned by Luca): We modify the code to put foreign
mapping. The worse that can happen if we don't release the foreign mapping. This would mean the page will not be freed. AFAIK, we don't exercise this path in the CI.
* domain allocation: This mainly look like refactoring. And the path
is exercised in the CI.
So I am not concerned with the domain allocation one. @Luca, would it be possible to detail how did you test the foreign pages were properly removed?
Cheers,
Signature · 1 line
Julien Grall
Hi Julien,
Quoted 26 lines · Julien Grall
Hi,
Quoted 13 lines · Michal Orzel
Quoted 13 lines
We would like this serie to be in Xen 4.19, there was a misunderstanding on our side because we thought that since the serie was sent before the last posting date, it could have been a candidate for merging in the new release, instead after speaking with Julien and Oleksii we are now aware that we need to provide a justification for its presence.
Pros to this serie is that we are closing the circle for static shared memory, allowing it to use memory from the host or from Xen, it is also a feature that is not enabled by default, so it should not cause too much disruption in case of any bugs that escaped the review, however we’ve tested many configurations for that with/without enabling the feature if that can be an additional value.
Cons: we are touching some common code related to p2m, but also there the impact should be minimal because the new code is subject to l2 foreign mapping (to be confirmed maybe from a p2m expert like Julien).
Quoted 7 lines
Quoted 5 lines
The comments on patch 3 of this serie are addressed by this patch:
https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/
And the serie is fully reviewed.So our request is to allow this serie in 4.19, Oleksii, ARM maintainers, do you agree on that?
As a main reviewer of this series I'm ok to have this series in. It is nicely encapsulated and the feature itself is still in unsupported state. I don't foresee any issues with it.
Quoted 7 lines
There are changes in the p2m code and the memory allocation for boot domains. So is it really encapsulated?
For me there are two risks:
* p2m (already mentioned by Luca): We modify the code to put foreign mapping. The worse that can happen if we don't release the foreign mapping. This would mean the page will not be freed. AFAIK, we don't exercise this path in the CI.
* domain allocation: This mainly look like refactoring. And the path is exercised in the CI.So I am not concerned with the domain allocation one. @Luca, would it be possible to detail how did you test the foreign pages were properly removed?
So at first we tested the code, with/without the static shared memory feature enabled, creating/destroying guest from Dom0 and checking that everything was ok.
After a chat on Matrix with Julien he suggested that using a virtio-mmio disk was better to stress out the foreign mapping looking for regressions.
Luckily I’ve found this slide deck from @Oleksandr: https://static.linaro.org/connect/lvc21/presentations/lvc21-314.pdf
So I did a setup using fvp-base, having a disk with two partitions containing Dom0 rootfs and DomU rootfs, Dom0 sees this disk using VirtIO block.
The Dom0 rootfs contains the virtio-disk backend: https://github.com/xen-troops/virtio-disk
And the DomU XL configuration is using these parameters:
cmdline="console=hvc0 root=/dev/vda rw"
disk = ['/dev/vda2,raw,xvda,w,specification=virtio’]
Running the setup and creating/destroying a couple of times the guest is not showing regressions, here an example of the output:
root@fvp-base:/opt/xtp/guests/linux-guests# xl create -c linux-ext-arm64-stresstests-rootfs.cfg Parsing config from linux-ext-arm64-stresstests-rootfs.cfg main: read frontend domid 2 Info: connected to dom2
demu_seq_next: >XENSTORE_ATTACHEDdemu_seq_next: domid = 2demu_seq_next: devid = 51712demu_seq_next: filename[0] = /dev/vda2demu_seq_next: readonly[0] = 0demu_seq_next: base[0] = 0x2000000demu_seq_next: irq[0] = 33demu_seq_next: >XENEVTCHN_OPENdemu_seq_next: >XENFOREIGNMEMORY_OPENdemu_seq_next: >XENDEVICEMODEL_OPENdemu_seq_next: >XENGNTTAB_OPENdemu_initialize: 1 vCPU(s)demu_seq_next: >SERVER_REGISTEREDdemu_seq_next: ioservid = 0demu_seq_next: >RESOURCE_MAPPEDdemu_seq_next: shared_iopage = 0x7f80c58000demu_seq_next: >SERVER_ENABLEDdemu_seq_next: >PORT_ARRAY_ALLOCATEDdemu_seq_next: >EVTCHN_PORTS_BOUNDdemu_seq_next: VCPU0: 3 -> 6demu_register_memory_space: 2000000 - 20001ff
Info: (virtio/mmio.c) virtio_mmio_init:165: virtio-mmio.devices=0x200@0x2000000:33demu_seq_next: >DEVICE_INITIALIZEDdemu_seq_next: >INITIALIZED
IO request not ready
(XEN) d2v0 Unhandled SMC/HVC: 0x84000050
(XEN) d2v0 Unhandled SMC/HVC: 0x8600ff01
(XEN) d2v0: vGICD: RAZ on reserved register offset 0x00000c
(XEN) d2v0: vGICD: unhandled word write 0x000000ffffffff to ICACTIVER4 (XEN) d2v0: vGICR: SGI: unhandled word write 0x000000ffffffff to ICACTIVER0
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd0f0] [ 0.000000] Linux version 6.1.25 (lucfan01@e125770) (aarch64-poky-linux-gcc (GCC) 12.2.0, GNU ld (GNU Binutils) 2.40.20230119) #4 SMP PREEMPT Thu Jun 13 21:55:06 UTC 2024 [ 0.000000] Machine model: XENVM-4.19 [ 0.000000] Xen 4.19 support found [ 0.000000] efi: UEFI not found. [ 0.000000] NUMA: No NUMA configuration found
[...]
[ 0.737758] virtio_blk virtio0: 1/0/0 default/read/poll queues demu_detect_mappings_model: Use foreign mapping (addr 0x5d660000) [ 0.764258] virtio_blk virtio0: [vda] 747094 512-byte logical blocks (383 MB/365 MiB) [ 0.781866] Invalid max_queues (4), will use default max: 1.
[...]
INIT: Entering runlevel: 5
Configuring network interfaces... ip: SIOCGIFFLAGS: No such device Starting syslogd/klogd: done
Poky (Yocto Project Reference Distro) 4.2.1 stressrootfs /dev/hvc0
stressrootfs login: [ 62.593440] cfg80211: failed to load regulatory.db
Poky (Yocto Project Reference Distro) 4.2.1 stressrootfs /dev/hvc0
stressrootfs login: root
root@stressrootfs:~# ls / bin etc lost+found proc sys var boot home media run tmp dev lib mnt sbin usr root@stressrootfs:~#
[...]
root@fvp-base:/opt/xtp/guests/linux-guests# xl destroy 2 Error: reading frontend state failed
main: lost connection to dom2demu_teardown: <INITIALIZEDdemu_teardown: <DEVICE_INITIALIZEDdemu_deregister_memory_space: 2000000demu_teardown: <EVTCHN_PORTS_BOUNDdemu_teardown: <PORT_ARRAY_ALLOCATEDdemu_teardown: VCPU0: 6demu_teardown: <SERVER_ENABLEDdemu_teardown: <RESOURCE_MAPPEDdemu_teardown: <SERVER_REGISTEREDdemu_teardown: <XENGNTTAB_OPENdemu_teardown: <XENDEVICEMODEL_OPENdemu_teardown: <XENFOREIGNMEMORY_OPENdemu_teardown: <XENEVTCHN_OPENdemu_teardown: <XENSTORE_ATTACHED
Info: disconnected from dom2
root@fvp-base:/opt/xtp/guests/linux-guests# xl list Name ID Mem VCPUs State Time(s) Domain-0 0 1024 2 r----- 66.6 root@fvp-base:/opt/xtp/guests/linux-guests#
Cheers,
Luca
Quoted 1 line · Luca Fancellu
Hi Julien,
Hi Luca,
Quoted 28 lines
Quoted 28 lines · Julien Grall
Hi,
Quoted 13 lines · Michal Orzel
Quoted 13 lines
We would like this serie to be in Xen 4.19, there was a misunderstanding on our side because we thought that since the serie was sent before the last posting date, it could have been a candidate for merging in the new release, instead after speaking with Julien and Oleksii we are now aware that we need to provide a justification for its presence.
Pros to this serie is that we are closing the circle for static shared memory, allowing it to use memory from the host or from Xen, it is also a feature that is not enabled by default, so it should not cause too much disruption in case of any bugs that escaped the review, however we’ve tested many configurations for that with/without enabling the feature if that can be an additional value.
Cons: we are touching some common code related to p2m, but also there the impact should be minimal because the new code is subject to l2 foreign mapping (to be confirmed maybe from a p2m expert like Julien).
Quoted 7 lines
Quoted 5 lines
The comments on patch 3 of this serie are addressed by this patch:
https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/
And the serie is fully reviewed.So our request is to allow this serie in 4.19, Oleksii, ARM maintainers, do you agree on that?
As a main reviewer of this series I'm ok to have this series in. It is nicely encapsulated and the feature itself is still in unsupported state. I don't foresee any issues with it.
There are changes in the p2m code and the memory allocation for boot domains. So is it really encapsulated?
Quoted 8 lines
Quoted 5 lines
For me there are two risks:
* p2m (already mentioned by Luca): We modify the code to put foreign mapping. The worse that can happen if we don't release the foreign mapping. This would mean the page will not be freed. AFAIK, we don't exercise this path in the CI.
* domain allocation: This mainly look like refactoring. And the path is exercised in the CI.So I am not concerned with the domain allocation one. @Luca, would it be possible to detail how did you test the foreign pages were properly removed?
So at first we tested the code, with/without the static shared memory feature enabled, creating/destroying guest from Dom0 and checking that everything was ok.
Just to details a bit more for the other. In a normal setup, guest would be using PV block/network which are based on grant table. To exercise the foreing mapping path, you would need a backend that map using the GFN directly.
This is the case for virtio MMIO. Other users are IIRC XenFB, IOREQ (if you emulate a device).
Quoted 8 lines
After a chat on Matrix with Julien he suggested that using a virtio-mmio disk was better to stress out the foreign mapping looking for regressions.
Luckily I’ve found this slide deck from @Oleksandr: https://static.linaro.org/connect/lvc21/presentations/lvc21-314.pdf
So I did a setup using fvp-base, having a disk with two partitions containing Dom0 rootfs and DomU rootfs, Dom0 sees this disk using VirtIO block.
Thanks for the testing! I am satisfied with the result. I have committed the series.
Cheers,
Signature · 1 line
Julien Grall
Quoted 84 lines · Luca Fancellu
+ Oleksii
Quoted 52 lines
On 24 May 2024, at 13:40, Luca Fancellu <[email protected]> wrote:
This serie is a partial rework of this other serie:
https://patchwork.kernel.org/project/xen-devel/cover/[email protected]/The original serie is addressing an issue of the static shared memory feature
that impacts the memory footprint of other component when the feature is
enabled, another issue impacts the device tree generation for the guests when
the feature is enabled and used and the last one is a missing feature that is
the option to have a static shared memory region that is not from the host
address space.This serie is handling some comment on the original serie and it is splitting
the rework in two part, this first part is addressing the memory footprint issue
and the device tree generation and currently is fully merged (
https://patchwork.kernel.org/project/xen-devel/cover/[email protected]
/),
this serie is addressing the static shared memory allocation from the Xen heap.Luca Fancellu (5):
xen/arm: Lookup bootinfo shm bank during the mapping xen/arm: Wrap shared memory mapping code in one function xen/arm: Parse xen,shared-mem when host phys address is not provided
xen/arm: Rework heap page allocation outsideallocate_bank_memoryxen/arm: Implement the logic for static shared memory from Xen heapPenny Zheng (2):
xen/p2m: put reference for level 2 superpage
xen/docs: Describe static shared memory when host address is not provideddocs/misc/arm/device-tree/booting.txt | 52 ++- xen/arch/arm/arm32/mmu/mm.c | 11 +- xen/arch/arm/dom0less-build.c | 4 +- xen/arch/arm/domain_build.c | 84 +++--
xen/arch/arm/include/asm/domain_build.h| 9 +- xen/arch/arm/mmu/p2m.c | 82 +++-- xen/arch/arm/setup.c | 14 +- xen/arch/arm/static-shmem.c | 432 +++++++++++++++++----
---Quoted 6 lines
8 files changed, 502 insertions(+), 186 deletions(-)Signature · 1 line
2.34.1Hi,
We would like this serie to be in Xen 4.19, there was a misunderstanding on our side because we thought
that since the serie was sent before the last posting date, it could have been a candidate for merging in the
new release, instead after speaking with Julien and Oleksii we are now aware that we need to provide a
justification for its presence.Pros to this serie is that we are closing the circle for static shared memory, allowing it to use memory from
the host or from Xen, it is also a feature that is not enabled by default, so it should not cause too much
disruption in case of any bugs that escaped the review, however we’ve tested many configurations for that
with/without enabling the feature if that can be an additional value.Cons: we are touching some common code related to p2m, but also there the impact should be minimal because
the new code is subject to l2 foreign mapping (to be confirmed maybe from a p2m expert like Julien).
Quoted 6 lines
The comments on patch 3 of this serie are addressed by this patch:
https://patchwork.kernel.org/project/xen-devel/patch/[email protected]/
And the serie is fully reviewed.So our request is to allow this serie in 4.19, Oleksii, ARM maintainers, do you agree on that?
Considering that it is not enabled by default and affect on common code is minimal we should consider this patch series in 4.19:
~ Oleksii