Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp951431ybi; Fri, 12 Jul 2019 07:15:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGnGEE7bWXRBrSfoHD3lZRutayln2y7IjL7RDwTO4wnKRbkj7HPkjXpac3mHiHPvR4HThP X-Received: by 2002:a65:57ca:: with SMTP id q10mr11551015pgr.52.1562940901995; Fri, 12 Jul 2019 07:15:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562940901; cv=none; d=google.com; s=arc-20160816; b=PI8XX/aCPYyL7hVTPBZFx3XwgtD3hyopMNWRb0GzUSzd4bsv6gymLhYWg2oYuMUdoy VqKeGy2siEFzP1x8C/sfNU8FN8fGTzDQZXy9LXPgxkQXdFmWBGPa6jxNwqV48853uGKK cYLXzsHZJQSvxSXbZa6Png2xYSKNsp5baqL9ZffGhbKZJSRvua/LZMvQKb+tFvo4EZ5k tu/xZBaenvcTYan1Yduf9S8ZXmx1kJdJao4U6R6BtbGqafBzROlADXZ5nwustV08bpJk sIxLTlJwlxAIU/yxyMAspZOMn3zBcMraJchOD7t22PEEfi2mnejUtBxv5jOg/PMzgrmg xurw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=QEcyMVoVVK2aAgqjYqU1quQyj8I0rByqDbaPdzIBJgc=; b=D2zMVqhSR4kdJIuoXGOYyNpnH+MY+qNqJAenp5+oLpXfFDj3/4EAm1zhZCYT4ytKEx gaS3fdxQdYbp1abzvymt2RMaQgikBMD36laIJZazsSmnqe5NMPtT7L4jmw0FHKoFq90C eggE1Ep7FLSfB4pA51uimPPTFcVadU5wksPIwHcVpDQalen6BQ9089zZxT5UjtWIqeOl kHh3RR4Nr4AzZZQ/pC07rdTH6XDp+IZeGigz863gIW1fflbnWz+56NlnbFpqryh41u3Z aSX9ZxehPK24PE/RhYefdiMhLBOOssivRW3ecoxvpD9Ad7gJ/XNS9di16fO+yTGN+KBA pKgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m184si5086717pgm.580.2019.07.12.07.14.46; Fri, 12 Jul 2019 07:15:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727372AbfGLONz (ORCPT + 99 others); Fri, 12 Jul 2019 10:13:55 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:53403 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726266AbfGLONz (ORCPT ); Fri, 12 Jul 2019 10:13:55 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.129]) with ESMTPA (Nemesis) id 1MrQN5-1iIXRL1mzv-00oVFL; Fri, 12 Jul 2019 16:13:24 +0200 From: Arnd Bergmann To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org Cc: Arnd Bergmann , "H. Peter Anvin" , Vitaly Kuznetsov , Roman Kagan , Liran Alon , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH] [v3] x86: kvm: avoid -Wsometimes-uninitized warning Date: Fri, 12 Jul 2019 16:13:09 +0200 Message-Id: <20190712141322.1073650-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:mtFUcYRsvqsqU3QJWJ/dFFjF0Yd9wHzp908nlZK83caY6JGVHPq LXymdLgLCegnaDKfu159IL/7oAudJltdZwXMGK63ZUlU+Jfths5bnLOzEW07+2q31Yg0tT6 1cg0EE/DQ8ump88F0paELKlusq6DBC2eUaOp+T4qfsjCs0IEYgQKtvAVQsTYQPgN5n/2fGp epCCJ0s3Sh3bwoaLinvzQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:LWYzu/LtLb0=:xHUs4tdQHd3Ct6Bu0svRXv PmWzRBS+0m95DYX/F7E+rFe5/XtDhnWQ6Tgs4mINPckQyZ/6MVAUsj0Xa70FI5l4+ppmPC7/x giOslqyC74d2r5fkPb6oDzt2fRVBSXCuNrWuX0zVgaJ8lou8DmUMBtpNmk8aVUsNx8yrJSZOY Z1tTYNcbvtrD+HQbondlxipmdzbY/YPT41GN1PvvrAPBX/49/8SYq8//DsoC0n2G/R7UKhldk 0zhoRK/WgQqBNPXo7nMihjnp5CzS2HerKKy+uMmt3IFZvWb6DQGKv+miSTTd3alE0t0t3FaCh 9iN0q+VNyr8gK1uAyY3DBYcD7Sp+cnr+e+XQqiWZDYKWPpV/IQD8UpNmOE3vytPncDe9MiDdo 4SJMRG1ZOVUcOoZOqBzR/hGq/qiRfDXfQXYMPfDl72JS2H8TOCL3kNkAj4IXZegf1ObSCy8KT ewuqXTfwJLV/Oxv2e7toe2Ge+4yujGs5LgcYjcGsvJiZwjxM1lVDSHqazN5juGS3rMADkCgb5 m8z4SlBUMsfYz+4h2dNYGw/hywY3xv8nDSoidRF9FwTgnI2uPJSxS2sCOiPARtNXloGKVbItC zXlx7ENBiMSKBz4uXbwTiMFAB/v8mVFzK/y06yHdq/L6ki33fBO2mh7j/DF9pXkkZcV4tcd15 597nbyjIn8WS3XkTo4GeBukcP3LM1eXUqx8Dr5MYxrBfNFwm4we/sFFBTFAItSvXfIpwJcCjQ CwHjsApxyYZYx8uOwIvBbUb/Wjm/ii7WpxJIlg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clang notices a code path in which some variables are never initialized, but fails to figure out that this can never happen on i386 because is_64_bit_mode() always returns false. arch/x86/kvm/hyperv.c:1610:6: error: variable 'ingpa' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] if (!longmode) { ^~~~~~~~~ arch/x86/kvm/hyperv.c:1632:55: note: uninitialized use occurs here trace_kvm_hv_hypercall(code, fast, rep_cnt, rep_idx, ingpa, outgpa); ^~~~~ arch/x86/kvm/hyperv.c:1610:2: note: remove the 'if' if its condition is always true if (!longmode) { ^~~~~~~~~~~~~~~ arch/x86/kvm/hyperv.c:1595:18: note: initialize the variable 'ingpa' to silence this warning u64 param, ingpa, outgpa, ret = HV_STATUS_SUCCESS; ^ = 0 arch/x86/kvm/hyperv.c:1610:6: error: variable 'outgpa' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] arch/x86/kvm/hyperv.c:1610:6: error: variable 'param' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] Flip the condition around to avoid the conditional execution on i386. Signed-off-by: Arnd Bergmann --- v3: reword commit log, simplify patch again v2: make the change inside of is_64_bit_mode(). --- arch/x86/kvm/hyperv.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index a39e38f13029..c10a8b10b203 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -1594,7 +1594,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu) { u64 param, ingpa, outgpa, ret = HV_STATUS_SUCCESS; uint16_t code, rep_idx, rep_cnt; - bool fast, longmode, rep; + bool fast, rep; /* * hypercall generates UD from non zero cpl and real mode @@ -1605,9 +1605,14 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu) return 1; } - longmode = is_64_bit_mode(vcpu); - - if (!longmode) { +#ifdef CONFIG_X86_64 + if (is_64_bit_mode(vcpu)) { + param = kvm_rcx_read(vcpu); + ingpa = kvm_rdx_read(vcpu); + outgpa = kvm_r8_read(vcpu); + } else +#endif + { param = ((u64)kvm_rdx_read(vcpu) << 32) | (kvm_rax_read(vcpu) & 0xffffffff); ingpa = ((u64)kvm_rbx_read(vcpu) << 32) | @@ -1615,13 +1620,6 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu) outgpa = ((u64)kvm_rdi_read(vcpu) << 32) | (kvm_rsi_read(vcpu) & 0xffffffff); } -#ifdef CONFIG_X86_64 - else { - param = kvm_rcx_read(vcpu); - ingpa = kvm_rdx_read(vcpu); - outgpa = kvm_r8_read(vcpu); - } -#endif code = param & 0xffff; fast = !!(param & HV_HYPERCALL_FAST_BIT); -- 2.20.0