diff mbox series

[v5,43/44] x86/boot: convert dom0_construct_pv to struct boot_domain

Message ID 20241006214956.24339-44-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
With construct_dom0 consuming struct boot_domain, continue passing the
structure down to dom0_construct_pv.

Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
---
 xen/arch/x86/dom0_build.c             |  2 +-
 xen/arch/x86/include/asm/dom0_build.h |  5 ++--
 xen/arch/x86/pv/dom0_build.c          | 43 ++++++++++++---------------
 3 files changed, 22 insertions(+), 28 deletions(-)

Comments

Jason Andryuk Oct. 8, 2024, 7:54 p.m. UTC | #1
On 2024-10-06 17:49, Daniel P. Smith wrote:
> With construct_dom0 consuming struct boot_domain, continue passing the
> structure down to dom0_construct_pv.
> 
> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>

> diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c
> index 16b8c1e40998..34974aa7cd56 100644
> --- a/xen/arch/x86/pv/dom0_build.c
> +++ b/xen/arch/x86/pv/dom0_build.c
> @@ -354,10 +354,7 @@ static struct page_info * __init alloc_chunk(struct domain *d,
>       return page;
>   }
>   
> -static int __init dom0_construct(struct domain *d,
> -                                 const struct boot_module *image,
> -                                 struct boot_module *initrd,
> -                                 const char *cmdline)
> +static int __init dom0_construct(struct boot_domain *bd)
>   {
>       int i, rc, order, machine;
>       bool compatible, compat;
> @@ -373,11 +370,12 @@ static int __init dom0_construct(struct domain *d,
>       struct page_info *page = NULL;
>       unsigned int flush_flags = 0;
>       start_info_t *si;
> -    struct vcpu *v = d->vcpu[0];
> -    void *image_base = bootstrap_map_bm(image);
> -    unsigned long image_len = image->size;
> -    void *image_start = image_base + image->headroom;
> -    unsigned long initrd_len = initrd ? initrd->size : 0;
> +    struct domain *d = bd->d;
> +    struct vcpu *v = bd->d->vcpu[0];

This can stay:
     struct vcpu *v = d->vcpu[0];

With that:

Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
Daniel P. Smith Oct. 10, 2024, 12:49 a.m. UTC | #2
On 10/8/24 15:54, Jason Andryuk wrote:
> On 2024-10-06 17:49, Daniel P. Smith wrote:
>> With construct_dom0 consuming struct boot_domain, continue passing the
>> structure down to dom0_construct_pv.
>>
>> Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
> 
>> diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c
>> index 16b8c1e40998..34974aa7cd56 100644
>> --- a/xen/arch/x86/pv/dom0_build.c
>> +++ b/xen/arch/x86/pv/dom0_build.c
>> @@ -354,10 +354,7 @@ static struct page_info * __init 
>> alloc_chunk(struct domain *d,
>>       return page;
>>   }
>> -static int __init dom0_construct(struct domain *d,
>> -                                 const struct boot_module *image,
>> -                                 struct boot_module *initrd,
>> -                                 const char *cmdline)
>> +static int __init dom0_construct(struct boot_domain *bd)
>>   {
>>       int i, rc, order, machine;
>>       bool compatible, compat;
>> @@ -373,11 +370,12 @@ static int __init dom0_construct(struct domain *d,
>>       struct page_info *page = NULL;
>>       unsigned int flush_flags = 0;
>>       start_info_t *si;
>> -    struct vcpu *v = d->vcpu[0];
>> -    void *image_base = bootstrap_map_bm(image);
>> -    unsigned long image_len = image->size;
>> -    void *image_start = image_base + image->headroom;
>> -    unsigned long initrd_len = initrd ? initrd->size : 0;
>> +    struct domain *d = bd->d;
>> +    struct vcpu *v = bd->d->vcpu[0];
> 
> This can stay:
>      struct vcpu *v = d->vcpu[0];

Ack.

> With that:
> 
> Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>

Thanks!

v/r,
dps
diff mbox series

Patch

diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c
index e552f2e9abef..8beb33032940 100644
--- a/xen/arch/x86/dom0_build.c
+++ b/xen/arch/x86/dom0_build.c
@@ -611,7 +611,7 @@  int __init construct_dom0(struct boot_domain *bd)
     if ( is_hvm_domain(bd->d) )
         rc = dom0_construct_pvh(bd->d, bd->kernel, bd->ramdisk, bd->cmdline);
     else if ( is_pv_domain(bd->d) )
-        rc = dom0_construct_pv(bd->d, bd->kernel, bd->ramdisk, bd->cmdline);
+        rc = dom0_construct_pv(bd);
     else
         panic("Cannot construct Dom0. No guest interface available\n");
 
diff --git a/xen/arch/x86/include/asm/dom0_build.h b/xen/arch/x86/include/asm/dom0_build.h
index 8f7b37f3d308..60e9cb21f14d 100644
--- a/xen/arch/x86/include/asm/dom0_build.h
+++ b/xen/arch/x86/include/asm/dom0_build.h
@@ -4,6 +4,7 @@ 
 #include <xen/libelf.h>
 #include <xen/sched.h>
 
+#include <asm/bootinfo.h>
 #include <asm/setup.h>
 
 extern unsigned int dom0_memflags;
@@ -13,9 +14,7 @@  unsigned long dom0_compute_nr_pages(struct domain *d,
                                     unsigned long initrd_len);
 int dom0_setup_permissions(struct domain *d);
 
-int dom0_construct_pv(
-    struct domain *d, const struct boot_module *image,
-    struct boot_module *initrd, const char *cmdline);
+int dom0_construct_pv(struct boot_domain *bd);
 
 int dom0_construct_pvh(
     struct domain *d, const struct boot_module *image,
diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c
index 16b8c1e40998..34974aa7cd56 100644
--- a/xen/arch/x86/pv/dom0_build.c
+++ b/xen/arch/x86/pv/dom0_build.c
@@ -354,10 +354,7 @@  static struct page_info * __init alloc_chunk(struct domain *d,
     return page;
 }
 
-static int __init dom0_construct(struct domain *d,
-                                 const struct boot_module *image,
-                                 struct boot_module *initrd,
-                                 const char *cmdline)
+static int __init dom0_construct(struct boot_domain *bd)
 {
     int i, rc, order, machine;
     bool compatible, compat;
@@ -373,11 +370,12 @@  static int __init dom0_construct(struct domain *d,
     struct page_info *page = NULL;
     unsigned int flush_flags = 0;
     start_info_t *si;
-    struct vcpu *v = d->vcpu[0];
-    void *image_base = bootstrap_map_bm(image);
-    unsigned long image_len = image->size;
-    void *image_start = image_base + image->headroom;
-    unsigned long initrd_len = initrd ? initrd->size : 0;
+    struct domain *d = bd->d;
+    struct vcpu *v = bd->d->vcpu[0];
+    void *image_base = bootstrap_map_bm(bd->kernel);
+    unsigned long image_len = bd->kernel->size;
+    void *image_start = image_base + bd->kernel->headroom;
+    unsigned long initrd_len = bd->ramdisk ? bd->ramdisk->size : 0;
     l4_pgentry_t *l4tab = NULL, *l4start = NULL;
     l3_pgentry_t *l3tab = NULL, *l3start = NULL;
     l2_pgentry_t *l2tab = NULL, *l2start = NULL;
@@ -613,7 +611,7 @@  static int __init dom0_construct(struct domain *d,
         initrd_pfn = vinitrd_start ?
                      (vinitrd_start - v_start) >> PAGE_SHIFT :
                      domain_tot_pages(d);
-        initrd_mfn = maddr_to_mfn(initrd->start);
+        initrd_mfn = maddr_to_mfn(bd->ramdisk->start);
         mfn = mfn_x(initrd_mfn);
         count = PFN_UP(initrd_len);
         if ( d->arch.physaddr_bitsize &&
@@ -629,13 +627,13 @@  static int __init dom0_construct(struct domain *d,
                     free_domheap_pages(page, order);
                     page += 1UL << order;
                 }
-            memcpy(page_to_virt(page), maddr_to_virt(initrd->start),
+            memcpy(page_to_virt(page), maddr_to_virt(bd->ramdisk->start),
                    initrd_len);
-            mpt_alloc = initrd->start;
+            mpt_alloc = bd->ramdisk->start;
             init_domheap_pages(mpt_alloc,
                                mpt_alloc + PAGE_ALIGN(initrd_len));
             initrd_mfn = page_to_mfn(page);
-            initrd->start = mfn_to_maddr(initrd_mfn);
+            bd->ramdisk->start = mfn_to_maddr(initrd_mfn);
         }
         else
         {
@@ -643,7 +641,7 @@  static int __init dom0_construct(struct domain *d,
                 if ( assign_pages(mfn_to_page(_mfn(mfn++)), 1, d, 0) )
                     BUG();
         }
-        initrd->size = 0;
+        bd->ramdisk->size = 0;
 
         iommu_memory_setup(d, "initrd", mfn_to_page(initrd_mfn),
                            PFN_UP(initrd_len), &flush_flags);
@@ -655,9 +653,9 @@  static int __init dom0_construct(struct domain *d,
     if ( domain_tot_pages(d) < nr_pages )
         printk(" (%lu pages to be allocated)",
                nr_pages - domain_tot_pages(d));
-    if ( initrd )
+    if ( bd->ramdisk )
     {
-        mpt_alloc = initrd->start;
+        mpt_alloc = bd->ramdisk->start;
         printk("\n Init. ramdisk: %"PRIpaddr"->%"PRIpaddr,
                mpt_alloc, mpt_alloc + initrd_len);
     }
@@ -885,7 +883,7 @@  static int __init dom0_construct(struct domain *d,
         if ( pfn >= initrd_pfn )
         {
             if ( pfn < initrd_pfn + PFN_UP(initrd_len) )
-                mfn = paddr_to_pfn(initrd->start) + (pfn - initrd_pfn);
+                mfn = paddr_to_pfn(bd->ramdisk->start) + (pfn - initrd_pfn);
             else
                 mfn -= PFN_UP(initrd_len);
         }
@@ -955,8 +953,8 @@  static int __init dom0_construct(struct domain *d,
     }
 
     memset(si->cmd_line, 0, sizeof(si->cmd_line));
-    if ( cmdline != NULL )
-        strlcpy((char *)si->cmd_line, cmdline, sizeof(si->cmd_line));
+    if ( bd->cmdline[0] != '\0' )
+        strlcpy((char *)si->cmd_line, bd->cmdline, sizeof(si->cmd_line));
 
 #ifdef CONFIG_VIDEO
     if ( !pv_shim && fill_console_start_info((void *)(si + 1)) )
@@ -1053,10 +1051,7 @@  out:
     return rc;
 }
 
-int __init dom0_construct_pv(struct domain *d,
-                             const struct boot_module *image,
-                             struct boot_module *initrd,
-                             const char *cmdline)
+int __init dom0_construct_pv(struct boot_domain *bd)
 {
     int rc;
 
@@ -1073,7 +1068,7 @@  int __init dom0_construct_pv(struct domain *d,
         write_cr4(read_cr4() & ~X86_CR4_SMAP);
     }
 
-    rc = dom0_construct(d, image, initrd, cmdline);
+    rc = dom0_construct(bd);
 
     if ( boot_cpu_has(X86_FEATURE_XEN_SMAP) )
     {