mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-21 16:57:20 +00:00
HV: refine copy_from_vm/copy_to_vm
If the target is an array, then only the first element will be copied. So replace structure assignment with memcpy_s(). Signed-off-by: Qi Yadong <yadong.qi@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -366,26 +366,26 @@ static inline int check_result(int found)
|
||||
return found ? 0 : -1;
|
||||
}
|
||||
|
||||
#define copy_from_vm(vm, ptr, gpa) ({ \
|
||||
#define copy_from_vm(vm, ptr, gpa, size) ({ \
|
||||
int found = 0; \
|
||||
typeof(*(ptr)) *h_ptr = (ptr); \
|
||||
typeof(*(ptr)) *g_ptr = \
|
||||
HPA2HVA(gpa2hpa_check(vm, gpa, \
|
||||
sizeof(*h_ptr), &found, true)); \
|
||||
size, &found, true)); \
|
||||
if (found) { \
|
||||
*h_ptr = *g_ptr; \
|
||||
memcpy_s(h_ptr, size, g_ptr, size); \
|
||||
} \
|
||||
check_result(found); \
|
||||
})
|
||||
|
||||
#define copy_to_vm(vm, ptr, gpa) ({ \
|
||||
#define copy_to_vm(vm, ptr, gpa, size) ({ \
|
||||
int found = 0; \
|
||||
typeof(*(ptr)) *h_ptr = (ptr); \
|
||||
typeof(*(ptr)) *g_ptr = \
|
||||
HPA2HVA(gpa2hpa_check(vm, gpa, \
|
||||
sizeof(*h_ptr), &found, true)); \
|
||||
size, &found, true)); \
|
||||
if (found) { \
|
||||
*g_ptr = *h_ptr; \
|
||||
memcpy_s(g_ptr, size, h_ptr, size); \
|
||||
} \
|
||||
check_result(found); \
|
||||
})
|
||||
|
Reference in New Issue
Block a user