[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] x86/boot: Annotate the multiboot headers with size and type information



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@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>

I was considering whether it was worth splitting the multiboot headers out
into a separate file, to declutter the top of head.S
---
 xen/arch/x86/boot/head.S | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S
index 63bc1b3..db19ac6 100644
--- a/xen/arch/x86/boot/head.S
+++ b/xen/arch/x86/boot/head.S
@@ -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!"
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.