mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-09 04:39:34 +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:
@@ -229,7 +229,7 @@ static int local_gva2gpa_pae(struct acrn_vcpu *vcpu, struct page_walk_info *pw_i
|
||||
int ret;
|
||||
|
||||
addr = pw_info->top_entry & 0xFFFFFFF0U;
|
||||
base = gpa2hva(vcpu->vm, addr);
|
||||
base = (uint64_t *)gpa2hva(vcpu->vm, addr);
|
||||
if (base == NULL) {
|
||||
ret = -EFAULT;
|
||||
goto out;
|
||||
@@ -282,7 +282,7 @@ int gva2gpa(struct acrn_vcpu *vcpu, uint64_t gva, uint64_t *gpa,
|
||||
*gpa = 0UL;
|
||||
|
||||
pw_info.top_entry = exec_vmread(VMX_GUEST_CR3);
|
||||
pw_info.level = pm;
|
||||
pw_info.level = (uint32_t)pm;
|
||||
pw_info.is_write_access = ((*err_code & PAGE_FAULT_WR_FLAG) != 0U);
|
||||
pw_info.is_inst_fetch = ((*err_code & PAGE_FAULT_ID_FLAG) != 0U);
|
||||
|
||||
|
@@ -1005,7 +1005,7 @@ static int emulate_movs(struct acrn_vcpu *vcpu, const struct instr_emul_vie *vie
|
||||
|
||||
/* we are sure it will success */
|
||||
(void)gva2gpa(vcpu, src_gva, &gpa, &err_code);
|
||||
src_hva = gpa2hva(vcpu->vm, gpa);
|
||||
src_hva = (uint64_t *)gpa2hva(vcpu->vm, gpa);
|
||||
(void)memcpy_s(&val, opsize, src_hva, opsize);
|
||||
|
||||
vie_mmio_write(vcpu, val);
|
||||
@@ -1015,7 +1015,7 @@ static int emulate_movs(struct acrn_vcpu *vcpu, const struct instr_emul_vie *vie
|
||||
/* The dest gpa is saved during dst check instruction
|
||||
* decoding.
|
||||
*/
|
||||
dst_hva = gpa2hva(vcpu->vm, vie->dst_gpa);
|
||||
dst_hva = (uint64_t *)gpa2hva(vcpu->vm, vie->dst_gpa);
|
||||
(void)memcpy_s(dst_hva, opsize, &val, opsize);
|
||||
}
|
||||
|
||||
|
@@ -27,17 +27,13 @@ static uint64_t trampoline_relo_addr(const void *addr)
|
||||
|
||||
uint64_t read_trampoline_sym(const void *sym)
|
||||
{
|
||||
uint64_t *hva;
|
||||
|
||||
hva = hpa2hva(trampoline_start16_paddr) + trampoline_relo_addr(sym);
|
||||
uint64_t *hva = (uint64_t *)(hpa2hva(trampoline_start16_paddr) + trampoline_relo_addr(sym));
|
||||
return *hva;
|
||||
}
|
||||
|
||||
void write_trampoline_sym(const void *sym, uint64_t val)
|
||||
{
|
||||
uint64_t *hva;
|
||||
|
||||
hva = hpa2hva(trampoline_start16_paddr) + trampoline_relo_addr(sym);
|
||||
uint64_t *hva = (uint64_t *)(hpa2hva(trampoline_start16_paddr) + trampoline_relo_addr(sym));
|
||||
*hva = val;
|
||||
clflush(hva);
|
||||
}
|
||||
|
Reference in New Issue
Block a user