From 3158c851ae58a9118ad56baac24d88445a6bbcea Mon Sep 17 00:00:00 2001 From: Arindam Roy Date: Wed, 6 Mar 2019 11:36:35 -0800 Subject: [PATCH] HV: Modularize boot folder In order to remove the usage of hypervisor.h, modularize the boot folder. Current changes include modifications to remove usage of acrn_vm structure pointer, from some of the call, and remove calls to hypervisor.h, as and when deemed fit. Removed hva2gpa, as this was not used anywhere else after the changes. Tracked-On: #2694 Signed-off-by: Arindam Roy Acked-by: Eddie Dong --- hypervisor/arch/x86/guest/guest_memory.c | 5 ----- hypervisor/boot/dmar_parse.c | 7 ++++++- hypervisor/boot/sbl/abl_seed_parse.c | 13 +++++++++---- hypervisor/boot/sbl/multiboot.c | 8 ++++---- hypervisor/boot/sbl/sbl_seed_parse.c | 16 +++++++++++----- hypervisor/boot/uefi/uefi_boot.c | 6 ++++-- hypervisor/include/arch/x86/abl_seed_parse.h | 2 +- hypervisor/include/arch/x86/guest/guest_memory.h | 2 -- hypervisor/include/arch/x86/sbl_seed_parse.h | 2 +- 9 files changed, 36 insertions(+), 25 deletions(-) diff --git a/hypervisor/arch/x86/guest/guest_memory.c b/hypervisor/arch/x86/guest/guest_memory.c index a535a361c..d1c794311 100644 --- a/hypervisor/arch/x86/guest/guest_memory.c +++ b/hypervisor/arch/x86/guest/guest_memory.c @@ -437,8 +437,3 @@ void *gpa2hva(struct acrn_vm *vm, uint64_t x) { return hpa2hva(gpa2hpa(vm, x)); } - -uint64_t hva2gpa(struct acrn_vm *vm, void *x) -{ - return (is_sos_vm(vm)) ? sos_vm_hpa2gpa(hva2hpa(x)) : INVALID_GPA; -} diff --git a/hypervisor/boot/dmar_parse.c b/hypervisor/boot/dmar_parse.c index 3ab454d0d..1335947cc 100644 --- a/hypervisor/boot/dmar_parse.c +++ b/hypervisor/boot/dmar_parse.c @@ -5,7 +5,12 @@ */ #ifdef CONFIG_DMAR_PARSE_ENABLED -#include +#include +#include +#include +#include +#include +#include #include "pci.h" #include "vtd.h" #include "acpi_priv.h" diff --git a/hypervisor/boot/sbl/abl_seed_parse.c b/hypervisor/boot/sbl/abl_seed_parse.c index 389cd2be4..f95a5e5b4 100644 --- a/hypervisor/boot/sbl/abl_seed_parse.c +++ b/hypervisor/boot/sbl/abl_seed_parse.c @@ -4,8 +4,14 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include +#include +#include +#include +#include +#include +#include #include +#include #define ABL_SEED_LEN 32U struct abl_seed_info { @@ -92,7 +98,6 @@ static void parse_seed_list_abl(void *param_addr) * original address is HPA. * * input: - * vm pointer to vm structure * cmdline pointer to cmdline string * out_len the max len of out_arg * @@ -102,7 +107,7 @@ static void parse_seed_list_abl(void *param_addr) * return value: * true if parse successfully, otherwise false. */ -bool abl_seed_parse(struct acrn_vm *vm, char *cmdline, char *out_arg, uint32_t out_len) +bool abl_seed_parse(char *cmdline, char *out_arg, uint32_t out_len) { char *arg = NULL, *arg_end; char *param; @@ -138,7 +143,7 @@ bool abl_seed_parse(struct acrn_vm *vm, char *cmdline, char *out_arg, uint32_t o /* Convert the param_addr to SOS GPA and copy to caller */ if (out_arg != NULL) { snprintf(out_arg, out_len, "%s0x%X ", - abl_seed_arg[i], hva2gpa(vm, param_addr)); + abl_seed_arg[i], sos_vm_hpa2gpa(hva2hpa(param_addr))); } parse_success = true; diff --git a/hypervisor/boot/sbl/multiboot.c b/hypervisor/boot/sbl/multiboot.c index 1934f0b13..a3903ae8e 100644 --- a/hypervisor/boot/sbl/multiboot.c +++ b/hypervisor/boot/sbl/multiboot.c @@ -152,8 +152,8 @@ int32_t sbl_init_vm_boot_info(struct acrn_vm *vm) vm->sw.linux_info.bootargs_size = strnlen_s(vm_config->os_config.bootargs, MEM_2K); } else { - vm->sw.kernel_info.kernel_load_addr = (void *)hva2gpa(vm, - get_kernel_load_addr(vm->sw.kernel_info.kernel_src_addr)); + vm->sw.kernel_info.kernel_load_addr = + get_kernel_load_addr(vm->sw.kernel_info.kernel_src_addr); /* * If there is cmdline from mbi->mi_cmdline, merge it with @@ -174,9 +174,9 @@ int32_t sbl_init_vm_boot_info(struct acrn_vm *vm) * so here first try to get seed from SBL, if fail then try * ABL. */ - status = sbl_seed_parse(vm, cmd_src, buf, sizeof(buf)); + status = sbl_seed_parse(is_sos_vm(vm), cmd_src, buf, sizeof(buf)); if (!status) { - status = abl_seed_parse(vm, cmd_src, buf, sizeof(buf)); + status = abl_seed_parse(cmd_src, buf, sizeof(buf)); } if (status) { diff --git a/hypervisor/boot/sbl/sbl_seed_parse.c b/hypervisor/boot/sbl/sbl_seed_parse.c index f4585d34f..5be77ddd1 100644 --- a/hypervisor/boot/sbl/sbl_seed_parse.c +++ b/hypervisor/boot/sbl/sbl_seed_parse.c @@ -4,8 +4,14 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include +#include +#include +#include +#include +#include +#include #include +#include #define SEED_ENTRY_TYPE_SVNSEED 0x1U /* #define SEED_ENTRY_TYPE_RPMBSEED 0x2U */ @@ -119,7 +125,7 @@ static void parse_seed_list_sbl(struct seed_list_hob *seed_hob) * original address is HPA. * * input: - * vm pointer to vm structure + * vm_is_sos Boolean to check if vm is sos * cmdline pointer to cmdline string * out_len the max len of out_arg * @@ -129,7 +135,7 @@ static void parse_seed_list_sbl(struct seed_list_hob *seed_hob) * return value: * true if parse successfully, otherwise false. */ -bool sbl_seed_parse(struct acrn_vm *vm, char *cmdline, char *out_arg, uint32_t out_len) +bool sbl_seed_parse(bool vm_is_sos, char *cmdline, char *out_arg, uint32_t out_len) { char *arg, *arg_end; char *param; @@ -138,7 +144,7 @@ bool sbl_seed_parse(struct acrn_vm *vm, char *cmdline, char *out_arg, uint32_t o uint32_t len; bool parse_success = false; - if (is_sos_vm(vm) && (cmdline != NULL)) { + if (vm_is_sos && (cmdline != NULL)) { len = strnlen_s(boot_params_arg, MEM_1K); arg = strstr_s((const char *)cmdline, MEM_2K, boot_params_arg, len); @@ -168,7 +174,7 @@ bool sbl_seed_parse(struct acrn_vm *vm, char *cmdline, char *out_arg, uint32_t o /* Convert the param_addr to SOS GPA and copy to caller */ if (out_arg != NULL) { snprintf(out_arg, out_len, "%s0x%X ", - boot_params_arg, hva2gpa(vm, param_addr)); + boot_params_arg, sos_vm_hpa2gpa(hva2hpa(param_addr))); } parse_success = true; diff --git a/hypervisor/boot/uefi/uefi_boot.c b/hypervisor/boot/uefi/uefi_boot.c index 4184113eb..01ae49e45 100644 --- a/hypervisor/boot/uefi/uefi_boot.c +++ b/hypervisor/boot/uefi/uefi_boot.c @@ -4,8 +4,10 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include -#include +#include +#include +#include +#include #include #include diff --git a/hypervisor/include/arch/x86/abl_seed_parse.h b/hypervisor/include/arch/x86/abl_seed_parse.h index fc6d6d1ca..c442b823f 100644 --- a/hypervisor/include/arch/x86/abl_seed_parse.h +++ b/hypervisor/include/arch/x86/abl_seed_parse.h @@ -7,6 +7,6 @@ #ifndef ABL_SEED_PARSE_H_ #define ABL_SEED_PARSE_H_ -bool abl_seed_parse(struct acrn_vm *vm, char *cmdline, char *out_arg, uint32_t out_len); +bool abl_seed_parse(char *cmdline, char *out_arg, uint32_t out_len); #endif /* ABL_SEED_PARSE_H_ */ diff --git a/hypervisor/include/arch/x86/guest/guest_memory.h b/hypervisor/include/arch/x86/guest/guest_memory.h index 899235745..1008660a9 100644 --- a/hypervisor/include/arch/x86/guest/guest_memory.h +++ b/hypervisor/include/arch/x86/guest/guest_memory.h @@ -36,8 +36,6 @@ enum vm_paging_mode get_vcpu_paging_mode(struct acrn_vcpu *vcpu); /* gpa --> hpa -->hva */ void *gpa2hva(struct acrn_vm *vm, uint64_t x); -uint64_t hva2gpa(struct acrn_vm *vm, void *x); - /** * @brief Data transfering between hypervisor and VM * diff --git a/hypervisor/include/arch/x86/sbl_seed_parse.h b/hypervisor/include/arch/x86/sbl_seed_parse.h index acfbef031..48f61a9c7 100644 --- a/hypervisor/include/arch/x86/sbl_seed_parse.h +++ b/hypervisor/include/arch/x86/sbl_seed_parse.h @@ -7,6 +7,6 @@ #ifndef SBL_SEED_PARSE_H_ #define SBL_SEED_PARSE_H_ -bool sbl_seed_parse(struct acrn_vm *vm, char *cmdline, char *out_arg, uint32_t out_len); +bool sbl_seed_parse(bool vm_is_sos, char *cmdline, char *out_arg, uint32_t out_len); #endif /* SBL_SEED_PARSE_H_ */