From 95b6661540a105003b8265789fa26c0590a8ef52 Mon Sep 17 00:00:00 2001 From: Jason Chen CJ Date: Wed, 21 Mar 2018 21:15:38 +0800 Subject: [PATCH] ioreq: only clear vcpu->req when io request needed Signed-off-by: Jason Chen CJ --- arch/x86/ept.c | 4 ++-- arch/x86/io.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/arch/x86/ept.c b/arch/x86/ept.c index de9927cf7..f3bcdbed8 100644 --- a/arch/x86/ept.c +++ b/arch/x86/ept.c @@ -416,8 +416,6 @@ int ept_violation_handler(struct vcpu *vcpu) /* Handle page fault from guest */ exit_qual = vcpu->arch_vcpu.exit_qualification; - memset(&vcpu->req, 0, sizeof(struct vhm_request)); - /* Specify if read or write operation */ if (exit_qual & 0x2) { /* Write operation */ @@ -486,6 +484,8 @@ int ept_violation_handler(struct vcpu *vcpu) * instruction emulation. For MMIO read, ask DM to run MMIO * emulation at first. */ + memset(&vcpu->req, 0, sizeof(struct vhm_request)); + status = dm_emulate_mmio_pre(vcpu, exit_qual); if (status != 0) goto out; diff --git a/arch/x86/io.c b/arch/x86/io.c index 05a3e6e23..62fa2673b 100644 --- a/arch/x86/io.c +++ b/arch/x86/io.c @@ -103,8 +103,6 @@ int io_instr_handler(struct vcpu *vcpu) direction = VM_EXIT_IO_INSTRUCTION_ACCESS_DIRECTION(exit_qual); mask = 0xfffffffful >> (32 - 8 * sz); - memset(&vcpu->req, 0, sizeof(struct vhm_request)); - TRACE_4I(TRC_VMEXIT_IO_INSTRUCTION, port, direction, sz, cur_context_idx); @@ -149,6 +147,7 @@ int io_instr_handler(struct vcpu *vcpu) if (status != 0) { uint64_t *rax = &cur_context->guest_cpu_regs.regs.rax; + memset(&vcpu->req, 0, sizeof(struct vhm_request)); dm_emulate_pio_pre(vcpu, exit_qual, sz, *rax); status = acrn_insert_request_wait(vcpu, &vcpu->req); }