From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v5 07/16] x86/hvm: unify dpci portio intercept with standard portio intercept Date: Thu, 2 Jul 2015 17:50:08 +0100 Message-ID: <55956BC0.1040702@citrix.com> References: <1435669558-5421-1-git-send-email-paul.durrant@citrix.com> <1435669558-5421-8-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.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZAhgk-0002ev-V7 for xen-devel@lists.xenproject.org; Thu, 02 Jul 2015 16:50:15 +0000 In-Reply-To: <1435669558-5421-8-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: Paul Durrant , xen-devel@lists.xenproject.org Cc: Keir Fraser , Jan Beulich List-Id: xen-devel@lists.xenproject.org On 30/06/15 14:05, Paul Durrant wrote: > This patch re-works the dpci portio intercepts so that they can be unified > with standard portio handling thereby removing a substantial amount of > code duplication. > > Signed-off-by: Paul Durrant > Cc: Keir Fraser > Cc: Jan Beulich > Cc: Andrew Cooper > --- > xen/arch/x86/hvm/hvm.c | 2 + > xen/arch/x86/hvm/intercept.c | 22 ++-- > xen/arch/x86/hvm/io.c | 220 ++++++++++++---------------------------- > xen/include/asm-x86/hvm/io.h | 5 + > xen/include/asm-x86/hvm/vcpu.h | 2 + > xen/include/xen/iommu.h | 1 - > 6 files changed, 80 insertions(+), 172 deletions(-) > > diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c > index 60f8972..6643e0c 100644 > --- a/xen/arch/x86/hvm/hvm.c > +++ b/xen/arch/x86/hvm/hvm.c > @@ -1486,6 +1486,8 @@ int hvm_domain_initialise(struct domain *d) > else > d->arch.hvm_domain.io_bitmap = hvm_io_bitmap; > > + register_dpci_portio_handler(d); > + > if ( is_pvh_domain(d) ) > { > register_portio_handler(d, 0, 0x10003, handle_pvh_io); > diff --git a/xen/arch/x86/hvm/intercept.c b/xen/arch/x86/hvm/intercept.c > index 42050f4..a613865 100644 > --- a/xen/arch/x86/hvm/intercept.c > +++ b/xen/arch/x86/hvm/intercept.c > @@ -124,10 +124,7 @@ static int hvm_process_io_intercept(const struct hvm_io_handler *handler, > { > struct vcpu *curr = current; > struct hvm_vcpu_io *vio = &curr->arch.hvm_vcpu.hvm_io; > - const struct hvm_io_ops *ops = > - (p->type == IOREQ_TYPE_COPY) ? > - &mmio_ops : > - &portio_ops; > + const struct hvm_io_ops *ops = handler->ops; > int rc = X86EMUL_OKAY, i, step = p->df ? -p->size : p->size; > uint64_t data; > uint64_t addr; > @@ -247,10 +244,6 @@ static int hvm_process_io_intercept(const struct hvm_io_handler *handler, > static const struct hvm_io_handler *hvm_find_io_handler(ioreq_t *p) > { > struct domain *curr_d = current->domain; > - const struct hvm_io_ops *ops = > - (p->type == IOREQ_TYPE_COPY) ? > - &mmio_ops : > - &portio_ops; > unsigned int i; > > BUG_ON((p->type != IOREQ_TYPE_PIO) && > @@ -260,6 +253,7 @@ static const struct hvm_io_handler *hvm_find_io_handler(ioreq_t *p) > { > const struct hvm_io_handler *handler = > &curr_d->arch.hvm_domain.io_handler[i]; > + const struct hvm_io_ops *ops = handler->ops; > > if ( handler->type != p->type ) > continue; > @@ -275,13 +269,7 @@ int hvm_io_intercept(ioreq_t *p) > { > const struct hvm_io_handler *handler; > > - if ( p->type == IOREQ_TYPE_PIO ) > - { > - int rc = dpci_ioport_intercept(p); > - if ( (rc == X86EMUL_OKAY) || (rc == X86EMUL_RETRY) ) > - return rc; > - } > - else if ( p->type == IOREQ_TYPE_COPY ) > + if ( p->type == IOREQ_TYPE_COPY ) > { > int rc = stdvga_intercept_mmio(p); > if ( (rc == X86EMUL_OKAY) || (rc == X86EMUL_RETRY) ) > @@ -296,7 +284,7 @@ int hvm_io_intercept(ioreq_t *p) > return hvm_process_io_intercept(handler, p); > } > > -static struct hvm_io_handler *hvm_next_io_handler(struct domain *d) > +struct hvm_io_handler *hvm_next_io_handler(struct domain *d) Instead of introducing this as a static in patch 5, then modifying it here to export it, introduce it directly as an exported function in 5. Otherwise, Reviewed-by: Andrew Cooper