diff mbox series

[v5,41/44] x86/boot: add struct domain to struct boot_domain

Message ID 20241006214956.24339-42-dpsmith@apertussolutions.com (mailing list archive)
State Superseded
Headers show
Series Boot modules for Hyperlaunch | expand

Commit Message

Daniel P. Smith Oct. 6, 2024, 9:49 p.m. UTC
Store a reference to the created domain in struct boot_domain.

Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
---
 xen/arch/x86/include/asm/bootdomain.h |  3 +++
 xen/arch/x86/setup.c                  | 15 +++++++--------
 2 files changed, 10 insertions(+), 8 deletions(-)

Comments

Jason Andryuk Oct. 8, 2024, 7:48 p.m. UTC | #1
On 2024-10-06 17:49, Daniel P. Smith wrote:
> Store a reference to the created domain in struct boot_domain.
> 
> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
> ---

> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index f250638edf09..e6a231bd2d42 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -959,7 +959,6 @@ static struct domain *__init create_dom0(struct boot_info *bi)
>           },
>       };
>       struct boot_domain *bd = &bi->domains[0];
> -    struct domain *d;
>   
>       if ( opt_dom0_pvh )
>       {
> @@ -976,13 +975,13 @@ static struct domain *__init create_dom0(struct boot_info *bi)
>   
>       /* Create initial domain.  Not d0 for pvshim. */
>       bd->domid = get_initial_domain_id();
> -    d = domain_create(bd->domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged);

It's a smaller patch if you keep `d` and the line above and then do:
        bd->d = d;

Regards,
Jason

> -    if ( IS_ERR(d) )
> -        panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(d));
> +    bd->d = domain_create(bd->domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged);
> +    if ( IS_ERR(bd->d) )
> +        panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(bd->d));
>   
> -    init_dom0_cpuid_policy(d);
> +    init_dom0_cpuid_policy(bd->d);
>   
> -    if ( alloc_dom0_vcpu0(d) == NULL )
> +    if ( alloc_dom0_vcpu0(bd->d) == NULL )
>           panic("Error creating d%uv0\n", bd->domid);
>   
>       /* Grab the DOM0 command line. */
Daniel P. Smith Oct. 10, 2024, 12:47 a.m. UTC | #2
On 10/8/24 15:48, Jason Andryuk wrote:
> On 2024-10-06 17:49, Daniel P. Smith wrote:
>> Store a reference to the created domain in struct boot_domain.
>>
>> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
>> ---
> 
>> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
>> index f250638edf09..e6a231bd2d42 100644
>> --- a/xen/arch/x86/setup.c
>> +++ b/xen/arch/x86/setup.c
>> @@ -959,7 +959,6 @@ static struct domain *__init create_dom0(struct 
>> boot_info *bi)
>>           },
>>       };
>>       struct boot_domain *bd = &bi->domains[0];
>> -    struct domain *d;
>>       if ( opt_dom0_pvh )
>>       {
>> @@ -976,13 +975,13 @@ static struct domain *__init create_dom0(struct 
>> boot_info *bi)
>>       /* Create initial domain.  Not d0 for pvshim. */
>>       bd->domid = get_initial_domain_id();
>> -    d = domain_create(bd->domid, &dom0_cfg, pv_shim ? 0 : 
>> CDF_privileged);
> 
> It's a smaller patch if you keep `d` and the line above and then do:
>         bd->d = d;

Yah, this can be done.

v/r,
dps
diff mbox series

Patch

diff --git a/xen/arch/x86/include/asm/bootdomain.h b/xen/arch/x86/include/asm/bootdomain.h
index 00f7d9267965..2322c459e36a 100644
--- a/xen/arch/x86/include/asm/bootdomain.h
+++ b/xen/arch/x86/include/asm/bootdomain.h
@@ -10,6 +10,7 @@ 
 
 #include <public/xen.h>
 
+struct domain;
 struct boot_module;
 
 struct boot_domain {
@@ -19,6 +20,8 @@  struct boot_domain {
 
     struct boot_module *kernel;
     struct boot_module *ramdisk;
+
+    struct domain *d;
 };
 
 #endif
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index f250638edf09..e6a231bd2d42 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -959,7 +959,6 @@  static struct domain *__init create_dom0(struct boot_info *bi)
         },
     };
     struct boot_domain *bd = &bi->domains[0];
-    struct domain *d;
 
     if ( opt_dom0_pvh )
     {
@@ -976,13 +975,13 @@  static struct domain *__init create_dom0(struct boot_info *bi)
 
     /* Create initial domain.  Not d0 for pvshim. */
     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", bd->domid, PTR_ERR(d));
+    bd->d = domain_create(bd->domid, &dom0_cfg, pv_shim ? 0 : CDF_privileged);
+    if ( IS_ERR(bd->d) )
+        panic("Error creating d%u: %ld\n", bd->domid, PTR_ERR(bd->d));
 
-    init_dom0_cpuid_policy(d);
+    init_dom0_cpuid_policy(bd->d);
 
-    if ( alloc_dom0_vcpu0(d) == NULL )
+    if ( alloc_dom0_vcpu0(bd->d) == NULL )
         panic("Error creating d%uv0\n", bd->domid);
 
     /* Grab the DOM0 command line. */
@@ -1014,10 +1013,10 @@  static struct domain *__init create_dom0(struct boot_info *bi)
         }
     }
 
-    if ( construct_dom0(d, bd->kernel, bd->ramdisk, bd->cmdline) != 0 )
+    if ( construct_dom0(bd->d, bd->kernel, bd->ramdisk, bd->cmdline) != 0 )
         panic("Could not construct domain 0\n");
 
-    return d;
+    return bd->d;
 }
 
 /* How much of the directmap is prebuilt at compile time. */