Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
compile error gentoo-sources
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
genterminl
Guru
Guru


Joined: 12 Feb 2005
Posts: 500
Location: Connecticut, USA

PostPosted: Thu May 14, 2020 6:30 pm    Post subject: compile error gentoo-sources Reply with quote

I just had a compile failure in the kernel modules with gentoo-sources-5.6.13 with gcc-10.1.0,

The error is
Code:
 arch/x86/kvm/../../../virt/kvm/kvm_main.c: In function '__kvm_gfn_to_hva_cache_init':
arch/x86/kvm/../../../virt/kvm/kvm_main.c:2236:42: error: 'nr_pages_avail' may be used uninitialized in this function [-Werror=maybe-uninitialized]
 2236 |  for ( ; start_gfn <= end_gfn; start_gfn += nr_pages_avail) {
      |                                ~~~~~~~~~~^~~~~~~~~~~~~~~~~

and I found https://bugzilla.kernel.org/show_bug.cgi?id=207173 which implies it is not specific to either that kernel version or to the gcc version, but due to a change from a while to for loop, and that warning being turned to an error. I have no idea why I haven't run across it with 5.6.10, which I've been running fine for at least a few days, and essentially (if not exactly) the same .config file. Comment 11 in that bug suggests a simple patch, which I'll try out and post if it works for me. The final comment in the bug is
Quote:
This is "fixed" in upstream (for kernel 5.7) by commit 78a5255ffb6a1 ("Stop the ad-hoc games with -Wno-maybe-initialized").
so I wonder why it isn't backported.

Mainly I'm curious whether there just might be something specific in my configuration which triggered this, and if so, why it didn't for previous kernels.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 15324

PostPosted: Fri May 15, 2020 2:21 am    Post subject: Reply with quote

The warning change is not flagged for backport to stable, and is only a few days old. There is a decent chance that the people who would backport it are not aware of it, or do not consider it sufficiently urgent.

This failure is typical of the "maybe uninitialized" warning. The variable is uninitialized if gfn_to_hva_many fails, but, if gfn_to_hva_many fails, then kvm_is_error_hva should trigger the return before the uninitialized variable is actually used. Thus, to avoid the warning, you need gcc to prove that every path which does not initialize nr_pages_avail will trigger a return value that will cause kvm_is_error_hva to exit the loop. Depending on your compilation options, and compiler details, it may or may not be able to prove that. For example, if it failed to inline kvm_is_error_hva, it might not predict anything about how the if test resolves. If it fails to predict the if, it will pessimistically assume that nr_pages_avail is always read at least once, which would be a bug, and a warning would be issued.
Back to top
View user's profile Send private message
genterminl
Guru
Guru


Joined: 12 Feb 2005
Posts: 500
Location: Connecticut, USA

PostPosted: Fri May 15, 2020 2:49 am    Post subject: Reply with quote

My understanding is that in reality, the value IS always set before use, although I have no idea if that can actually be proved from the code. The patch just adds an "=0" to the initial definition, and it does allow successful compilation. (I don't know if actual booting from that compiled kernel works, but that is a totally separate issue.).

I do realize this is a relatively newly posted issue, and it will take a while to percolate through the various channels that will eventually result in patches or modified sources. Since it does result in a compile failure, I just wonder if there is any poirnt in filing a Gentoo bug at this point, or just wait until the patch works it's way down from upstream. Since it apparently occurs with gcc-9 as well as gcc-10, it doesn't seem to matter whether or not the gcc-10 compiled version might still not actually boot.
Back to top
View user's profile Send private message
DaggyStyle
Watchman
Watchman


Joined: 22 Mar 2006
Posts: 5452

PostPosted: Fri May 15, 2020 6:20 am    Post subject: Reply with quote

fix was committed to 5.7, see https://github.com/torvalds/linux/commit/78a5255ffb6a1af189a83e493d916ba1c54d8c75
_________________
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 15324

PostPosted: Sat May 16, 2020 12:50 am    Post subject: Reply with quote

genterminl wrote:
My understanding is that in reality, the value IS always set before use, although I have no idea if that can actually be proved from the code.
Isn't that what I just explained above? :) The code is correct, but confirming it requires proving that the error-exit path will always be triggered by the paths that do not initialize the variable.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum