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

Re: [PATCH v2] xen/device-tree: Allow region overlapping with /memreserve/ ranges


  • To: Luca Fancellu <luca.fancellu@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
  • Date: Thu, 14 Nov 2024 13:08:35 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • 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=PWjwJdgEjAg0pVlHjrnvoQQVUCrIB47RZjxSVRvZYe4=; b=t+LqM/VRoA3GhdDScAeNs9igctRdyyOdNykAfwzjcfwtEVHBv11b3dua/+BT5PDS0wuqRxLEIj+pOzG1BytTRdPxI4MCA9SU+a+fqGMajAwZS0B6gcyJsP83zdyfGZ8qr/qU/xR5TQ4VMRGlNKdqPDtIzzQkwoKottc46OEQVB7UBbNgxMbXR8FrklsTYzRM8/ztR2XQDMZN9Jhc5RF/vLj/CEhGAmgN8jQs2RJYRwOLHyrJNZsUd35jv+l5DUrkvV7xij+Dl+Ln2HEx+4xeYIQknL059FRssmOXfIlE2sxUf3zhT2ckeENaKYUz1rL0XI+nnokBHgKT3gJ6f7CCMg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EbXVHJR3HHY6X83bS1fzhU+TF/mv4W7WMj37m1GCiqROG/422tDasLjkppEdCWe0IzVHpkszgkAtXPrG6Ka6qpgXZF1xZ6oSrhcCGFvQJIUEkEPFGBrDyXqhwT2c1WnOX4fIrsjBAhpJv+Hf3qojVeNwsTiqKQ/LKbVOPnS7zdzTQrKzq8TeV00hEbZpfWcdHbZ1sQchZ/6YeFNVHk1k6OTMisJLCl+XmG2UZIBfgbz3Xj55+MEKx271t1wQVJjFM4A7Xlu4DDEJl/YwUpv6atAuGRtOXYdYB/6txzF214Ea7SnXud0cApiEAVMfTi0wP9r4P/n7/uYYc6hhMzI+Qg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Shawn Anastasio <sanastasio@xxxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 14 Nov 2024 11:09:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>



On 14.11.24 12:28, Luca Fancellu wrote:
There are some cases where the device tree exposes a memory range
in both /memreserve/ and reserved-memory node, in this case the
current code will stop Xen to boot since it will find that the
latter range is clashing with the already recorded /memreserve/
ranges.

Furthermore, u-boot lists boot modules ranges, such as ramdisk,
in the /memreserve/ part and even in this case this will prevent
Xen to boot since it will see that the module memory range that
it is going to add in 'add_boot_module' clashes with a /memreserve/
range.

When Xen populate the data structure that tracks the memory ranges,
it also adds a memory type described in 'enum membank_type', so
in order to fix this behavior, allow overlapping with the /memreserve/
ranges in the 'check_reserved_regions_overlap' function when a flag
is set.

In order to implement this solution, there is a distinction between
the 'struct membanks *' handled by meminfo_overlap_check(...) that
needs to be done, because the static shared memory banks doesn't have
a usable bank[].type field and so it can't be accessed, hence now
the 'struct membanks_hdr' have a 'enum region_type type' field in order
to be able to identify static shared memory banks in meminfo_overlap_check(...).

While there, set a type for the memory recorded using meminfo_add_bank()
from efi-boot.h.

Fixes: 53dc37829c31 ("xen/arm: Add DT reserve map regions to 
bootinfo.reserved_mem")
Reported-by: Shawn Anastasio <sanastasio@xxxxxxxxxxxxxxxxxxxxx>
Reported-by: Grygorii Strashko <grygorii_strashko@xxxxxxxx>
Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx>
---
Changes from v1:
  - fixed commit message
  - used boolean to allow /memreserve/ overlap or not
  - now 'struct membanks *' have a type, while it might seem a waste of space,
    it might be used in the future to consolidate also the 'struct bootmodules'
    and 'struct bootcmdlines' to use the same 'struct membanks *' interface.
    Also the added space is limited to 3/4 enum size.
  - The change above allowed this version to remove the "hack" when dealing with
    static shared memory banks, that doesn't have a type.

I tested this patch adding the same range in a /memreserve/ entry and
/reserved-memory node, and by letting u-boot pass a ramdisk.
I've also tested that a configuration running static shared memory still works
fine.
---
---
  xen/arch/arm/efi/efi-boot.h       |  3 ++-
  xen/arch/arm/static-shmem.c       |  2 +-
  xen/common/device-tree/bootfdt.c  |  9 ++++++-
  xen/common/device-tree/bootinfo.c | 39 +++++++++++++++++++++++--------
  xen/include/xen/bootfdt.h         | 20 +++++++++++++---
  5 files changed, 57 insertions(+), 16 deletions(-)


[...]

Dom0 started successfully with Initrd.

Tested-by: Grygorii Strashko <grygorii_strashko@xxxxxxxx>

Meminfo from boot log is below:

(XEN) Checking for initrd in /chosen
(XEN) Initrd 0000000084000040-0000000087bc5831
(XEN) RAM: 0000000048000000 - 00000000bfffffff
(XEN) RAM: 0000000480000000 - 00000004ffffffff
(XEN) RAM: 0000000600000000 - 00000006ffffffff
(XEN)
(XEN) MODULE[0]: 0000000048080000 - 00000000481ec000 Xen
(XEN) MODULE[1]: 0000000048000000 - 000000004801e080 Device Tree
(XEN) MODULE[2]: 0000000084000040 - 0000000087bc5831 Ramdisk
(XEN) MODULE[3]: 0000000048300000 - 000000004a300000 Kernel
(XEN) MODULE[4]: 0000000048070000 - 0000000048080000 XSM
(XEN)  RESVD[0]: 0000000084000040 - 0000000087bc5830
(XEN)  RESVD[1]: 0000000060000000 - 000000007fffffff
(XEN)  RESVD[2]: 00000000b0000000 - 00000000bfffffff
(XEN)  RESVD[3]: 00000000a0000000 - 00000000afffffff

Thank you,
-grygorii



 


Rackspace

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