These changes introduce the page related definitions needed for mapping and
accessing guests memory. These values are intended to be used by any toolstack
component that needs to map guests memory. Until now, the values were defined
by the xenctrl.h header, therefore whenever a component had to use them it also
had to add a dependency for the xenctrl library.
This patch also introduces xen_mk_long() macrodefinition for defining long
constants both for C and assembler code.
Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
---
xen/include/public/page.h | 36 ++++++++++++++++++++++++++++++++++++
xen/include/public/xen.h | 3 +++
2 files changed, 39 insertions(+)
create mode 100644 xen/include/public/page.h
diff --git a/xen/include/public/page.h b/xen/include/public/page.h
new file mode 100644
index 0000000000..6b06259bad
--- /dev/null
+++ b/xen/include/public/page.h
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * page.h
+ *
+ * Page definitions for accessing guests memory
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Copyright (c) 2021, Costin Lupu
+ */
+
+#ifndef __XEN_PUBLIC_PAGE_H__
+#define __XEN_PUBLIC_PAGE_H__
+
+#include "xen.h"
+
+#define XEN_PAGE_SHIFT 12
+#define XEN_PAGE_SIZE (xen_mk_long(1) << XEN_PAGE_SHIFT)
+#define XEN_PAGE_MASK (~(XEN_PAGE_SIZE - 1))
+
+#endif /* __XEN_PUBLIC_PAGE_H__ */
diff --git a/xen/include/public/xen.h b/xen/include/public/xen.h
index e373592c33..12531c02b5 100644
--- a/xen/include/public/xen.h
+++ b/xen/include/public/xen.h
@@ -64,11 +64,13 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t);
/* Turn a plain number into a C unsigned (long (long)) constant. */
#define __xen_mk_uint(x) x ## U
+#define __xen_mk_long(x) x ## L
#define __xen_mk_ulong(x) x ## UL
#ifndef __xen_mk_ullong
# define __xen_mk_ullong(x) x ## ULL
#endif
#define xen_mk_uint(x) __xen_mk_uint(x)
+#define xen_mk_long(x) __xen_mk_long(x)
#define xen_mk_ulong(x) __xen_mk_ulong(x)
#define xen_mk_ullong(x) __xen_mk_ullong(x)
@@ -76,6 +78,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_ulong_t);
/* In assembly code we cannot use C numeric constant suffixes. */
#define xen_mk_uint(x) x
+#define xen_mk_long(x) x
#define xen_mk_ulong(x) x
#define xen_mk_ullong(x) x
--
2.20.1
On 19.08.2021 19:50, Costin Lupu wrote: > These changes introduce the page related definitions needed for mapping and > accessing guests memory. These values are intended to be used by any toolstack > component that needs to map guests memory. Until now, the values were defined > by the xenctrl.h header, therefore whenever a component had to use them it also > had to add a dependency for the xenctrl library. > > This patch also introduces xen_mk_long() macrodefinition for defining long > constants both for C and assembler code. I'm still missing justification for the addition of a new header, especially as I don't see that header to gain much more contents down the road. > --- /dev/null > +++ b/xen/include/public/page.h > @@ -0,0 +1,36 @@ > +/****************************************************************************** > + * page.h > + * > + * Page definitions for accessing guests memory > + * > + * Permission is hereby granted, free of charge, to any person obtaining a copy > + * of this software and associated documentation files (the "Software"), to > + * deal in the Software without restriction, including without limitation the > + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or > + * sell copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE > + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING > + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER > + * DEALINGS IN THE SOFTWARE. > + * > + * Copyright (c) 2021, Costin Lupu > + */ > + > +#ifndef __XEN_PUBLIC_PAGE_H__ > +#define __XEN_PUBLIC_PAGE_H__ > + > +#include "xen.h" > + > +#define XEN_PAGE_SHIFT 12 > +#define XEN_PAGE_SIZE (xen_mk_long(1) << XEN_PAGE_SHIFT) > +#define XEN_PAGE_MASK (~(XEN_PAGE_SIZE - 1)) You went too far here, I'm afraid: In reply to v1 I did say "The latter two, being identical ..." - XEN_PAGE_SHIFT ought to continue to be a per-arch constant, even if right now it is the same for Arm and x86. Thinking of which - with exposing this as a stable ABI (not just the abstraction, but the specific values and the fact that they're invariable become part of the stable ABI this way), what is the plan for supporting 64k(?) page size on Arm in the future? At that point you _cannot_ simply remove or replace the #define you add here. As the immediate need is by the tool stack, enclosing in #if defined(__XEN__) || defined(__XEN_TOOLS__) might be an option, with the downside of having stable libraries (foreignmemory and gnttab) depend on an unstable hypervisor interface (again). I can't seem to be able to think of anything better ... Jan
Hi Jan, Please see inline. On 8/20/21 9:52 AM, Jan Beulich wrote: > On 19.08.2021 19:50, Costin Lupu wrote: >> These changes introduce the page related definitions needed for mapping and >> accessing guests memory. These values are intended to be used by any toolstack >> component that needs to map guests memory. Until now, the values were defined >> by the xenctrl.h header, therefore whenever a component had to use them it also >> had to add a dependency for the xenctrl library. >> >> This patch also introduces xen_mk_long() macrodefinition for defining long >> constants both for C and assembler code. > > I'm still missing justification for the addition of a new header, especially > as I don't see that header to gain much more contents down the road. > For the first version, since it didn't need to include other headers, I thought it would make sense to isolate the definitions in their own headers. Now maybe it makes more sense to put the definitions in arch-x86/xen.h, arch-arm.h and xen.h (the latter two) respectively. What do you think? I'm open to suggestions here. >> --- /dev/null >> +++ b/xen/include/public/page.h >> @@ -0,0 +1,36 @@ >> +/****************************************************************************** >> + * page.h >> + * >> + * Page definitions for accessing guests memory >> + * >> + * Permission is hereby granted, free of charge, to any person obtaining a copy >> + * of this software and associated documentation files (the "Software"), to >> + * deal in the Software without restriction, including without limitation the >> + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or >> + * sell copies of the Software, and to permit persons to whom the Software is >> + * furnished to do so, subject to the following conditions: >> + * >> + * The above copyright notice and this permission notice shall be included in >> + * all copies or substantial portions of the Software. >> + * >> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR >> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, >> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE >> + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER >> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING >> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER >> + * DEALINGS IN THE SOFTWARE. >> + * >> + * Copyright (c) 2021, Costin Lupu >> + */ >> + >> +#ifndef __XEN_PUBLIC_PAGE_H__ >> +#define __XEN_PUBLIC_PAGE_H__ >> + >> +#include "xen.h" >> + >> +#define XEN_PAGE_SHIFT 12 >> +#define XEN_PAGE_SIZE (xen_mk_long(1) << XEN_PAGE_SHIFT) >> +#define XEN_PAGE_MASK (~(XEN_PAGE_SIZE - 1)) > > You went too far here, I'm afraid: In reply to v1 I did say "The latter > two, being identical ..." - XEN_PAGE_SHIFT ought to continue to be a > per-arch constant, even if right now it is the same for Arm and x86. > Alright, now I got it. > Thinking of which - with exposing this as a stable ABI (not just the > abstraction, but the specific values and the fact that they're > invariable become part of the stable ABI this way), what is the plan > for supporting 64k(?) page size on Arm in the future? At that point > you _cannot_ simply remove or replace the #define you add here. As > the immediate need is by the tool stack, enclosing in > > #if defined(__XEN__) || defined(__XEN_TOOLS__) > > might be an option, with the downside of having stable libraries > (foreignmemory and gnttab) depend on an unstable hypervisor interface > (again). I can't seem to be able to think of anything better ... Here I can be only guessing because I don't know all the requirements and I would need more input. One would have to add new values for ARM that would be enabled by some flag and then both the toolstack and the hypervisor would have to be rebuilt. With the current approach I don't think there is room for anything else, but I'm curious to hear about other ideas. Cheers, Costin
On 20.08.2021 09:44, Costin Lupu wrote: > On 8/20/21 9:52 AM, Jan Beulich wrote: >> On 19.08.2021 19:50, Costin Lupu wrote: >>> These changes introduce the page related definitions needed for mapping and >>> accessing guests memory. These values are intended to be used by any toolstack >>> component that needs to map guests memory. Until now, the values were defined >>> by the xenctrl.h header, therefore whenever a component had to use them it also >>> had to add a dependency for the xenctrl library. >>> >>> This patch also introduces xen_mk_long() macrodefinition for defining long >>> constants both for C and assembler code. >> >> I'm still missing justification for the addition of a new header, especially >> as I don't see that header to gain much more contents down the road. >> > > For the first version, since it didn't need to include other headers, I > thought it would make sense to isolate the definitions in their own > headers. Now maybe it makes more sense to put the definitions in > arch-x86/xen.h, arch-arm.h and xen.h (the latter two) respectively. What > do you think? I'm open to suggestions here. Well, yes, the headers you name are where I thought these new #define-s would go. Jan
Hi, Replying to a single e-mail for simplicity. On 20/08/2021 08:44, Costin Lupu wrote: > On 8/20/21 9:52 AM, Jan Beulich wrote: >>> --- /dev/null >>> +++ b/xen/include/public/page.h >>> @@ -0,0 +1,36 @@ >>> +/****************************************************************************** >>> + * page.h >>> + * >>> + * Page definitions for accessing guests memory >>> + * >>> + * Permission is hereby granted, free of charge, to any person obtaining a copy >>> + * of this software and associated documentation files (the "Software"), to >>> + * deal in the Software without restriction, including without limitation the >>> + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or >>> + * sell copies of the Software, and to permit persons to whom the Software is >>> + * furnished to do so, subject to the following conditions: >>> + * >>> + * The above copyright notice and this permission notice shall be included in >>> + * all copies or substantial portions of the Software. >>> + * >>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR >>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, >>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE >>> + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER >>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING >>> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER >>> + * DEALINGS IN THE SOFTWARE. >>> + * >>> + * Copyright (c) 2021, Costin Lupu >>> + */ >>> + >>> +#ifndef __XEN_PUBLIC_PAGE_H__ >>> +#define __XEN_PUBLIC_PAGE_H__ >>> + >>> +#include "xen.h" >>> + >>> +#define XEN_PAGE_SHIFT 12 >>> +#define XEN_PAGE_SIZE (xen_mk_long(1) << XEN_PAGE_SHIFT) This will use UL whereas on Arm a page frame should always be 64-bit regardless the bitness. Shouldn't this be converted to use xen_ulong_t instead? >>> +#define XEN_PAGE_MASK (~(XEN_PAGE_SIZE - 1)) >> >> You went too far here, I'm afraid: In reply to v1 I did say "The latter >> two, being identical ..." - XEN_PAGE_SHIFT ought to continue to be a >> per-arch constant, even if right now it is the same for Arm and x86. >> > > Alright, now I got it. > >> Thinking of which - with exposing this as a stable ABI (not just the >> abstraction, but the specific values and the fact that they're >> invariable become part of the stable ABI this way), what is the plan >> for supporting 64k(?) page size on Arm in the future? At that point >> you _cannot_ simply remove or replace the #define you add here. As >> the immediate need is by the tool stack, enclosing in I would like to get support for 64KB and 16KB pages in Xen (we already support in guests). But there is not much we can do with the current ABI as guests assume this is 4KB (that would break if Xen was using 64KB). >> >> #if defined(__XEN__) || defined(__XEN_TOOLS__) >> >> might be an option, with the downside of having stable libraries >> (foreignmemory and gnttab) depend on an unstable hypervisor interface >> (again). I can't seem to be able to think of anything better ... I am not sure why you write (again) here. The two libraries always assumed the hypervisor was using 4KB page granularity. But until recently it was also assuming that the OS page granularity matched. Our stable ABI has not been designed with multiple page granularity in mind. We could introduce a hypercall to query the page size used by the ABI. But then, I don't think we have the full picture of how this is going to pan out (I haven't try to use another page size on Xen yet). I think we have three choices here: 1) Stick with the existing definition in the tools 2) Move the definition in the public headers and only expose them to the tools. 3) Query the page size via a new hypervisor As I wrote above, 3) is going to take some time to get it right. So the question here is whether 2) is temporarily better than 1). I think it is because it at least clarify a long standing question on what is the granularity of page in the ABI. Cheers, -- Julien Grall
On 20.08.2021 11:08, Julien Grall wrote: > On 20/08/2021 08:44, Costin Lupu wrote: >> On 8/20/21 9:52 AM, Jan Beulich wrote: >>>> --- /dev/null >>>> +++ b/xen/include/public/page.h >>>> @@ -0,0 +1,36 @@ >>>> +/****************************************************************************** >>>> + * page.h >>>> + * >>>> + * Page definitions for accessing guests memory >>>> + * >>>> + * Permission is hereby granted, free of charge, to any person obtaining a copy >>>> + * of this software and associated documentation files (the "Software"), to >>>> + * deal in the Software without restriction, including without limitation the >>>> + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or >>>> + * sell copies of the Software, and to permit persons to whom the Software is >>>> + * furnished to do so, subject to the following conditions: >>>> + * >>>> + * The above copyright notice and this permission notice shall be included in >>>> + * all copies or substantial portions of the Software. >>>> + * >>>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR >>>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, >>>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE >>>> + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER >>>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING >>>> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER >>>> + * DEALINGS IN THE SOFTWARE. >>>> + * >>>> + * Copyright (c) 2021, Costin Lupu >>>> + */ >>>> + >>>> +#ifndef __XEN_PUBLIC_PAGE_H__ >>>> +#define __XEN_PUBLIC_PAGE_H__ >>>> + >>>> +#include "xen.h" >>>> + >>>> +#define XEN_PAGE_SHIFT 12 >>>> +#define XEN_PAGE_SIZE (xen_mk_long(1) << XEN_PAGE_SHIFT) > > This will use UL whereas on Arm a page frame should always be 64-bit > regardless the bitness. Shouldn't this be converted to use xen_ulong_t > instead? As pointed out on v1, XEN_PAGE_SIZE would better not end up as a value of signed type, for ... >>>> +#define XEN_PAGE_MASK (~(XEN_PAGE_SIZE - 1)) ... this to suitably sign-extend to wider types is necessary. Also unless you expect someone to use typeof(XEN_PAGE_SIZE) I'm afraid I don't see where the constant being long vs xen_long_t (if such existed) might matter. Otoh perhaps xen_mk_ulong() would better have produced a xen_ulong_t typed values in the first place, but I'm afraid we can't alter the existing macro. >>> Thinking of which - with exposing this as a stable ABI (not just the >>> abstraction, but the specific values and the fact that they're >>> invariable become part of the stable ABI this way), what is the plan >>> for supporting 64k(?) page size on Arm in the future? At that point >>> you _cannot_ simply remove or replace the #define you add here. As >>> the immediate need is by the tool stack, enclosing in > > I would like to get support for 64KB and 16KB pages in Xen (we already > support in guests). But there is not much we can do with the current ABI > as guests assume this is 4KB (that would break if Xen was using 64KB). > >>> >>> #if defined(__XEN__) || defined(__XEN_TOOLS__) >>> >>> might be an option, with the downside of having stable libraries >>> (foreignmemory and gnttab) depend on an unstable hypervisor interface >>> (again). I can't seem to be able to think of anything better ... > I am not sure why you write (again) here. The two libraries always > assumed the hypervisor was using 4KB page granularity. But until > recently it was also assuming that the OS page granularity matched. Assuming 4k page size was a plain assumption imo, not reliance on a stable hypervisor interface. Just like is assuming OS and hypervisor page sizes would match. I wrote "(again)" because at least the foreignmemory code was, iirc, split off of libxc at some point, i.e. used to be unstable and hence was "fine" to rely on unstable hypervisor interfaces. > Our stable ABI has not been designed with multiple page granularity in > mind. We could introduce a hypercall to query the page size used by the > ABI. But then, I don't think we have the full picture of how this is > going to pan out (I haven't try to use another page size on Xen yet). > > I think we have three choices here: > 1) Stick with the existing definition in the tools > 2) Move the definition in the public headers and only expose them to > the tools. > 3) Query the page size via a new hypervisor > > As I wrote above, 3) is going to take some time to get it right. So the > question here is whether 2) is temporarily better than 1). Because I understand 3) is some way out, and because I think 2) is better than 1), I wrote "might be an option" for what you call 2). But I could see people (Andrew for example) to take a different position and object to such a temporary measure. Jan
Hi Jan, On 20/08/2021 10:26, Jan Beulich wrote: > On 20.08.2021 11:08, Julien Grall wrote: >> On 20/08/2021 08:44, Costin Lupu wrote: >>> On 8/20/21 9:52 AM, Jan Beulich wrote: >>>>> --- /dev/null >>>>> +++ b/xen/include/public/page.h >>>>> @@ -0,0 +1,36 @@ >>>>> +/****************************************************************************** >>>>> + * page.h >>>>> + * >>>>> + * Page definitions for accessing guests memory >>>>> + * >>>>> + * Permission is hereby granted, free of charge, to any person obtaining a copy >>>>> + * of this software and associated documentation files (the "Software"), to >>>>> + * deal in the Software without restriction, including without limitation the >>>>> + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or >>>>> + * sell copies of the Software, and to permit persons to whom the Software is >>>>> + * furnished to do so, subject to the following conditions: >>>>> + * >>>>> + * The above copyright notice and this permission notice shall be included in >>>>> + * all copies or substantial portions of the Software. >>>>> + * >>>>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR >>>>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, >>>>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE >>>>> + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER >>>>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING >>>>> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER >>>>> + * DEALINGS IN THE SOFTWARE. >>>>> + * >>>>> + * Copyright (c) 2021, Costin Lupu >>>>> + */ >>>>> + >>>>> +#ifndef __XEN_PUBLIC_PAGE_H__ >>>>> +#define __XEN_PUBLIC_PAGE_H__ >>>>> + >>>>> +#include "xen.h" >>>>> + >>>>> +#define XEN_PAGE_SHIFT 12 >>>>> +#define XEN_PAGE_SIZE (xen_mk_long(1) << XEN_PAGE_SHIFT) >> >> This will use UL whereas on Arm a page frame should always be 64-bit >> regardless the bitness. Shouldn't this be converted to use xen_ulong_t >> instead? > > As pointed out on v1, XEN_PAGE_SIZE would better not end up as a > value of signed type, for ... Did you mean "not end up as a value of **unsigned** type"... > >>>>> +#define XEN_PAGE_MASK (~(XEN_PAGE_SIZE - 1)) > > ... this to suitably sign-extend to wider types is necessary. ... because, if I am not mistaken, the sign-extension wouldn't happen with unsigned type. But then on v1 you wrote: "Imo the smallest type this should evaluate to is xen_ulong_t" Which I interpreted as this value should be 64-bit on Arm32. If this not what you meant then I am lost. > > Also unless you expect someone to use typeof(XEN_PAGE_SIZE) I'm > afraid I don't see where the constant being long vs xen_long_t > (if such existed) might matter. > Otoh perhaps xen_mk_ulong() would > better have produced a xen_ulong_t typed values in the first > place, but I'm afraid we can't alter the existing macro. We can create a new one. >> Our stable ABI has not been designed with multiple page granularity in >> mind. We could introduce a hypercall to query the page size used by the >> ABI. But then, I don't think we have the full picture of how this is >> going to pan out (I haven't try to use another page size on Xen yet). >> >> I think we have three choices here: >> 1) Stick with the existing definition in the tools >> 2) Move the definition in the public headers and only expose them to >> the tools. >> 3) Query the page size via a new hypervisor >> >> As I wrote above, 3) is going to take some time to get it right. So the >> question here is whether 2) is temporarily better than 1). > > Because I understand 3) is some way out, and because I think 2) is > better than 1), I wrote "might be an option" for what you call 2). > But I could see people (Andrew for example) to take a different > position and object to such a temporary measure. I think we need to make a decision so Costin doesn't keep sending version on something that can't be merged. What does the others thinks? Cheers, -- Julien Grall
On 23.08.2021 19:16, Julien Grall wrote: > Hi Jan, > > On 20/08/2021 10:26, Jan Beulich wrote: >> On 20.08.2021 11:08, Julien Grall wrote: >>> On 20/08/2021 08:44, Costin Lupu wrote: >>>> On 8/20/21 9:52 AM, Jan Beulich wrote: >>>>>> --- /dev/null >>>>>> +++ b/xen/include/public/page.h >>>>>> @@ -0,0 +1,36 @@ >>>>>> +/****************************************************************************** >>>>>> + * page.h >>>>>> + * >>>>>> + * Page definitions for accessing guests memory >>>>>> + * >>>>>> + * Permission is hereby granted, free of charge, to any person obtaining a copy >>>>>> + * of this software and associated documentation files (the "Software"), to >>>>>> + * deal in the Software without restriction, including without limitation the >>>>>> + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or >>>>>> + * sell copies of the Software, and to permit persons to whom the Software is >>>>>> + * furnished to do so, subject to the following conditions: >>>>>> + * >>>>>> + * The above copyright notice and this permission notice shall be included in >>>>>> + * all copies or substantial portions of the Software. >>>>>> + * >>>>>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR >>>>>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, >>>>>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE >>>>>> + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER >>>>>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING >>>>>> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER >>>>>> + * DEALINGS IN THE SOFTWARE. >>>>>> + * >>>>>> + * Copyright (c) 2021, Costin Lupu >>>>>> + */ >>>>>> + >>>>>> +#ifndef __XEN_PUBLIC_PAGE_H__ >>>>>> +#define __XEN_PUBLIC_PAGE_H__ >>>>>> + >>>>>> +#include "xen.h" >>>>>> + >>>>>> +#define XEN_PAGE_SHIFT 12 >>>>>> +#define XEN_PAGE_SIZE (xen_mk_long(1) << XEN_PAGE_SHIFT) >>> >>> This will use UL whereas on Arm a page frame should always be 64-bit >>> regardless the bitness. Shouldn't this be converted to use xen_ulong_t >>> instead? >> >> As pointed out on v1, XEN_PAGE_SIZE would better not end up as a >> value of signed type, for ... > > Did you mean "not end up as a value of **unsigned** type"... Oh, of course I did. I'm sorry for the confusion caused. >>>>>> +#define XEN_PAGE_MASK (~(XEN_PAGE_SIZE - 1)) >> >> ... this to suitably sign-extend to wider types is necessary. > > ... because, if I am not mistaken, the sign-extension wouldn't happen > with unsigned type. But then on v1 you wrote: > > "Imo the smallest type this should evaluate to is xen_ulong_t" > > Which I interpreted as this value should be 64-bit on Arm32. If this not > what you meant then I am lost. And there I would better have said "If indeed unsigned for whatever reason, the smallest type this should evaluate to is xen_ulong_t." >> Also unless you expect someone to use typeof(XEN_PAGE_SIZE) I'm >> afraid I don't see where the constant being long vs xen_long_t >> (if such existed) might matter. >> Otoh perhaps xen_mk_ulong() would >> better have produced a xen_ulong_t typed values in the first >> place, but I'm afraid we can't alter the existing macro. > > We can create a new one. But we shouldn't carelessly add stuff, as we can't later remove it. Jan
Hi guys, On 8/23/21 8:16 PM, Julien Grall wrote: > Hi Jan, > > On 20/08/2021 10:26, Jan Beulich wrote: >> On 20.08.2021 11:08, Julien Grall wrote: >>> On 20/08/2021 08:44, Costin Lupu wrote: >>>> On 8/20/21 9:52 AM, Jan Beulich wrote: >>>>>> --- /dev/null >>>>>> +++ b/xen/include/public/page.h >>>>>> @@ -0,0 +1,36 @@ >>>>>> +/****************************************************************************** >>>>>> >>>>>> + * page.h >>>>>> + * >>>>>> + * Page definitions for accessing guests memory >>>>>> + * >>>>>> + * Permission is hereby granted, free of charge, to any person >>>>>> obtaining a copy >>>>>> + * of this software and associated documentation files (the >>>>>> "Software"), to >>>>>> + * deal in the Software without restriction, including without >>>>>> limitation the >>>>>> + * rights to use, copy, modify, merge, publish, distribute, >>>>>> sublicense, and/or >>>>>> + * sell copies of the Software, and to permit persons to whom the >>>>>> Software is >>>>>> + * furnished to do so, subject to the following conditions: >>>>>> + * >>>>>> + * The above copyright notice and this permission notice shall be >>>>>> included in >>>>>> + * all copies or substantial portions of the Software. >>>>>> + * >>>>>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY >>>>>> KIND, EXPRESS OR >>>>>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF >>>>>> MERCHANTABILITY, >>>>>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO >>>>>> EVENT SHALL THE >>>>>> + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES >>>>>> OR OTHER >>>>>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR >>>>>> OTHERWISE, ARISING >>>>>> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR >>>>>> OTHER >>>>>> + * DEALINGS IN THE SOFTWARE. >>>>>> + * >>>>>> + * Copyright (c) 2021, Costin Lupu >>>>>> + */ >>>>>> + >>>>>> +#ifndef __XEN_PUBLIC_PAGE_H__ >>>>>> +#define __XEN_PUBLIC_PAGE_H__ >>>>>> + >>>>>> +#include "xen.h" >>>>>> + >>>>>> +#define XEN_PAGE_SHIFT 12 >>>>>> +#define XEN_PAGE_SIZE (xen_mk_long(1) << XEN_PAGE_SHIFT) >>> >>> This will use UL whereas on Arm a page frame should always be 64-bit >>> regardless the bitness. Shouldn't this be converted to use xen_ulong_t >>> instead? >> >> As pointed out on v1, XEN_PAGE_SIZE would better not end up as a >> value of signed type, for ... > > Did you mean "not end up as a value of **unsigned** type"... > >> >>>>>> +#define XEN_PAGE_MASK (~(XEN_PAGE_SIZE - 1)) >> >> ... this to suitably sign-extend to wider types is necessary. > > ... because, if I am not mistaken, the sign-extension wouldn't happen > with unsigned type. But then on v1 you wrote: > > "Imo the smallest type this should evaluate to is xen_ulong_t" > > Which I interpreted as this value should be 64-bit on Arm32. If this not > what you meant then I am lost. > >> >> Also unless you expect someone to use typeof(XEN_PAGE_SIZE) I'm >> afraid I don't see where the constant being long vs xen_long_t >> (if such existed) might matter. >> Otoh perhaps xen_mk_ulong() would >> better have produced a xen_ulong_t typed values in the first >> place, but I'm afraid we can't alter the existing macro. > > We can create a new one. > >>> Our stable ABI has not been designed with multiple page granularity in >>> mind. We could introduce a hypercall to query the page size used by the >>> ABI. But then, I don't think we have the full picture of how this is >>> going to pan out (I haven't try to use another page size on Xen yet). >>> >>> I think we have three choices here: >>> 1) Stick with the existing definition in the tools >>> 2) Move the definition in the public headers and only expose them to >>> the tools. >>> 3) Query the page size via a new hypervisor >>> >>> As I wrote above, 3) is going to take some time to get it right. So the >>> question here is whether 2) is temporarily better than 1). >> >> Because I understand 3) is some way out, and because I think 2) is >> better than 1), I wrote "might be an option" for what you call 2). >> But I could see people (Andrew for example) to take a different >> position and object to such a temporary measure. > > I think we need to make a decision so Costin doesn't keep sending > version on something that can't be merged. What does the others thinks? From what I understood, in his last reply to 'stubdom: foreignmemory: Fix build after 0dbb4be739c5' thread, Andrew was OK with solution 2). Cheers, Costin
On 24.08.2021 15:03, Costin Lupu wrote: > On 8/23/21 8:16 PM, Julien Grall wrote: >> On 20/08/2021 10:26, Jan Beulich wrote: >>> On 20.08.2021 11:08, Julien Grall wrote: >>>> On 20/08/2021 08:44, Costin Lupu wrote: >>>>> On 8/20/21 9:52 AM, Jan Beulich wrote: >>>>>>> --- /dev/null >>>>>>> +++ b/xen/include/public/page.h >>>>>>> @@ -0,0 +1,36 @@ >>>>>>> +/****************************************************************************** >>>>>>> >>>>>>> + * page.h >>>>>>> + * >>>>>>> + * Page definitions for accessing guests memory >>>>>>> + * >>>>>>> + * Permission is hereby granted, free of charge, to any person >>>>>>> obtaining a copy >>>>>>> + * of this software and associated documentation files (the >>>>>>> "Software"), to >>>>>>> + * deal in the Software without restriction, including without >>>>>>> limitation the >>>>>>> + * rights to use, copy, modify, merge, publish, distribute, >>>>>>> sublicense, and/or >>>>>>> + * sell copies of the Software, and to permit persons to whom the >>>>>>> Software is >>>>>>> + * furnished to do so, subject to the following conditions: >>>>>>> + * >>>>>>> + * The above copyright notice and this permission notice shall be >>>>>>> included in >>>>>>> + * all copies or substantial portions of the Software. >>>>>>> + * >>>>>>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY >>>>>>> KIND, EXPRESS OR >>>>>>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF >>>>>>> MERCHANTABILITY, >>>>>>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO >>>>>>> EVENT SHALL THE >>>>>>> + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES >>>>>>> OR OTHER >>>>>>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR >>>>>>> OTHERWISE, ARISING >>>>>>> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR >>>>>>> OTHER >>>>>>> + * DEALINGS IN THE SOFTWARE. >>>>>>> + * >>>>>>> + * Copyright (c) 2021, Costin Lupu >>>>>>> + */ >>>>>>> + >>>>>>> +#ifndef __XEN_PUBLIC_PAGE_H__ >>>>>>> +#define __XEN_PUBLIC_PAGE_H__ >>>>>>> + >>>>>>> +#include "xen.h" >>>>>>> + >>>>>>> +#define XEN_PAGE_SHIFT 12 >>>>>>> +#define XEN_PAGE_SIZE (xen_mk_long(1) << XEN_PAGE_SHIFT) >>>> >>>> This will use UL whereas on Arm a page frame should always be 64-bit >>>> regardless the bitness. Shouldn't this be converted to use xen_ulong_t >>>> instead? >>> >>> As pointed out on v1, XEN_PAGE_SIZE would better not end up as a >>> value of signed type, for ... >> >> Did you mean "not end up as a value of **unsigned** type"... >> >>> >>>>>>> +#define XEN_PAGE_MASK (~(XEN_PAGE_SIZE - 1)) >>> >>> ... this to suitably sign-extend to wider types is necessary. >> >> ... because, if I am not mistaken, the sign-extension wouldn't happen >> with unsigned type. But then on v1 you wrote: >> >> "Imo the smallest type this should evaluate to is xen_ulong_t" >> >> Which I interpreted as this value should be 64-bit on Arm32. If this not >> what you meant then I am lost. >> >>> >>> Also unless you expect someone to use typeof(XEN_PAGE_SIZE) I'm >>> afraid I don't see where the constant being long vs xen_long_t >>> (if such existed) might matter. >>> Otoh perhaps xen_mk_ulong() would >>> better have produced a xen_ulong_t typed values in the first >>> place, but I'm afraid we can't alter the existing macro. >> >> We can create a new one. >> >>>> Our stable ABI has not been designed with multiple page granularity in >>>> mind. We could introduce a hypercall to query the page size used by the >>>> ABI. But then, I don't think we have the full picture of how this is >>>> going to pan out (I haven't try to use another page size on Xen yet). >>>> >>>> I think we have three choices here: >>>> 1) Stick with the existing definition in the tools >>>> 2) Move the definition in the public headers and only expose them to >>>> the tools. >>>> 3) Query the page size via a new hypervisor >>>> >>>> As I wrote above, 3) is going to take some time to get it right. So the >>>> question here is whether 2) is temporarily better than 1). >>> >>> Because I understand 3) is some way out, and because I think 2) is >>> better than 1), I wrote "might be an option" for what you call 2). >>> But I could see people (Andrew for example) to take a different >>> position and object to such a temporary measure. >> >> I think we need to make a decision so Costin doesn't keep sending >> version on something that can't be merged. What does the others thinks? > > From what I understood, in his last reply to 'stubdom: foreignmemory: > Fix build after 0dbb4be739c5' thread, Andrew was OK with solution 2). I agree it can be read this way. Jan
© 2016 - 2026 Red Hat, Inc.