Memory region overlap check in device tree
cover Memory region overlap check in device tree
As we are having more and more types of memory region defined in the device tree, it is necessary to add the overlap check of these memory regions in Xen, because such check will help user to identify the misconfiguration in the device tree at the early stage of boot time.
The first patch introduces the basic memory overlap check mechanism, and does the memory check for memory regions in bootinfo.reserved_mem. Following patches extend the overlap check to include bootmodules and EfiACPIReclaimMemory.
Henry Wang (3):
xen/arm: Add memory overlap check for bootinfo.reserved_mem xen/arm: Extend the memory overlap check to include bootmodules xen/arm: Extend the memory overlap check to include
EfiACPIReclaimMemory
xen/arch/arm/bootfdt.c | 13 +++-- xen/arch/arm/efi/efi-boot.h | 10 +++- xen/arch/arm/include/asm/setup.h | 2 + xen/arch/arm/setup.c | 90 ++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 9 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/3 xen/arm: Add memory overlap check for bootinfo.reserved_mem
As we are having more and more types of static region, and all of these static regions are defined in bootinfo.reserved_mem, it is necessary to add the overlap check of reserved memory regions in Xen, because such check will help user to identify the misconfiguration in the device tree at the early stage of boot time.
Currently we have 3 types of static region, namely (1) static memory,
(2) static heap, (3) static shared memory. (1) and (2) are parsed by the function device_tree_get_meminfo() and (3) is parsed using its own logic. Therefore, to unify the checking logic for all of these types of static region, this commit firstly introduces a helper check_reserved_regions_overlap() to check if an input physical address range is overlapping with the existing reserved memory regions defined in bootinfo. After that, use this helper in device_tree_get_meminfo() to do the overlap check of (1) and (2) and replace the original overlap check of (3) with this new helper.
--- xen/arch/arm/bootfdt.c | 13 ++++---- xen/arch/arm/include/asm/setup.h | 2 ++ xen/arch/arm/setup.c | 52 ++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 7 deletions(-)
xen/arch/arm/bootfdt.c +6 -7
@@ -91,6 +91,9 @@ static int __init device_tree_get_meminfo(const void *fdt, int node,for ( i =0 ; i < banks && mem->nr_banks <NR_MEM_BANKS ; i++ ) {device_tree_get_reg (&cell, address_cells, size_cells, &start, &size); +if ( mem == &bootinfo.reserved_mem && +check_reserved_regions_overlap (start, size) ) +return -EINVAL ;/* Some DT may describe empty bank, ignore them */ if ( !size )continue ;
@@ -485,7 +488,9 @@ static int __init process_shm_node(const void *fdt, int node,return -EINVAL ; } -if ( (end <= mem->bank[i].start) || (paddr >= bank_end) ) +if (check_reserved_regions_overlap (paddr, size) ) +return -EINVAL ; +else {if (strcmp (shm_id, mem->bank[i].shm_id) !=0 )continue ;
@@ -496,12 +501,6 @@ static int __init process_shm_node(const void *fdt, int node,return -EINVAL ; } } -else - { -printk ("fdt: shared memory region overlap with an existing entry %#" PRIpaddr" - %#" PRIpaddr"\n" , - mem->bank[i].start, bank_end); -return -EINVAL ; - } } }
xen/arch/arm/include/asm/setup.h +2 -0
@@ -143,6 +143,8 @@ void fw_unreserved_regions(paddr_t s, paddr_t e,size_t boot_fdt_info (const void *fdt,paddr_t paddr);const char *boot_fdt_cmdline (const void *fdt); +int check_reserved_regions_overlap (paddr_t region_start,paddr_t region_size); +struct bootmodule *add_boot_module (bootmodule_kind kind,paddr_t start,paddr_t size,bool domU);struct bootmodule *boot_module_find_by_kind (bootmodule_kind kind);
xen/arch/arm/setup.c +52 -0
65 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH 1/3] xen/arm: Add memory overlap check for bootinfo.reserved_mem
Quoted 17 lines · Henry Wang
As we are having more and more types of static region, and all of these static regions are defined in bootinfo.reserved_mem, it is necessary to add the overlap check of reserved memory regions in Xen, because such check will help user to identify the misconfiguration in the device tree at the early stage of boot time.
Currently we have 3 types of static region, namely (1) static memory,
(2) static heap, (3) static shared memory. (1) and (2) are parsed by the functiondevice_tree_get_meminfo()and (3) is parsed using its own logic. Therefore, to unify the checking logic for all of these types of static region, this commit firstly introduces a helpercheck_reserved_regions_overlap()to check if an input physical address range is overlapping with the existing reserved memory regions defined in bootinfo. After that, use this helper indevice_tree_get_meminfo()to do the overlap check of (1) and (2) and replace the original overlap check of (3) with this new helper.
Quoted 1 line
Signed-off-by Henry Wang <[email protected]>
I wonder if the check should only be done #ifdef DEBUG. The idea would be that a given static configuration should be validated and corrected before going into production. By the time you go in production, it is too late to do checks anyway. Especially the panic below.
Julien, Bertrand, what do you think about this?
Quoted 90 lines
--- xen/arch/arm/bootfdt.c | 13 ++++---- xen/arch/arm/include/asm/setup.h | 2 ++ xen/arch/arm/setup.c | 52 ++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 7 deletions(-)xen/arch/arm/bootfdt.c +6
-7@@ -91,6 +91,9 @@ static int __init device_tree_get_meminfo(const void *fdt, int node,for ( i =0 ; i < banks && mem->nr_banks <NR_MEM_BANKS ; i++ ) {device_tree_get_reg (&cell, address_cells, size_cells, &start, &size); +if ( mem == &bootinfo.reserved_mem && +check_reserved_regions_overlap (start, size) ) +return -EINVAL ;/* Some DT may describe empty bank, ignore them */ if ( !size )continue ;@@ -485,7 +488,9 @@ static int __init process_shm_node(const void *fdt, int node,return -EINVAL ; } -if ( (end <= mem->bank[i].start) || (paddr >= bank_end) ) +if (check_reserved_regions_overlap (paddr, size) ) +return -EINVAL ; +else {if (strcmp (shm_id, mem->bank[i].shm_id) !=0 )continue ;@@ -496,12 +501,6 @@ static int __init process_shm_node(const void *fdt, int node,return -EINVAL ; } } -else - { -printk ("fdt: shared memory region overlap with an existing entry %#" PRIpaddr" - %#" PRIpaddr"\n" , - mem->bank[i].start, bank_end); -return -EINVAL ; - } } }xen/arch/arm/include/asm/setup.h +2
-0@@ -143,6 +143,8 @@ void fw_unreserved_regions(paddr_t s, paddr_t e,size_t boot_fdt_info (const void *fdt,paddr_t paddr);const char *boot_fdt_cmdline (const void *fdt); +int check_reserved_regions_overlap (paddr_t region_start,paddr_t region_size); +struct bootmodule *add_boot_module (bootmodule_kind kind,paddr_t start,paddr_t size,bool domU);struct bootmodule *boot_module_find_by_kind (bootmodule_kind kind);xen/arch/arm/setup.c +25
-0@@ -270,6 +270,42 @@ static void __init dt_unreserved_regions(paddr_t s, paddr_t e,cb (s, e); } +static int __init overlap_check (void *bootinfo_type, +paddr_t region_start,paddr_t region_end) +{ +unsigned int i, num =0 ; +paddr_t bank_start =INVALID_PADDR , bank_end =0 ; +char *type_str ="NONAME" ; + +if ( bootinfo_type == &bootinfo.reserved_mem ) + { + num = bootinfo.reserved_mem.nr_banks; + type_str ="reserved_mem" ; + } +else +panic ("Invalid bootinfo type passed to overlap check\n" ); + +for ( i =0 ; i < num; i++ ) + { +if ( bootinfo_type == &bootinfo.reserved_mem ) + { + bank_start = bootinfo.reserved_mem.bank[i].start; + bank_end = bank_start + bootinfo.reserved_mem.bank[i].size; + } + +if ( region_end <= bank_start || region_start >= bank_end ) +continue ;
xen/arch/arm/setup.c static void __init dt_unreserved_regions(paddr_t s, paddr_t e, · line 307
Quoted 10 lines
xen/arch/arm/setup.c +10
-0+else + { +printk ("%s: Region %#" PRIpaddr" - %#" PRIpaddr" overlapping with bank[%u] %#" PRIpaddr" - %#" PRIpaddr"\n" , + type_str, region_start, region_end, i, bank_start, bank_end); +return -EINVAL ; + } + } + +return 0 ; +}
As much as I dislike MACROs in general I think this function should be written as a MACRO so that we can write it once for all use cases. The below in not compiled and not tested, just for explanation purposes. Look how much simpler the code becomes.
#define overlap_check(bootinfo, \
num, \
region_start, \
region_end) \
({ \
unsigned int i, ret; \
paddr_t bank_start = INVALID_PADDR, bank_end = 0; \
\
for ( i = 0; i < num; i++ ) \
{ \
bank_start = bootinfo->start; \
bank_end = bank_start + bootinfo->size; \
\
if ( region_end <= bank_start || region_start >= bank_end ) \
continue; \
else \
{ \
printk("Region %#"PRIpaddr" - %#"PRIpaddr" overlapping with bank[%u] %#"PRIpaddr" - %#"PRIpaddr"\n", \
region_start, region_end, i, bank_start, bank_end); \
ret = -EINVAL; \
break; \
} \
} \
\
retval = 0; \
retval;\
})And the caller:
check_reserved_regions_overlap(&bootinfo.reserved_mem,
bootinfo.reserved_mem.nr_banks,
start, size);Re: [PATCH 1/3] xen/arm: Add memory overlap check for bootinfo.reserved_mem
Hi Stefano,
Quoted 18 lines · Stefano Stabellini
Quoted 17 lines · Henry Wang
As we are having more and more types of static region, and all of these static regions are defined in bootinfo.reserved_mem, it is necessary to add the overlap check of reserved memory regions in Xen, because such check will help user to identify the misconfiguration in the device tree at the early stage of boot time.
Currently we have 3 types of static region, namely (1) static memory,
(2) static heap, (3) static shared memory. (1) and (2) are parsed by the functiondevice_tree_get_meminfo()and (3) is parsed using its own logic. Therefore, to unify the checking logic for all of these types of static region, this commit firstly introduces a helpercheck_reserved_regions_overlap()to check if an input physical address range is overlapping with the existing reserved memory regions defined in bootinfo. After that, use this helper indevice_tree_get_meminfo()to do the overlap check of (1) and (2) and replace the original overlap check of (3) with this new helper.
Quoted 8 lines
Quoted 1 line
Signed-off-by Henry Wang <[email protected]>I wonder if the check should only be done #ifdef DEBUG. The idea would be that a given static configuration should be validated and corrected before going into production. By the time you go in production, it is too late to do checks anyway. Especially the panic below.
Julien, Bertrand, what do you think about this?
The integrator may be a different person (or even a different company) than the one building Xen.
So I think, the new check shoudl not be protected by CONFIG_DEBUG.
That said, any output in bootfd will only printed when earlyprintk is enabled. I think we should consider to support dynamic early printk. Anyway, that's something that doesn't need to be handled in this series.
Quoted 98 lines
Quoted 98 lines
--- xen/arch/arm/bootfdt.c | 13 ++++---- xen/arch/arm/include/asm/setup.h | 2 ++ xen/arch/arm/setup.c | 52 ++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 7 deletions(-)xen/arch/arm/bootfdt.c +6
-7@@ -91,6 +91,9 @@ static int __init device_tree_get_meminfo(const void *fdt, int node,for ( i =0 ; i < banks && mem->nr_banks <NR_MEM_BANKS ; i++ ) {device_tree_get_reg (&cell, address_cells, size_cells, &start, &size); +if ( mem == &bootinfo.reserved_mem && +check_reserved_regions_overlap (start, size) ) +return -EINVAL ;/* Some DT may describe empty bank, ignore them */ if ( !size )continue ;@@ -485,7 +488,9 @@ static int __init process_shm_node(const void *fdt, int node,return -EINVAL ; } -if ( (end <= mem->bank[i].start) || (paddr >= bank_end) ) +if (check_reserved_regions_overlap (paddr, size) ) +return -EINVAL ; +else {if (strcmp (shm_id, mem->bank[i].shm_id) !=0 )continue ;@@ -496,12 +501,6 @@ static int __init process_shm_node(const void *fdt, int node,return -EINVAL ; } } -else - { -printk ("fdt: shared memory region overlap with an existing entry %#" PRIpaddr" - %#" PRIpaddr"\n" , - mem->bank[i].start, bank_end); -return -EINVAL ; - } } }xen/arch/arm/include/asm/setup.h +2
-0@@ -143,6 +143,8 @@ void fw_unreserved_regions(paddr_t s, paddr_t e,size_t boot_fdt_info (const void *fdt,paddr_t paddr);const char *boot_fdt_cmdline (const void *fdt); +int check_reserved_regions_overlap (paddr_t region_start,paddr_t region_size); +struct bootmodule *add_boot_module (bootmodule_kind kind,paddr_t start,paddr_t size,bool domU);struct bootmodule *boot_module_find_by_kind (bootmodule_kind kind);xen/arch/arm/setup.c +32
-0@@ -270,6 +270,42 @@ static void __init dt_unreserved_regions(paddr_t s, paddr_t e,cb (s, e); } +static int __init overlap_check (void *bootinfo_type, +paddr_t region_start,paddr_t region_end) +{ +unsigned int i, num =0 ; +paddr_t bank_start =INVALID_PADDR , bank_end =0 ; +char *type_str ="NONAME" ; + +if ( bootinfo_type == &bootinfo.reserved_mem ) + { + num = bootinfo.reserved_mem.nr_banks; + type_str ="reserved_mem" ; + } +else +panic ("Invalid bootinfo type passed to overlap check\n" ); + +for ( i =0 ; i < num; i++ ) + { +if ( bootinfo_type == &bootinfo.reserved_mem ) + { + bank_start = bootinfo.reserved_mem.bank[i].start; + bank_end = bank_start + bootinfo.reserved_mem.bank[i].size; + } + +if ( region_end <= bank_start || region_start >= bank_end ) +continue ; +else + { +printk ("%s: Region %#" PRIpaddr" - %#" PRIpaddr" overlapping with bank[%u] %#" PRIpaddr" - %#" PRIpaddr"\n" , + type_str, region_start, region_end, i, bank_start, bank_end); +return -EINVAL ; + } + }
Quoted 8 lines
xen/arch/arm/setup.c static void __init dt_unreserved_regions(paddr_t s, paddr_t e, · line 307
Quoted 3 lines
xen/arch/arm/setup.c +3
-0+ +return 0 ; +}As much as I dislike MACROs in general I think this function should be written as a MACRO so that we can write it once for all use cases. The below in not compiled and not tested, just for explanation purposes. Look how much simpler the code becomes.
I agree the duplication is not nice. But it is not clear to me why a static inline function cannot be used.
Quoted 30 lines
#define overlap_check(bootinfo, \
num, \
region_start, \
region_end) \
({ \
unsigned int i, ret; \
paddr_t bank_start = INVALID_PADDR, bank_end = 0; \
\
for ( i = 0; i < num; i++ ) \
{ \
bank_start = bootinfo->start; \
bank_end = bank_start + bootinfo->size; \
\
if ( region_end <= bank_start || region_start >= bank_end ) \
continue; \
else \
{ \
printk("Region %#"PRIpaddr" - %#"PRIpaddr" overlapping with bank[%u] %#"PRIpaddr" - %#"PRIpaddr"\n", \
region_start, region_end, i, bank_start, bank_end); \
ret = -EINVAL; \
break; \
} \
} \
\
retval = 0; \
retval;\
})Quoted 5 lines
And the caller:
check_reserved_regions_overlap(&bootinfo.reserved_mem,
bootinfo.reserved_mem.nr_banks, start, size);
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 1/3] xen/arm: Add memory overlap check for bootinfo.reserved_mem
Quoted 28 lines · Julien Grall
Hi Stefano,
Quoted 25 lines · Stefano Stabellini
Quoted 17 lines · Henry Wang
As we are having more and more types of static region, and all of these static regions are defined in bootinfo.reserved_mem, it is necessary to add the overlap check of reserved memory regions in Xen, because such check will help user to identify the misconfiguration in the device tree at the early stage of boot time.
Currently we have 3 types of static region, namely (1) static memory,
(2) static heap, (3) static shared memory. (1) and (2) are parsed by the functiondevice_tree_get_meminfo()and (3) is parsed using its own logic. Therefore, to unify the checking logic for all of these types of static region, this commit firstly introduces a helpercheck_reserved_regions_overlap()to check if an input physical address range is overlapping with the existing reserved memory regions defined in bootinfo. After that, use this helper indevice_tree_get_meminfo()to do the overlap check of (1) and (2) and replace the original overlap check of (3) with this new helper.Quoted 1 line
Signed-off-by Henry Wang <[email protected]>I wonder if the check should only be done #ifdef DEBUG. The idea would be that a given static configuration should be validated and corrected before going into production. By the time you go in production, it is too late to do checks anyway. Especially the panic below.
Quoted 6 lines
Quoted 1 line
Julien, Bertrand, what do you think about this?
The integrator may be a different person (or even a different company) than the one building Xen.
So I think, the new check shoudl not be protected by
CONFIG_DEBUG.
It is almost like we need something else to say "this is really a production build, disable all checks, I want it to go fast and be as small as possible". Maybe it would be better as a new kconfig option?
In any case, this patch is OK as is.
Quoted 3 lines
That said, any output in bootfd will only printed when earlyprintk is enabled. I think we should consider to support dynamic early printk. Anyway, that's something that doesn't need to be handled in this series.
+1
Quoted 113 lines
Quoted 104 lines
Quoted 104 lines
--- xen/arch/arm/bootfdt.c | 13 ++++---- xen/arch/arm/include/asm/setup.h | 2 ++ xen/arch/arm/setup.c | 52 ++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 7 deletions(-)xen/arch/arm/bootfdt.c +3
-0@@ -91,6 +91,9 @@ static int __init device_tree_get_meminfo(const void *fdt, int node, for ( i = 0; i < banks && mem->nr_banks < NR_MEM_BANKS; i++ ) {device_tree_get_reg (&cell, address_cells, size_cells, &start, &size); +if ( mem == &bootinfo.reserved_mem && +check_reserved_regions_overlap (start, size) ) +return -EINVAL ;/* Some DT may describe empty bank, ignore them */ if ( !size )
continue;xen/arch/arm/bootfdt.c +3
-6@@ -485,7 +488,9 @@ static int __init process_shm_node(const void *fdt,int node, return -EINVAL; } - if ( (end <= mem->bank[i].start) || (paddr >= bank_end) ) +if (check_reserved_regions_overlap (paddr, size) ) +return -EINVAL ; +else {if (strcmp (shm_id, mem->bank[i].shm_id) !=0 )continue ;@@ -496,12 +501,6 @@ static int __init process_shm_node(const void *fdt,int node, return -EINVAL; } } -else - { - printk("fdt: shared memory region overlap with an existing entry %#"PRIpaddr" - %#"PRIpaddr"\n", - mem->bank[i].start, bank_end); -return -EINVAL ; - } }}diff --git
a/xen/arch/arm/include/asm/setup.hb/xen/arch/arm/include/asm/setup.h
indexfdbf68aadc..6a9f88ecbb100644xen/arch/arm/include/asm/setup.h +1
-0@@ -143,6 +143,8 @@ void fw_unreserved_regions(paddr_t s, paddr_t e,size_t boot_fdt_info (const void *fdt,paddr_t paddr);const char *boot_fdt_cmdline (const void *fdt); +int check_reserved_regions_overlap(paddr_t region_start, paddr_t region_size); +struct bootmodule *add_boot_module (bootmodule_kind kind, paddr_t start, paddr_t size, booldomU);
struct bootmodule *boot_module_find_by_kind(bootmodule_kind kind);xen/arch/arm/setup.c +31
-0@@ -270,6 +270,42 @@ static void __init dt_unreserved_regions(paddr_t s,paddr_t e,cb (s ,e ); } +static int __init overlap_check(void *bootinfo_type, +paddr_t region_start,paddr_t region_end) +{ +unsigned int i, num =0 ; +paddr_t bank_start =INVALID_PADDR , bank_end =0 ; +char *type_str ="NONAME" ; + +if ( bootinfo_type == &bootinfo.reserved_mem ) + { + num = bootinfo.reserved_mem.nr_banks; + type_str ="reserved_mem" ; + } +else +panic ("Invalid bootinfo type passed to overlap check\n" ); + +for ( i =0 ; i < num; i++ ) + { +if ( bootinfo_type == &bootinfo.reserved_mem ) + { + bank_start = bootinfo.reserved_mem.bank[i].start; + bank_end = bank_start + bootinfo.reserved_mem.bank[i].size; + } + +if ( region_end <= bank_start || region_start >= bank_end ) +continue ; +else + { + printk("%s: Region %#"PRIpaddr" - %#"PRIpaddr" overlapping with bank[%u] %#"PRIpaddr" - %#"PRIpaddr"\n", + type_str, region_start, region_end, i, bank_start, bank_end); +return -EINVAL ; + } + }Quoted 8 lines
xen/arch/arm/setup.c static void __init dt_unreserved_regions(paddr_t s, paddr_t e, · line 307
Quoted 3 lines
xen/arch/arm/setup.c +3
-0+ +return 0 ; +}As much as I dislike MACROs in general I think this function should be written as a MACRO so that we can write it once for all use cases. The below in not compiled and not tested, just for explanation purposes. Look how much simpler the code becomes.
Quoted 2 lines
I agree the duplication is not nice. But it is not clear to me why a static inline function cannot be used.
You mean a macro generating static inline functions?
It cannot be a single static inline function because the bootinfo arguments are of three different types, it just happens that all three have a "start" and "size" struct member so it works great with a macro, but doesn't for a function.
Quoted 36 lines
Quoted 36 lines
#define overlap_check(bootinfo, \ num, \ region_start, \ region_end) \ ({ \ unsigned int i, ret; \ paddr_t bank_start = INVALID_PADDR, bank_end = 0; \ \ for ( i = 0; i < num; i++ ) \ { \ bank_start = bootinfo->start; \ bank_end = bank_start + bootinfo->size; \ \ if ( region_end <= bank_start || region_start >= bank_end ) \ continue; \ else \ { \ printk("Region %#"PRIpaddr" - %#"PRIpaddr" overlapping with bank[%u] %#"PRIpaddr" - %#"PRIpaddr"\n", \ region_start, region_end, i, bank_start, bank_end); \ ret = -EINVAL; \ break; \ } \ } \ \ retval = 0; \ retval;\ })And the caller:
check_reserved_regions_overlap(&bootinfo.reserved_mem,
bootinfo.reserved_mem.nr_banks, start, size);
Re: [PATCH 1/3] xen/arm: Add memory overlap check for bootinfo.reserved_mem
Hi Stefano,
Quoted 29 lines · Stefano Stabellini
Quoted 28 lines · Julien Grall
Quoted 26 lines · Stefano Stabellini
Quoted 17 lines · Henry Wang
As we are having more and more types of static region, and all of these static regions are defined in bootinfo.reserved_mem, it is necessary to add the overlap check of reserved memory regions in Xen, because such check will help user to identify the misconfiguration in the device tree at the early stage of boot time.
Currently we have 3 types of static region, namely (1) static memory,
(2) static heap, (3) static shared memory. (1) and (2) are parsed by the functiondevice_tree_get_meminfo()and (3) is parsed using its own logic. Therefore, to unify the checking logic for all of these types of static region, this commit firstly introduces a helpercheck_reserved_regions_overlap()to check if an input physical address range is overlapping with the existing reserved memory regions defined in bootinfo. After that, use this helper indevice_tree_get_meminfo()to do the overlap check of (1) and (2) and replace the original overlap check of (3) with this new helper.Quoted 1 line
Signed-off-by Henry Wang <[email protected]>I wonder if the check should only be done #ifdef DEBUG. The idea would be that a given static configuration should be validated and corrected before going into production. By the time you go in production, it is too late to do checks anyway. Especially the panic below.
Julien, Bertrand, what do you think about this?
Quoted 8 lines
Quoted 4 lines
The integrator may be a different person (or even a different company) than the one building Xen.
So I think, the new check shoudl not be protected by
CONFIG_DEBUG.It is almost like we need something else to say "this is really a production build, disable all checks, I want it to go fast and be as small as possible". Maybe it would be better as a new kconfig option?
I am not convinced this should be a Kconfig option for the same reason as before: the integrator may be a different entity and you want to be able to check your setup with the final binary.
So this most likely want to a be a command line option.
Quoted 127 lines
In any case, this patch is OK as is.
Quoted 3 lines
That said, any output in bootfd will only printed when earlyprintk is enabled. I think we should consider to support dynamic early printk. Anyway, that's something that doesn't need to be handled in this series.
+1
Quoted 113 lines
Quoted 104 lines
Quoted 104 lines
--- xen/arch/arm/bootfdt.c | 13 ++++---- xen/arch/arm/include/asm/setup.h | 2 ++ xen/arch/arm/setup.c | 52 ++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 7 deletions(-)xen/arch/arm/bootfdt.c +3
-0@@ -91,6 +91,9 @@ static int __init device_tree_get_meminfo(const void *fdt, int node, for ( i = 0; i < banks && mem->nr_banks < NR_MEM_BANKS; i++ ) {device_tree_get_reg (&cell, address_cells, size_cells, &start, &size); +if ( mem == &bootinfo.reserved_mem && +check_reserved_regions_overlap (start, size) ) +return -EINVAL ;/* Some DT may describe empty bank, ignore them */ if ( !size )
continue;xen/arch/arm/bootfdt.c +3
-6@@ -485,7 +488,9 @@ static int __init process_shm_node(const void *fdt,int node, return -EINVAL; } - if ( (end <= mem->bank[i].start) || (paddr >= bank_end) ) +if (check_reserved_regions_overlap (paddr, size) ) +return -EINVAL ; +else {if (strcmp (shm_id, mem->bank[i].shm_id) !=0 )continue ;@@ -496,12 +501,6 @@ static int __init process_shm_node(const void *fdt,int node, return -EINVAL; } } -else - { - printk("fdt: shared memory region overlap with an existing entry %#"PRIpaddr" - %#"PRIpaddr"\n", - mem->bank[i].start, bank_end); -return -EINVAL ; - } }}diff --git
a/xen/arch/arm/include/asm/setup.hb/xen/arch/arm/include/asm/setup.h
indexfdbf68aadc..6a9f88ecbb100644xen/arch/arm/include/asm/setup.h +1
-0@@ -143,6 +143,8 @@ void fw_unreserved_regions(paddr_t s, paddr_t e,size_t boot_fdt_info (const void *fdt,paddr_t paddr);const char *boot_fdt_cmdline (const void *fdt); +int check_reserved_regions_overlap(paddr_t region_start, paddr_t region_size); +struct bootmodule *add_boot_module (bootmodule_kind kind, paddr_t start, paddr_t size, booldomU); struct bootmodule *boot_module_find_by_kind(bootmodule_kind kind);xen/arch/arm/setup.c +31
-0@@ -270,6 +270,42 @@ static void __init dt_unreserved_regions(paddr_t s,paddr_t e,cb (s ,e ); } +static int __init overlap_check(void *bootinfo_type, +paddr_t region_start,paddr_t region_end) +{ +unsigned int i, num =0 ; +paddr_t bank_start =INVALID_PADDR , bank_end =0 ; +char *type_str ="NONAME" ; + +if ( bootinfo_type == &bootinfo.reserved_mem ) + { + num = bootinfo.reserved_mem.nr_banks; + type_str ="reserved_mem" ; + } +else +panic ("Invalid bootinfo type passed to overlap check\n" ); + +for ( i =0 ; i < num; i++ ) + { +if ( bootinfo_type == &bootinfo.reserved_mem ) + { + bank_start = bootinfo.reserved_mem.bank[i].start; + bank_end = bank_start + bootinfo.reserved_mem.bank[i].size; + } + +if ( region_end <= bank_start || region_start >= bank_end ) +continue ; +else + { + printk("%s: Region %#"PRIpaddr" - %#"PRIpaddr" overlapping with bank[%u] %#"PRIpaddr" - %#"PRIpaddr"\n", + type_str, region_start, region_end, i, bank_start, bank_end); +return -EINVAL ; + } + }Quoted 8 lines
xen/arch/arm/setup.c static void __init dt_unreserved_regions(paddr_t s, paddr_t e, · line 307
Quoted 3 lines
xen/arch/arm/setup.c +3
-0+ +return 0 ; +}As much as I dislike MACROs in general I think this function should be written as a MACRO so that we can write it once for all use cases. The below in not compiled and not tested, just for explanation purposes. Look how much simpler the code becomes.
Quoted 2 lines
I agree the duplication is not nice. But it is not clear to me why a static inline function cannot be used.
Quoted 6 lines
You mean a macro generating static inline functions?
It cannot be a single static inline function because the bootinfo arguments are of three different types, it just happens that all three have a "start" and "size" struct member so it works great with a macro, but doesn't for a function.
It is not clear to me what are the three types you are referring to. Looking at the definition of bootinfo is:
struct bootinfo {
struct meminfo mem;
/* The reserved regions are only used when booting using Device-Tree */
struct meminfo reserved_mem;
struct bootmodules modules;
struct bootcmdlines cmdlines;
#ifdef CONFIG_ACPI
struct meminfo acpi;
#endif
bool static_heap;
};cmdlines is something uninteresting here. So we have two types:
- bootmodules for modules
- meminfo used by reserved_mem, mem and acpi
Looking in details the code, now I understand why you suggested the macro. This is far better than the checking what the array type (not very scalable).
Personally, I think trying to share the code between the two types is a bit odd. The logic is the same today, but I envision to merge reserved_mem, mem and acpi in a single array (it would look like the E820) as this would make easier to find the caching attributes per regions when mapping the RAM. So sharing the code would not be possible.
That said, if you really want to share the code between the two types. Then I would prefer one of the following option:
1) Provide a callback that is used to fetch the information from the
array
2) Provide a common structure that could be used by the function.
This would match other generic function like sort & co.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 1/3] xen/arm: Add memory overlap check for bootinfo.reserved_mem
Quoted 207 lines · Julien Grall
Quoted 33 lines · Stefano Stabellini
Quoted 32 lines · Julien Grall
Quoted 18 lines · Stefano Stabellini
Quoted 17 lines · Henry Wang
As we are having more and more types of static region, and all of these static regions are defined in bootinfo.reserved_mem, it is necessary to add the overlap check of reserved memory regions in Xen, because such check will help user to identify the misconfiguration in the device tree at the early stage of boot time.
Currently we have 3 types of static region, namely (1) static memory,
(2) static heap, (3) static shared memory. (1) and (2) are parsed by the functiondevice_tree_get_meminfo()and (3) is parsed using its own logic. Therefore, to unify the checking logic for all of these types of static region, this commit firstly introduces a helpercheck_reserved_regions_overlap()to check if an input physical address range is overlapping with the existing reserved memory regions defined in bootinfo. After that, use this helper indevice_tree_get_meminfo()to do the overlap check of (1) and (2) and replace the original overlap check of (3) with this new helper.Quoted 8 lines
Quoted 1 line
Signed-off-by Henry Wang <[email protected]>I wonder if the check should only be done #ifdef DEBUG. The idea would be that a given static configuration should be validated and corrected before going into production. By the time you go in production, it is too late to do checks anyway. Especially the panic below.
Julien, Bertrand, what do you think about this?
The integrator may be a different person (or even a different company) than
the one building Xen.Quoted 5 lines
Quoted 1 line
So I think, the new check shoudl not be protected by
CONFIG_DEBUG.It is almost like we need something else to say "this is really a production build, disable all checks, I want it to go fast and be as small as possible". Maybe it would be better as a new kconfig option?
I am not convinced this should be a
Kconfigoption for the same reason as
before: the integrator may be a different entity and you want to be able to check your setup with the final binary.So this most likely want to a be a command line option.
Quoted 139 lines
In any case, this patch is OK as is.
Quoted 4 lines
That said, any output in bootfd will only printed when earlyprintk is enabled.
I think we should consider to support dynamic early printk. Anyway, that's something that doesn't need to be handled in this series.+1
Quoted 123 lines
Quoted 114 lines
Quoted 114 lines
--- xen/arch/arm/bootfdt.c | 13 ++++---- xen/arch/arm/include/asm/setup.h | 2 ++ xen/arch/arm/setup.c | 52 ++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 7 deletions(-)xen/arch/arm/bootfdt.c +3
-0@@ -91,6 +91,9 @@ static int __init device_tree_get_meminfo(const void *fdt, int node, for ( i = 0; i < banks && mem->nr_banks < NR_MEM_BANKS; i++ ) {device_tree_get_reg (&cell, address_cells, size_cells, &start, &size); +if ( mem == &bootinfo.reserved_mem && +check_reserved_regions_overlap (start, size) ) +return -EINVAL ;/* Some DT may describe empty bank, ignore them */ if ( !size ) continue;xen/arch/arm/bootfdt.c +3
-6@@ -485,7 +488,9 @@ static int __init process_shm_node(const void *fdt, int node, return -EINVAL ; } - if ( (end <= mem->bank[i].start) || (paddr >= bank_end) ) +if (check_reserved_regions_overlap (paddr, size) ) +return -EINVAL ; +else {if (strcmp (shm_id, mem->bank[i].shm_id) !=0 )continue ;@@ -496,12 +501,6 @@ static int __init process_shm_node(const void *fdt, int node, return -EINVAL ; } } -else - { - printk("fdt: shared memory region overlap with an existing entry %#"PRIpaddr" - %#"PRIpaddr"\n", - mem->bank[i].start, bank_end); -return -EINVAL ; - }} }diff --git
a/xen/arch/arm/include/asm/setup.hb/xen/arch/arm/include/asm/setup.h
indexfdbf68aadc..6a9f88ecbb100644xen/arch/arm/include/asm/setup.h +1
-0@@ -143,6 +143,8 @@ void fw_unreserved_regions(paddr_t s, paddr_t e,size_t boot_fdt_info (const void *fdt,paddr_t paddr);const char *boot_fdt_cmdline (const void *fdt); +int check_reserved_regions_overlap(paddr_t region_start, paddr_t region_size); + struct bootmodule *add_boot_module(bootmodule_kind kind, paddr_t start, paddr_t size,bool
domU); struct bootmodule *boot_module_find_by_kind(bootmodule_kind kind);xen/arch/arm/setup.c +20
-0@@ -270,6 +270,42 @@ static void __init dt_unreserved_regions(paddr_t s, paddr_t e,cb (s, e); } +static int __init overlap_check(void *bootinfo_type, +paddr_t region_start,paddr_t region_end) +{ +unsigned int i, num =0 ; +paddr_t bank_start =INVALID_PADDR , bank_end =0 ; +char *type_str ="NONAME" ; + +if ( bootinfo_type == &bootinfo.reserved_mem ) + { + num = bootinfo.reserved_mem.nr_banks; + type_str ="reserved_mem" ; + } +else +panic ("Invalid bootinfo type passed to overlap check\n" ); + +for ( i =0 ; i < num; i++ ) + { +if ( bootinfo_type == &bootinfo.reserved_mem ) + { + bank_start = bootinfo.reserved_mem.bank[i].start; + bank_end = bank_start +bootinfo.reserved_mem.bank[i].size;
xen/arch/arm/setup.c +7
-0+ } + +if ( region_end <= bank_start || region_start >= bank_end ) +continue ; + else + { + printk("%s: Region %#"PRIpaddr" - %#"PRIpaddr"overlapping
with bank[%u] %#"PRIpaddr" - %#"PRIpaddr"\n",
+type_str,region_start,region_end, i,bank_start,bank_end);xen/arch/arm/setup.c +3
-0+return -EINVAL ; + } + }Quoted 8 lines
xen/arch/arm/setup.c static void __init dt_unreserved_regions(paddr_t s, paddr_t e, · line 307
Quoted 3 lines
xen/arch/arm/setup.c +3
-0+ +return 0 ; +}As much as I dislike MACROs in general I think this function should be written as a MACRO so that we can write it once for all use cases. The below in not compiled and not tested, just for explanation purposes. Look how much simpler the code becomes.
Quoted 3 lines
I agree the duplication is not nice. But it is not clear to me why a static
inline function cannot be used.Quoted 6 lines
You mean a macro generating static inline functions?
It cannot be a single static inline function because the bootinfo arguments are of three different types, it just happens that all three have a "start" and "size" struct member so it works great with a macro, but doesn't for a function.
It is not clear to me what are the three types you are referring to. Looking at the definition of bootinfo is:
struct bootinfo { struct meminfo mem; /* The reserved regions are only used when booting using Device-Tree */ struct meminfo reserved_mem; struct bootmodules modules; struct bootcmdlines cmdlines; #ifdef CONFIG_ACPI struct meminfo acpi; #endif bool static_heap; };
Quoted 6 lines
cmdlines is something uninteresting here. So we have two types:
- bootmodules for modules
- meminfo used byreserved_mem, mem and acpiLooking in details the code, now I understand why you suggested the macro. This is far better than the checking what the array type (not very scalable).
Thank you :-)
Quoted 6 lines
Personally, I think trying to share the code between the two types is a bit odd. The logic is the same today, but I envision to merge
reserved_mem, mem and acpi in a single array (it would look like the E820) as this would make easier to find the caching attributes per regions when mapping the RAM. So sharing the code would not be possible.
Quoted 6 lines
That said, if you really want to share the code between the two types. Then I would prefer one of the following option:
1) Provide a callback that is used to fetch the information from the array
2) Provide a common structure that could be used by the function.This would match other generic function like sort & co.
I think option 2) would be the best but I couldn't think of a simple way to do it (without using a union and I thought a union would not make things nicer in this case).
Rather than option 1), I think I would rather have 2 different functions to check struct bootmodules and struct meminfo, or the macro.
RE: [PATCH 1/3] xen/arm: Add memory overlap check for bootinfo.reserved_mem
Hi both,
I was lurking around to see how the discussion would go. Thanks for the discussions/inputs in this thread :)
Quoted 27 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Subject: Re: [PATCH 1/3] xen/arm: Add memory overlap check for bootinfo.reserved_memQuoted 23 lines
Quoted 4 lines
It cannot be a single static inline function because the bootinfo arguments are of three different types, it just happens that all three have a "start" and "size" struct member so it works great with a macro, but doesn't for a function.
It is not clear to me what are the three types you are referring to. Looking at the definition of bootinfo is:
struct bootinfo { struct meminfo mem; /* The reserved regions are only used when booting using Device-Tree */ struct meminfo reserved_mem; struct bootmodules modules; struct bootcmdlines cmdlines; #ifdef CONFIG_ACPI struct meminfo acpi; #endif bool static_heap; };cmdlines is something uninteresting here. So we have two types:
- bootmodules for modules
- meminfo used byreserved_mem, mem and acpi
Exactly, we need to check the given input physical address range is not overlapping with any of the banks in bootmodules and meminfo used by reserved_mem & acpi.
Quoted 6 lines
Quoted 2 lines
Looking in details the code, now I understand why you suggested the
macro.
Quoted 1 line
This is far better than the checking what the array type (not very scalable).
Thank you :-)
+1, I also thought this would be quite painful to extend in the future (once we add a new member in bootinfo, for example what Penny did in [1], we need to extend the overlap check as well), but I didn't think of using macro so thank you Stefano :)
Quoted 15 lines
Quoted 4 lines
Personally, I think trying to share the code between the two types is a bit odd. The logic is the same today, but I envision to merge
reserved_mem,mem
Quoted 5 lines
and acpi in a single array (it would look like the E820) as this would make easier to find the caching attributes per regions when mapping the RAM. So sharing the code would not be possible.
That said, if you really want to share the code between the two types. Then
I
Quoted 4 lines
would prefer one of the following option:
1) Provide a callback that is used to fetch the information from the array
2) Provide a common structure that could be used by the function.
Quoted 8 lines
Quoted 1 line
This would match other generic function like sort & co.
I think option 2) would be the best but I couldn't think of a simple way to do it (without using a union and I thought a union would not make things nicer in this case).
Rather than option 1), I think I would rather have 2 different functions to check struct bootmodules and struct meminfo, or the macro.
I personally don't have specific taste here. I think the option is good one as long as we can (1) share most part of the code (2) make the code easy to extend in the future. So as long as you two reach a consensus here I will change to the agreed method in v2.
[1] https://lore.kernel.org/xen-devel/[email protected]/
Kind regards,
Henry
RE: [PATCH 1/3] xen/arm: Add memory overlap check for bootinfo.reserved_mem
Quoted 70 lines · Henry Wang
Hi both,
I was lurking around to see how the discussion would go. Thanks for the discussions/inputs in this thread :)
Quoted 27 lines
-----Original Message-----
From: Stefano Stabellini <[email protected]>
Subject: Re: [PATCH 1/3] xen/arm: Add memory overlap check for bootinfo.reserved_memQuoted 23 lines
Quoted 4 lines
It cannot be a single static inline function because the bootinfo arguments are of three different types, it just happens that all three have a "start" and "size" struct member so it works great with a macro, but doesn't for a function.
It is not clear to me what are the three types you are referring to. Looking at the definition of bootinfo is:
struct bootinfo { struct meminfo mem; /* The reserved regions are only used when booting using Device-Tree */ struct meminfo reserved_mem; struct bootmodules modules; struct bootcmdlines cmdlines; #ifdef CONFIG_ACPI struct meminfo acpi; #endif bool static_heap; };cmdlines is something uninteresting here. So we have two types:
- bootmodules for modules
- meminfo used byreserved_mem, mem and acpiExactly, we need to check the given input physical address range is not overlapping with any of the banks in bootmodules and meminfo used by
reserved_mem& acpi.Quoted 6 lines
Quoted 2 lines
Looking in details the code, now I understand why you suggested the
macro.
Quoted 1 line
This is far better than the checking what the array type (not very scalable).
Thank you :-)
+1, I also thought this would be quite painful to extend in the future (once we add a new member in bootinfo, for example what Penny did in [1], we need to extend the overlap check as well), but I didn't think of using macro so thank you Stefano :)
Quoted 21 lines
Quoted 4 lines
Personally, I think trying to share the code between the two types is a bit odd. The logic is the same today, but I envision to merge
reserved_mem,mem
Quoted 5 lines
and acpi in a single array (it would look like the E820) as this would make easier to find the caching attributes per regions when mapping the RAM. So sharing the code would not be possible.
That said, if you really want to share the code between the two types. Then
I
Quoted 5 lines
would prefer one of the following option:
1) Provide a callback that is used to fetch the information from the array
2) Provide a common structure that could be used by the function.This would match other generic function like sort & co.
I think option 2) would be the best but I couldn't think of a simple way to do it (without using a union and I thought a union would not make things nicer in this case).
Quoted 7 lines
Quoted 2 lines
Rather than option 1), I think I would rather have 2 different functions to check struct bootmodules and struct meminfo, or the macro.
I personally don't have specific taste here. I think the option is good one as long as we can (1) share most part of the code (2) make the code easy to extend in the future. So as long as you two reach a consensus here I will change to the agreed method in v2.
I think Julien and I already agree on having 2 separate functions to check for struct bootmodules and struct meminfo. Julien, I take you prefer the two separate functions to a MACRO, right?
Re: [PATCH 1/3] xen/arm: Add memory overlap check for bootinfo.reserved_mem
Hi Stefano,
Quoted 22 lines · Stefano Stabellini
Quoted 22 lines
Quoted 21 lines
Quoted 2 lines
Personally, I think trying to share the code between the two types is a bit odd. The logic is the same today, but I envision to merge
reserved_mem,mem
Quoted 5 lines
and acpi in a single array (it would look like the E820) as this would make easier to find the caching attributes per regions when mapping the RAM. So sharing the code would not be possible.
That said, if you really want to share the code between the two types. Then
I
Quoted 5 lines
would prefer one of the following option:
1) Provide a callback that is used to fetch the information from the array
2) Provide a common structure that could be used by the function.This would match other generic function like sort & co.
I think option 2) would be the best but I couldn't think of a simple way to do it (without using a union and I thought a union would not make things nicer in this case).
Rather than option 1), I think I would rather have 2 different functions to check struct bootmodules and struct meminfo, or the macro.
Quoted 8 lines
Quoted 4 lines
I personally don't have specific taste here. I think the option is good one as long as we can (1) share most part of the code (2) make the code easy to extend in the future. So as long as you two reach a consensus here I will change to the agreed method in v2.
I think Julien and I already agree on having 2 separate functions to check for struct bootmodules and struct meminfo. Julien, I take you prefer the two separate functions to a MACRO, right?
In this case, yes because the macro would IMHO a bit too large.
Cheers,
Signature · 1 line
Julien Grall
PATCH 2/3 xen/arm: Extend the memory overlap check to include bootmodules
In reply to Henry WangSimilarly as the static regions defined in bootinfo.reserved_mem, the bootmodule regions defined in bootinfo.modules should also not be overlapping with memory regions in either bootinfo.reserved_mem or bootinfo.modules.
Therefore, this commit extends the check in function check_reserved_regions_overlap() to include memory regions in bootinfo.modules, and use check_reserved_regions_overlap() in add_boot_module() to return early if any error occurs.
--- xen/arch/arm/setup.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
xen/arch/arm/setup.c +18 -0
@@ -282,6 +282,11 @@ static int __init overlap_check(void *bootinfo_type, num = bootinfo.reserved_mem.nr_banks; type_str ="reserved_mem" ; } +else if ( bootinfo_type == &bootinfo.modules ) + { + num = bootinfo.modules.nr_mods; + type_str ="bootmodules" ; + }else panic ("Invalid bootinfo type passed to overlap check\n" );
@@ -292,6 +297,11 @@ static int __init overlap_check(void *bootinfo_type, bank_start = bootinfo.reserved_mem.bank[i].start; bank_end = bank_start + bootinfo.reserved_mem.bank[i].size; } +else if ( bootinfo_type == &bootinfo.modules ) + { + bank_start = bootinfo.modules.module[i].start; + bank_end = bank_start + bootinfo.modules.module[i].size; + }if ( region_end <= bank_start || region_start >= bank_end )continue ;
@@ -331,6 +341,10 @@ int __init check_reserved_regions_overlap(paddr_t region_start,if (overlap_check (&bootinfo.reserved_mem, region_start, region_end) )return -EINVAL ; +/* Check if input region is overlapping with bootmodules */ +if (overlap_check (&bootinfo.modules, region_start, region_end) ) +return -EINVAL ; +return 0 ; }
@@ -348,6 +362,10 @@ struct bootmodule __init *add_boot_module(bootmodule_kind kind, boot_module_kind_as_string(kind), start, start + size);return NULL ; } + +if (check_reserved_regions_overlap (start, size) ) +return NULL ; +for ( i =0 ; i < mods->nr_mods ; i++ ) { mod = &mods->module[i];
Signature · 1 line
2.25.1
PATCH 3/3 xen/arm: Extend the memory overlap check to include EfiACPIReclaimMemory
In reply to Henry WangSimilarly as the static regions and boot modules, memory regions with EfiACPIReclaimMemory type (defined in bootinfo.acpi if CONFIG_ACPI is enabled) should also not be overlapping with memory regions in bootinfo.reserved_mem and bootinfo.modules.
Therefore, this commit further extends the check in function check_reserved_regions_overlap() to include memory regions in bootinfo.acpi, and use the extended check_reserved_regions_overlap() in meminfo_add_bank() defined in efi-boot.h to return early if any error occurs.
--- xen/arch/arm/efi/efi-boot.h | 10 ++++++++-- xen/arch/arm/setup.c | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-)
xen/arch/arm/efi/efi-boot.h +8 -2
@@ -161,13 +161,19 @@ static bool __init meminfo_add_bank(struct meminfo *mem, EFI_MEMORY_DESCRIPTOR *desc) {struct membank *bank; +paddr_t start = desc->PhysicalStart; +paddr_t size = desc->NumberOfPages *EFI_PAGE_SIZE ;if ( mem->nr_banks >=NR_MEM_BANKS )return false; +#ifdef CONFIG_ACPI +if (check_reserved_regions_overlap (start, size) ) +return false; +#endif bank = &mem->bank[mem->nr_banks]; - bank->start = desc->PhysicalStart; - bank->size = desc->NumberOfPages *EFI_PAGE_SIZE ; + bank->start = start; + bank->size = size; mem->nr_banks++;
xen/arch/arm/setup.c +20 -0
@@ -287,6 +287,13 @@ static int __init overlap_check(void *bootinfo_type, num = bootinfo.modules.nr_mods; type_str ="bootmodules" ; } +#ifdef CONFIG_ACPI + else if ( bootinfo_type == &bootinfo.acpi ) + { + num = bootinfo.acpi.nr_banks; + type_str ="EfiACPIReclaimMemory" ; + } +#endif else panic("Invalid bootinfo type passed to overlap check\n");
@@ -302,6 +309,13 @@ static int __init overlap_check(void *bootinfo_type, bank_start = bootinfo.modules.module[i].start; bank_end = bank_start + bootinfo.modules.module[i].size; } +#ifdef CONFIG_ACPI + else if ( bootinfo_type == &bootinfo.acpi ) + { + bank_start = bootinfo.acpi.bank[i].start; + bank_end = bank_start + bootinfo.acpi.bank[i].size; + } +#endif if ( region_end <= bank_start || region_start >= bank_end )continue ;
@@ -345,6 +359,12 @@ int __init check_reserved_regions_overlap(paddr_t region_start,if (overlap_check (&bootinfo.modules, region_start, region_end) )return -EINVAL ; +#ifdef CONFIG_ACPI +/* Check if input region is overlapping with ACPI EfiACPIReclaimMemory */ +if (overlap_check (&bootinfo.acpi, region_start, region_end) ) +return -EINVAL ; +#endif +return 0 ; }
Signature · 1 line
2.25.1