* [PATCH] tools/libxc: Correct XC_DOM_PAGE_SIZE() to return a long long
@ 2015-11-19 14:45 Andrew Cooper
2015-11-19 16:50 ` Wei Liu
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cooper @ 2015-11-19 14:45 UTC (permalink / raw)
To: Xen-devel; +Cc: Andrew Cooper, Ian Jackson, Ian Campbell, Wei Liu
c/s abdf3c5b "libxc: create p2m list outside of kernel mapping if supported"
introduces a use which Coverity objects to; an int used to mask a uint64_t.
The result needs to be signed to allow ~XC_DOM_PAGE_SIZE() to function
correctly, and long long to function properly in 32bit builds.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Ian Campbell <Ian.Campbell@citrix.com>
CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
---
tools/libxc/include/xc_dom.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h
index 6f0c6e0..2176216 100644
--- a/tools/libxc/include/xc_dom.h
+++ b/tools/libxc/include/xc_dom.h
@@ -249,7 +249,7 @@ struct xc_dom_arch {
void xc_dom_register_arch_hooks(struct xc_dom_arch *hooks);
#define XC_DOM_PAGE_SHIFT(dom) ((dom)->arch_hooks->page_shift)
-#define XC_DOM_PAGE_SIZE(dom) (1 << (dom)->arch_hooks->page_shift)
+#define XC_DOM_PAGE_SIZE(dom) (1LL << (dom)->arch_hooks->page_shift)
/* --- main functions ---------------------------------------------- */
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] tools/libxc: Correct XC_DOM_PAGE_SIZE() to return a long long
2015-11-19 14:45 [PATCH] tools/libxc: Correct XC_DOM_PAGE_SIZE() to return a long long Andrew Cooper
@ 2015-11-19 16:50 ` Wei Liu
2015-11-19 17:01 ` Andrew Cooper
0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2015-11-19 16:50 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Wei Liu, Ian Jackson, Ian Campbell, Xen-devel
On Thu, Nov 19, 2015 at 02:45:41PM +0000, Andrew Cooper wrote:
> c/s abdf3c5b "libxc: create p2m list outside of kernel mapping if supported"
> introduces a use which Coverity objects to; an int used to mask a uint64_t.
>
> The result needs to be signed to allow ~XC_DOM_PAGE_SIZE() to function
$ git grep XC_DOM_PAGE_SIZE
tools/libxc/include/xc_dom.h:#define XC_DOM_PAGE_SIZE(dom) (1 << (dom)->arch_hooks
tools/libxc/include/xc_dom.h: unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
tools/libxc/xc_dom_core.c: unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
tools/libxc/xc_dom_core.c: unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
tools/libxc/xc_dom_core.c: unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
tools/libxc/xc_dom_core.c: unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
tools/libxc/xc_dom_core.c: page_size = XC_DOM_PAGE_SIZE(dom);
tools/libxc/xc_dom_core.c: (dom->parms.p2m_base & (XC_DOM_PAGE_SIZE(dom) - 1
tools/libxc/xc_dom_elfloader.c: elf->dest_size = pages * XC_DOM_PAGE_SIZE(dom);
tools/libxc/xc_dom_hvmloader.c: elf->dest_size = pages * XC_DOM_PAGE_SIZE(dom);
tools/libxc/xc_dom_x86.c: memset(l3tab, 0, XC_DOM_PAGE_SIZE(dom));
There is no use for ~XC_DOM_PAGE_SIZE.
And what is the possible scenario you want that?
> correctly, and long long to function properly in 32bit builds.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Ian Campbell <Ian.Campbell@citrix.com>
> CC: Ian Jackson <Ian.Jackson@eu.citrix.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> ---
> tools/libxc/include/xc_dom.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h
> index 6f0c6e0..2176216 100644
> --- a/tools/libxc/include/xc_dom.h
> +++ b/tools/libxc/include/xc_dom.h
> @@ -249,7 +249,7 @@ struct xc_dom_arch {
> void xc_dom_register_arch_hooks(struct xc_dom_arch *hooks);
>
> #define XC_DOM_PAGE_SHIFT(dom) ((dom)->arch_hooks->page_shift)
> -#define XC_DOM_PAGE_SIZE(dom) (1 << (dom)->arch_hooks->page_shift)
> +#define XC_DOM_PAGE_SIZE(dom) (1LL << (dom)->arch_hooks->page_shift)
>
> /* --- main functions ---------------------------------------------- */
>
> --
> 2.1.4
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] tools/libxc: Correct XC_DOM_PAGE_SIZE() to return a long long
2015-11-19 16:50 ` Wei Liu
@ 2015-11-19 17:01 ` Andrew Cooper
2015-11-20 11:30 ` Wei Liu
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cooper @ 2015-11-19 17:01 UTC (permalink / raw)
To: Wei Liu; +Cc: Ian Jackson, Ian Campbell, Xen-devel
On 19/11/15 16:50, Wei Liu wrote:
> On Thu, Nov 19, 2015 at 02:45:41PM +0000, Andrew Cooper wrote:
>> c/s abdf3c5b "libxc: create p2m list outside of kernel mapping if supported"
>> introduces a use which Coverity objects to; an int used to mask a uint64_t.
>>
>> The result needs to be signed to allow ~XC_DOM_PAGE_SIZE() to function
> $ git grep XC_DOM_PAGE_SIZE
>
> tools/libxc/include/xc_dom.h:#define XC_DOM_PAGE_SIZE(dom) (1 << (dom)->arch_hooks
> tools/libxc/include/xc_dom.h: unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
> tools/libxc/xc_dom_core.c: unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
> tools/libxc/xc_dom_core.c: unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
> tools/libxc/xc_dom_core.c: unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
> tools/libxc/xc_dom_core.c: unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
> tools/libxc/xc_dom_core.c: page_size = XC_DOM_PAGE_SIZE(dom);
> tools/libxc/xc_dom_core.c: (dom->parms.p2m_base & (XC_DOM_PAGE_SIZE(dom) - 1
> tools/libxc/xc_dom_elfloader.c: elf->dest_size = pages * XC_DOM_PAGE_SIZE(dom);
> tools/libxc/xc_dom_hvmloader.c: elf->dest_size = pages * XC_DOM_PAGE_SIZE(dom);
> tools/libxc/xc_dom_x86.c: memset(l3tab, 0, XC_DOM_PAGE_SIZE(dom));
>
> There is no use for ~XC_DOM_PAGE_SIZE.
>
> And what is the possible scenario you want that?
There might not be a current user of this in libxc, but it is a common bug.
>From xen/include/asm-x86/page.h
/*
* It is important that the masks are signed quantities. This ensures
that
* the compiler sign-extends a 32-bit mask to 64 bits if that is
required.
*/
#define PAGE_SIZE (_AC(1,L) << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))
#define PAGE_FLAG_MASK (~0)
#define PAGE_ORDER_4K 0
#define PAGE_ORDER_2M 9
#define PAGE_ORDER_1G 18
~Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tools/libxc: Correct XC_DOM_PAGE_SIZE() to return a long long
2015-11-19 17:01 ` Andrew Cooper
@ 2015-11-20 11:30 ` Wei Liu
2015-11-20 14:23 ` Ian Campbell
0 siblings, 1 reply; 5+ messages in thread
From: Wei Liu @ 2015-11-20 11:30 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Ian Jackson, Wei Liu, Ian Campbell, Xen-devel
On Thu, Nov 19, 2015 at 05:01:52PM +0000, Andrew Cooper wrote:
> On 19/11/15 16:50, Wei Liu wrote:
> > On Thu, Nov 19, 2015 at 02:45:41PM +0000, Andrew Cooper wrote:
> >> c/s abdf3c5b "libxc: create p2m list outside of kernel mapping if supported"
> >> introduces a use which Coverity objects to; an int used to mask a uint64_t.
> >>
> >> The result needs to be signed to allow ~XC_DOM_PAGE_SIZE() to function
> > $ git grep XC_DOM_PAGE_SIZE
> >
> > tools/libxc/include/xc_dom.h:#define XC_DOM_PAGE_SIZE(dom) (1 << (dom)->arch_hooks
> > tools/libxc/include/xc_dom.h: unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
> > tools/libxc/xc_dom_core.c: unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
> > tools/libxc/xc_dom_core.c: unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
> > tools/libxc/xc_dom_core.c: unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
> > tools/libxc/xc_dom_core.c: unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
> > tools/libxc/xc_dom_core.c: page_size = XC_DOM_PAGE_SIZE(dom);
> > tools/libxc/xc_dom_core.c: (dom->parms.p2m_base & (XC_DOM_PAGE_SIZE(dom) - 1
> > tools/libxc/xc_dom_elfloader.c: elf->dest_size = pages * XC_DOM_PAGE_SIZE(dom);
> > tools/libxc/xc_dom_hvmloader.c: elf->dest_size = pages * XC_DOM_PAGE_SIZE(dom);
> > tools/libxc/xc_dom_x86.c: memset(l3tab, 0, XC_DOM_PAGE_SIZE(dom));
> >
> > There is no use for ~XC_DOM_PAGE_SIZE.
> >
> > And what is the possible scenario you want that?
>
> There might not be a current user of this in libxc, but it is a common bug.
>
> From xen/include/asm-x86/page.h
>
> /*
>
> * It is important that the masks are signed quantities. This ensures
> that
>
> * the compiler sign-extends a 32-bit mask to 64 bits if that is
> required.
>
> */
> #define PAGE_SIZE (_AC(1,L) << PAGE_SHIFT)
> #define PAGE_MASK (~(PAGE_SIZE-1))
> #define PAGE_FLAG_MASK (~0)
>
> #define PAGE_ORDER_4K 0
> #define PAGE_ORDER_2M 9
> #define PAGE_ORDER_1G 18
>
Good to know.
Acked-by: Wei Liu <wei.liu2@citrix.com>
> ~Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-11-20 14:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-19 14:45 [PATCH] tools/libxc: Correct XC_DOM_PAGE_SIZE() to return a long long Andrew Cooper
2015-11-19 16:50 ` Wei Liu
2015-11-19 17:01 ` Andrew Cooper
2015-11-20 11:30 ` Wei Liu
2015-11-20 14:23 ` 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).