mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-01-05 07:35:31 +00:00
page walk during copy_from_vm/copy_to_vm
there are data transfer between guest(GPA) & hv(HPA), especially for hypercall from guest. guest should make sure these GPAs are address continous, but hv cannot assure HPAs which mapped to these GPAs are address continous, for example, after enable hugetlb, a contious GPA range could come from two different 2M pages. this patch is handling such case by doing gpa page walking during copy_from_vm & copy_to_vm. Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -372,33 +372,4 @@ int64_t hcall_initialize_trusty(struct vcpu *vcpu, uint64_t param);
|
||||
* @}
|
||||
*/
|
||||
|
||||
static inline int check_result(int found)
|
||||
{
|
||||
return found ? 0 : -1;
|
||||
}
|
||||
|
||||
#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, \
|
||||
size, &found, true)); \
|
||||
if (found) { \
|
||||
memcpy_s(h_ptr, size, g_ptr, size); \
|
||||
} \
|
||||
check_result(found); \
|
||||
})
|
||||
|
||||
#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, \
|
||||
size, &found, true)); \
|
||||
if (found) { \
|
||||
memcpy_s(g_ptr, size, h_ptr, size); \
|
||||
} \
|
||||
check_result(found); \
|
||||
})
|
||||
|
||||
#endif /* HYPERCALL_H*/
|
||||
|
||||
Reference in New Issue
Block a user