mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-08-14 14:25:14 +00:00
HV: remove multi-returns in few routine in guest.c
To meet MISRA, remove multi-returns in routines Tracked-On: #861 Signed-off-by: Chaohong guo <chaohong.guo@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
e2c11c0c75
commit
8ed393a03d
@ -263,8 +263,8 @@ int32_t gva2gpa(struct acrn_vcpu *vcpu, uint64_t gva, uint64_t *gpa,
|
||||
int32_t ret = 0;
|
||||
|
||||
if ((gpa == NULL) || (err_code == NULL)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
ret = -EINVAL;
|
||||
} else {
|
||||
*gpa = 0UL;
|
||||
|
||||
pw_info.top_entry = exec_vmread(VMX_GUEST_CR3);
|
||||
@ -279,8 +279,7 @@ int32_t gva2gpa(struct acrn_vcpu *vcpu, uint64_t gva, uint64_t *gpa,
|
||||
* and others.
|
||||
* So we use DPL of SS access rights field for guest DPL.
|
||||
*/
|
||||
pw_info.is_user_mode_access =
|
||||
(((exec_vmread32(VMX_GUEST_SS_ATTR) >> 5U) & 0x3U) == 3U);
|
||||
pw_info.is_user_mode_access = (((exec_vmread32(VMX_GUEST_SS_ATTR) >> 5U) & 0x3U) == 3U);
|
||||
pw_info.pse = true;
|
||||
pw_info.nxe = ((vcpu_get_efer(vcpu) & MSR_IA32_EFER_NXE_BIT) != 0UL);
|
||||
pw_info.wp = ((vcpu_get_cr0(vcpu) & CR0_WP) != 0UL);
|
||||
@ -309,6 +308,7 @@ int32_t gva2gpa(struct acrn_vcpu *vcpu, uint64_t gva, uint64_t *gpa,
|
||||
*err_code |= PAGE_FAULT_US_FLAG;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -324,16 +324,15 @@ static inline uint32_t local_copy_gpa(struct acrn_vm *vm, void *h_ptr, uint64_t
|
||||
if (hpa == INVALID_HPA) {
|
||||
pr_err("%s,vm[%hu] gpa 0x%llx,GPA is unmapping",
|
||||
__func__, vm->vm_id, gpa);
|
||||
return 0U;
|
||||
}
|
||||
len = 0U;
|
||||
} else {
|
||||
|
||||
if (fix_pg_size != 0U) {
|
||||
pg_size = fix_pg_size;
|
||||
}
|
||||
|
||||
offset_in_pg = (uint32_t)gpa & (pg_size - 1U);
|
||||
len = (size > (pg_size - offset_in_pg)) ?
|
||||
(pg_size - offset_in_pg) : size;
|
||||
len = (size > (pg_size - offset_in_pg)) ? (pg_size - offset_in_pg) : size;
|
||||
|
||||
g_ptr = hpa2hva(hpa);
|
||||
|
||||
@ -344,6 +343,7 @@ static inline uint32_t local_copy_gpa(struct acrn_vm *vm, void *h_ptr, uint64_t
|
||||
(void)memcpy_s(g_ptr, len, h_ptr, len);
|
||||
}
|
||||
clac();
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
@ -355,11 +355,13 @@ static inline int32_t copy_gpa(struct acrn_vm *vm, void *h_ptr_arg, uint64_t gpa
|
||||
uint32_t len;
|
||||
uint64_t gpa = gpa_arg;
|
||||
uint32_t size = size_arg;
|
||||
int32_t err = 0;
|
||||
|
||||
while (size > 0U) {
|
||||
len = local_copy_gpa(vm, h_ptr, gpa, size, 0U, cp_from_vm);
|
||||
if (len == 0U) {
|
||||
return -EINVAL;
|
||||
err = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
gpa += len;
|
||||
@ -367,7 +369,7 @@ static inline int32_t copy_gpa(struct acrn_vm *vm, void *h_ptr_arg, uint64_t gpa
|
||||
size -= len;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user