From: "Jan Beulich" Subject: Re: [PATCH v6 09/16] x86/hvm: limit reps to avoid the need to handle retry Date: Thu, 09 Jul 2015 11:05:27 +0100 Message-ID: <559E6387020000780008EAB5@mail.emea.novell.com> References: <1435940733-20856-1-git-send-email-paul.durrant@citrix.com> <1435940733-20856-10-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 1ZD8hu-0003v1-GB for xen-devel@lists.xenproject.org; Thu, 09 Jul 2015 10:05:30 +0000 In-Reply-To: <1435940733-20856-10-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: Andrew Cooper , Keir Fraser , xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org >>> On 03.07.15 at 18:25, wrote: > @@ -287,17 +271,56 @@ static int hvmemul_do_io_addr( > bool_t is_mmio, paddr_t addr, unsigned long *reps, > unsigned int size, uint8_t dir, bool_t df, paddr_t ram_gpa) > { > - struct page_info *ram_page; > + struct vcpu *v = current; > + unsigned long ram_gmfn = paddr_to_pfn(ram_gpa); > + unsigned int page_off = ram_gpa & (PAGE_SIZE - 1); > + struct page_info *ram_page[2]; > + int nr_pages = 0; unsigned int > + unsigned long count; > int rc; > > - rc = hvmemul_acquire_page(paddr_to_pfn(ram_gpa), &ram_page); > + rc = hvmemul_acquire_page(ram_gmfn, &ram_page[nr_pages]); > if ( rc != X86EMUL_OKAY ) > - return rc; > + goto out; > > - rc = hvmemul_do_io(is_mmio, addr, reps, size, dir, df, 1, > + nr_pages++; > + > + /* Detemine how many reps will fit within this page */ "Determine" and missing stop. > + count = min_t(unsigned long, > + *reps, > + df ? > + (page_off + size - 1) / size : Looks like this won't be correct for the page crossing case (where the code below really expects to see zero). I think you simply need to mask with (PAGE_SIZE - 1) again here before dividing. > @@ -468,6 +469,9 @@ void hvm_do_resume(struct vcpu *v) > } > } > > + if ( vio->mmio_retry ) > + (void)handle_mmio(); Pointless cast. Jan