From: Ian Campbell Subject: Re: Error ignored in xc_map_foreign_pages Date: Thu, 13 Feb 2014 10:00:32 +0000 Message-ID: <1392285632.27366.8.camel@kazak.uk.xensource.com> References: <20140212185352.4c920a54@mantra.us.oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20140212185352.4c920a54@mantra.us.oracle.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: Mukesh Rathor Cc: "Xen-devel@lists.xensource.com" , Andres Lagar-Cavilla , Julien Grall , Ian Jackson , David Vrabel , Jan Beulich List-Id: xen-devel@lists.xenproject.org On Wed, 2014-02-12 at 18:53 -0800, Mukesh Rathor wrote: > It appears that xc_map_foreign_pages() handles return incorrectly : libxc is a complete mess in this regard (error handling) generally. IIRC there is some subtlety on the Linux privcmd side wrt partial failure of batches, particularly once paging/sharing gets involved and you want to retry the missing subset, which might have something to do with this. David and Andres might know if that is relevant here. > res = xc_map_foreign_bulk(xch, dom, prot, arr, err, num); > if (res) { > for (i = 0; i < num; i++) { > if (err[i]) { > errno = -err[i]; > munmap(res, num * PAGE_SIZE); > res = NULL; > break; > } > } > } > > The add to_physmap batch'd interface actually will store errors > in the err array, and return 0 unless EFAULT or something like that. > See xenmem_add_to_physmap_batch(). The case I'm looking at, xentrace > calls here to map page which fails, but the return is 0 as the error is > succesfully copied by xen. But the error is missed above since res is 0. > xentrace does something again, and that causes xen crash. > > It appears the fix could be just removing the check for res above... > > res = xc_map_foreign_bulk(xch, dom, prot, arr, err, num); > for (i = 0; i < num; i++) { > if (err[i]) { > ..... > > What do you guys think? > > thanks, > Mukesh