* [PATCH for-4.6] tools/libxc: linux: Don't use getpagesize() when unmapping the grants
@ 2015-08-07 18:53 Julien Grall
2015-08-07 21:45 ` Wei Liu
0 siblings, 1 reply; 5+ messages in thread
From: Julien Grall @ 2015-08-07 18:53 UTC (permalink / raw)
To: xen-devel
Cc: Wei Liu, ian.campbell, Stefano Stabellini, Ian Jackson,
Julien Grall, stefano.stabellini
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 <julien.grall@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH for-4.6] tools/libxc: linux: Don't use getpagesize() when unmapping the grants
2015-08-07 18:53 [PATCH for-4.6] tools/libxc: linux: Don't use getpagesize() when unmapping the grants Julien Grall
@ 2015-08-07 21:45 ` Wei Liu
2015-08-11 12:48 ` Ian Campbell
0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2015-08-07 21:45 UTC (permalink / raw)
To: Julien Grall
Cc: Wei.Liu2, ian.campbell, Stefano Stabellini, Ian Jackson,
stefano.stabellini, xen-devel
On Fri, Aug 07, 2015 at 07:53:55PM +0100, Julien Grall wrote:
> 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 <julien.grall@citrix.com>
>
> ---
> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Cc: Ian Campbell <ian.campbell@citrix.com>
> Cc: Wei Liu <wei.liu2@citrix.com>
>
Acked-by: Wei Liu <wei.liu2@citrix.com>
I think this is a bug fix and should be applied for 4.6.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH for-4.6] tools/libxc: linux: Don't use getpagesize() when unmapping the grants
2015-08-07 21:45 ` Wei Liu
@ 2015-08-11 12:48 ` Ian Campbell
2015-08-12 10:07 ` Julien Grall
2015-08-13 10:31 ` Ian Campbell
0 siblings, 2 replies; 5+ messages in thread
From: Ian Campbell @ 2015-08-11 12:48 UTC (permalink / raw)
To: Wei Liu, Julien Grall
Cc: xen-devel, stefano.stabellini, Ian Jackson, Stefano Stabellini
On Fri, 2015-08-07 at 22:45 +0100, Wei Liu wrote:
> On Fri, Aug 07, 2015 at 07:53:55PM +0100, Julien Grall wrote:
> > 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 <julien.grall@citrix.com>
> >
> > ---
> > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > Cc: Ian Campbell <ian.campbell@citrix.com>
> > Cc: Wei Liu <wei.liu2@citrix.com>
> >
>
> Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
> I think this is a bug fix and should be applied for 4.6.
Agreed.
WRT to backports for 4.5 I'd appreciate being given a full list of required
fixes once everything is in place and working for 4.6/devbranch rather than
my tracking it piecemeal.
Ian.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH for-4.6] tools/libxc: linux: Don't use getpagesize() when unmapping the grants
2015-08-11 12:48 ` Ian Campbell
@ 2015-08-12 10:07 ` Julien Grall
2015-08-13 10:31 ` Ian Campbell
1 sibling, 0 replies; 5+ messages in thread
From: Julien Grall @ 2015-08-12 10:07 UTC (permalink / raw)
To: Ian Campbell, Wei Liu
Cc: xen-devel, stefano.stabellini, Ian Jackson, Stefano Stabellini
Hi Ian,
On 11/08/2015 13:48, Ian Campbell wrote:
> On Fri, 2015-08-07 at 22:45 +0100, Wei Liu wrote:
>> On Fri, Aug 07, 2015 at 07:53:55PM +0100, Julien Grall wrote:
>>> 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 <julien.grall@citrix.com>
>>>
>>> ---
>>> Cc: Ian Jackson <ian.jackson@eu.citrix.com>
>>> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>>> Cc: Ian Campbell <ian.campbell@citrix.com>
>>> Cc: Wei Liu <wei.liu2@citrix.com>
>>>
>>
>> Acked-by: Wei Liu <wei.liu2@citrix.com>
>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
>
>> I think this is a bug fix and should be applied for 4.6.
>
> Agreed.
>
> WRT to backports for 4.5 I'd appreciate being given a full list of required
> fixes once everything is in place and working for 4.6/devbranch rather than
> my tracking it piecemeal.
I have a working branch with Xen tools running on 64KB, and I didn't
expected to find another problem.
I spotted this one by reading the code and see inconsistency between the
mmap and the mmunmap. And I'm sure I haven't spot all the things because
testing every configuration to see if 64KB guest are working is a huge work.
Anyway, I will send a mail with all the patch to backport.
Regards,
--
Julien Grall
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH for-4.6] tools/libxc: linux: Don't use getpagesize() when unmapping the grants
2015-08-11 12:48 ` Ian Campbell
2015-08-12 10:07 ` Julien Grall
@ 2015-08-13 10:31 ` Ian Campbell
1 sibling, 0 replies; 5+ messages in thread
From: Ian Campbell @ 2015-08-13 10:31 UTC (permalink / raw)
To: Wei Liu, Julien Grall
Cc: xen-devel, stefano.stabellini, Ian Jackson, Stefano Stabellini
On Tue, 2015-08-11 at 13:48 +0100, Ian Campbell wrote:
> On Fri, 2015-08-07 at 22:45 +0100, Wei Liu wrote:
> > On Fri, Aug 07, 2015 at 07:53:55PM +0100, Julien Grall wrote:
> > > 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 <julien.grall@citrix.com>
> > >
> > > ---
> > > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > > Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > > Cc: Ian Campbell <ian.campbell@citrix.com>
> > > Cc: Wei Liu <wei.liu2@citrix.com>
> > >
> >
> > Acked-by: Wei Liu <wei.liu2@citrix.com>
>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
>
> > I think this is a bug fix and should be applied for 4.6.
I took this as a release ack and applied.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-08-13 10:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-07 18:53 [PATCH for-4.6] tools/libxc: linux: Don't use getpagesize() when unmapping the grants Julien Grall
2015-08-07 21:45 ` Wei Liu
2015-08-11 12:48 ` Ian Campbell
2015-08-12 10:07 ` Julien Grall
2015-08-13 10:31 ` Ian Campbell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).