From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Durrant Subject: [PATCH v4 16/17] x86/hvm: always re-emulate I/O from a buffer Date: Wed, 24 Jun 2015 12:24:48 +0100 Message-ID: <1435145089-21999-17-git-send-email-paul.durrant@citrix.com> References: <1435145089-21999-1-git-send-email-paul.durrant@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z7j7X-0001LK-Es for xen-devel@lists.xenproject.org; Wed, 24 Jun 2015 11:45:35 +0000 In-Reply-To: <1435145089-21999-1-git-send-email-paul.durrant@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Andrew Cooper , Paul Durrant , Keir Fraser , Jan Beulich List-Id: xen-devel@lists.xenproject.org If memory mapped I/O is 'chunked' then the I/O must be re-emulated, otherwise only the first chunk will be processed. This patch makes sure all I/O from a buffer is re-emulated regardless of whether it is a read or a write. Signed-off-by: Paul Durrant Cc: Keir Fraser Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/hvm/emulate.c | 4 ++-- xen/arch/x86/hvm/hvm.c | 13 ++++++++----- xen/include/asm-x86/hvm/vcpu.h | 3 +-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index 6c50ef5..aa68787 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -148,7 +148,7 @@ static int hvmemul_do_io( (p.data_is_ptr != data_is_addr) ) domain_crash(curr->domain); - if ( data_is_addr || dir == IOREQ_WRITE ) + if ( data_is_addr ) return X86EMUL_UNHANDLEABLE; goto finish_access; default: @@ -188,7 +188,7 @@ static int hvmemul_do_io( rc = hvm_send_assist_req(s, &p); if ( rc != X86EMUL_RETRY ) vio->io_req.state = STATE_IOREQ_NONE; - else if ( data_is_addr || dir == IOREQ_WRITE ) + else if ( data_is_addr ) rc = X86EMUL_OKAY; } break; diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 8abf29b..c062c9f 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -501,11 +501,14 @@ void hvm_do_resume(struct vcpu *v) (void)handle_mmio(); break; case HVMIO_pio_completion: - if ( vio->io_req.size == 4 ) /* Needs zero extension. */ - guest_cpu_user_regs()->rax = (uint32_t)vio->io_req.data; - else - memcpy(&guest_cpu_user_regs()->rax, &vio->io_req.data, - vio->io_req.size); + if ( vio->io_req.dir == IOREQ_READ ) + { + if ( vio->io_req.size == 4 ) /* Needs zero extension. */ + guest_cpu_user_regs()->rax = (uint32_t)vio->io_req.data; + else + memcpy(&guest_cpu_user_regs()->rax, &vio->io_req.data, + vio->io_req.size); + } vio->io_req.state = STATE_IOREQ_NONE; break; case HVMIO_realmode_completion: diff --git a/xen/include/asm-x86/hvm/vcpu.h b/xen/include/asm-x86/hvm/vcpu.h index 7338638..008c8fa 100644 --- a/xen/include/asm-x86/hvm/vcpu.h +++ b/xen/include/asm-x86/hvm/vcpu.h @@ -49,8 +49,7 @@ struct hvm_vcpu_io { #define HVMIO_NEED_COMPLETION(_vio) \ ( ((_vio)->io_req.state == STATE_IOREQ_READY) && \ - !(_vio)->io_req.data_is_ptr && \ - ((_vio)->io_req.dir == IOREQ_READ) ) + !(_vio)->io_req.data_is_ptr ) /* * HVM emulation: -- 1.7.10.4