Skip to contentSkip to conversation

xen/arm: Sanity test specified domain's memory for being a multiple of a page size

PATCH In review Michal Orzel 2 participants 7 messages Oct 7 – Oct 12

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/arm: Sanity test specified domain's memory for being a multiple of a page size

We require memory to allocate for a domain as RAM to be a multiple of a page size. However, we neither document this nor sanity test. Specifying memory size that does not conform to this requirement fails the domain memory allocation in the non-obvious way that is difficult to parse for the user (printing over-allocation messages followed by the panic that Xen could not allocate the requested amount of memory).

While there, fix indentation from tabs to spaces for "memory" parameter in booting.txt.

---
 docs/misc/arm/device-tree/booting.txt   | 4 ++--
 docs/misc/xen-command-line.pandoc       | 5 +++--
 xen/arch/arm/domain_build.c             | 6 ++++++
 xen/common/device-tree/dom0less-build.c | 7 +++++++
 4 files changed, 18 insertions(+), 4 deletions(-)
docs/misc/arm/device-tree/booting.txt +2 -2
index bcb06bc796bf..7dfac2062a37 100644
@@ -155,8 +155,8 @@ with the following properties:
 
 - memory
 
-	A 64-bit integer specifying the amount of kilobytes of RAM to
-    allocate to the guest.
+    A 64-bit integer specifying the amount of kilobytes of RAM to
+    allocate to the guest. Must be a multiple of 4KB (the page size).
 
 - cpus
 
docs/misc/xen-command-line.pandoc +3 -2
index ea0e3368b1d6..d49db353d8a8 100644
@@ -1020,8 +1020,9 @@ and architecture-specific domain limits.
 > `= <size>`
 
 Set the amount of memory for the initial domain (dom0). It must be
-greater than zero. This parameter is required (and only used) when the initial
-domain is not described in the Device-Tree.
+greater than zero and a multiple of the page size (4KB). This parameter is
+required (and only used) when the initial domain is not described in the
+Device-Tree.
 
 ### dom0_mem (x86)
 > `= List of ( min:<sz> | max:<sz> | <sz> )`
xen/arch/arm/domain_build.c +6 -0
index 72d531618045..bc3d1ebad1c4 100644
@@ -1881,6 +1881,12 @@ static int __init construct_dom0(struct domain *d)
         warning_add("PLEASE SPECIFY dom0_mem PARAMETER - USING 512M FOR NOW\n");
         dom0_mem = MB(512);
     }
+    else if ( dom0_mem % PAGE_SIZE )
+    {
+        printk("%pd: specified dom0_mem (%"PRIu64"B) is not a multiple of a page size\n",
+               d, dom0_mem);
+        return -EINVAL;
+    }
 
     d->max_pages = dom0_mem >> PAGE_SHIFT;
 
xen/common/device-tree/dom0less-build.c +7 -0
index fcbeb8adbd73..b3f24e5d555f 100644
@@ -789,6 +789,13 @@ static int __init construct_domU(struct kernel_info *kinfo,
     }
     kinfo->unassigned_mem = (paddr_t)mem * SZ_1K;
 
+    if ( kinfo->unassigned_mem % PAGE_SIZE )
+    {
+        printk("%pd: specified \"memory\" (%"PRIu64"KB) is not a multiple of a page size\n",
+               d, mem);
+        return -EINVAL;
+    }
+
     rc = domain_p2m_set_allocation(d, mem, node);
     if ( rc != 0 )
         return rc;
Signature · 1 line
2.43.0
#1 lore raw
Quoted 23 lines · Michal Orzel

We require memory to allocate for a domain as RAM to be a multiple of a page size. However, we neither document this nor sanity test. Specifying memory size that does not conform to this requirement fails the domain memory allocation in the non-obvious way that is difficult to parse for the user (printing over-allocation messages followed by the panic that Xen could not allocate the requested amount of memory).

While there, fix indentation from tabs to spaces for "memory" parameter in booting.txt.

---
 docs/misc/arm/device-tree/booting.txt   | 4 ++--
 docs/misc/xen-command-line.pandoc       | 5 +++--
 xen/arch/arm/domain_build.c             | 6 ++++++
 xen/common/device-tree/dom0less-build.c | 7 +++++++
 4 files changed, 18 insertions(+), 4 deletions(-)
docs/misc/arm/device-tree/booting.txt +0 -0
index bcb06bc796bf..7dfac2062a37 100644

docs/misc/arm/device-tree/booting.txt with the following properties: · line 159

Quoted 7 lines
docs/misc/arm/device-tree/booting.txt +2 -2
@@ -155,8 +155,8 @@ with the following properties:
 
 - memory
 
-	A 64-bit integer specifying the amount of kilobytes of RAM to
-    allocate to the guest.
+    A 64-bit integer specifying the amount of kilobytes of RAM to
+    allocate to the guest. Must be a multiple of 4KB (the page size).

nit: s/KB/KiB

But page size isn't always 4KiB on all ports. PowerPC has 64KiB pages. IMO, 4KB shouldn't be here or elsewhere in documentation.

Quoted 8 lines
docs/misc/arm/device-tree/booting.txt +0 -0
 - cpus
 
docs/misc/xen-command-line.pandoc +0 -0
index ea0e3368b1d6..d49db353d8a8 100644

docs/misc/xen-command-line.pandoc and architecture-specific domain limits. · line 1025

Quoted 8 lines
docs/misc/xen-command-line.pandoc +3 -2
@@ -1020,8 +1020,9 @@ and architecture-specific domain limits.
 > `= <size>`
 
 Set the amount of memory for the initial domain (dom0). It must be
-greater than zero. This parameter is required (and only used) when the initial
-domain is not described in the Device-Tree.
+greater than zero and a multiple of the page size (4KB). This parameter is
+required (and only used) when the initial domain is not described in the
+Device-Tree.

Same 4KB remark.

Quoted 8 lines
docs/misc/xen-command-line.pandoc +0 -0
 ### dom0_mem (x86)
 > `= List of ( min:<sz> | max:<sz> | <sz> )`
xen/arch/arm/domain_build.c +0 -0
index 72d531618045..bc3d1ebad1c4 100644

xen/arch/arm/domain_build.c static int __init construct_dom0(struct domain *d) · line 1889

Quoted 9 lines
xen/arch/arm/domain_build.c +6 -0
@@ -1881,6 +1881,12 @@ static int __init construct_dom0(struct domain *d)
         warning_add("PLEASE SPECIFY dom0_mem PARAMETER - USING 512M FOR NOW\n");
         dom0_mem = MB(512);
     }
+    else if ( dom0_mem % PAGE_SIZE )
+    {
+        printk("%pd: specified dom0_mem (%"PRIu64"B) is not a multiple of a page size\n",
+               d, dom0_mem);
+        return -EINVAL;
+    }

nit: XENLOG_WARNING?

Also, is this is meant to be self-healing? If so the return should just be:

    dom0_mem = round_pgdown(dom0_mem);

and continue. And if it isn't meant to be self-healing, why not just panic()?

Quoted 8 lines
xen/arch/arm/domain_build.c +0 -0
     d->max_pages = dom0_mem >> PAGE_SHIFT;
 
xen/common/device-tree/dom0less-build.c +0 -0
index fcbeb8adbd73..b3f24e5d555f 100644

xen/common/device-tree/dom0less-build.c static int __init construct_domU(struct kernel_info *kinfo, · line 794

Quoted 6 lines
xen/common/device-tree/dom0less-build.c +3 -0
@@ -789,6 +789,13 @@ static int __init construct_domU(struct kernel_info *kinfo,
     }
     kinfo->unassigned_mem = (paddr_t)mem * SZ_1K;
 
+    if ( kinfo->unassigned_mem % PAGE_SIZE )
+    {
+        printk("%pd: specified \"memory\" (%"PRIu64"KB) is not a multiple of a page size\n",

Seeing how PowerPC has 64KiB it might be prudent to print PAGE_SIZE to avoid surprises later.

Same remark about panic() vs self-healing (either is fine. It's this middle ground that looks off).

xen/common/device-tree/dom0less-build.c static int __init construct_domU(struct kernel_info *kinfo, · line 801

Quoted 7 lines
xen/common/device-tree/dom0less-build.c +4 -0
+               d, mem);
+        return -EINVAL;
+    }
+
     rc = domain_p2m_set_allocation(d, mem, node);
     if ( rc != 0 )
         return rc;

Cheers,
Alejandro

#2 lore raw
Quoted 25 lines · Alejandro Vallejo
Quoted 24 lines · Michal Orzel

We require memory to allocate for a domain as RAM to be a multiple of a page size. However, we neither document this nor sanity test. Specifying memory size that does not conform to this requirement fails the domain memory allocation in the non-obvious way that is difficult to parse for the user (printing over-allocation messages followed by the panic that Xen could not allocate the requested amount of memory).

While there, fix indentation from tabs to spaces for "memory" parameter in booting.txt.

---
 docs/misc/arm/device-tree/booting.txt   | 4 ++--
 docs/misc/xen-command-line.pandoc       | 5 +++--
 xen/arch/arm/domain_build.c             | 6 ++++++
 xen/common/device-tree/dom0less-build.c | 7 +++++++
 4 files changed, 18 insertions(+), 4 deletions(-)
docs/misc/arm/device-tree/booting.txt +0 -0
index bcb06bc796bf..7dfac2062a37 100644
@@ -155,8 +155,8 @@ with the following properties:
 
Quoted 8 lines

docs/misc/arm/device-tree/booting.txt with the following properties: · line 159

Quoted 6 lines
docs/misc/arm/device-tree/booting.txt +2 -2
 - memory
 
-	A 64-bit integer specifying the amount of kilobytes of RAM to
-    allocate to the guest.
+    A 64-bit integer specifying the amount of kilobytes of RAM to
+    allocate to the guest. Must be a multiple of 4KB (the page size).

nit: s/KB/KiB

Is it? I don't think it matters at all seeing the number of occurrences in the code.

Quoted 3 lines

But page size isn't always 4KiB on all ports. PowerPC has 64KiB pages. IMO, 4KB shouldn't be here or elsewhere in documentation.

This is Arm doc and on Arm we only support 4KB at the moment. User should not need to dig into the code to check what is the page size. It's better imo to give this information right away and change in the future when we add support for 16 and 64KB pages on Arm.

Quoted 11 lines
Quoted 11 lines
docs/misc/arm/device-tree/booting.txt +0 -0
 - cpus
 
docs/misc/xen-command-line.pandoc +0 -0
index ea0e3368b1d6..d49db353d8a8 100644
@@ -1020,8 +1020,9 @@ and architecture-specific domain limits.
 > `= <size>`
 
Quoted 8 lines

docs/misc/xen-command-line.pandoc and architecture-specific domain limits. · line 1025

Quoted 6 lines
docs/misc/xen-command-line.pandoc +3 -2
 Set the amount of memory for the initial domain (dom0). It must be
-greater than zero. This parameter is required (and only used) when the initial
-domain is not described in the Device-Tree.
+greater than zero and a multiple of the page size (4KB). This parameter is
+required (and only used) when the initial domain is not described in the
+Device-Tree.

Same 4KB remark.

Still Arm only section and see my reasoning above.

Quoted 12 lines
Quoted 12 lines
docs/misc/xen-command-line.pandoc +0 -0
 ### dom0_mem (x86)
 > `= List of ( min:<sz> | max:<sz> | <sz> )`
xen/arch/arm/domain_build.c +0 -0
index 72d531618045..bc3d1ebad1c4 100644
@@ -1881,6 +1881,12 @@ static int __init construct_dom0(struct domain *d)
         warning_add("PLEASE SPECIFY dom0_mem PARAMETER - USING 512M FOR NOW\n");
         dom0_mem = MB(512);
     }
Quoted 8 lines

xen/arch/arm/domain_build.c static int __init construct_dom0(struct domain *d) · line 1889

Quoted 6 lines
xen/arch/arm/domain_build.c +6 -0
+    else if ( dom0_mem % PAGE_SIZE )
+    {
+        printk("%pd: specified dom0_mem (%"PRIu64"B) is not a multiple of a page size\n",
+               d, dom0_mem);
+        return -EINVAL;
+    }

nit: XENLOG_WARNING?

I can use XENLOG_ERR.

Quoted 6 lines

Also, is this is meant to be self-healing? If so the return should just be:

    dom0_mem = round_pgdown(dom0_mem);

and continue. And if it isn't meant to be self-healing, why not just panic()?

1. It should not be self-healing. On Arm and in DT subsystem in general we chose to follow the contract to bail out on unsatisfied user requests rather than silently adjusting them.
2. I think it's always better to propagate the error to the caller if possible. Sometimes you don't know where this function end up being used in the future. In general if the function returns non-void I tend to leave the decision (here panic will be executed anyway) to the caller. Printk explains why and the panic follow. This also matches the existing paths nearby this code.

Quoted 12 lines
Quoted 12 lines
xen/arch/arm/domain_build.c +0 -0
     d->max_pages = dom0_mem >> PAGE_SHIFT;
 
xen/common/device-tree/dom0less-build.c +0 -0
index fcbeb8adbd73..b3f24e5d555f 100644
@@ -789,6 +789,13 @@ static int __init construct_domU(struct kernel_info *kinfo,
     }
     kinfo->unassigned_mem = (paddr_t)mem * SZ_1K;
 
Quoted 6 lines

xen/common/device-tree/dom0less-build.c static int __init construct_domU(struct kernel_info *kinfo, · line 794

Quoted 3 lines
xen/common/device-tree/dom0less-build.c +3 -0
+    if ( kinfo->unassigned_mem % PAGE_SIZE )
+    {
+        printk("%pd: specified \"memory\" (%"PRIu64"KB) is not a multiple of a page size\n",

Seeing how PowerPC has 64KiB it might be prudent to print PAGE_SIZE to avoid surprises later.

Yes, I can print page size here.

Quoted 12 lines

Same remark about panic() vs self-healing (either is fine. It's this middle ground that looks off).

xen/common/device-tree/dom0less-build.c static int __init construct_domU(struct kernel_info *kinfo, · line 801

Quoted 7 lines
xen/common/device-tree/dom0less-build.c +4 -0
+               d, mem);
+        return -EINVAL;
+    }
+
     rc = domain_p2m_set_allocation(d, mem, node);
     if ( rc != 0 )
         return rc;
Quoted 2 lines

Cheers,
Alejandro

~Michal

#3 lore raw
Quoted 39 lines · Michal
Quoted 25 lines · Alejandro Vallejo
Quoted 24 lines · Michal Orzel

We require memory to allocate for a domain as RAM to be a multiple of a page size. However, we neither document this nor sanity test. Specifying memory size that does not conform to this requirement fails the domain memory allocation in the non-obvious way that is difficult to parse for the user (printing over-allocation messages followed by the panic that Xen could not allocate the requested amount of memory).

While there, fix indentation from tabs to spaces for "memory" parameter in booting.txt.

---
 docs/misc/arm/device-tree/booting.txt   | 4 ++--
 docs/misc/xen-command-line.pandoc       | 5 +++--
 xen/arch/arm/domain_build.c             | 6 ++++++
 xen/common/device-tree/dom0less-build.c | 7 +++++++
 4 files changed, 18 insertions(+), 4 deletions(-)
docs/misc/arm/device-tree/booting.txt +0 -0
index bcb06bc796bf..7dfac2062a37 100644
@@ -155,8 +155,8 @@ with the following properties:
 
Quoted 8 lines

docs/misc/arm/device-tree/booting.txt with the following properties: · line 159

Quoted 6 lines
docs/misc/arm/device-tree/booting.txt +2 -2
 - memory
 
-	A 64-bit integer specifying the amount of kilobytes of RAM to
-    allocate to the guest.
+    A 64-bit integer specifying the amount of kilobytes of RAM to
+    allocate to the guest. Must be a multiple of 4KB (the page size).

nit: s/KB/KiB

Is it? I don't think it matters at all seeing the number of occurrences in the code.

Quoted 1 line
Quoted 6 lines
Quoted 2 lines

But page size isn't always 4KiB on all ports. PowerPC has 64KiB pages. IMO, 4KB shouldn't be here or elsewhere in documentation.

This is Arm doc and on Arm we only support 4KB at the moment. User should not need to dig into the code to check what is the page size. It's better imo to give this information right away and change in the future when we add support for 16 and 64KB pages on Arm.

This is already the only reference the other ports have for dom0less. The document shouldn't be here since the movement of dom0less to common code, but the side effect of it is that this no longer an arm-only reference.

I won't be annoying about moving the doc on this patch because that's a separate matter, but not adding more easily avoidable debt seems warranted.

Quoted 50 lines
Quoted 12 lines
Quoted 12 lines
docs/misc/arm/device-tree/booting.txt +0 -0
 - cpus
 
docs/misc/xen-command-line.pandoc +0 -0
index ea0e3368b1d6..d49db353d8a8 100644
@@ -1020,8 +1020,9 @@ and architecture-specific domain limits.
 > `= <size>`
 
Quoted 8 lines

docs/misc/xen-command-line.pandoc and architecture-specific domain limits. · line 1025

Quoted 6 lines
docs/misc/xen-command-line.pandoc +3 -2
 Set the amount of memory for the initial domain (dom0). It must be
-greater than zero. This parameter is required (and only used) when the initial
-domain is not described in the Device-Tree.
+greater than zero and a multiple of the page size (4KB). This parameter is
+required (and only used) when the initial domain is not described in the
+Device-Tree.

Same 4KB remark.

Still Arm only section and see my reasoning above.

Quoted 12 lines
Quoted 12 lines
docs/misc/xen-command-line.pandoc +0 -0
 ### dom0_mem (x86)
 > `= List of ( min:<sz> | max:<sz> | <sz> )`
xen/arch/arm/domain_build.c +0 -0
index 72d531618045..bc3d1ebad1c4 100644
@@ -1881,6 +1881,12 @@ static int __init construct_dom0(struct domain *d)
         warning_add("PLEASE SPECIFY dom0_mem PARAMETER - USING 512M FOR NOW\n");
         dom0_mem = MB(512);
     }
Quoted 8 lines

xen/arch/arm/domain_build.c static int __init construct_dom0(struct domain *d) · line 1889

Quoted 6 lines
xen/arch/arm/domain_build.c +6 -0
+    else if ( dom0_mem % PAGE_SIZE )
+    {
+        printk("%pd: specified dom0_mem (%"PRIu64"B) is not a multiple of a page size\n",
+               d, dom0_mem);
+        return -EINVAL;
+    }

nit: XENLOG_WARNING?

I can use XENLOG_ERR.

Quoted 6 lines

Also, is this is meant to be self-healing? If so the return should just be:

    dom0_mem = round_pgdown(dom0_mem);

and continue. And if it isn't meant to be self-healing, why not just panic()?

Quoted 8 lines

1. It should not be self-healing. On Arm and in DT subsystem in general we chose to follow the contract to bail out on unsatisfied user requests rather than silently adjusting them.
2. I think it's always better to propagate the error to the caller if possible. Sometimes you don't know where this function end up being used in the future. In general if the function returns non-void I tend to leave the decision (here panic will be executed anyway) to the caller. Printk explains why and the panic follow. This also matches the existing paths nearby this code.

Fair enough.

Quoted 37 lines
Quoted 13 lines
Quoted 13 lines
xen/arch/arm/domain_build.c +0 -0
     d->max_pages = dom0_mem >> PAGE_SHIFT;
 
xen/common/device-tree/dom0less-build.c +0 -0
index fcbeb8adbd73..b3f24e5d555f 100644
@@ -789,6 +789,13 @@ static int __init construct_domU(struct kernel_info *kinfo,
     }
     kinfo->unassigned_mem = (paddr_t)mem * SZ_1K;
 
Quoted 6 lines

xen/common/device-tree/dom0less-build.c static int __init construct_domU(struct kernel_info *kinfo, · line 794

Quoted 3 lines
xen/common/device-tree/dom0less-build.c +3 -0
+    if ( kinfo->unassigned_mem % PAGE_SIZE )
+    {
+        printk("%pd: specified \"memory\" (%"PRIu64"KB) is not a multiple of a page size\n",

Seeing how PowerPC has 64KiB it might be prudent to print PAGE_SIZE to avoid surprises later.

Yes, I can print page size here.

Quoted 12 lines

Same remark about panic() vs self-healing (either is fine. It's this middle ground that looks off).

xen/common/device-tree/dom0less-build.c static int __init construct_domU(struct kernel_info *kinfo, · line 801

Quoted 7 lines
xen/common/device-tree/dom0less-build.c +4 -0
+               d, mem);
+        return -EINVAL;
+    }
+
     rc = domain_p2m_set_allocation(d, mem, node);
     if ( rc != 0 )
         return rc;
Quoted 2 lines

Cheers,
Alejandro

~Michal

#4 lore raw
Quoted 47 lines · Alejandro Vallejo
Quoted 39 lines · Michal
Quoted 25 lines · Alejandro Vallejo
Quoted 24 lines · Michal Orzel

We require memory to allocate for a domain as RAM to be a multiple of a page size. However, we neither document this nor sanity test. Specifying memory size that does not conform to this requirement fails the domain memory allocation in the non-obvious way that is difficult to parse for the user (printing over-allocation messages followed by the panic that Xen could not allocate the requested amount of memory).

While there, fix indentation from tabs to spaces for "memory" parameter in booting.txt.

---
 docs/misc/arm/device-tree/booting.txt   | 4 ++--
 docs/misc/xen-command-line.pandoc       | 5 +++--
 xen/arch/arm/domain_build.c             | 6 ++++++
 xen/common/device-tree/dom0less-build.c | 7 +++++++
 4 files changed, 18 insertions(+), 4 deletions(-)
docs/misc/arm/device-tree/booting.txt +0 -0
index bcb06bc796bf..7dfac2062a37 100644
@@ -155,8 +155,8 @@ with the following properties:
 
Quoted 8 lines

docs/misc/arm/device-tree/booting.txt with the following properties: · line 159

Quoted 6 lines
docs/misc/arm/device-tree/booting.txt +2 -2
 - memory
 
-	A 64-bit integer specifying the amount of kilobytes of RAM to
-    allocate to the guest.
+    A 64-bit integer specifying the amount of kilobytes of RAM to
+    allocate to the guest. Must be a multiple of 4KB (the page size).

nit: s/KB/KiB

Is it? I don't think it matters at all seeing the number of occurrences in the code.

Quoted 1 line
Quoted 6 lines
Quoted 2 lines

But page size isn't always 4KiB on all ports. PowerPC has 64KiB pages. IMO, 4KB shouldn't be here or elsewhere in documentation.

This is Arm doc and on Arm we only support 4KB at the moment. User should not need to dig into the code to check what is the page size. It's better imo to give this information right away and change in the future when we add support for 16 and 64KB pages on Arm.

Quoted 7 lines

This is already the only reference the other ports have for dom0less. The document shouldn't be here since the movement of dom0less to common code, but the side effect of it is that this no longer an arm-only reference.

I won't be annoying about moving the doc on this patch because that's a separate matter, but not adding more easily avoidable debt seems warranted.

I don't quite understand your reasoning. If you worry about dom0less != Arm, then on that basis HAS_DOM0LESS is selected only for Arm and RISCV where PAGE_SIZE is 4KB. I don't think I'm introducing any doubt here. I can remove the 4KB mentioning from the docs if you really insist but at least for me it's clearer for the user to know right away what's the requirement for the size.

~Michal

Reviewed-by
#5 lore raw
Quoted 54 lines · Michal
Quoted 51 lines · Alejandro Vallejo
Quoted 39 lines · Michal
Quoted 25 lines · Alejandro Vallejo
Quoted 24 lines · Michal Orzel

We require memory to allocate for a domain as RAM to be a multiple of a page size. However, we neither document this nor sanity test. Specifying memory size that does not conform to this requirement fails the domain memory allocation in the non-obvious way that is difficult to parse for the user (printing over-allocation messages followed by the panic that Xen could not allocate the requested amount of memory).

While there, fix indentation from tabs to spaces for "memory" parameter in booting.txt.

---
 docs/misc/arm/device-tree/booting.txt   | 4 ++--
 docs/misc/xen-command-line.pandoc       | 5 +++--
 xen/arch/arm/domain_build.c             | 6 ++++++
 xen/common/device-tree/dom0less-build.c | 7 +++++++
 4 files changed, 18 insertions(+), 4 deletions(-)
docs/misc/arm/device-tree/booting.txt +0 -0
index bcb06bc796bf..7dfac2062a37 100644
@@ -155,8 +155,8 @@ with the following properties:
 
Quoted 8 lines

docs/misc/arm/device-tree/booting.txt with the following properties: · line 159

Quoted 6 lines
docs/misc/arm/device-tree/booting.txt +2 -2
 - memory
 
-	A 64-bit integer specifying the amount of kilobytes of RAM to
-    allocate to the guest.
+    A 64-bit integer specifying the amount of kilobytes of RAM to
+    allocate to the guest. Must be a multiple of 4KB (the page size).

nit: s/KB/KiB

Is it? I don't think it matters at all seeing the number of occurrences in the code.

Quoted 1 line
Quoted 6 lines
Quoted 2 lines

But page size isn't always 4KiB on all ports. PowerPC has 64KiB pages. IMO, 4KB shouldn't be here or elsewhere in documentation.

This is Arm doc and on Arm we only support 4KB at the moment. User should not need to dig into the code to check what is the page size. It's better imo to give this information right away and change in the future when we add support for 16 and 64KB pages on Arm.

This is already the only reference the other ports have for dom0less. The document shouldn't be here since the movement of dom0less to common code, but the side effect of it is that this no longer an arm-only reference.

Quoted 8 lines
Quoted 3 lines

I won't be annoying about moving the doc on this patch because that's a separate matter, but not adding more easily avoidable debt seems warranted.

I don't quite understand your reasoning. If you worry about dom0less != Arm, then on that basis HAS_DOM0LESS is selected only for Arm and RISCV where PAGE_SIZE is 4KB. I don't think I'm introducing any doubt here. I can remove the 4KB mentioning from the docs if you really insist but at least for me it's clearer for the user to know right away what's the requirement for the size.

It's a small adjustment to make the documentation truly generic. And prevents the pgsz == 4KiB assumption from spreading further. Many docs are spawned from copying other docs.

If you're so strongly against, that's fine; it's not incorrect today. I still think the 4K should be gone, but if don't want to block the patch on such silly things.

Cheers,
Alejandro

Quoted 2 lines

~Michal

#6 lore raw
Quoted 64 lines · Alejandro Vallejo
Quoted 54 lines · Michal
Quoted 51 lines · Alejandro Vallejo
Quoted 39 lines · Michal
Quoted 25 lines · Alejandro Vallejo
Quoted 24 lines · Michal Orzel

We require memory to allocate for a domain as RAM to be a multiple of a page size. However, we neither document this nor sanity test. Specifying memory size that does not conform to this requirement fails the domain memory allocation in the non-obvious way that is difficult to parse for the user (printing over-allocation messages followed by the panic that Xen could not allocate the requested amount of memory).

While there, fix indentation from tabs to spaces for "memory" parameter in booting.txt.

---
 docs/misc/arm/device-tree/booting.txt   | 4 ++--
 docs/misc/xen-command-line.pandoc       | 5 +++--
 xen/arch/arm/domain_build.c             | 6 ++++++
 xen/common/device-tree/dom0less-build.c | 7 +++++++
 4 files changed, 18 insertions(+), 4 deletions(-)
docs/misc/arm/device-tree/booting.txt +0 -0
index bcb06bc796bf..7dfac2062a37 100644
@@ -155,8 +155,8 @@ with the following properties:
 
Quoted 8 lines

docs/misc/arm/device-tree/booting.txt with the following properties: · line 159

Quoted 6 lines
docs/misc/arm/device-tree/booting.txt +2 -2
 - memory
 
-	A 64-bit integer specifying the amount of kilobytes of RAM to
-    allocate to the guest.
+    A 64-bit integer specifying the amount of kilobytes of RAM to
+    allocate to the guest. Must be a multiple of 4KB (the page size).

nit: s/KB/KiB

Is it? I don't think it matters at all seeing the number of occurrences in the code.

Quoted 1 line
Quoted 6 lines
Quoted 2 lines

But page size isn't always 4KiB on all ports. PowerPC has 64KiB pages. IMO, 4KB shouldn't be here or elsewhere in documentation.

This is Arm doc and on Arm we only support 4KB at the moment. User should not need to dig into the code to check what is the page size. It's better imo to give this information right away and change in the future when we add support for 16 and 64KB pages on Arm.

This is already the only reference the other ports have for dom0less. The document shouldn't be here since the movement of dom0less to common code, but the side effect of it is that this no longer an arm-only reference.

Quoted 8 lines
Quoted 3 lines

I won't be annoying about moving the doc on this patch because that's a separate matter, but not adding more easily avoidable debt seems warranted.

I don't quite understand your reasoning. If you worry about dom0less != Arm, then on that basis HAS_DOM0LESS is selected only for Arm and RISCV where PAGE_SIZE is 4KB. I don't think I'm introducing any doubt here. I can remove the 4KB mentioning from the docs if you really insist but at least for me it's clearer for the user to know right away what's the requirement for the size.

Quoted 7 lines

It's a small adjustment to make the documentation truly generic. And prevents the pgsz == 4KiB assumption from spreading further. Many docs are spawned from copying other docs.

If you're so strongly against, that's fine; it's not incorrect today. I still think the 4K should be gone, but if don't want to block the patch on such silly things.

Fine, I'll remove 4KB mentioning from the docs.

Quoted 2 lines

Thanks. I'll handle the changes on commit.

~Michal