All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libxc/arm: initialise p2m_size to make gcc happy
@ 2018-03-14 12:32 Wei Liu
  2018-03-14 12:35 ` Andrew Cooper
  2018-03-14 13:27 ` Julien Grall
  0 siblings, 2 replies; 7+ messages in thread
From: Wei Liu @ 2018-03-14 12:32 UTC (permalink / raw)
  To: Xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

Gcc with -O3 failed to spot the loop to initialise p2m_size runs at
least once.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxc/xc_dom_arm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c
index 5b9eca6087..97d08f055a 100644
--- a/tools/libxc/xc_dom_arm.c
+++ b/tools/libxc/xc_dom_arm.c
@@ -395,7 +395,7 @@ static int meminit(struct xc_dom_image *dom)
     const uint64_t modsize = dtb_size + ramdisk_size;
     const uint64_t ram128mb = bankbase[0] + (128<<20);
 
-    xen_pfn_t p2m_size;
+    xen_pfn_t p2m_size = 0; /* make gcc -O3 happy */
     uint64_t bank0end;
 
     assert(dom->rambase_pfn << XC_PAGE_SHIFT == bankbase[0]);
@@ -438,6 +438,7 @@ static int meminit(struct xc_dom_image *dom)
 
     assert(dom->rambank_size[0] != 0);
     assert(ramsize == 0); /* Too much RAM is rejected above */
+    assert(p2m_size != 0);
 
     dom->p2m_size = p2m_size;
     dom->p2m_host = xc_dom_malloc(dom, sizeof(xen_pfn_t) * p2m_size);
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] libxc/arm: initialise p2m_size to make gcc happy
  2018-03-14 12:32 [PATCH] libxc/arm: initialise p2m_size to make gcc happy Wei Liu
@ 2018-03-14 12:35 ` Andrew Cooper
  2018-03-14 12:37   ` Wei Liu
  2018-03-14 13:45   ` Jan Beulich
  2018-03-14 13:27 ` Julien Grall
  1 sibling, 2 replies; 7+ messages in thread
From: Andrew Cooper @ 2018-03-14 12:35 UTC (permalink / raw)
  To: Wei Liu, Xen-devel; +Cc: Julien Grall, Stefano Stabellini, Ian Jackson

On 14/03/18 12:32, Wei Liu wrote:
> Gcc with -O3 failed to spot the loop to initialise p2m_size runs at
> least once.

It is -Og in this case, rather than -O3.  My -O3 comment on the thread
was for the more generic cases.

~Andrew

>
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> ---
>  tools/libxc/xc_dom_arm.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c
> index 5b9eca6087..97d08f055a 100644
> --- a/tools/libxc/xc_dom_arm.c
> +++ b/tools/libxc/xc_dom_arm.c
> @@ -395,7 +395,7 @@ static int meminit(struct xc_dom_image *dom)
>      const uint64_t modsize = dtb_size + ramdisk_size;
>      const uint64_t ram128mb = bankbase[0] + (128<<20);
>  
> -    xen_pfn_t p2m_size;
> +    xen_pfn_t p2m_size = 0; /* make gcc -O3 happy */
>      uint64_t bank0end;
>  
>      assert(dom->rambase_pfn << XC_PAGE_SHIFT == bankbase[0]);
> @@ -438,6 +438,7 @@ static int meminit(struct xc_dom_image *dom)
>  
>      assert(dom->rambank_size[0] != 0);
>      assert(ramsize == 0); /* Too much RAM is rejected above */
> +    assert(p2m_size != 0);
>  
>      dom->p2m_size = p2m_size;
>      dom->p2m_host = xc_dom_malloc(dom, sizeof(xen_pfn_t) * p2m_size);


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libxc/arm: initialise p2m_size to make gcc happy
  2018-03-14 12:35 ` Andrew Cooper
@ 2018-03-14 12:37   ` Wei Liu
  2018-03-14 13:45   ` Jan Beulich
  1 sibling, 0 replies; 7+ messages in thread
From: Wei Liu @ 2018-03-14 12:37 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Xen-devel, Julien Grall, Stefano Stabellini, Wei Liu, Ian Jackson

On Wed, Mar 14, 2018 at 12:35:48PM +0000, Andrew Cooper wrote:
> On 14/03/18 12:32, Wei Liu wrote:
> > Gcc with -O3 failed to spot the loop to initialise p2m_size runs at
> > least once.
> 
> It is -Og in this case, rather than -O3.  My -O3 comment on the thread
> was for the more generic cases.

OK. I will fix the commit message and code comment.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libxc/arm: initialise p2m_size to make gcc happy
  2018-03-14 12:32 [PATCH] libxc/arm: initialise p2m_size to make gcc happy Wei Liu
  2018-03-14 12:35 ` Andrew Cooper
@ 2018-03-14 13:27 ` Julien Grall
  2018-03-21 16:43   ` Wei Liu
  1 sibling, 1 reply; 7+ messages in thread
From: Julien Grall @ 2018-03-14 13:27 UTC (permalink / raw)
  To: Wei Liu, Xen-devel; +Cc: Stefano Stabellini, Ian Jackson

Hi,

On 03/14/2018 12:32 PM, Wei Liu wrote:
> Gcc with -O3 failed to spot the loop to initialise p2m_size runs at
> least once.

Aside, Andrew's comment the patch looks okay. But I am wondering why we 
need to allocate p2m_host for Arm?

 From a quick look I have seen no real user except 
xc_dom_update_guest_p2m that can cope with p2m_host = NULL.

Cheers,

> 
> Signed-off-by: Wei Liu <wei.liu2@citrix.com>
> ---
>   tools/libxc/xc_dom_arm.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c
> index 5b9eca6087..97d08f055a 100644
> --- a/tools/libxc/xc_dom_arm.c
> +++ b/tools/libxc/xc_dom_arm.c
> @@ -395,7 +395,7 @@ static int meminit(struct xc_dom_image *dom)
>       const uint64_t modsize = dtb_size + ramdisk_size;
>       const uint64_t ram128mb = bankbase[0] + (128<<20);
>   
> -    xen_pfn_t p2m_size;
> +    xen_pfn_t p2m_size = 0; /* make gcc -O3 happy */
>       uint64_t bank0end;
>   
>       assert(dom->rambase_pfn << XC_PAGE_SHIFT == bankbase[0]);
> @@ -438,6 +438,7 @@ static int meminit(struct xc_dom_image *dom)
>   
>       assert(dom->rambank_size[0] != 0);
>       assert(ramsize == 0); /* Too much RAM is rejected above */
> +    assert(p2m_size != 0);
>   
>       dom->p2m_size = p2m_size;
>       dom->p2m_host = xc_dom_malloc(dom, sizeof(xen_pfn_t) * p2m_size);
> 

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libxc/arm: initialise p2m_size to make gcc happy
  2018-03-14 12:35 ` Andrew Cooper
  2018-03-14 12:37   ` Wei Liu
@ 2018-03-14 13:45   ` Jan Beulich
  1 sibling, 0 replies; 7+ messages in thread
From: Jan Beulich @ 2018-03-14 13:45 UTC (permalink / raw)
  To: Andrew Cooper, Wei Liu, Xen-devel
  Cc: Julien Grall, Stefano Stabellini, Ian Jackson

>>> On 14.03.18 at 13:35, <andrew.cooper3@citrix.com> wrote:
> On 14/03/18 12:32, Wei Liu wrote:
>> Gcc with -O3 failed to spot the loop to initialise p2m_size runs at
>> least once.
> 
> It is -Og in this case, rather than -O3.  My -O3 comment on the thread
> was for the more generic cases.

Yeah, it is likely the fact that gcc does _less_ optimization with -Og
that makes it no longer spot that the variable can't be used
uninitialized.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libxc/arm: initialise p2m_size to make gcc happy
  2018-03-14 13:27 ` Julien Grall
@ 2018-03-21 16:43   ` Wei Liu
  2018-03-22  9:09     ` Julien Grall
  0 siblings, 1 reply; 7+ messages in thread
From: Wei Liu @ 2018-03-21 16:43 UTC (permalink / raw)
  To: Julien Grall; +Cc: Xen-devel, Stefano Stabellini, Wei Liu, Ian Jackson

On Wed, Mar 14, 2018 at 01:27:37PM +0000, Julien Grall wrote:
> Hi,
> 
> On 03/14/2018 12:32 PM, Wei Liu wrote:
> > Gcc with -O3 failed to spot the loop to initialise p2m_size runs at
> > least once.
> 
> Aside, Andrew's comment the patch looks okay. But I am wondering why we need
> to allocate p2m_host for Arm?
> 

Not sure, really. :-)

> From a quick look I have seen no real user except xc_dom_update_guest_p2m
> that can cope with p2m_host = NULL.
> 

Maybe it is to work around this limitation in code.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libxc/arm: initialise p2m_size to make gcc happy
  2018-03-21 16:43   ` Wei Liu
@ 2018-03-22  9:09     ` Julien Grall
  0 siblings, 0 replies; 7+ messages in thread
From: Julien Grall @ 2018-03-22  9:09 UTC (permalink / raw)
  To: Wei Liu; +Cc: Xen-devel, Stefano Stabellini, Ian Jackson

Hi,

On 03/21/2018 04:43 PM, Wei Liu wrote:
> On Wed, Mar 14, 2018 at 01:27:37PM +0000, Julien Grall wrote:
>> Hi,
>>
>> On 03/14/2018 12:32 PM, Wei Liu wrote:
>>> Gcc with -O3 failed to spot the loop to initialise p2m_size runs at
>>> least once.
>>
>> Aside, Andrew's comment the patch looks okay. But I am wondering why we need
>> to allocate p2m_host for Arm?
>>
> 
> Not sure, really. :-)
> 
>>  From a quick look I have seen no real user except xc_dom_update_guest_p2m
>> that can cope with p2m_host = NULL.
>>
> 
> Maybe it is to work around this limitation in code.

I will have a look at it. Meanwhile, I guess it is better to make GCC 
happy with that patch.

Cheers,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-03-22  9:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-14 12:32 [PATCH] libxc/arm: initialise p2m_size to make gcc happy Wei Liu
2018-03-14 12:35 ` Andrew Cooper
2018-03-14 12:37   ` Wei Liu
2018-03-14 13:45   ` Jan Beulich
2018-03-14 13:27 ` Julien Grall
2018-03-21 16:43   ` Wei Liu
2018-03-22  9:09     ` Julien Grall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.