xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@arm.com>
To: Stefano Stabellini <sstabellini@kernel.org>,
	xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <stefanos@xilinx.com>
Subject: Re: [Xen-devel] [PATCH v4 3/7] xen/arm: keep track of reserved-memory regions
Date: Wed, 7 Aug 2019 17:33:52 +0100	[thread overview]
Message-ID: <ac88a18f-0651-628c-fb74-e979f26df6b3@arm.com> (raw)
In-Reply-To: <20190806214925.7534-3-sstabellini@kernel.org>

Hi Stefano,

On 06/08/2019 22:49, Stefano Stabellini wrote:
> As we parse the device tree in Xen, keep track of the reserved-memory
> regions as they need special treatment (follow-up patches will make use
> of the stored information.)
> 
> Reuse process_memory_node to add reserved-memory regions to the
> bootinfo.reserved_mem array.
> 
> Refuse to continue once we reach the max number of reserved memory
> regions to avoid accidentally mapping any portions of them into a VM.
> 
> Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
> 
> ---
> Changes in v4:
> - depth + 1 in process_reserved_memory_node

Ah, you fixed it in this patch. But then, this does not match the documentation 
in patch #1.

> - pass address_cells and size_cells to device_tree_for_each_node
> - pass struct meminfo * instead of a boolean to process_memory_node
> - improve in-code comment

I can't see any comment, is that an improvement? :)

> - use a separate process_reserved_memory_node (separate from
>    process_memory_node) function wrapper to have different error handling
> 
> Changes in v3:
> - match only /reserved-memory
> - put the warning back in place for reg not present on a normal memory
>    region
> - refuse to continue once we reach the max number of reserved memory
>    regions
> 
> Changes in v2:
> - call process_memory_node from process_reserved_memory_node to avoid
>    duplication
> ---
>   xen/arch/arm/bootfdt.c      | 43 +++++++++++++++++++++++++++++++------
>   xen/include/asm-arm/setup.h |  1 +
>   2 files changed, 38 insertions(+), 6 deletions(-)
> 
> diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
> index c22d57cd72..3e6fd63b16 100644
> --- a/xen/arch/arm/bootfdt.c
> +++ b/xen/arch/arm/bootfdt.c
> @@ -144,6 +144,7 @@ static int __init process_memory_node(const void *fdt, int node,
>       const __be32 *cell;
>       paddr_t start, size;
>       u32 reg_cells = address_cells + size_cells;
> +    struct meminfo *mem = (struct meminfo *)data;

The cast is unnecessary.

The rest of the code looks good. Pending the discussion about 
device_tree_for_each_node:

Acked-by: Julien Grall <julien.grall@arm.com>

>   
>       if ( address_cells < 1 || size_cells < 1 )
>       {
> @@ -159,21 +160,47 @@ static int __init process_memory_node(const void *fdt, int node,
>       cell = (const __be32 *)prop->data;
>       banks = fdt32_to_cpu(prop->len) / (reg_cells * sizeof (u32));
>   
> -    for ( i = 0; i < banks && bootinfo.mem.nr_banks < NR_MEM_BANKS; i++ )
> +    for ( i = 0; i < banks && mem->nr_banks < NR_MEM_BANKS; i++ )
>       {
>           device_tree_get_reg(&cell, address_cells, size_cells, &start, &size);
>           if ( !size )
>               continue;
> -        bootinfo.mem.bank[bootinfo.mem.nr_banks].start = start;
> -        bootinfo.mem.bank[bootinfo.mem.nr_banks].size = size;
> -        bootinfo.mem.nr_banks++;
> +        mem->bank[mem->nr_banks].start = start;
> +        mem->bank[mem->nr_banks].size = size;
> +        mem->nr_banks++;
>       }
>   
> -    if ( bootinfo.mem.nr_banks == NR_MEM_BANKS )
> +    if ( mem->nr_banks == NR_MEM_BANKS )
>           return -ENOSPC;
>       return 0;
>   }
>   
> +static int __init process_reserved_memory_node(const void *fdt, int node,
> +                                               const char *name, int depth,
> +                                               u32 address_cells,
> +                                               u32 size_cells,
> +                                               void *data)
> +{
> +    int rc = process_memory_node(fdt, node, name, depth, address_cells,
> +                                 size_cells, data);
> +
> +    if ( rc == -ENOSPC )
> +        panic("Max number of supported reserved-memory regions reached.");
> +    else if ( rc != -ENOENT )
> +        return rc;
> +    return 0;
> +}
> +
> +static int __init process_reserved_memory(const void *fdt, int node,
> +                                          const char *name, int depth,
> +                                          u32 address_cells, u32 size_cells)
> +{
> +    return device_tree_for_each_node(fdt, node, depth + 1,
> +                                     address_cells, size_cells,
> +                                     process_reserved_memory_node,
> +                                     &bootinfo.reserved_mem);
> +}
> +
>   static void __init process_multiboot_node(const void *fdt, int node,
>                                             const char *name,
>                                             u32 address_cells, u32 size_cells)
> @@ -307,7 +334,11 @@ static int __init early_scan_node(const void *fdt,
>   
>       if ( device_tree_node_matches(fdt, node, "memory") )
>           rc = process_memory_node(fdt, node, name, depth,
> -                                 address_cells, size_cells, NULL);
> +                                 address_cells, size_cells, &bootinfo.mem);
> +    else if ( depth == 1 && !strcmp(name, "reserved-memory") &&
> +              strlen(name) == strlen("reserved-memory") )
> +        rc = process_reserved_memory(fdt, node, name, depth,
> +                                     address_cells, size_cells);
>       else if ( depth <= 3 && (device_tree_node_compatible(fdt, node, "xen,multiboot-module" ) ||
>                 device_tree_node_compatible(fdt, node, "multiboot,module" )))
>           process_multiboot_node(fdt, node, name, address_cells, size_cells);
> diff --git a/xen/include/asm-arm/setup.h b/xen/include/asm-arm/setup.h
> index 8bf3d5910a..efcba545c2 100644
> --- a/xen/include/asm-arm/setup.h
> +++ b/xen/include/asm-arm/setup.h
> @@ -66,6 +66,7 @@ struct bootcmdlines {
>   
>   struct bootinfo {
>       struct meminfo mem;
> +    struct meminfo reserved_mem;
>       struct bootmodules modules;
>       struct bootcmdlines cmdlines;
>   #ifdef CONFIG_ACPI
> 

Cheers,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-08-07 16:34 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-06 21:49 [Xen-devel] [PATCH v4 0/7] reserved-memory in dom0 Stefano Stabellini
2019-08-06 21:49 ` [Xen-devel] [PATCH v4 1/7] xen/arm: extend device_tree_for_each_node Stefano Stabellini
2019-08-07 16:08   ` Julien Grall
2019-08-07 16:16     ` Julien Grall
2019-08-09 22:01     ` Stefano Stabellini
2019-08-06 21:49 ` [Xen-devel] [PATCH v4 2/7] xen/arm: make process_memory_node a device_tree_node_func Stefano Stabellini
2019-08-07 16:19   ` Julien Grall
2019-08-09 21:08     ` Stefano Stabellini
2019-08-06 21:49 ` [Xen-devel] [PATCH v4 3/7] xen/arm: keep track of reserved-memory regions Stefano Stabellini
2019-08-07 16:33   ` Julien Grall [this message]
2019-08-09 22:19     ` Stefano Stabellini
2019-08-09 23:57       ` Julien Grall
2019-08-12 18:10         ` Stefano Stabellini
2019-08-07 16:46   ` Julien Grall
2019-08-09 20:37     ` Stefano Stabellini
2019-08-06 21:49 ` [Xen-devel] [PATCH v4 4/7] xen/arm: early_print_info print reserved_mem Stefano Stabellini
2019-08-07 16:36   ` Julien Grall
2019-08-09 20:29     ` Stefano Stabellini
2019-08-06 21:49 ` [Xen-devel] [PATCH v4 5/7] xen/arm: handle reserved-memory in consider_modules and dt_unreserved_regions Stefano Stabellini
2019-08-06 21:49 ` [Xen-devel] [PATCH v4 6/7] xen/arm: don't iomem_permit_access for reserved-memory regions Stefano Stabellini
2019-08-08 19:19   ` Volodymyr Babchuk
2019-08-09 22:56     ` Stefano Stabellini
2019-08-12 10:43       ` Julien Grall
2019-08-12 17:45         ` Stefano Stabellini
2019-08-06 21:49 ` [Xen-devel] [PATCH v4 7/7] xen/arm: add reserved-memory regions to the dom0 memory node Stefano Stabellini
2019-08-07 18:29   ` Julien Grall
2019-08-08 19:11 ` [Xen-devel] [PATCH v4 0/7] reserved-memory in dom0 Volodymyr Babchuk
2019-08-08 19:16   ` Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ac88a18f-0651-628c-fb74-e979f26df6b3@arm.com \
    --to=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=stefanos@xilinx.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).