[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v5 1/3] xen/device-tree: Let DT reserve map entries overlap reserved-memory


  • To: Shawn Anastasio <sanastasio@xxxxxxxxxxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Mon, 4 Nov 2024 11:49:44 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=raptorengineering.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vIfRaUY5EJyTddYIo+WOIA4bm03Ox6iDG39+dv3ABew=; b=qOeT+JYGJvMybVT5p33WIMKeQPdjWKG1n/kQxCkRGTXisjyYlmoOMg0MstKDS6pwhHnPJ+FCU3wdNnf0+vw6jXJ/SUL9x0flOgjf+lVf9NcnniL988cQ48kOh9G7aiJPhxOc6M26APGYhT+/8bZ46TGf4ysJmjva1tRVR50RoKayTV1niHIYum2Duz9vKCSReCbaTg0aByTp/XlBYrs7Q88LT/3IIv3IiSiI/BXltXsG6l1peKA2tYW1v0hc4pl2bL2Ga6MkRFJCj1bGEd7Pwf9OuGARRs9QtBbit9o2lzk+O7W+FXf9e1hr1SOF2+Gia42DrhR6XWKn4PCWnNR/nw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=snx5Hi9HEr6Ytosaefn73PK1/KxY2wCV2mtUR8qm2wKrG6v+R8QLfDLstd2Uu7nTr+lugZuNB2d8ZEgJATgnbDUNmBYBH4O6mi8lNbL0JXYccdkwrSX0Kj7iwt7yCyGTVgKTS6Jy4yiU1ai+Rvhn8+bSCcBA2y97JRbwwGKhtIgaztDY14mnL2wP9T3h6X5P2dpGnc4b6dV157N+P3xQStcPlC+diYodmrJ/WLa4RQr12UzjZsrLvS9oSW4Jx3dxo8+Zm+qjtIt1/runnCav6hn/ZB7d4y0uRqoFNmZyLTPtaL4FGukjy6a6ZEjw4OiARf12nqHebL3qHr3i4qD2mg==
  • Cc: <tpearson@xxxxxxxxxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>
  • Delivery-date: Mon, 04 Nov 2024 10:50:18 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 27/09/2024 00:24, Shawn Anastasio wrote:
> 
> 
> Commit 53dc37829c31 ("xen/arm: Add DT reserve map regions to
> bootinfo.reserved_mem") changes the way reserve map regions are tracked,
> and as a result broke bootfdt's ability to handle device trees in which
> the reserve map and the `reserved-memory` node contain the same entries
> as each other, as is the case on PPC when booted by skiboot.
> 
> Fix this behavior by moving the reserve map check to after the DT has
> been parsed and by explicitly allowing overlap with entries created by
> `reserved-memory` nodes.
> 
> Fixes: 53dc37829c31 ("xen/arm: Add DT reserve map regions to 
> bootinfo.reserved_mem")
> Signed-off-by: Shawn Anastasio <sanastasio@xxxxxxxxxxxxxxxxxxxxx>
> ---
>  xen/common/device-tree/bootfdt.c  | 28 +++++++++++++++++++++++-----
>  xen/common/device-tree/bootinfo.c | 11 +++++++++--
>  xen/include/xen/bootfdt.h         |  3 ++-
>  3 files changed, 34 insertions(+), 8 deletions(-)
> 
> diff --git a/xen/common/device-tree/bootfdt.c 
> b/xen/common/device-tree/bootfdt.c
> index 911a630e7d..2a51ee44a3 100644
> --- a/xen/common/device-tree/bootfdt.c
> +++ b/xen/common/device-tree/bootfdt.c
> @@ -177,7 +177,7 @@ static int __init device_tree_get_meminfo(const void 
> *fdt, int node,
>      {
>          device_tree_get_reg(&cell, address_cells, size_cells, &start, &size);
>          if ( mem == bootinfo_get_reserved_mem() &&
> -             check_reserved_regions_overlap(start, size) )
> +             check_reserved_regions_overlap(start, size, NULL) )
>              return -EINVAL;
>          /* Some DT may describe empty bank, ignore them */
>          if ( !size )
> @@ -590,14 +590,36 @@ size_t __init boot_fdt_info(const void *fdt, paddr_t 
> paddr)
>      if ( nr_rsvd < 0 )
>          panic("Parsing FDT memory reserve map failed (%d)\n", nr_rsvd);
> 
> +    ret = device_tree_for_each_node(fdt, 0, early_scan_node, NULL);
This should be moved before fdt_num_mem_rsv so that the program flow makes 
sense. In your case nr_rsvd is
not used immediately after.

> +    if ( ret )
> +        panic("Early FDT parsing failed (%d)\n", ret);
> +
>      for ( i = 0; i < nr_rsvd; i++ )
>      {
> +        const struct membanks *overlap = NULL;
>          struct membank *bank;
>          paddr_t s, sz;
> 
>          if ( fdt_get_mem_rsv_paddr(device_tree_flattened, i, &s, &sz) < 0 )
>              continue;
> 
> +        if ( check_reserved_regions_overlap(s, sz, &overlap) )
> +        {
> +            if ( overlap == bootinfo_get_reserved_mem() )
> +            {
> +                /*
> +                 * Some valid device trees, such as those generated by 
> OpenPOWER
> +                 * skiboot firmware, expose all reserved memory regions in 
> the
> +                 * FDT memory reservation block (here) AND in the
> +                 * reserved-memory node which has already been parsed. Thus, 
> any
> +                 * overlaps in the mem_reserved banks should be ignored.
> +                 */
> +                 continue;
I think this is incorrect. Imagine this scenario:
/memreserve/ 0x40000000 0x40000000;
and /reserved-memory/foo with:
reg = <0x0 0x7FFFF000 0x0 0x1000>;

You would ignore the entire region described with /memreserve/ even though it 
overlaps just the last page.

The problem you're describing is about regions that match 1:1 in /memreserve/ 
and /reserved-memory/.
Therefore I think you should check that the overlapped regions match exactly.

~Michal



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.