All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix uninitialized variable error in do_poll()
@ 2018-10-05 10:12 Jan Beulich
  2018-10-05 10:28 ` Wei Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Beulich @ 2018-10-05 10:12 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan,
	Julien Grall

Now that CONFIG_HVM can (and should) be turned off for the shim, gcc 8.2
apparently is no longer sure that "port" is indeed initialized at

    if ( sched_poll->nr_ports == 1 )
        v->poll_evtchn = port;

It doesn't look to be impossible for the compiler to prove it is not,
but we also can't rely on that to be the case. Add an initializer.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/common/schedule.c
+++ b/xen/common/schedule.c
@@ -1014,7 +1014,7 @@ static long do_poll(struct sched_poll *s
 {
     struct vcpu   *v = current;
     struct domain *d = v->domain;
-    evtchn_port_t  port;
+    evtchn_port_t  port = 0;
     long           rc;
     unsigned int   i;
 



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

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

* Re: [PATCH] fix uninitialized variable error in do_poll()
  2018-10-05 10:12 [PATCH] fix uninitialized variable error in do_poll() Jan Beulich
@ 2018-10-05 10:28 ` Wei Liu
  2018-10-05 11:22   ` Jan Beulich
  0 siblings, 1 reply; 6+ messages in thread
From: Wei Liu @ 2018-10-05 10:28 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan,
	Julien Grall, xen-devel

On Fri, Oct 05, 2018 at 04:12:10AM -0600, Jan Beulich wrote:
> Now that CONFIG_HVM can (and should) be turned off for the shim, gcc 8.2
> apparently is no longer sure that "port" is indeed initialized at
> 
>     if ( sched_poll->nr_ports == 1 )
>         v->poll_evtchn = port;
> 
> It doesn't look to be impossible for the compiler to prove it is not,
> but we also can't rely on that to be the case. Add an initializer.
> 
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

TBH I fail to see how CONFIG_HVM would affect do_poll. Also there is
already build test with gcc 8.2 which never discovered the issue you
described.

The code in this patch is trivially correct, but I think the commit
message should be more straightforward.

Wei.

> 
> --- a/xen/common/schedule.c
> +++ b/xen/common/schedule.c
> @@ -1014,7 +1014,7 @@ static long do_poll(struct sched_poll *s
>  {
>      struct vcpu   *v = current;
>      struct domain *d = v->domain;
> -    evtchn_port_t  port;
> +    evtchn_port_t  port = 0;
>      long           rc;
>      unsigned int   i;
>  
> 
> 

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

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

* Re: [PATCH] fix uninitialized variable error in do_poll()
  2018-10-05 10:28 ` Wei Liu
@ 2018-10-05 11:22   ` Jan Beulich
  2018-10-05 11:25     ` Wei Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Beulich @ 2018-10-05 11:22 UTC (permalink / raw)
  To: Wei Liu
  Cc: Stefano Stabellini, Konrad Rzeszutek Wilk, George Dunlap,
	Andrew Cooper, Ian Jackson, Tim Deegan, Julien Grall, xen-devel

>>> On 05.10.18 at 12:28, <wei.liu2@citrix.com> wrote:
> On Fri, Oct 05, 2018 at 04:12:10AM -0600, Jan Beulich wrote:
>> Now that CONFIG_HVM can (and should) be turned off for the shim, gcc 8.2
>> apparently is no longer sure that "port" is indeed initialized at
>> 
>>     if ( sched_poll->nr_ports == 1 )
>>         v->poll_evtchn = port;
>> 
>> It doesn't look to be impossible for the compiler to prove it is not,
>> but we also can't rely on that to be the case. Add an initializer.
>> 
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> 
> TBH I fail to see how CONFIG_HVM would affect do_poll. Also there is
> already build test with gcc 8.2 which never discovered the issue you
> described.

I can't explain the sudden diagnostic too (without taking apart what
exactly the compiler does), but the same config (just with HVM=y)
built fine before. Without any further insight (which I don't think is
worth the time) I don't see how I could improve the description.

Jan



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

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

* Re: [PATCH] fix uninitialized variable error in do_poll()
  2018-10-05 11:22   ` Jan Beulich
@ 2018-10-05 11:25     ` Wei Liu
  2018-10-05 11:43       ` Andrew Cooper
  0 siblings, 1 reply; 6+ messages in thread
From: Wei Liu @ 2018-10-05 11:25 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan,
	Julien Grall, xen-devel

On Fri, Oct 05, 2018 at 05:22:29AM -0600, Jan Beulich wrote:
> >>> On 05.10.18 at 12:28, <wei.liu2@citrix.com> wrote:
> > On Fri, Oct 05, 2018 at 04:12:10AM -0600, Jan Beulich wrote:
> >> Now that CONFIG_HVM can (and should) be turned off for the shim, gcc 8.2
> >> apparently is no longer sure that "port" is indeed initialized at
> >> 
> >>     if ( sched_poll->nr_ports == 1 )
> >>         v->poll_evtchn = port;
> >> 
> >> It doesn't look to be impossible for the compiler to prove it is not,
> >> but we also can't rely on that to be the case. Add an initializer.
> >> 
> >> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> > 
> > TBH I fail to see how CONFIG_HVM would affect do_poll. Also there is
> > already build test with gcc 8.2 which never discovered the issue you
> > described.
> 
> I can't explain the sudden diagnostic too (without taking apart what
> exactly the compiler does), but the same config (just with HVM=y)
> built fine before. Without any further insight (which I don't think is
> worth the time) I don't see how I could improve the description.

Oh well.

Acked-by: Wei Liu <wei.liu2@citrix.com>


> 
> Jan
> 
> 

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

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

* Re: [PATCH] fix uninitialized variable error in do_poll()
  2018-10-05 11:25     ` Wei Liu
@ 2018-10-05 11:43       ` Andrew Cooper
  2018-10-05 11:56         ` Jan Beulich
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Cooper @ 2018-10-05 11:43 UTC (permalink / raw)
  To: Wei Liu, Jan Beulich
  Cc: Stefano Stabellini, Konrad Rzeszutek Wilk, George Dunlap,
	Tim Deegan, Ian Jackson, Julien Grall, xen-devel

On 05/10/18 12:25, Wei Liu wrote:
> On Fri, Oct 05, 2018 at 05:22:29AM -0600, Jan Beulich wrote:
>>>>> On 05.10.18 at 12:28, <wei.liu2@citrix.com> wrote:
>>> On Fri, Oct 05, 2018 at 04:12:10AM -0600, Jan Beulich wrote:
>>>> Now that CONFIG_HVM can (and should) be turned off for the shim, gcc 8.2
>>>> apparently is no longer sure that "port" is indeed initialized at
>>>>
>>>>     if ( sched_poll->nr_ports == 1 )
>>>>         v->poll_evtchn = port;
>>>>
>>>> It doesn't look to be impossible for the compiler to prove it is not,
>>>> but we also can't rely on that to be the case. Add an initializer.
>>>>
>>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>> TBH I fail to see how CONFIG_HVM would affect do_poll. Also there is
>>> already build test with gcc 8.2 which never discovered the issue you
>>> described.
>> I can't explain the sudden diagnostic too (without taking apart what
>> exactly the compiler does), but the same config (just with HVM=y)
>> built fine before. Without any further insight (which I don't think is
>> worth the time) I don't see how I could improve the description.
> Oh well.
>
> Acked-by: Wei Liu <wei.liu2@citrix.com>

TBH, I'm not sure that relying on DCE is a good longterm option.  It
will almost certainly break the build at -O0, and our code really should
build at all optimisation levels.  (There is still a fair chunk of work
to make -O3 work, which I haven't got time for atm).

~Andrew

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

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

* Re: [PATCH] fix uninitialized variable error in do_poll()
  2018-10-05 11:43       ` Andrew Cooper
@ 2018-10-05 11:56         ` Jan Beulich
  0 siblings, 0 replies; 6+ messages in thread
From: Jan Beulich @ 2018-10-05 11:56 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Tim Deegan, Ian Jackson, Julien Grall, xen-devel

>>> On 05.10.18 at 13:43, <andrew.cooper3@citrix.com> wrote:
> On 05/10/18 12:25, Wei Liu wrote:
>> On Fri, Oct 05, 2018 at 05:22:29AM -0600, Jan Beulich wrote:
>>>>>> On 05.10.18 at 12:28, <wei.liu2@citrix.com> wrote:
>>>> On Fri, Oct 05, 2018 at 04:12:10AM -0600, Jan Beulich wrote:
>>>>> Now that CONFIG_HVM can (and should) be turned off for the shim, gcc 8.2
>>>>> apparently is no longer sure that "port" is indeed initialized at
>>>>>
>>>>>     if ( sched_poll->nr_ports == 1 )
>>>>>         v->poll_evtchn = port;
>>>>>
>>>>> It doesn't look to be impossible for the compiler to prove it is not,
>>>>> but we also can't rely on that to be the case. Add an initializer.
>>>>>
>>>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>>> TBH I fail to see how CONFIG_HVM would affect do_poll. Also there is
>>>> already build test with gcc 8.2 which never discovered the issue you
>>>> described.
>>> I can't explain the sudden diagnostic too (without taking apart what
>>> exactly the compiler does), but the same config (just with HVM=y)
>>> built fine before. Without any further insight (which I don't think is
>>> worth the time) I don't see how I could improve the description.
>> Oh well.
>>
>> Acked-by: Wei Liu <wei.liu2@citrix.com>
> 
> TBH, I'm not sure that relying on DCE is a good longterm option.

Well, we'll have too see how well it fares. If we get into increasing
trouble, we may indeed want to ...

> It will almost certainly break the build at -O0,

... allow for this.

> and our code really should build at all optimisation levels.

I'd say it is us to establish how much optimization we want to
support being enabled.

Jan



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

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

end of thread, other threads:[~2018-10-05 11:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-05 10:12 [PATCH] fix uninitialized variable error in do_poll() Jan Beulich
2018-10-05 10:28 ` Wei Liu
2018-10-05 11:22   ` Jan Beulich
2018-10-05 11:25     ` Wei Liu
2018-10-05 11:43       ` Andrew Cooper
2018-10-05 11:56         ` Jan Beulich

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.