hv: update the hypervisor 64-bit entry address for efi-stub

- remove .data and .text directives. We want to place all the boot data and
  text in the .entry section since the boot code is different from others
  in terms of relocation fixup. With this change, the page tables are in
  entry section now and it's aligned at 4KB.

- regardless CONFIG_MULTIBOOT2 is set or not, the 64-bit entry offset is
  fixed at 0x1200:

  0x00 -- 0x10: Multiboot1 header
  0x10 -- 0x88: Multiboot2 header if CONFIG_MULTIBOOT2 is set
  0x1000: start of entry section: cpu_primary_start_32
  0x1200: cpu_primary_start_64 (thanks to the '.org 0x200' directive)
          GDT tables
	  initial page tables
	  etc.

Tracked-On: #4441
Reviewed-by: Fengwei Yin <fengwei.yin@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
This commit is contained in:
Zide Chen 2020-03-02 18:16:51 +00:00 committed by wenlingz
parent 49ffe168af
commit 67cb1029d9
2 changed files with 17 additions and 11 deletions

View File

@ -115,8 +115,14 @@ relocatable_tag_end:
mb2_header_end:
#endif
/*
* The page tables are aligned to 4KB, which implicitly aligns this section at
* 4KB boundary. Put an extra .align here to explicitly state that regardless
* the actual length of the multiboot header section, this section will be linked
* at offset 0x1000 to the beginning of the target executable.
*/
.align 0x1000
.section entry, "ax"
.align 8
.code32
@ -210,8 +216,13 @@ jmpbuf_32:
/* 0x0008 = HOST_GDT_RING0_CODE_SEL */
.word 0x0008
.code64
/*
* Offset from the beginning of the entry section.
* This is to make sure that cpu_primary_start_64 is linked to a known address
* so that efi-stub knows where to pass control to hypervisor.
*/
.org 0x200
.code64
.global cpu_primary_start_64
cpu_primary_start_64:
/* save the MULTBOOT magic number & MBI */
@ -252,11 +263,10 @@ primary_start_long_mode:
lea after(%rip), %rbx
mov %rbx, (%rax)
rex.w ljmp *(%rax)
.data
jmpbuf_64: .quad 0
/* 0x0008 = HOST_GDT_RING0_CODE_SEL */
.word 0x0008
.text
after:
/* 0x10 = HOST_GDT_RING0_DATA_SEL*/
movl $0x10,%eax

View File

@ -94,14 +94,10 @@ static inline void hv_jump(EFI_PHYSICAL_ADDRESS hv_start,
efi_ctx->vcpu_regs.rip = (uint64_t)&guest_entry;
/* The 64-bit entry of acrn hypervisor is 0x200 from the start
* address of hv image. But due to there is multiboot header,
* so it has to be added with 0x10.
*
* FIXME: The hardcode value 0x210 should be worked out
* from the link address of cpu_primary_start_64 in acrn.out
/* The 64-bit entry of acrn hypervisor is 0x1200 from the start
* address of hv image.
*/
hf = (hv_func)(hv_start + 0x210);
hf = (hv_func)(hv_start + 0x1200);
asm volatile ("cli");