From: "Daniel P. Smith" <dpsm...@apertussolutions.com> boot_domain stores the domid until it is used to create (and allocate) struct domain. d->domain_id is not available early enough.
boot_domain domids are initialized to DOMID_INVALID. If not overridden by device tree, domids of DOMID_INVALID are assigned a valid value. The domid will be optionally parsed from the device tree configuration. Signed-off-by: Daniel P. Smith <dpsm...@apertussolutions.com> Reviewed-by: Jason Andryuk <jason.andr...@amd.com> Signed-off-by: Jason Andryuk <jason.andr...@amd.com> Signed-off-by: Alejandro Vallejo <agarc...@amd.com> --- v3: * Initialize all boot_info.domains domid fields * Re-write commit message to justify the new domid field. * Use "%pd vcpu 0" in error message * Move xen.h include (introduced in v1) inside ifdef guards --- xen/arch/x86/include/asm/boot-domain.h | 4 ++++ xen/arch/x86/setup.c | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/include/asm/boot-domain.h b/xen/arch/x86/include/asm/boot-domain.h index 5e1e1a0b61..fcbedda0f0 100644 --- a/xen/arch/x86/include/asm/boot-domain.h +++ b/xen/arch/x86/include/asm/boot-domain.h @@ -8,7 +8,11 @@ #ifndef __XEN_X86_BOOTDOMAIN_H__ #define __XEN_X86_BOOTDOMAIN_H__ +#include <public/xen.h> + struct boot_domain { + domid_t domid; + struct boot_module *kernel; struct boot_module *module; diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index ddb10ea03d..585316f1ca 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -295,6 +295,7 @@ 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 } }, }; static struct boot_info *__init multiboot_fill_boot_info( @@ -994,7 +995,6 @@ static struct domain *__init create_dom0(struct boot_info *bi) }; struct boot_domain *bd = &bi->domains[0]; struct domain *d; - domid_t domid; if ( opt_dom0_pvh ) { @@ -1010,15 +1010,15 @@ static struct domain *__init create_dom0(struct boot_info *bi) dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu; /* Create initial domain. Not d0 for pvshim. */ - domid = get_initial_domain_id(); - d = domain_create(domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged); + bd->domid = get_initial_domain_id(); + d = domain_create(bd->domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged); if ( IS_ERR(d) ) - panic("Error creating d%u: %ld\n", domid, PTR_ERR(d)); + panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(d)); init_dom0_cpuid_policy(d); if ( alloc_dom0_vcpu0(d) == NULL ) - panic("Error creating d%uv0\n", domid); + panic("Error creating %pd vcpu 0\n", d); /* Grab the DOM0 command line. */ if ( bd->kernel->cmdline_pa || bi->kextra ) -- 2.43.0