diff mbox series

[v2,1/2] x86/PVH: don't open-code elf_round_up()

Message ID b1b94660-da2f-48ad-a1b6-10cb52e559f6@suse.com (mailing list archive)
State New
Headers show
Series x86/PVH: initial space allocation | expand

Commit Message

Jan Beulich March 20, 2025, 9:28 a.m. UTC
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
I was wondering whether in elf_round_up() itself we might better use
ROUNDUP().
---
v2: New.

Comments

Andrew Cooper March 20, 2025, 10:04 a.m. UTC | #1
On 20/03/2025 9:28 am, Jan Beulich wrote:
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> ---
> I was wondering whether in elf_round_up() itself we might better use
> ROUNDUP().

I did wonder that too.  It's probably easier to arrange now we've got
xen-tools/common-macros.h.

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff mbox series

Patch

--- a/xen/arch/x86/hvm/dom0_build.c
+++ b/xen/arch/x86/hvm/dom0_build.c
@@ -718,8 +718,7 @@  static int __init pvh_load_kernel(
         extra_space += sizeof(mod) + ROUNDUP(initrd_len, PAGE_SIZE);
 
     if ( cmdline )
-        extra_space += ROUNDUP(strlen(cmdline) + 1,
-                               elf_64bit(&elf) ? 8 : 4);
+        extra_space += elf_round_up(&elf, strlen(cmdline) + 1);
 
     last_addr = find_memory(d, &elf, extra_space);
     if ( last_addr == INVALID_PADDR )
@@ -740,7 +739,7 @@  static int __init pvh_load_kernel(
 
         mod.paddr = last_addr;
         mod.size = initrd_len;
-        last_addr += ROUNDUP(initrd_len, elf_64bit(&elf) ? 8 : 4);
+        last_addr += elf_round_up(&elf, initrd_len);
         if ( initrd->cmdline_pa )
         {
             char *str = __va(initrd->cmdline_pa);
@@ -774,7 +773,7 @@  static int __init pvh_load_kernel(
          * Round up to 32/64 bits (depending on the guest kernel bitness) so
          * the modlist/start_info is aligned.
          */
-        last_addr += ROUNDUP(strlen(cmdline) + 1, elf_64bit(&elf) ? 8 : 4);
+        last_addr += elf_round_up(&elf, strlen(cmdline) + 1);
     }
     if ( initrd != NULL )
     {