]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
x86/boot: Simplify the expression for extra allocation space
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 27 Mar 2025 14:24:43 +0000 (15:24 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 27 Mar 2025 14:24:43 +0000 (15:24 +0100)
The expression for one parameter of find_memory() is already complicated and
about to become moreso.  Break it out into a new variable, and express it in
an easier-to-follow way.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
master commit: ce703c84df1cb279605b0a85a45c6419464a16e8
master date: 2025-03-21 11:52:39 +0000

xen/arch/x86/hvm/dom0_build.c

index 411beb3f06db00c96314ddf51bb18bd62528b3de..2a1bbd6929807600b080ce0bedd01be61345085e 100644 (file)
@@ -540,6 +540,7 @@ static int __init pvh_load_kernel(struct domain *d, const module_t *image,
     unsigned long image_len = image->mod_end;
     struct elf_binary elf;
     struct elf_dom_parms parms;
+    size_t extra_space;
     paddr_t last_addr;
     struct hvm_start_info start_info = { 0 };
     struct hvm_modlist_entry mod = { 0 };
@@ -592,13 +593,16 @@ static int __init pvh_load_kernel(struct domain *d, const module_t *image,
      * split into smaller allocations, done as a single region in order to
      * simplify it.
      */
-    last_addr = find_memory(d, &elf, sizeof(start_info) +
-                            (initrd ? ROUNDUP(initrd->mod_end, PAGE_SIZE) +
-                                      sizeof(mod)
-                                    : 0) +
-                            (cmdline ? ROUNDUP(strlen(cmdline) + 1,
-                                               elf_64bit(&elf) ? 8 : 4)
-                                     : 0));
+    extra_space = sizeof(start_info);
+
+    if ( initrd )
+        extra_space += sizeof(mod) + ROUNDUP(initrd->mod_end, PAGE_SIZE);
+
+    if ( cmdline )
+        extra_space += ROUNDUP(strlen(cmdline) + 1,
+                               elf_64bit(&elf) ? 8 : 4);
+
+    last_addr = find_memory(d, &elf, extra_space);
     if ( last_addr == INVALID_PADDR )
     {
         printk("Unable to find a memory region to load initrd and metadata\n");