mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-14 13:30:01 +00:00
hv: fix type conversion without cast with explicit conversion
Implicit conversion may result in loss of information or undefined behaviour. So make it with explicit conversion. Tracked-On: #861 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
@@ -235,8 +235,7 @@ local_parse_madt(void *madt, uint32_t lapic_id_array[CONFIG_MAX_PCPU_NUM])
|
||||
uint16_t pcpu_num = 0U;
|
||||
struct acpi_madt_local_apic *processor;
|
||||
struct acpi_table_madt *madt_ptr;
|
||||
void *first;
|
||||
void *end;
|
||||
void *first, *end, *iterator;
|
||||
struct acpi_subtable_header *entry;
|
||||
|
||||
madt_ptr = (struct acpi_table_madt *)madt;
|
||||
@@ -244,13 +243,14 @@ local_parse_madt(void *madt, uint32_t lapic_id_array[CONFIG_MAX_PCPU_NUM])
|
||||
first = madt_ptr + 1;
|
||||
end = (char *)madt_ptr + madt_ptr->header.length;
|
||||
|
||||
for (entry = first; (void *)entry < end; ) {
|
||||
for (iterator = first; (iterator) < (end); iterator += entry->length) {
|
||||
entry = (struct acpi_subtable_header *)iterator;
|
||||
if (entry->length < sizeof(struct acpi_subtable_header)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (entry->type == ACPI_MADT_TYPE_LOCAL_APIC) {
|
||||
processor = (struct acpi_madt_local_apic *)entry;
|
||||
processor = (struct acpi_madt_local_apic *)iterator;
|
||||
if ((processor->lapic_flags & ACPI_MADT_ENABLED) != 0U) {
|
||||
if (pcpu_num < CONFIG_MAX_PCPU_NUM) {
|
||||
lapic_id_array[pcpu_num] = processor->id;
|
||||
@@ -258,9 +258,6 @@ local_parse_madt(void *madt, uint32_t lapic_id_array[CONFIG_MAX_PCPU_NUM])
|
||||
pcpu_num++;
|
||||
}
|
||||
}
|
||||
|
||||
entry = (struct acpi_subtable_header *)
|
||||
(((uint64_t)entry) + entry->length);
|
||||
}
|
||||
|
||||
return pcpu_num;
|
||||
@@ -369,16 +366,11 @@ static void *get_facs_table(void)
|
||||
/* put all ACPI fix up code here */
|
||||
void acpi_fixup(void)
|
||||
{
|
||||
uint8_t *facs_addr;
|
||||
|
||||
facs_addr = get_facs_table();
|
||||
void *facs_addr = get_facs_table();
|
||||
|
||||
if (facs_addr != NULL) {
|
||||
host_pm_s_state.wake_vector_32 =
|
||||
(uint32_t *)(facs_addr + OFFSET_WAKE_VECTOR_32);
|
||||
host_pm_s_state.wake_vector_64 =
|
||||
(uint64_t *)(facs_addr + OFFSET_WAKE_VECTOR_64);
|
||||
host_pm_s_state.wake_vector_32 = (uint32_t *)(facs_addr + OFFSET_WAKE_VECTOR_32);
|
||||
host_pm_s_state.wake_vector_64 = (uint64_t *)(facs_addr + OFFSET_WAKE_VECTOR_64);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -79,7 +79,7 @@ static void parse_other_modules(struct acrn_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 = (char *)hpa2hva((uint64_t)mods[i].mm_string);
|
||||
const char *end;
|
||||
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;
|
||||
@@ -174,7 +174,7 @@ int init_vm_boot_info(struct acrn_vm *vm)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mbi = hpa2hva((uint64_t)boot_regs[1]);
|
||||
mbi = (struct multiboot_info *)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) {
|
||||
@@ -211,7 +211,7 @@ int init_vm_boot_info(struct acrn_vm *vm)
|
||||
char buf[MAX_BOOT_PARAMS_LEN];
|
||||
|
||||
cmd_dst = kernel_cmdline;
|
||||
cmd_src = hpa2hva((uint64_t)mbi->mi_cmdline);
|
||||
cmd_src = (char *)hpa2hva((uint64_t)mbi->mi_cmdline);
|
||||
|
||||
(void)memset(buf, 0U, sizeof(buf));
|
||||
/*
|
||||
@@ -241,7 +241,7 @@ int init_vm_boot_info(struct acrn_vm *vm)
|
||||
off += 1U;
|
||||
|
||||
cmd_dst += off;
|
||||
cmd_src = hpa2hva((uint64_t)mods[0].mm_string);
|
||||
cmd_src = (char *)hpa2hva((uint64_t)mods[0].mm_string);
|
||||
(void)strncpy_s(cmd_dst, MEM_2K - off, cmd_src,
|
||||
strnlen_s(cmd_src, MEM_2K - off));
|
||||
|
||||
|
Reference in New Issue
Block a user