|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2 2/3] xen/arm: Extend the memory overlap check to include bootmodules
On Wed, 14 Dec 2022, Henry Wang wrote:
> Similarly 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 introduces a helper `bootmodules_overlap_check()`
> and uses this helper to extend the check in function
> `check_reserved_regions_overlap()` so that memory regions in
> bootinfo.modules are included. Use `check_reserved_regions_overlap()`
> in `add_boot_module()` to return early if any error occurs.
>
> Signed-off-by: Henry Wang <Henry.Wang@xxxxxxx>
Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
> ---
> v1 -> v2:
> 1. Split original `overlap_check()` to `bootmodules_overlap_check()`.
> 2. Rework commit message.
> ---
> xen/arch/arm/setup.c | 34 ++++++++++++++++++++++++++++++++++
> 1 file changed, 34 insertions(+)
>
> diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
> index e6eeb3a306..ba0152f868 100644
> --- a/xen/arch/arm/setup.c
> +++ b/xen/arch/arm/setup.c
> @@ -286,6 +286,31 @@ static int __init meminfo_overlap_check(struct meminfo
> *meminfo,
> return 0;
> }
>
> +static int __init bootmodules_overlap_check(struct bootmodules *bootmodules,
> + paddr_t region_start,
> + paddr_t region_end)
> +{
> + paddr_t mod_start = INVALID_PADDR, mod_end = 0;
> + unsigned int i, mod_num = bootmodules->nr_mods;
> +
> + for ( i = 0; i < mod_num; i++ )
> + {
> + mod_start = bootmodules->module[i].start;
> + mod_end = mod_start + bootmodules->module[i].size;
> +
> + if ( region_end <= mod_start || region_start >= mod_end )
> + continue;
> + else
> + {
> + printk("Region %#"PRIpaddr" - %#"PRIpaddr" overlapping with
> mod[%u] %#"PRIpaddr" - %#"PRIpaddr"\n",
> + region_start, region_end, i, mod_start, mod_end);
> + return -EINVAL;
> + }
> + }
> +
> + return 0;
> +}
> +
> void __init fw_unreserved_regions(paddr_t s, paddr_t e,
> void (*cb)(paddr_t, paddr_t),
> unsigned int first)
> @@ -312,6 +337,11 @@ int __init check_reserved_regions_overlap(paddr_t
> region_start,
> region_start, region_end) )
> return -EINVAL;
>
> + /* Check if input region is overlapping with bootmodules */
> + if ( bootmodules_overlap_check(&bootinfo.modules,
> + region_start, region_end) )
> + return -EINVAL;
> +
> return 0;
> }
>
> @@ -329,6 +359,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];
> --
> 2.25.1
>
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |