From: "Jan Beulich" Subject: Re: [PATCH v6 05/16] x86/hvm: unify internal portio and mmio intercepts Date: Wed, 08 Jul 2015 17:28:52 +0100 Message-ID: <559D6BE4020000780008E661@mail.emea.novell.com> References: <1435940733-20856-1-git-send-email-paul.durrant@citrix.com> <1435940733-20856-6-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 1ZCsDO-0006dL-Mk for xen-devel@lists.xenproject.org; Wed, 08 Jul 2015 16:28:54 +0000 In-Reply-To: <1435940733-20856-6-git-send-email-paul.durrant@citrix.com> Content-Disposition: inline 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 Cc: xen-devel@lists.xenproject.org, Keir Fraser List-Id: xen-devel@lists.xenproject.org >>> On 03.07.15 at 18:25, wrote: > -void relocate_io_handler( > - struct domain *d, unsigned long old_addr, unsigned long new_addr, > - unsigned int size, int type) > +void relocate_portio_handler(struct domain *d, uint16_t old_port, > + uint16_t new_port, unsigned int size) > { > - struct hvm_io_handler *handler = d->arch.hvm_domain.io_handler; > - int i; > - > - for ( i = 0; i < handler->num_slot; i++ ) > - if ( (handler->hdl_list[i].addr == old_addr) && > - (handler->hdl_list[i].size == size) && > - (handler->hdl_list[i].type == type) ) > - handler->hdl_list[i].addr = new_addr; > + unsigned int i; > + > + for ( i = 0; i < d->arch.hvm_domain.io_handler_count; i++ ) > + { > + struct hvm_io_handler *handler = > + &d->arch.hvm_domain.io_handler[i]; > + > + if ( handler->type != IOREQ_TYPE_PIO ) > + continue; > + > + if ( (handler->portio.start == old_port) && > + (handler->portio.end = old_port + size) ) > + { > + handler->portio.start = new_port; > + handler->portio.end = new_port + size; > + break; > + } > + } > +} I'm afraid you're introducing a race with the consumer of this data here: Previously the update consisted of a single write, i.e. the consumer would see either the old or the new data. After the change it may see partially updated state. Jan