hv: add code to fixup ELF relocation sections

For UEFI boot, currently EFI application loads hypervisor to the
hard coded COMNFIG_RAM_START, which may cause it fail to boot if
this address is not available in the target.

This patch series resolve this issue by allocating memory for hypervisor
at run time, and do relocation fixup if the allocated address is
different from the base address that the hypervisor is built.

The summary of the first patch [1/6] in this series:

In x86_64 ELF, .rela sections hold information of symbols which must be
relocated before being referenced.

This patch adds code to fixup .rela sections with the relocated offset,
also, it provides utilities to assist address fixup

Signed-off-by: Zheng Gen <gen.zheng@intel.com>
Signed-off-by: Zide Chen <zide.chen@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
This commit is contained in:
Zide Chen
2018-06-22 08:15:12 -07:00
committed by lijinxia
parent b52be90a2f
commit ca728fb3c5
3 changed files with 156 additions and 0 deletions

22
hypervisor/boot/include/reloc.h Executable file
View File

@@ -0,0 +1,22 @@
/*
* Copyright (C) <2018> Intel Corporation
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef RELOCATE_H
#define RELOCATE_H
extern void _relocate(void);
extern uint64_t get_hv_image_delta(void);
extern uint64_t get_hv_image_base(void);
extern uint64_t trampoline_relo_addr(void *addr);
/* external symbols that are helpful for relocation */
extern uint8_t _DYNAMIC[];
extern uint8_t cpu_primary_start_32[];
extern uint8_t cpu_primary_start_64[];
extern uint8_t trampoline_spinlock_ptr[];
#endif /* RELOCATE_H */