mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-22 05:30:24 +00:00
instr_emul: remove vm_gva2gpa
- vm_gva2gpa is same as gva2gpa, so replace it with gva2gpa directly. - remove dead usage of vm_gva2gpa in emulate_movs. Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
51528d4a81
commit
8d35d8752b
@ -243,7 +243,6 @@ static uint64_t size2mask[] = {
|
|||||||
[8] = 0xffffffffffffffff,
|
[8] = 0xffffffffffffffff,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
vie_read_register(struct vcpu *vcpu, enum vm_reg_name reg, uint64_t *rval)
|
vie_read_register(struct vcpu *vcpu, enum vm_reg_name reg, uint64_t *rval)
|
||||||
{
|
{
|
||||||
@ -671,10 +670,9 @@ emulate_movs(struct vcpu *vcpu, __unused uint64_t gpa, struct vie *vie,
|
|||||||
__unused mem_region_write_t memwrite,
|
__unused mem_region_write_t memwrite,
|
||||||
__unused void *arg)
|
__unused void *arg)
|
||||||
{
|
{
|
||||||
uint64_t dstaddr, srcaddr, dstgpa, srcgpa;
|
uint64_t dstaddr, srcaddr;
|
||||||
uint64_t rcx, rdi, rsi, rflags;
|
uint64_t rcx, rdi, rsi, rflags;
|
||||||
int error, fault, opsize, seg, repeat;
|
int error, fault, opsize, seg, repeat;
|
||||||
uint32_t err_code;
|
|
||||||
|
|
||||||
opsize = (vie->op.op_byte == 0xA4) ? 1 : vie->opsize;
|
opsize = (vie->op.op_byte == 0xA4) ? 1 : vie->opsize;
|
||||||
error = 0;
|
error = 0;
|
||||||
@ -714,14 +712,6 @@ emulate_movs(struct vcpu *vcpu, __unused uint64_t gpa, struct vie *vie,
|
|||||||
if (error || fault)
|
if (error || fault)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
err_code = 0;
|
|
||||||
error = vm_gva2gpa(vcpu, srcaddr, &srcgpa, &err_code);
|
|
||||||
if (error)
|
|
||||||
goto done;
|
|
||||||
err_code = PAGE_FAULT_WR_FLAG;
|
|
||||||
error = vm_gva2gpa(vcpu, dstaddr, &dstgpa, &err_code);
|
|
||||||
if (error)
|
|
||||||
goto done;
|
|
||||||
memcpy_s((char *)dstaddr, 16, (char *)srcaddr, opsize);
|
memcpy_s((char *)dstaddr, 16, (char *)srcaddr, opsize);
|
||||||
|
|
||||||
error = vie_read_register(vcpu, VM_REG_GUEST_RSI, &rsi);
|
error = vie_read_register(vcpu, VM_REG_GUEST_RSI, &rsi);
|
||||||
@ -1310,13 +1300,19 @@ emulate_stack_op(struct vcpu *vcpu, uint64_t mmio_gpa, struct vie *vie,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: currently emulate_instruction is only for mmio, so here
|
||||||
|
* stack_gpa actually is unused for mmio_write & mmio_read, need
|
||||||
|
* take care of data trans if stack_gpa be used for memwrite in
|
||||||
|
* the future.
|
||||||
|
*/
|
||||||
if (pushop)
|
if (pushop)
|
||||||
err_code |= PAGE_FAULT_WR_FLAG;
|
err_code |= PAGE_FAULT_WR_FLAG;
|
||||||
error = vm_gva2gpa(vcpu, stack_gla, &stack_gpa, &err_code);
|
error = gva2gpa(vcpu, stack_gla, &stack_gpa, &err_code);
|
||||||
if (error) {
|
if (error == -EFAULT) {
|
||||||
pr_err("%s: failed to translate gva2gpa", __func__);
|
vcpu_inject_pf(vcpu, stack_gla, err_code);
|
||||||
|
return error;
|
||||||
|
} else if (error < 0)
|
||||||
return error;
|
return error;
|
||||||
}
|
|
||||||
if (pushop) {
|
if (pushop) {
|
||||||
error = memread(vcpu, mmio_gpa, &val, size, arg);
|
error = memread(vcpu, mmio_gpa, &val, size, arg);
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
|
@ -287,17 +287,6 @@ static int mmio_write(struct vcpu *vcpu, __unused uint64_t gpa, uint64_t wval,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vm_gva2gpa(struct vcpu *vcpu, uint64_t gva, uint64_t *gpa,
|
|
||||||
uint32_t *err_code)
|
|
||||||
{
|
|
||||||
|
|
||||||
ASSERT(gpa != NULL, "Error in input arguments");
|
|
||||||
ASSERT(vcpu != NULL,
|
|
||||||
"Invalid vcpu id when gva2gpa");
|
|
||||||
|
|
||||||
return gva2gpa(vcpu, gva, gpa, err_code);
|
|
||||||
}
|
|
||||||
|
|
||||||
int decode_instruction(struct vcpu *vcpu)
|
int decode_instruction(struct vcpu *vcpu)
|
||||||
{
|
{
|
||||||
struct emul_cnx *emul_cnx;
|
struct emul_cnx *emul_cnx;
|
||||||
|
@ -93,8 +93,6 @@ bool vm_lapic_disabled(struct vm *vm);
|
|||||||
uint64_t vcpumask2pcpumask(struct vm *vm, uint64_t vdmask);
|
uint64_t vcpumask2pcpumask(struct vm *vm, uint64_t vdmask);
|
||||||
|
|
||||||
int gva2gpa(struct vcpu *vcpu, uint64_t gva, uint64_t *gpa, uint32_t *err_code);
|
int gva2gpa(struct vcpu *vcpu, uint64_t gva, uint64_t *gpa, uint32_t *err_code);
|
||||||
int vm_gva2gpa(struct vcpu *vcpu, uint64_t gla, uint64_t *gpa,
|
|
||||||
uint32_t *err_code);
|
|
||||||
|
|
||||||
struct vcpu *get_primary_vcpu(struct vm *vm);
|
struct vcpu *get_primary_vcpu(struct vm *vm);
|
||||||
struct vcpu *vcpu_from_vid(struct vm *vm, int vcpu_id);
|
struct vcpu *vcpu_from_vid(struct vm *vm, int vcpu_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user