mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-22 09:17:58 +00:00
hv: pgtable: fix 'Use of function like macro'
Convert HPA2HVA, HVA2HPA, GPA2HVA and HVA2GPA to inline functions. v1 -> v2: * Modify the following statement. rsdp = biosacpi_search_rsdp((char *)hpa2hva((uint64_t)(*addr << 4)), 0x400); Instead of "(uint64_t)(*addr << 4)", "(uint64_t)(*addr) << 4U" would be clearer. Tracked-On: #861 Signed-off-by: Shiqing Gao <shiqing.gao@intel.com> Reviewed-by: Junjie Mao <junjie.mao@intel.com>
This commit is contained in:
@@ -40,9 +40,9 @@ static void parse_other_modules(struct vm *vm,
|
||||
|
||||
for (i = 0U; i < mods_count; i++) {
|
||||
uint32_t type_len;
|
||||
const char *start = HPA2HVA((uint64_t)mods[i].mm_string);
|
||||
const char *start = hpa2hva((uint64_t)mods[i].mm_string);
|
||||
const char *end;
|
||||
void *mod_addr = HPA2HVA((uint64_t)mods[i].mm_mod_start);
|
||||
void *mod_addr = hpa2hva((uint64_t)mods[i].mm_mod_start);
|
||||
uint32_t mod_size = mods[i].mm_mod_end - mods[i].mm_mod_start;
|
||||
|
||||
dev_dbg(ACRN_DBG_BOOT, "other mod-%d start=0x%x, end=0x%x",
|
||||
@@ -62,7 +62,7 @@ static void parse_other_modules(struct vm *vm,
|
||||
type_len = end - start;
|
||||
if (strncmp("FIRMWARE", start, type_len) == 0) {
|
||||
char dyn_bootargs[100] = {'\0'};
|
||||
void *load_addr = GPA2HVA(vm,
|
||||
void *load_addr = gpa2hva(vm,
|
||||
(uint64_t)vm->sw.linux_info.bootargs_load_addr);
|
||||
uint32_t args_size = vm->sw.linux_info.bootargs_size;
|
||||
static int copy_once = 1;
|
||||
@@ -154,12 +154,12 @@ static void *parse_image_boot_params(struct vm *vm, char *cmdline)
|
||||
}
|
||||
|
||||
param = arg + len;
|
||||
boot_params = (struct image_boot_params *)HPA2HVA(strtoul_hex(param));
|
||||
boot_params = (struct image_boot_params *)hpa2hva(strtoul_hex(param));
|
||||
if (boot_params == NULL) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
parse_seed_list((struct seed_list_hob *)HPA2HVA(
|
||||
parse_seed_list((struct seed_list_hob *)hpa2hva(
|
||||
boot_params->p_seed_list));
|
||||
|
||||
/*
|
||||
@@ -198,7 +198,7 @@ int init_vm_boot_info(struct vm *vm)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mbi = HPA2HVA((uint64_t)boot_regs[1]);
|
||||
mbi = hpa2hva((uint64_t)boot_regs[1]);
|
||||
|
||||
dev_dbg(ACRN_DBG_BOOT, "Multiboot detected, flag=0x%x", mbi->mi_flags);
|
||||
if ((mbi->mi_flags & MULTIBOOT_INFO_HAS_MODS) == 0U) {
|
||||
@@ -218,7 +218,7 @@ int init_vm_boot_info(struct vm *vm)
|
||||
|
||||
vm->sw.kernel_type = VM_LINUX_GUEST;
|
||||
vm->sw.kernel_info.kernel_src_addr =
|
||||
HPA2HVA((uint64_t)mods[0].mm_mod_start);
|
||||
hpa2hva((uint64_t)mods[0].mm_mod_start);
|
||||
vm->sw.kernel_info.kernel_size =
|
||||
mods[0].mm_mod_end - mods[0].mm_mod_start;
|
||||
|
||||
@@ -253,7 +253,7 @@ int init_vm_boot_info(struct vm *vm)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mbi = HPA2HVA((uint64_t)boot_regs[1]);
|
||||
mbi = hpa2hva((uint64_t)boot_regs[1]);
|
||||
|
||||
dev_dbg(ACRN_DBG_BOOT, "Multiboot detected, flag=0x%x", mbi->mi_flags);
|
||||
if ((mbi->mi_flags & MULTIBOOT_INFO_HAS_MODS) == 0U) {
|
||||
@@ -264,7 +264,7 @@ int init_vm_boot_info(struct vm *vm)
|
||||
dev_dbg(ACRN_DBG_BOOT, "mod counts=%d\n", mbi->mi_mods_count);
|
||||
|
||||
/* mod[0] is for kernel&cmdline, other mod for ramdisk/firmware info*/
|
||||
mods = (struct multiboot_module *)HPA2HVA((uint64_t)mbi->mi_mods_addr);
|
||||
mods = (struct multiboot_module *)hpa2hva((uint64_t)mbi->mi_mods_addr);
|
||||
|
||||
dev_dbg(ACRN_DBG_BOOT, "mod0 start=0x%x, end=0x%x",
|
||||
mods[0].mm_mod_start, mods[0].mm_mod_end);
|
||||
@@ -273,10 +273,10 @@ int init_vm_boot_info(struct vm *vm)
|
||||
|
||||
vm->sw.kernel_type = VM_LINUX_GUEST;
|
||||
vm->sw.kernel_info.kernel_src_addr =
|
||||
HPA2HVA((uint64_t)mods[0].mm_mod_start);
|
||||
hpa2hva((uint64_t)mods[0].mm_mod_start);
|
||||
vm->sw.kernel_info.kernel_size =
|
||||
mods[0].mm_mod_end - mods[0].mm_mod_start;
|
||||
vm->sw.kernel_info.kernel_load_addr = (void *)HVA2GPA(vm,
|
||||
vm->sw.kernel_info.kernel_load_addr = (void *)hva2gpa(vm,
|
||||
get_kernel_load_addr(vm->sw.kernel_info.kernel_src_addr));
|
||||
|
||||
/*
|
||||
@@ -290,7 +290,7 @@ int init_vm_boot_info(struct vm *vm)
|
||||
char buf[MAX_BOOT_PARAMS_LEN];
|
||||
|
||||
cmd_dst = kernel_cmdline;
|
||||
cmd_src = HPA2HVA((uint64_t)mbi->mi_cmdline);
|
||||
cmd_src = hpa2hva((uint64_t)mbi->mi_cmdline);
|
||||
|
||||
boot_params_addr = parse_image_boot_params(vm, cmd_src);
|
||||
/*
|
||||
@@ -300,8 +300,7 @@ int init_vm_boot_info(struct vm *vm)
|
||||
if (boot_params_addr != NULL) {
|
||||
(void)memset(buf, 0U, sizeof(buf));
|
||||
snprintf(buf, MAX_BOOT_PARAMS_LEN, "%s0x%X ",
|
||||
boot_params_arg,
|
||||
HVA2GPA(vm, (uint64_t)boot_params_addr));
|
||||
boot_params_arg, hva2gpa(vm, boot_params_addr));
|
||||
(void)strncpy_s(cmd_dst, MEM_2K, buf,
|
||||
MAX_BOOT_PARAMS_LEN);
|
||||
off = strnlen_s(cmd_dst, MEM_2K);
|
||||
@@ -315,7 +314,7 @@ int init_vm_boot_info(struct vm *vm)
|
||||
off += 1U;
|
||||
|
||||
cmd_dst += off;
|
||||
cmd_src = HPA2HVA((uint64_t)mods[0].mm_string);
|
||||
cmd_src = hpa2hva((uint64_t)mods[0].mm_string);
|
||||
(void)strncpy_s(cmd_dst, MEM_2K - off, cmd_src,
|
||||
strnlen_s(cmd_src, MEM_2K - off));
|
||||
|
||||
@@ -324,9 +323,9 @@ int init_vm_boot_info(struct vm *vm)
|
||||
strnlen_s(kernel_cmdline, MEM_2K);
|
||||
} else {
|
||||
vm->sw.linux_info.bootargs_src_addr =
|
||||
HPA2HVA((uint64_t)mods[0].mm_string);
|
||||
hpa2hva((uint64_t)mods[0].mm_string);
|
||||
vm->sw.linux_info.bootargs_size =
|
||||
strnlen_s(HPA2HVA((uint64_t)mods[0].mm_string),
|
||||
strnlen_s(hpa2hva((uint64_t)mods[0].mm_string),
|
||||
MEM_2K);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user