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

[Minios-devel] [UNIKRAFT PATCH] plat/kvm: Place early boot code to the start of the image (x86)



Places early boot code (e.g., 64bit mode switch) and
data (e.g., GDT) to the start of the image.
This avoids general protection faults that were caused
whenever the linker placed such items to addresses
that were not accessible while the mode switch to 64bit
and address space setup was not finished.

Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
---
 plat/kvm/x86/entry64.S | 21 ++++++++++++---------
 plat/kvm/x86/link64.ld |  3 ++-
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/plat/kvm/x86/entry64.S b/plat/kvm/x86/entry64.S
index da1da25..35738b6 100644
--- a/plat/kvm/x86/entry64.S
+++ b/plat/kvm/x86/entry64.S
@@ -31,24 +31,24 @@
 #include <kvm-x86/traps.h>
 #include <kvm-x86/multiboot_defs.h>
 
-#define ENTRY(x) .text; .globl x; .type x,%function; x:
+#define ENTRY(x) .globl x; .type x,%function; x:
 #define END(x)   .size x, . - x
 
 #define MYMULTIBOOT_FLAGS \
     (MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE)
 
-.section .data.multiboot
+.section .data.boot
 
 .align 4
 _multiboot_header:
 .long MULTIBOOT_HEADER_MAGIC
 .long MYMULTIBOOT_FLAGS
-.long -(MULTIBOOT_HEADER_MAGIC+MYMULTIBOOT_FLAGS)
-.long _multiboot_header
-.long 0x100000
-.long _edata
-.long _end
-.long _libkvmplat_start32
+.long -(MULTIBOOT_HEADER_MAGIC+MYMULTIBOOT_FLAGS) /* checksum */
+.long _multiboot_header                           /* header addr */
+.long 0x100000                                    /* load addr */
+.long _edata                                      /* load end addr */
+.long _end                                        /* bss end addr */
+.long _libkvmplat_start32                         /* entry addr */
 
 .section .bss
 
@@ -64,6 +64,7 @@ bootstack:
  * we've switched to long mode.
  */
 .code32
+.section .text.boot
 
 ENTRY(_libkvmplat_start32)
        cld
@@ -140,7 +141,7 @@ END(_libkvmplat_start32)
  * Uuuyea, exceptions.
  */
 
-.data
+.section .data.boot
 .align 64
 gdt64:
        .quad 0x0000000000000000
@@ -166,6 +167,7 @@ mxcsr_ptr:
 #include "pagetable.S"
 
 .code64
+.section .text.boot
 
 ENTRY(_libkvmplat_start64)
        movq $bootstack, %rsp
@@ -193,6 +195,7 @@ ENTRY(_libkvmplat_start64)
        hlt
 END(_libkvmplat_start64)
 
+.text
 ENTRY(_libkvmplat_newstack)
        movq %rdi, %rsp
        movq %rdx, %rdi
diff --git a/plat/kvm/x86/link64.ld b/plat/kvm/x86/link64.ld
index d1bfa73..60b5d21 100644
--- a/plat/kvm/x86/link64.ld
+++ b/plat/kvm/x86/link64.ld
@@ -33,7 +33,8 @@ SECTIONS
        .text :
        {
                /* prevent linker gc from removing multiboot header */
-               KEEP (*(.data.multiboot))
+               KEEP (*(.data.boot))
+               *(.text.boot)
 
                *(.text)
                *(.text.*)
-- 
2.7.4


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

 


Rackspace

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