add copy_from_gva/copy_to_gva functions

there are data transfer between guest virtual space(GVA) & hv(HVA), for
example, guest rip fetching during instruction decoding.

GVA is address continuous, but its GPA could be only 4K page address
continuous, this patch adds copy_from_gva & copy_to_gva functions by
doing page walking of GVA to avoid address breaking during accessing GVA.

v2:
- modify API interface based on new gva2gpa function, err_code added
- combine similar code with inline function _copy_gpa
- change API name from vcopy_from/to_vm to copy_from/to_gva

Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
This commit is contained in:
Jason Chen CJ
2018-05-24 08:25:48 +08:00
committed by lijinxia
parent 6be8283334
commit 88758dfe57
2 changed files with 120 additions and 65 deletions

View File

@@ -124,6 +124,10 @@ extern vm_sw_loader_t vm_sw_loader;
int copy_from_vm(struct vm *vm, void *h_ptr, uint64_t gpa, uint32_t size);
int copy_to_vm(struct vm *vm, void *h_ptr, uint64_t gpa, uint32_t size);
int copy_from_gva(struct vcpu *vcpu, void *h_ptr, uint64_t gva,
uint32_t size, uint32_t *err_code);
int copy_to_gva(struct vcpu *vcpu, void *h_ptr, uint64_t gva,
uint32_t size, uint32_t *err_code);
uint32_t create_guest_init_gdt(struct vm *vm, uint32_t *limit);
#endif /* !ASSEMBLER */