From: dmkhn@proton.me
To: Alejandro Vallejo <agarciav@amd.com>
Cc: xen-devel@lists.xenproject.org,
"Daniel P. Smith" <dpsmith@apertussolutions.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Anthony PERARD" <anthony.perard@vates.tech>,
"Michal Orzel" <michal.orzel@amd.com>,
"Julien Grall" <julien@xen.org>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Bertrand Marquis" <bertrand.marquis@arm.com>,
"Jason Andryuk" <jason.andryuk@amd.com>
Subject: Re: [PATCH v4 11/13] x86/hyperlaunch: add memory parsing to domain config
Date: Fri, 18 Apr 2025 23:21:10 +0000 [thread overview]
Message-ID: <aALeY6bt7lDCwXii@kraken> (raw)
In-Reply-To: <20250417124844.11143-12-agarciav@amd.com>
On Thu, Apr 17, 2025 at 01:48:33PM +0100, Alejandro Vallejo wrote:
> From: "Daniel P. Smith" <dpsmith@apertussolutions.com>
>
> Add three properties, memory, mem-min, and mem-max, to the domain node device
> tree parsing to define the memory allocation for a domain. All three fields are
> expressed in kb and written as a u64 in the device tree entries.
>
> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
> Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
> Signed-off-by: Alejandro Vallejo <agarciav@amd.com>
> ---
> Can't use KB() rather tha SZ_1K, as that's strictly for literals.
Oh, that's right! Thanks!
>
> v4:
> * Don't override fdt_prop_as_u64() rc on error.
> * Add separate printk statements for each memory prop error.
> * Fix bug setting up dom0_size, dom0_min_size and dom0_max_size
> * Was overriding dom0_size on all 3 paths.
> * Pre-initialise max_pages of all boot_domains to be LONG_MAX, just as
> dom0_max_size.
> * Eventually dom0_max_size drops out in the bigger series, so we
> need that logic to be correct.
> ---
> xen/arch/x86/dom0_build.c | 8 ++++++
> xen/arch/x86/include/asm/boot-domain.h | 4 +++
> xen/arch/x86/setup.c | 5 +++-
> xen/common/domain-builder/fdt.c | 36 ++++++++++++++++++++++++++
> xen/include/xen/libfdt/libfdt-xen.h | 10 +++++++
> 5 files changed, 62 insertions(+), 1 deletion(-)
>
> diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c
> index 0b467fd4a4..8db24dbc0a 100644
> --- a/xen/arch/x86/dom0_build.c
> +++ b/xen/arch/x86/dom0_build.c
> @@ -627,6 +627,14 @@ int __init construct_dom0(const struct boot_domain *bd)
>
> process_pending_softirqs();
>
> + /* If param dom0_size was not set and HL config provided memory size */
> + if ( !get_memsize(&dom0_size, ULONG_MAX) && bd->mem_pages )
> + dom0_size.nr_pages = bd->mem_pages;
> + if ( !get_memsize(&dom0_min_size, ULONG_MAX) && bd->min_pages )
> + dom0_min_size.nr_pages = bd->min_pages;
> + if ( !get_memsize(&dom0_max_size, ULONG_MAX) && bd->max_pages )
> + dom0_max_size.nr_pages = bd->max_pages;
> +
> if ( is_hvm_domain(d) )
> rc = dom0_construct_pvh(bd);
> else if ( is_pv_domain(d) )
> diff --git a/xen/arch/x86/include/asm/boot-domain.h b/xen/arch/x86/include/asm/boot-domain.h
> index e316d4bcde..fa8ea1cc66 100644
> --- a/xen/arch/x86/include/asm/boot-domain.h
> +++ b/xen/arch/x86/include/asm/boot-domain.h
> @@ -18,6 +18,10 @@ struct boot_domain {
> #define BUILD_MODE_ENABLE_DM (1 << 1) /* HVM | PVH */
> uint32_t mode;
>
> + unsigned long mem_pages;
> + unsigned long min_pages;
> + unsigned long max_pages;
> +
> struct boot_module *kernel;
> struct boot_module *module;
> const char *cmdline;
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index 05e3d2cf2a..455dad454c 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -296,7 +296,10 @@ static const char *cmdline_cook(const char *p, const char *loader_name);
> struct boot_info __initdata xen_boot_info = {
> .loader = "unknown",
> .cmdline = "",
> - .domains = { [0 ... MAX_NR_BOOTDOMS - 1] = { .domid = DOMID_INVALID } },
> + .domains = { [0 ... MAX_NR_BOOTDOMS - 1] = {
> + .domid = DOMID_INVALID,
> + .max_pages = ULONG_MAX,
> + }},
> };
>
> static struct boot_info *__init multiboot_fill_boot_info(
> diff --git a/xen/common/domain-builder/fdt.c b/xen/common/domain-builder/fdt.c
> index 6809c7f917..90218d120a 100644
> --- a/xen/common/domain-builder/fdt.c
> +++ b/xen/common/domain-builder/fdt.c
> @@ -7,6 +7,7 @@
> #include <xen/init.h>
> #include <xen/lib.h>
> #include <xen/libfdt/libfdt.h>
> +#include <xen/sizes.h>
>
> #include <asm/bootinfo.h>
> #include <asm/page.h>
> @@ -246,6 +247,41 @@ static int __init process_domain_node(
> (bd->mode & BUILD_MODE_ENABLE_DM) ? "hvm" :
> "pvh");
> }
> + else if ( strncmp(prop_name, "memory", name_len) == 0 )
Use !strncmp(...) like in the below code?
> + {
> + uint64_t kb;
> + if ( (rc = fdt_prop_as_u64(prop, &kb)) )
> + {
> + printk(XENLOG_ERR " bad \"memory\" prop on domain %s\n", name);
> + return rc;
> + }
> + bd->mem_pages = PFN_DOWN(kb * SZ_1K);
> + printk(XENLOG_ERR " memory: %lu KiB\n", kb);
> + }
> + else if ( !strncmp(prop_name, "mem-min", name_len) )
> + {
> + uint64_t kb;
> + if ( (rc = fdt_prop_as_u64(prop, &kb)) )
> + {
> + printk(XENLOG_ERR
> + " bad \"mem-min\" prop on domain %s\n", name);
> + return rc;
> + }
> + bd->min_pages = PFN_DOWN(kb * SZ_1K);
> + printk(XENLOG_INFO " min memory: %lu kb\n", kb);
> + }
> + else if ( !strncmp(prop_name, "mem-max", name_len) )
> + {
> + uint64_t kb;
> + if ( (rc = fdt_prop_as_u64(prop, &kb)) )
> + {
> + printk(XENLOG_ERR
> + " bad \"mem-max\" prop on domain %s\n", name);
> + return rc;
> + }
> + bd->max_pages = PFN_DOWN(kb * SZ_1K);
> + printk(XENLOG_INFO " max memory: %lu KiB\n", kb);
> + }
> }
>
> fdt_for_each_subnode(node, fdt, dom_node)
> diff --git a/xen/include/xen/libfdt/libfdt-xen.h b/xen/include/xen/libfdt/libfdt-xen.h
> index afc76e7750..3054b48a83 100644
> --- a/xen/include/xen/libfdt/libfdt-xen.h
> +++ b/xen/include/xen/libfdt/libfdt-xen.h
> @@ -24,6 +24,16 @@ static inline int __init fdt_prop_as_u32(
> return 0;
> }
>
> +static inline int __init fdt_prop_as_u64(
> + const struct fdt_property *prop, uint64_t *val)
> +{
> + if ( !prop || fdt32_to_cpu(prop->len) < sizeof(uint64_t) )
> + return -EINVAL;
> +
> + *val = fdt64_to_cpu(*(const fdt64_t *)prop->data);
> + return 0;
> +}
Perhaps move the call to common/domain-builder/fdt.c?
> +
> static inline bool __init fdt_get_prop_offset(
> const void *fdt, int node, const char *pname, unsigned long *poffset)
> {
> --
> 2.43.0
>
>
next prev parent reply other threads:[~2025-04-18 23:21 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-17 12:48 [PATCH v4 00/13] Hyperlaunch device tree for dom0 Alejandro Vallejo
2025-04-17 12:48 ` [PATCH v4 01/13] x86/boot: add cmdline to struct boot_domain Alejandro Vallejo
2025-04-17 14:54 ` Jan Beulich
2025-04-17 16:06 ` Alejandro Vallejo
2025-04-18 21:16 ` dmkhn
2025-04-23 11:40 ` Alejandro Vallejo
2025-04-17 12:48 ` [PATCH v4 02/13] kconfig: introduce domain builder config options Alejandro Vallejo
2025-04-17 15:00 ` Jan Beulich
2025-04-17 15:39 ` Jason Andryuk
2025-04-17 16:18 ` Alejandro Vallejo
2025-04-22 6:57 ` Jan Beulich
2025-04-17 12:48 ` [PATCH v4 03/13] common/hyperlaunch: introduce the domain builder Alejandro Vallejo
2025-04-18 21:55 ` dmkhn
2025-04-23 11:52 ` Alejandro Vallejo
2025-04-23 21:53 ` dmkhn
2025-04-17 12:48 ` [PATCH v4 04/13] x86/hyperlaunch: initial support for hyperlaunch device tree Alejandro Vallejo
2025-04-18 22:11 ` dmkhn
2025-04-23 11:54 ` Alejandro Vallejo
2025-04-17 12:48 ` [PATCH v4 05/13] x86/hyperlaunch: Add helpers to locate multiboot modules Alejandro Vallejo
2025-04-18 22:30 ` dmkhn
2025-04-23 12:12 ` Alejandro Vallejo
2025-04-17 12:48 ` [PATCH v4 06/13] x86/hyperlaunch: locate dom0 kernel with hyperlaunch Alejandro Vallejo
2025-04-18 22:39 ` dmkhn
2025-04-23 12:16 ` Alejandro Vallejo
2025-04-17 12:48 ` [PATCH v4 07/13] x86/hyperlaunch: obtain cmdline from device tree Alejandro Vallejo
2025-04-18 22:53 ` dmkhn
2025-04-23 13:01 ` Alejandro Vallejo
2025-04-23 13:08 ` Jan Beulich
2025-04-24 5:11 ` dmkhn
2025-04-17 12:48 ` [PATCH v4 08/13] x86/hyperlaunch: locate dom0 initrd with hyperlaunch Alejandro Vallejo
2025-04-18 22:58 ` dmkhn
2025-04-23 13:01 ` Alejandro Vallejo
2025-04-17 12:48 ` [PATCH v4 09/13] x86/hyperlaunch: add domain id parsing to domain config Alejandro Vallejo
2025-04-18 23:08 ` dmkhn
2025-04-23 13:03 ` Alejandro Vallejo
2025-04-17 12:48 ` [PATCH v4 10/13] x86/hyperlaunch: specify dom0 mode with device tree Alejandro Vallejo
2025-04-18 23:10 ` dmkhn
2025-04-17 12:48 ` [PATCH v4 11/13] x86/hyperlaunch: add memory parsing to domain config Alejandro Vallejo
2025-04-18 23:21 ` dmkhn [this message]
2025-04-23 13:05 ` Alejandro Vallejo
2025-04-17 12:48 ` [PATCH v4 12/13] x86/hyperlaunch: add max vcpu parsing of hyperlaunch device tree Alejandro Vallejo
2025-04-18 23:22 ` dmkhn
2025-04-17 12:48 ` [PATCH v4 13/13] x86/hyperlaunch: add capabilities to boot domain Alejandro Vallejo
2025-04-18 23:24 ` dmkhn
2025-04-23 13:07 ` Alejandro Vallejo
2025-04-17 13:00 ` [PATCH v4 00/13] Hyperlaunch device tree for dom0 Alejandro Vallejo
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=aALeY6bt7lDCwXii@kraken \
--to=dmkhn@proton.me \
--cc=agarciav@amd.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=bertrand.marquis@arm.com \
--cc=dpsmith@apertussolutions.com \
--cc=jason.andryuk@amd.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.