x86/boot: Annotate the multiboot headers with size and type information
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 2 Mar 2018 17:45:52 +0000 (17:45 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 5 Mar 2018 17:36:31 +0000 (17:36 +0000)
This causes objdump not to try and disassemble the data.

While altering this area, switch to using .balign, and fill with 0xc2 to help
highlight the embedded padding (rather than having it filled with 0f 1f 40 00
which is a long nop).  Also, shorten the labels by stripping off the _start
suffix.

The end result is now:
  ffff82d080200000 <_start>:
  ffff82d080200000:       e9 af c1 1c 00          jmpq   ffff82d0803cc1b4 <__start>
  ffff82d080200005:       0f 1f 00                nopl   (%rax)

  ffff82d080200008 <multiboot1_header>:
  ffff82d080200008:       02 b0 ad 1b 03 00 00 00 fb 4f 52 e4 c2 c2 c2 c2     .........OR.....

  ffff82d080200018 <multiboot2_header>:
  ffff82d080200018:       d6 50 52 e8 00 00 00 00 88 00 00 00 a2 ae ad 17     .PR.............
  ffff82d080200028:       01 00 00 00 10 00 00 00 04 00 00 00 06 00 00 00     ................
  ffff82d080200038:       06 00 00 00 08 00 00 00 0a 00 01 00 18 00 00 00     ................
  ffff82d080200048:       00 00 20 00 ff ff ff ff 00 00 20 00 02 00 00 00     .. ....... .....
  ffff82d080200058:       04 00 01 00 0c 00 00 00 02 00 00 00 c2 c2 c2 c2     ................
  ffff82d080200068:       05 00 01 00 14 00 00 00 00 00 00 00 00 00 00 00     ................
  ffff82d080200078:       00 00 00 00 c2 c2 c2 c2 07 00 01 00 08 00 00 00     ................
  ffff82d080200088:       09 00 01 00 0c 00 00 00 5e c0 3c 00 c2 c2 c2 c2     ........^.<.....
  ffff82d080200098:       00 00 00 00 08 00 00 00                             ........

  ffff82d0802000a0 <__high_start>:
  ffff82d0802000a0:       0f 01 15 5f 8f 25 00    lgdt   0x258f5f(%rip)        # ffff82d080459006 <gdt_descr>

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/boot/head.S

index 63bc1b3621f9668f95084f499d4641aaac904ae2..db19ac6fd80fccd6833985add410bcedc5657255 100644 (file)
@@ -34,7 +34,7 @@
         .endm
 
         .macro mb2ht_init type:req, req:req, args:vararg
-        .align MULTIBOOT2_TAG_ALIGN
+        .balign MULTIBOOT2_TAG_ALIGN, 0xc2 /* Avoid padding with long nops. */
 .Lmb2ht_init_start\@:
         .short \type
         .short \req
@@ -48,8 +48,8 @@
 ENTRY(start)
         jmp     __start
 
-        .align 4
-multiboot1_header_start:       /*** MULTIBOOT1 HEADER ****/
+        .balign 4
+multiboot1_header:             /*** MULTIBOOT1 HEADER ****/
 #define MULTIBOOT_HEADER_FLAGS (MULTIBOOT_HEADER_MODS_ALIGNED | \
                                 MULTIBOOT_HEADER_WANT_MEMORY)
         /* Magic number indicating a Multiboot header. */
@@ -58,22 +58,24 @@ multiboot1_header_start:       /*** MULTIBOOT1 HEADER ****/
         .long   MULTIBOOT_HEADER_FLAGS
         /* Checksum: must be the negated sum of the first two fields. */
         .long   -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
-multiboot1_header_end:
+
+        .size multiboot1_header, . - multiboot1_header
+        .type multiboot1_header, @object
 
 /*** MULTIBOOT2 HEADER ****/
 /* Some ideas are taken from grub-2.00/grub-core/tests/boot/kernel-i386.S file. */
-        .align  MULTIBOOT2_HEADER_ALIGN
+        .balign MULTIBOOT2_HEADER_ALIGN, 0xc2  /* Avoid padding the MB1 header with long nops. */
 
-multiboot2_header_start:
+multiboot2_header:
         /* Magic number indicating a Multiboot2 header. */
         .long   MULTIBOOT2_HEADER_MAGIC
         /* Architecture: i386. */
         .long   MULTIBOOT2_ARCHITECTURE_I386
         /* Multiboot2 header length. */
-        .long   .Lmultiboot2_header_end - multiboot2_header_start
+        .long   .Lmultiboot2_header_end - multiboot2_header
         /* Multiboot2 header checksum. */
         .long   -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_ARCHITECTURE_I386 + \
-                        (.Lmultiboot2_header_end - multiboot2_header_start))
+                        (.Lmultiboot2_header_end - multiboot2_header))
 
         /* Multiboot2 information request tag. */
         mb2ht_init MB2_HT(INFORMATION_REQUEST), MB2_HT(REQUIRED), \
@@ -110,6 +112,9 @@ multiboot2_header_start:
         mb2ht_init MB2_HT(END), MB2_HT(REQUIRED)
 .Lmultiboot2_header_end:
 
+        .size multiboot2_header, . - multiboot2_header
+        .type multiboot2_header, @object
+
         .section .init.rodata, "a", @progbits
 
 .Lbad_cpu_msg: .asciz "ERR: Not a 64-bit CPU!"