Introduce reserved Xenheap
cover Introduce reserved Xenheap
The reserved Xenheap, or statically configured Xenheap, refers to parts of RAM reserved in the beginning for Xenheap. Like the static memory allocation, such reserved Xenheap regions are reserved by configuration in the device tree using physical address ranges.
This feature is useful to run Xen on Arm MPU systems, where only a finite number of memory protection regions are available. The limited number of protection regions places requirement on planning the use of MPU protection regions and one or more MPU protection regions needs to be reserved only for Xenheap.
Therefore, this patch series is sent as RFC for comments from the community. The first patch introduces the reserved Xenheap and the device tree processing code. The second patch adds the implementation of the reserved Xenheap pages handling in boot and heap allocator on Arm64.
Henry Wang (2):
docs, xen/arm: Introduce reserved Xenheap memory xen/arm: Handle reserved Xenheap pages in boot/heap allocator
docs/misc/arm/device-tree/booting.txt | 43 ++++++++++++++++++++++ xen/arch/arm/bootfdt.c | 52 +++++++++++++++++++++------ xen/arch/arm/include/asm/setup.h | 3 ++ xen/arch/arm/setup.c | 52 +++++++++++++++++++-------- 4 files changed, 125 insertions(+), 25 deletions(-)
Signature · 1 line
2.17.1
RFC PATCH 1/2 docs, xen/arm: Introduce reserved Xenheap memory
This commit introduces the reserved Xenheap memory, which is parts of RAM reserved in the beginning of the boot time for Xenheap.
A new boolean field xen_heap in struct membank is added to store the configuration telling if the memory bank is reserved as Xenheap through xen,static-mem in device tree chosen node.
Also, this commit introduces the logic to parse the reserved Xenheap configuation in device tree by reusing the device tree entry definition of the static memory allocation feature:
- Add a boolean parameter xen_heap to device_tree_get_meminfo to reflect whether the memory bank is reserved as the Xenheap.
- Use device_tree_get_meminfo to parse the reserved Xenheap configuation in chosen node of the device tree.
- In order to reuse the function device_tree_get_meminfo, the return type of process_chosen_node is changed from void to int.
A documentation section is added, describing the definition of reserved Xenheap memory and the method of enabling the reserved Xenheap memory through device tree on AArch64 at boot time.
---
For reviewers:
The name of the device tree property was chosen because we want to reuse as much as the device tree parsing helpers from the static memory allocation feature, but we would like to hear the upstream reviewers' opinion about if using "xen,static-heap" is better, although this will add another checking path in early_scan_node.
--- docs/misc/arm/device-tree/booting.txt | 43 +++++++++++++++++++++++ xen/arch/arm/bootfdt.c | 50 +++++++++++++++++++++------ xen/arch/arm/include/asm/setup.h | 1 + 3 files changed, 84 insertions(+), 10 deletions(-)
docs/misc/arm/device-tree/booting.txt +43 -0
@@ -355,3 +355,46 @@ device-tree: This will reserve a 512MB region starting at the host physical address 0x30000000 to be exclusively used by DomU1. + + +Reserved Xenheap Memory +======================= + +The reserved Xenheap memory (also known as statically configured Xenheap) +refers to parts of RAM reserved in the beginning for Xenheap. The memory is +reserved by configuration in the device tree using physical address ranges. + +The definition of reserved Xenheap memory in the device tree indicates: + +(1) Only the defined reserved memory areas will be used as Xenheap. + +(2) The defined reserved heap areas shall always go to the heap allocator +and only be used as Xenheap. + +The reserved Xenheap memory is an optional feature and can be enabled by +adding a device tree property in the `chosen` node. Currently, this feature +is only supported on AArch64 and this feature reuses the static memory +allocation device tree configuration. + +The dtb property should look like as follows: + +- property name + + "xen,static-mem" (Should be used in the `chosen` node) + +- cells + + Specify the start address and the length of the reserved Xenheap memory. + The number of cells for the address and the size should be defined + using the properties `#xen,static-mem-address-cells` and + `#xen,static-mem-size-cells` respectively. + +Below is an example on how to specify the reserved Xenheap in device tree: + + chosen { + #xen,static-mem-address-cells = <0x2>; + #xen,static-mem-size-cells = <0x2>; + xen,static-mem = <0x0 0x30000000 0x0 0x40000000>; + }; + +RAM at 0x30000000 of 1G size will be reserved as Xenheap.
xen/arch/arm/bootfdt.c +40 -10
121 lines not on this page · raw message
xen/arch/arm/include/asm/setup.h +1 -0
@@ -27,6 +27,7 @@ struct membank {paddr_t start;paddr_t size;bool xen_domain;/* whether the memory bank is bound to a Xen domain. */ +bool xen_heap;/* whether the memory bank is reserved as Xenheap. */ };struct meminfo {
Signature · 1 line
2.17.1
RFC PATCH 2/2 xen/arm: Handle reserved Xenheap pages in boot/heap allocator
In reply to Henry WangThis commit firstly adds a global variable reserved_heap. This newly introduced global variable is set at the device tree parsing time if the reserved Xenheap ranges are defined in the device tree chosen node.
In setup_mm, If the reserved Xenheap is enabled and used, we make sure that these reserved Xenheap pages are added to the boot allocator. Otherwise there would be a case that if all available memory is used for the reserved Xenheap, the boot allocator will contain zero page at boot time and eventually cause failures.
These reserved Xenheap pages in the boot allocator are added to the heap allocator at end_boot_allocator().
If the reserved Xenheap is disabled, we stick to the current page allocation strategy at boot time.
Also, this commit removes some unneeded brackets in setup_mm following the Xen coding style.
--- xen/arch/arm/bootfdt.c | 2 ++ xen/arch/arm/include/asm/setup.h | 2 ++ xen/arch/arm/setup.c | 52 +++++++++++++++++++++++--------- 3 files changed, 41 insertions(+), 15 deletions(-)
xen/arch/arm/bootfdt.c +2 -0
@@ -328,6 +328,8 @@ static int __init process_chosen_node(const void *fdt, int node, true);if ( rc )return rc; + + reserved_heap = true; }printk ("Checking for initrd in /chosen\n" );
xen/arch/arm/include/asm/setup.h +2 -0
@@ -92,6 +92,8 @@ extern struct bootinfo bootinfo;extern domid_t max_init_domid; +extern bool reserved_heap; +void copy_from_paddr (void *dst,paddr_t paddr,unsigned long len);size_t estimate_efi_size (int mem_nr_banks);
xen/arch/arm/setup.c +37 -15
84 lines not on this page · raw message
Signature · 1 line
2.17.1
Hi Henry,
Quoted 4 lines · Henry Wang
The reserved Xenheap, or statically configured Xenheap, refers to parts of RAM reserved in the beginning for Xenheap. Like the static memory allocation, such reserved Xenheap regions are reserved by configuration in the device tree using physical address ranges.
In Xen, we have the concept of domheap and xenheap. For Arm64 and x86 they would be the same. But for Arm32, they would be different: xenheap is always mapped whereas domheap is separate.
Skimming through the series, I think you want to use the region for both domheap and xenheap. Is that correct?
Furthemore, now that we are introducing more static region, it will get easier to overlap the regions by mistakes. I think we want to have some logic in Xen (or outside) to ensure that none of them overlaps. Do you have any plan for that?
Quoted 22 lines
This feature is useful to run Xen on Arm MPU systems, where only a finite number of memory protection regions are available. The limited number of protection regions places requirement on planning the use of MPU protection regions and one or more MPU protection regions needs to be reserved only for Xenheap.
Therefore, this patch series is sent as RFC for comments from the community. The first patch introduces the reserved Xenheap and the device tree processing code. The second patch adds the implementation of the reserved Xenheap pages handling in boot and heap allocator on Arm64.
Henry Wang (2):
docs, xen/arm: Introduce reserved Xenheap memory xen/arm: Handle reserved Xenheap pages in boot/heap allocatordocs/misc/arm/device-tree/booting.txt | 43 ++++++++++++++++++++++ xen/arch/arm/bootfdt.c | 52 +++++++++++++++++++++------ xen/arch/arm/include/asm/setup.h | 3 ++ xen/arch/arm/setup.c | 52 +++++++++++++++++++-------- 4 files changed, 125 insertions(+), 25 deletions(-)
Signature · 1 line
Julien Grall
Hi Julien,
Thanks very much for your time reading the series and your feedback. Please find the inline reply below.
Quoted 17 lines
-----Original Message-----
From: Julien Grall <[email protected]>
Sent: Saturday, February 26, 2022 4:09 AM
To: Henry Wang <[email protected]>; [email protected]; [email protected]
Cc: Bertrand Marquis <[email protected]>; Wei Chen <[email protected]>; Penny Zheng <[email protected]>
Subject: Re: [RFC PATCH 0/2] Introduce reserved XenheapHi Henry,
Quoted 4 lines · Henry Wang
The reserved Xenheap, or statically configured Xenheap, refers to parts of RAM reserved in the beginning for Xenheap. Like the static memory allocation, such reserved Xenheap regions are reserved by configuration in the device tree using physical address ranges.
Quoted 6 lines
In Xen, we have the concept of domheap and xenheap. For Arm64 and x86 they would be the same. But for Arm32, they would be different: xenheap is always mapped whereas domheap is separate.
Skimming through the series, I think you want to use the region for both domheap and xenheap. Is that correct?
Yes I think that would be correct, for Arm32, instead of using the full ram_pages as the initial value of heap_pages, we want to use the region specified in the device tree. But we are confused if this is the correct (or preferred) way for Arm32, so in this series we only implemented the reserved heap for Arm64.
Could you please share your opinion on this? Thanks!
Quoted 5 lines
Furthemore, now that we are introducing more static region, it will get easier to overlap the regions by mistakes. I think we want to have some logic in Xen (or outside) to ensure that none of them overlaps. Do you have any plan for that?
Totally agree with this idea, but before we actually implement the code, we would like to firstly share our thoughts on this: One option could be to add data structures to notes down these static memory regions when the device tree is parsed, and then we can check if they are overlapped. Over the long term (and this long term option is currently not in our plan), maybe we can add something in the Xen toolstack for this usage?
Also, I am wondering if the overlapping check logic should be introduced in this series. WDYT?
Quoted 24 lines
Quoted 17 lines
This feature is useful to run Xen on Arm MPU systems, where only a finite number of memory protection regions are available. The limited number of protection regions places requirement on planning the use of MPU protection regions and one or more MPU protection regions needs to be reserved only for Xenheap.
Therefore, this patch series is sent as RFC for comments from the community. The first patch introduces the reserved Xenheap and the device tree processing code. The second patch adds the implementation of the reserved Xenheap pages handling in boot and heap allocator on Arm64.
Henry Wang (2):
docs, xen/arm: Introduce reserved Xenheap memory xen/arm: Handle reserved Xenheap pages in boot/heap allocatorQuoted 6 lines
docs/misc/arm/device-tree/booting.txt | 43 ++++++++++++++++++++++ xen/arch/arm/bootfdt.c | 52 +++++++++++++++++++++------ xen/arch/arm/include/asm/setup.h | 3 ++ xen/arch/arm/setup.c | 52 +++++++++++++++++++-------- 4 files changed, 125 insertions(+), 25 deletions(-)
Quoted 2 lines
--
Julien Grall
Kind regards,
Henry
Quoted 1 line · Henry Wang
Hi Julien,
Hi Henry,
Quoted 21 lines
Quoted 21 lines
-----Original Message-----
From: Julien Grall <[email protected]>
Sent: Saturday, February 26, 2022 4:09 AM
To: Henry Wang <[email protected]>; [email protected]; [email protected]
Cc: Bertrand Marquis <[email protected]>; Wei Chen <[email protected]>; Penny Zheng <[email protected]>
Subject: Re: [RFC PATCH 0/2] Introduce reserved XenheapHi Henry,
Quoted 4 lines · Henry Wang
The reserved Xenheap, or statically configured Xenheap, refers to parts of RAM reserved in the beginning for Xenheap. Like the static memory allocation, such reserved Xenheap regions are reserved by configuration in the device tree using physical address ranges.
In Xen, we have the concept of domheap and xenheap. For Arm64 and x86 they would be the same. But for Arm32, they would be different: xenheap is always mapped whereas domheap is separate.
Quoted 8 lines
Quoted 2 lines
Skimming through the series, I think you want to use the region for both domheap and xenheap. Is that correct?
Yes I think that would be correct, for Arm32, instead of using the full
ram_pagesas the initial value ofheap_pages, we want to use the region specified in the device tree. But we are confused if this is the correct (or preferred) way for Arm32, so in this series we only implemented the reserved heap for Arm64.
That's an interesting point. When I skimmed through the series on Friday, my first thought was that for arm32 it would be only xenheap (so all the rest of memory is domheap).
However, Xen can allocate memory from domheap for its own purpose (e.g. we don't need contiguous memory, or for page-tables).
In a fully static environment, the domheap and xenheap are both going to be quite small. It would also be somewhat difficult for a user to size it. So I think, it would be easier to use the region you introduce for both domheap and xenheap.
Stefano, Bertrand, any opionions?
On a separate topic, I think we need some documentation explaining how a user can size the xenheap. How did you figure out for your setup?
Quoted 10 lines
Quoted 5 lines
Furthemore, now that we are introducing more static region, it will get easier to overlap the regions by mistakes. I think we want to have some logic in Xen (or outside) to ensure that none of them overlaps. Do you have any plan for that?
Totally agree with this idea, but before we actually implement the code, we would like to firstly share our thoughts on this: One option could be to add data structures to notes down these static memory regions when the device tree is parsed, and then we can check if they are overlapped.
This should work.
Quoted 3 lines
Over
the long term (and this long term option is currently not in our plan), maybe we can add something in the Xen toolstack for this usage?
When I read "Xen toolstack", I read the tools that will run in dom0. Is it what you meant?
Quoted 3 lines
Also, I am wondering if the overlapping check logic should be introduced in this series. WDYT?
I would do that in a separate series.
Cheers,
Signature · 1 line
Julien Grall
Hi Julien,
Quoted 43 lines
-----Original Message-----
From: Julien Grall <[email protected]>Quoted 1 line · Henry Wang
Hi Julien,
Hi Henry,
Quoted 11 lines
Quoted 11 lines
-----Original Message-----
From: Julien Grall <[email protected]>
Hi Henry,Quoted 4 lines · Henry Wang
The reserved Xenheap, or statically configured Xenheap, refers to parts of RAM reserved in the beginning for Xenheap. Like the static memory allocation, such reserved Xenheap regions are reserved by configuration in the device tree using physical address ranges.
In Xen, we have the concept of domheap and xenheap. For Arm64 and
x86
Quoted 11 lines
Quoted 5 lines
they would be the same. But for Arm32, they would be different: xenheap is always mapped whereas domheap is separate.
Skimming through the series, I think you want to use the region for both domheap and xenheap. Is that correct?
Yes I think that would be correct, for Arm32, instead of using the full
ram_pagesas the initial value ofheap_pages, we want to use the region specified in the device tree. But we are confused if this is the correct (or preferred) way for Arm32, so in this series we only implemented the reserved heap for Arm64.That's an interesting point. When I skimmed through the series on Friday, my first thought was that for arm32 it would be only xenheap (so all the rest of memory is domheap).
However, Xen can allocate memory from domheap for its own purpose (e.g. we don't need contiguous memory, or for page-tables).
In a fully static environment, the domheap and xenheap are both going to be quite small. It would also be somewhat difficult for a user to size it. So I think, it would be easier to use the region you introduce for both domheap and xenheap.
Quoted 4 lines
Stefano, Bertrand, any opionions?
On a separate topic, I think we need some documentation explaining how a user can size the xenheap. How did you figure out for your setup?
Not sure if I fully understand the question. I will explain in two parts: I tested this series on a dom0less (static mem) system on FVP_Base.
(1) For configuring the system, I followed the documentation I added in the first patch in this series (docs/misc/arm/device-tree/booting.txt). The idea is adding some static mem regions under the chosen node.
chosen {
+ #xen,static-mem-address-cells = <0x2>;
+ #xen,static-mem-size-cells = <0x2>;
+ xen,static-mem = <0x8 0x80000000 0x0 0x00100000 0x8 0x90000000 0x0 0x08000000>;
[...]
}(2) For verifying this series, what I did was basically playing with the region size and number of the regions, adding printks and also see if the guests can boot as expected when I change the xenheap size.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Furthemore, now that we are introducing more static region, it will get easier to overlap the regions by mistakes. I think we want to have some logic in Xen (or outside) to ensure that none of them overlaps. Do you have any plan for that?
Quoted 6 lines
Quoted 4 lines
Totally agree with this idea, but before we actually implement the code, we would like to firstly share our thoughts on this: One option could be to add data structures to notes down these static memory regions when the device tree is parsed, and then we can check if they are overlapped.
This should work.
Ack.
Quoted 7 lines
Quoted 4 lines
Over
the long term (and this long term option is currently not in our plan), maybe we can add something in the Xen toolstack for this usage?When I read "Xen toolstack", I read the tools that will run in dom0. Is it what you meant?
Nonono, sorry for the misleading. I mean a build time tool that can run on host (build machine) to generate/configure the Xen DTS for static allocated memory. But maybe this tool can be placed in Xen tool or it can be a separate tool that out of Xen's scope.
Anyway, this is just an idea as we find it is not easy for users to configure so many static items manually.
Quoted 6 lines
Quoted 4 lines
Also, I am wondering if the overlapping check logic should be introduced in this series. WDYT?
I would do that in a separate series.
Ack.
Kind regards,
Henry
Quoted 5 lines
Cheers,
--
Julien Grall
Hi Julien,
Quoted 117 lines
-----Original Message-----
From: Henry Wang <[email protected]>
Sent: 2022年3月1日 10:11
To: Julien Grall <[email protected]>; [email protected]; [email protected]
Cc: Bertrand Marquis <[email protected]>; Wei Chen <[email protected]>; Penny Zheng <[email protected]>
Subject: RE: [RFC PATCH 0/2] Introduce reserved XenheapHi Julien,
Quoted 13 lines
-----Original Message-----
From: Julien Grall <[email protected]>Quoted 1 line · Henry Wang
Hi Julien,
Hi Henry,
Quoted 6 lines
Quoted 6 lines
-----Original Message-----
From: Julien Grall <[email protected]>
Hi Henry,Quoted 1 line · Henry Wang
The reserved Xenheap, or statically configured Xenheap, refers to
parts
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
of RAM reserved in the beginning for Xenheap. Like the static memory allocation, such reserved Xenheap regions are reserved by
configuration
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
in the device tree using physical address ranges.
In Xen, we have the concept of domheap and xenheap. For Arm64 and
x86
Quoted 1 line
Quoted 1 line
they would be the same. But for Arm32, they would be different:
xenheap
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
is always mapped whereas domheap is separate.
Skimming through the series, I think you want to use the region for
both
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
domheap and xenheap. Is that correct?
Yes I think that would be correct, for Arm32, instead of using the
full
Quoted 2 lines
Quoted 2 lines
ram_pagesas the initial value ofheap_pages, we want to use the region specified in the device tree. But we are confused if this isthe
Quoted 15 lines
Quoted 2 lines
correct (or preferred) way for Arm32, so in this series we only implemented the reserved heap for Arm64.
That's an interesting point. When I skimmed through the series on Friday, my first thought was that for arm32 it would be only xenheap (so all the rest of memory is domheap).
However, Xen can allocate memory from domheap for its own purpose (e.g. we don't need contiguous memory, or for page-tables).
In a fully static environment, the domheap and xenheap are both going to be quite small. It would also be somewhat difficult for a user to size it. So I think, it would be easier to use the region you introduce for both domheap and xenheap.
Quoted 4 lines
Stefano, Bertrand, any opionions?
On a separate topic, I think we need some documentation explaining how a user can size the xenheap. How did you figure out for your setup?
Not sure if I fully understand the question. I will explain in two parts:
I tested
this series on a dom0less (static mem) system onFVP_Base.
(1) For configuring the system, I followed the documentation I added in the
first patch in this series (docs/misc/arm/device-tree/booting.txt). The idea is
adding some static mem regions under the chosen node.chosen {(quoted diff) +3
-0+ #xen,static-mem-address-cells = <0x2>; + #xen,static-mem-size-cells = <0x2>; + xen,static-mem = <0x8 0x80000000 0x0 0x00100000 0x8 0x900000000x0 0x08000000>; [...] }(2) For verifying this series, what I did was basically playing with the region size
and number of the regions, adding printks and also see if the guests can boot
as expected when I change the xenheap size.Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Furthemore, now that we are introducing more static region, it will
get
Quoted 1 line
Quoted 1 line
Quoted 1 line
easier to overlap the regions by mistakes. I think we want to have
some
Quoted 1 line
Quoted 1 line
Quoted 1 line
logic in Xen (or outside) to ensure that none of them overlaps. Do
you
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
have any plan for that?
Totally agree with this idea, but before we actually implement the
code,
Quoted 1 line
Quoted 1 line
we would like to firstly share our thoughts on this: One option could
be to
Quoted 4 lines
Quoted 2 lines
add data structures to notes down these static memory regions when the device tree is parsed, and then we can check if they are overlapped.
This should work.
Ack.
Quoted 7 lines
Quoted 4 lines
Over
the long term (and this long term option is currently not in our plan), maybe we can add something in the Xen toolstack for this usage?When I read "Xen toolstack", I read the tools that will run in dom0. Is it what you meant?
Quoted 8 lines
Nonono, sorry for the misleading. I mean a build time tool that can run on host (build machine) to generate/configure the Xen DTS for static allocated memory. But maybe this tool can be placed in Xen tool or it can be a separate tool that out of Xen's scope.
Anyway, this is just an idea as we find it is not easy for users to configure
so many static items manually.
Not only for this one. As v8R64 support code also includes lots of static allocated items, it will also encounter this user configuration issue. So this would be a long term consideration. We can discuss this topic after Xen V8R64 support code upstream work be done.
And this tool does not necessarily need to be provided by the community. Vendors that want to use Xen also can do it. IMO, it would be better if community could provide it. Anyway let's defer this topic : )
Thanks,
Wei Chen
Quoted 20 lines
Quoted 4 lines
Quoted 4 lines
Also, I am wondering if the overlapping check logic should be
introduced
Quoted 3 lines
Quoted 1 line
in this series. WDYT?
I would do that in a separate series.
Ack.
Kind regards,
Henry
Quoted 5 lines
Cheers,
--
Julien Grall
Quoted 117 lines · Wei Chen
Quoted 108 lines
Hi Julien,
Quoted 13 lines
-----Original Message-----
From: Julien Grall <[email protected]>Quoted 1 line · Henry Wang
Hi Julien,
Hi Henry,
Quoted 6 lines
Quoted 6 lines
-----Original Message-----
From: Julien Grall <[email protected]>
Hi Henry,Quoted 1 line · Henry Wang
The reserved Xenheap, or statically configured Xenheap, refers to
parts
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
of RAM reserved in the beginning for Xenheap. Like the static memory allocation, such reserved Xenheap regions are reserved by
configuration
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
in the device tree using physical address ranges.
In Xen, we have the concept of domheap and xenheap. For Arm64 and
x86
Quoted 1 line
Quoted 1 line
they would be the same. But for Arm32, they would be different:
xenheap
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
is always mapped whereas domheap is separate.
Skimming through the series, I think you want to use the region for
both
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
domheap and xenheap. Is that correct?
Yes I think that would be correct, for Arm32, instead of using the
full
Quoted 2 lines
Quoted 2 lines
ram_pagesas the initial value ofheap_pages, we want to use the region specified in the device tree. But we are confused if this isthe
Quoted 15 lines
Quoted 2 lines
correct (or preferred) way for Arm32, so in this series we only implemented the reserved heap for Arm64.
That's an interesting point. When I skimmed through the series on Friday, my first thought was that for arm32 it would be only xenheap (so all the rest of memory is domheap).
However, Xen can allocate memory from domheap for its own purpose (e.g. we don't need contiguous memory, or for page-tables).
In a fully static environment, the domheap and xenheap are both going to be quite small. It would also be somewhat difficult for a user to size it. So I think, it would be easier to use the region you introduce for both domheap and xenheap.
Quoted 4 lines
Stefano, Bertrand, any opionions?
On a separate topic, I think we need some documentation explaining how a user can size the xenheap. How did you figure out for your setup?
Not sure if I fully understand the question. I will explain in two parts:
I tested
this series on a dom0less (static mem) system onFVP_Base.
(1) For configuring the system, I followed the documentation I added in the
first patch in this series (docs/misc/arm/device-tree/booting.txt). The idea is
adding some static mem regions under the chosen node.chosen {(quoted diff) +3
-0+ #xen,static-mem-address-cells = <0x2>; + #xen,static-mem-size-cells = <0x2>; + xen,static-mem = <0x8 0x80000000 0x0 0x00100000 0x8 0x900000000x0 0x08000000>; [...] }(2) For verifying this series, what I did was basically playing with the region size
and number of the regions, adding printks and also see if the guests can boot
as expected when I change the xenheap size.Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Furthemore, now that we are introducing more static region, it will
get
Quoted 1 line
Quoted 1 line
Quoted 1 line
easier to overlap the regions by mistakes. I think we want to have
some
Quoted 1 line
Quoted 1 line
Quoted 1 line
logic in Xen (or outside) to ensure that none of them overlaps. Do
you
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
have any plan for that?
Totally agree with this idea, but before we actually implement the
code,
Quoted 1 line
Quoted 1 line
we would like to firstly share our thoughts on this: One option could
be to
Quoted 4 lines
Quoted 2 lines
add data structures to notes down these static memory regions when the device tree is parsed, and then we can check if they are overlapped.
This should work.
Ack.
Quoted 7 lines
Quoted 4 lines
Over
the long term (and this long term option is currently not in our plan), maybe we can add something in the Xen toolstack for this usage?When I read "Xen toolstack", I read the tools that will run in dom0. Is it what you meant?
Quoted 8 lines
Nonono, sorry for the misleading. I mean a build time tool that can run on host (build machine) to generate/configure the Xen DTS for static allocated memory. But maybe this tool can be placed in Xen tool or it can be a separate tool that out of Xen's scope.
Anyway, this is just an idea as we find it is not easy for users to configure
so many static items manually.
Quoted 8 lines
Not only for this one. As v8R64 support code also includes lots of static allocated items, it will also encounter this user configuration issue. So this would be a long term consideration. We can discuss this topic after Xen V8R64 support code upstream work be done.
And this tool does not necessarily need to be provided by the community. Vendors that want to use Xen also can do it. IMO, it would be better if community could provide it. Anyway let's defer this topic : )
Yes, I agree with you that it would be best if this tool was provided by the community. I'll continue the conversation on the Armv8-R64 thread.
Hi,
Quoted 38 lines · Julien Grall
Quoted 1 line · Henry Wang
Hi Julien,
Hi Henry,
Quoted 21 lines
Quoted 21 lines
-----Original Message-----
From: Julien Grall <[email protected]>
Sent: Saturday, February 26, 2022 4:09 AM
To: Henry Wang <[email protected]>; [email protected]; [email protected]
Cc: Bertrand Marquis <[email protected]>; Wei Chen <[email protected]>; Penny Zheng <[email protected]>
Subject: Re: [RFC PATCH 0/2] Introduce reserved XenheapHi Henry,
Quoted 4 lines · Henry Wang
The reserved Xenheap, or statically configured Xenheap, refers to parts of RAM reserved in the beginning for Xenheap. Like the static memory allocation, such reserved Xenheap regions are reserved by configuration in the device tree using physical address ranges.
In Xen, we have the concept of domheap and xenheap. For Arm64 and x86 they would be the same. But for Arm32, they would be different: xenheap is always mapped whereas domheap is separate.
Quoted 7 lines
Quoted 2 lines
Skimming through the series, I think you want to use the region for both domheap and xenheap. Is that correct?
Yes I think that would be correct, for Arm32, instead of using the full
ram_pagesas the initial value ofheap_pages, we want to use the region specified in the device tree. But we are confused if this is the correct (or preferred) way for Arm32, so in this series we only implemented the reserved heap for Arm64.
Quoted 8 lines
That's an interesting point. When I skimmed through the series on Friday, my first thought was that for arm32 it would be only xenheap (so all the rest of memory is domheap).
However, Xen can allocate memory from domheap for its own purpose (e.g. we don't need contiguous memory, or for page-tables).
In a fully static environment, the domheap and xenheap are both going to be quite small. It would also be somewhat difficult for a user to size it. So I think, it would be easier to use the region you introduce for both domheap and xenheap.
Stefano, Bertrand, any opionions?
Only one region is easier to configure and I think in this case it will also prevent lots of over allocation. So in a full static case, having only one heap is a good strategy for now.
There might be some cases where someone would want to fully control the memory allocated by Xen per domain and in this case be able to size it for each guest (to make sure one guest cannot be impacted by an other at all). But this is definitely something that could be done later, if needed.
Cheers
Bertrand
Quoted 30 lines
On a separate topic, I think we need some documentation explaining how a user can size the xenheap. How did you figure out for your setup?
Quoted 9 lines
Quoted 5 lines
Furthemore, now that we are introducing more static region, it will get easier to overlap the regions by mistakes. I think we want to have some logic in Xen (or outside) to ensure that none of them overlaps. Do you have any plan for that?
Totally agree with this idea, but before we actually implement the code, we would like to firstly share our thoughts on this: One option could be to add data structures to notes down these static memory regions when the device tree is parsed, and then we can check if they are overlapped.
This should work.
Quoted 3 lines
Over
the long term (and this long term option is currently not in our plan), maybe we can add something in the Xen toolstack for this usage?When I read "Xen toolstack", I read the tools that will run in dom0. Is it what you meant?
Quoted 2 lines
Also, I am wondering if the overlapping check logic should be introduced in this series. WDYT?
I would do that in a separate series.
Cheers,
Signature · 1 line
Julien Grall