From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: [PATCH for-4.6] tools/libxc: linux: Don't use getpagesize() when unmapping the grants Date: Fri, 7 Aug 2015 19:53:55 +0100 Message-ID: <1438973635-16517-1-git-send-email-julien.grall@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 1ZNmnF-0006xN-II for xen-devel@lists.xenproject.org; Fri, 07 Aug 2015 18:55:01 +0000 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: Wei Liu , ian.campbell@citrix.com, Stefano Stabellini , Ian Jackson , Julien Grall , stefano.stabellini@citrix.com List-Id: xen-devel@lists.xenproject.org The grants are based on the Xen granularity (i.e 4KB). While the function to map grants for Linux (linux_gnttab_grant_map) is using the correct size (XC_PAGE_SIZE), the unmap one (linux_gnttab_munmap) is using getpagesize(). On domain using a page granularity different than Xen (this is the case for AARCH64 guest using 64KB page), the unmap will be called with the wrong size. Signed-off-by: Julien Grall --- Cc: Ian Jackson Cc: Stefano Stabellini Cc: Ian Campbell Cc: Wei Liu This is a candidate for Xen 4.6 and backport for Xen 4.5. There is no functional changes for 4KB domain (i.e x86, arm32, arm64 when 4KB is used) but fixes a latent problem when the domain is using 64KB page on ARM64. The mmap is done correctly use XC_PAGE_SIZE but not the munmap. This will likely fail to unmap. I don't think it will unmap too much. I grepped getpagesize in the tools, and so far I haven't found any other in Xen specific code. There is some in blktap2 and QEMU. I don't think the former is that important for ARM64. I will take care of the latter in a separate series. --- tools/libxc/xc_linux_osdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/libxc/xc_linux_osdep.c b/tools/libxc/xc_linux_osdep.c index e375428..76c55ff 100644 --- a/tools/libxc/xc_linux_osdep.c +++ b/tools/libxc/xc_linux_osdep.c @@ -742,7 +742,7 @@ static int linux_gnttab_munmap(xc_gnttab *xcg, xc_osdep_handle h, } /* Next, unmap the memory. */ - if ( (rc = munmap(start_address, count * getpagesize())) ) + if ( (rc = munmap(start_address, count * XC_PAGE_SIZE)) ) return rc; /* Finally, unmap the driver slots used to store the grant information. */ -- 2.1.4