* [PATCH v2] KVM: MIPS: Fix maybe-uninitialized build failure
@ 2017-06-20 9:57 James Cowgill
2017-06-20 14:54 ` James Hogan
0 siblings, 1 reply; 3+ messages in thread
From: James Cowgill @ 2017-06-20 9:57 UTC (permalink / raw)
To: James Hogan, Paolo Bonzini, Radim Krčmář
Cc: Ralf Baechle, linux-mips, kvm, James Cowgill
This commit fixes a "maybe-uninitialized" build failure in
arch/mips/kvm/tlb.c when KVM, DYNAMIC_DEBUG and JUMP_LABEL are all
enabled. The failure is:
In file included from ./include/linux/printk.h:329:0,
from ./include/linux/kernel.h:13,
from ./include/asm-generic/bug.h:15,
from ./arch/mips/include/asm/bug.h:41,
from ./include/linux/bug.h:4,
from ./include/linux/thread_info.h:11,
from ./include/asm-generic/current.h:4,
from ./arch/mips/include/generated/asm/current.h:1,
from ./include/linux/sched.h:11,
from arch/mips/kvm/tlb.c:13:
arch/mips/kvm/tlb.c: In function ‘kvm_mips_host_tlb_inv’:
./include/linux/dynamic_debug.h:126:3: error: ‘idx_kernel’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
__dynamic_pr_debug(&descriptor, pr_fmt(fmt), \
^~~~~~~~~~~~~~~~~~
arch/mips/kvm/tlb.c:169:16: note: ‘idx_kernel’ was declared here
int idx_user, idx_kernel;
^~~~~~~~~~
There is a similar error relating to "idx_user". Both errors were
observed with GCC 6.
As far as I can tell, it is impossible for either idx_user or idx_kernel
to be uninitialized when they are later read in the calls to kvm_debug,
but to satisfy the compiler, add zero initializers to both variables.
Signed-off-by: James Cowgill <James.Cowgill@imgtec.com>
Fixes: 57e3869cfaae ("KVM: MIPS/TLB: Generalise host TLB invalidate to kernel ASID")
Cc: <stable@vger.kernel.org> # 4.11+
---
arch/mips/kvm/tlb.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/mips/kvm/tlb.c b/arch/mips/kvm/tlb.c
index 7c6336dd2638..7cd92166a0b9 100644
--- a/arch/mips/kvm/tlb.c
+++ b/arch/mips/kvm/tlb.c
@@ -166,7 +166,11 @@ static int _kvm_mips_host_tlb_inv(unsigned long entryhi)
int kvm_mips_host_tlb_inv(struct kvm_vcpu *vcpu, unsigned long va,
bool user, bool kernel)
{
- int idx_user, idx_kernel;
+ /*
+ * Initialize idx_user and idx_kernel to workaround bogus
+ * maybe-initialized warning when using GCC 6.
+ */
+ int idx_user = 0, idx_kernel = 0;
unsigned long flags, old_entryhi;
local_irq_save(flags);
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] KVM: MIPS: Fix maybe-uninitialized build failure
2017-06-20 9:57 [PATCH v2] KVM: MIPS: Fix maybe-uninitialized build failure James Cowgill
@ 2017-06-20 14:54 ` James Hogan
2017-06-20 15:07 ` Radim Krčmář
0 siblings, 1 reply; 3+ messages in thread
From: James Hogan @ 2017-06-20 14:54 UTC (permalink / raw)
To: James Cowgill
Cc: Paolo Bonzini, Radim Krčmář, Ralf Baechle,
linux-mips, kvm
[-- Attachment #1: Type: text/plain, Size: 2614 bytes --]
On Tue, Jun 20, 2017 at 10:57:51AM +0100, James Cowgill wrote:
> This commit fixes a "maybe-uninitialized" build failure in
> arch/mips/kvm/tlb.c when KVM, DYNAMIC_DEBUG and JUMP_LABEL are all
> enabled. The failure is:
>
> In file included from ./include/linux/printk.h:329:0,
> from ./include/linux/kernel.h:13,
> from ./include/asm-generic/bug.h:15,
> from ./arch/mips/include/asm/bug.h:41,
> from ./include/linux/bug.h:4,
> from ./include/linux/thread_info.h:11,
> from ./include/asm-generic/current.h:4,
> from ./arch/mips/include/generated/asm/current.h:1,
> from ./include/linux/sched.h:11,
> from arch/mips/kvm/tlb.c:13:
> arch/mips/kvm/tlb.c: In function ‘kvm_mips_host_tlb_inv’:
> ./include/linux/dynamic_debug.h:126:3: error: ‘idx_kernel’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> __dynamic_pr_debug(&descriptor, pr_fmt(fmt), \
> ^~~~~~~~~~~~~~~~~~
> arch/mips/kvm/tlb.c:169:16: note: ‘idx_kernel’ was declared here
> int idx_user, idx_kernel;
> ^~~~~~~~~~
>
> There is a similar error relating to "idx_user". Both errors were
> observed with GCC 6.
>
> As far as I can tell, it is impossible for either idx_user or idx_kernel
> to be uninitialized when they are later read in the calls to kvm_debug,
> but to satisfy the compiler, add zero initializers to both variables.
>
> Signed-off-by: James Cowgill <James.Cowgill@imgtec.com>
> Fixes: 57e3869cfaae ("KVM: MIPS/TLB: Generalise host TLB invalidate to kernel ASID")
> Cc: <stable@vger.kernel.org> # 4.11+
Acked-by: James Hogan <james.hogan@imgtec.com>
Paolo / Radim: is it okay for one of you to pick this one up for 4.12?
Thanks
James
> ---
> arch/mips/kvm/tlb.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/mips/kvm/tlb.c b/arch/mips/kvm/tlb.c
> index 7c6336dd2638..7cd92166a0b9 100644
> --- a/arch/mips/kvm/tlb.c
> +++ b/arch/mips/kvm/tlb.c
> @@ -166,7 +166,11 @@ static int _kvm_mips_host_tlb_inv(unsigned long entryhi)
> int kvm_mips_host_tlb_inv(struct kvm_vcpu *vcpu, unsigned long va,
> bool user, bool kernel)
> {
> - int idx_user, idx_kernel;
> + /*
> + * Initialize idx_user and idx_kernel to workaround bogus
> + * maybe-initialized warning when using GCC 6.
> + */
> + int idx_user = 0, idx_kernel = 0;
> unsigned long flags, old_entryhi;
>
> local_irq_save(flags);
> --
> 2.11.0
>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] KVM: MIPS: Fix maybe-uninitialized build failure
2017-06-20 14:54 ` James Hogan
@ 2017-06-20 15:07 ` Radim Krčmář
0 siblings, 0 replies; 3+ messages in thread
From: Radim Krčmář @ 2017-06-20 15:07 UTC (permalink / raw)
To: James Hogan; +Cc: James Cowgill, Paolo Bonzini, Ralf Baechle, linux-mips, kvm
2017-06-20 15:54+0100, James Hogan:
> Acked-by: James Hogan <james.hogan@imgtec.com>
>
> Paolo / Radim: is it okay for one of you to pick this one up for 4.12?
It's in, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-20 15:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-20 9:57 [PATCH v2] KVM: MIPS: Fix maybe-uninitialized build failure James Cowgill
2017-06-20 14:54 ` James Hogan
2017-06-20 15:07 ` Radim Krčmář
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).