From patchwork Fri Jul 12 09:12:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 168919 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp604340ilk; Fri, 12 Jul 2019 02:13:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXFzQzoIW0wcNFUIDy+AmqTpvEmnvb+Ag4rP08Am2anBNJzf3S8l2Ji+uEt5vbavxA0UZI X-Received: by 2002:a63:8ac3:: with SMTP id y186mr9489846pgd.13.1562922792248; Fri, 12 Jul 2019 02:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562922792; cv=none; d=google.com; s=arc-20160816; b=jbRD3zosc7hfrJv2qC5KtY7kIeGdYa26F8IQ4Jm1v+KficJ0hpVi82pIu+SFvpT5B3 hH6y5s3RAEv3r9T7AULvVUlgzwmS4SLEyD0Mv4JByUBbBz9y/kDYGeKah610bHq4xnJK Gg/lTJNh6vZjfpxeAnbhEDhCx9ZsFN2E4IzhqJgB99AwzU7igNr3pwzbU3ke9HY5K5t/ FTY5Ad5Bgt9b52ZxMykClzt15l16YMlD4XCkJO5jzB4C2gn2v5r1FqzaHU/0JcNvyiu9 sxP2ajXaXnWFrrnt/YIVP6oqiOYucBRsItHMkic81Pdvu62pJoI5BwabpYGhoTIXWLiB wfJQ== 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=POyz6aOGNVRg0oFTOSXQp9BG24KyDAht5rKNFkeGs/U=; b=Aqxhi4tytOIoMto+GwZ4BiYv/Tn2npGlXXEHqMzmm7y2QSJYDfrTHUWbpl7fUT1h+i ZQHGx3kTcf0gVa4HY6X8sd8gILoOCvOFPF/iACyoitOkfXxH9C0NQDFm4lsR07lMcjq+ TauqoRHUZhsh0XZR1vBJPpd8iz+VSf7PRNx/reu2fWtmHv1BL0X4LdoqKJqYzpvHsJ63 ecfEBJO5zZqvAoehN7fQ0J2aUtFOBDHxPzV8McnMwb/wUq+KzqfiO+McuRsk+LqJ+wHa vXi53XVP9kdG6I9q9O68JESuEf439F+FoBopt5jeECR7mmBUQww0VHec9UR6AQRkiaRm 8QcQ== 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 i9si7099439plb.284.2019.07.12.02.13.12; Fri, 12 Jul 2019 02:13:12 -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 S1726415AbfGLJNL (ORCPT + 29 others); Fri, 12 Jul 2019 05:13:11 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:41875 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725877AbfGLJNK (ORCPT ); Fri, 12 Jul 2019 05:13:10 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.145]) with ESMTPA (Nemesis) id 1MeC1p-1iN7Ik04EJ-00bKOj; Fri, 12 Jul 2019 11:12:41 +0200 From: Arnd Bergmann To: Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , 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 1/2] x86: kvm: avoid -Wsometimes-uninitized warning Date: Fri, 12 Jul 2019 11:12:29 +0200 Message-Id: <20190712091239.716978-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:jwYhgxUv0AqFLNDzVo6wysNnAi/KwXb/EoxoA0pMMuPkZD7WvpX SiHy+yF55QFjTCdbtQYSYvGz7fCvrCkf5Fglh7UrM2Z3T2fIMOrK+VxQNEOcar71gln41fT a0AcjmpKU0FFi9U/1kw9UuN38z7vudvXTKSFI3gNcKAgm+zdndz7cmKTmis62iY8kPINghL 4jYB2F14QzSagGXw2O43w== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:4ze24aU6tjo=:rBuxHH89tgwq6563QiEIei cCbeMAuQXh3Rwudc8KuL66S7hExosHEdrkySheaJ17Aci6pm/ZmFiUvPKU1BPWzPC6wC+ioX9 IAXHwOeqyJDFDaYWV53jAY7VJyt8QjaypiCMNHmWRL9S6qzYChL7f3dCrMqC+xZelZqkyfp14 OPPvsOc1fc+0faGqCLqW54UBOFCMwYnKAavVDradaOw4DFfOycQ+/65LZ1PNVYBqje7LHK06X cbKpQUbLbCfkf+aWzup4lByTxUAJj/TbjozE/14E2HLKOOSNQZBE4feW75lm0NlnUJxM2JHVM F/nV45kAUtzl9/SYBlAzUzV5mTzE52Fu0LHd78H1ROC0E4vh3QI8qEOYXQYpihzvhtBPPitzU wwu8hRCQJK8/FJGUx9cy3SxvsUnH7VSpJqYcNuDacWEdZWv6ZrDirg/AWMCH0JtyP7YXxgzt9 7jrlp6MOdemmD04ZNheEf9H+4QPtUM4ECEad9l4T2V0Gc5CzTdRmkcP2E/5FXdnIOuPHGJeVC 18j/526Pngxu9IQqbzxMezvzP/ggjjwSA0KTSGhbLMnE56jpOMqNlaWd9cOGkaG6EvinfZIaJ +YiErd93+F99VFS+lIgAasBSEnNv/7BnT+LqDWBJts49RKcKV2oSqkl2N4S1lPtg5666ZYbPN e7R+iFYo9Gn5GdxqFw+Oql+rudlOgmMZVMZAjmsvnYFy1+i/M+drc2OeEH/f0W8sGE2Hmv6b/ h3IlW5CBYeVHpAYxHR6aqQechRU/sgPtsCq4xw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org clang points out that running a 64-bit guest on a 32-bit host would lead to uninitialized variables: 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] Since that combination is not supported anyway, change the condition to tell the compiler how the code is actually executed. Signed-off-by: Arnd Bergmann --- arch/x86/kvm/hyperv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.0 diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index a39e38f13029..950436c502ba 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -1607,7 +1607,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu) longmode = is_64_bit_mode(vcpu); - if (!longmode) { + if (!IS_ENABLED(CONFIG_X86_64) || !longmode) { param = ((u64)kvm_rdx_read(vcpu) << 32) | (kvm_rax_read(vcpu) & 0xffffffff); ingpa = ((u64)kvm_rbx_read(vcpu) << 32) | From patchwork Fri Jul 12 09:12:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 168920 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp604926ilk; Fri, 12 Jul 2019 02:13:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMqfFJoNZiixy/1jBLletvpFS56vUiVS4t7McD1CumrKbWSIHm4eP7LmU2MUVT0cU86g7z X-Received: by 2002:a17:90a:710c:: with SMTP id h12mr10216136pjk.36.1562922822348; Fri, 12 Jul 2019 02:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562922822; cv=none; d=google.com; s=arc-20160816; b=OQaCX8j3m+6AghCQDJMpa+oSAhj2khX1ZOvay35AwLnUHOPcECnmpXpXgEnBnveFLQ w4JDk/hNvvYCcDcYu5U9d1doGMsxIhiOlPFK7u5MMMMnI4+PVkGQv7BlZVy944QQCDvv /0kGxDfMOY1HR4PROcHpgCk44M4c5sYLLaDx06hbw60mYFDHUTg4aRKVTmlyX2lP4yCG uzGofEVLPkjcgx6X1l0j5UmMmwfztZzNoxc/KEWPNbBkEuFGVz462KoHD/4Kds66sT78 zDEWHcq/py0Q0CS7U2cgrJqS2VkvsLm+XCxBhCUT9Kw+wVqoCWSNQD2DqxHc+zAyaj5y LoZA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=9ciWcbQJi4Vhr9kggcHWNZPTnC2LhHfHjA8K91Iee3o=; b=QEKjacAQ4bByZ2VcpxNCDiMH8A05yC1zCXsiHsB3e+Np4e5N86l+rbtk+LKMZpdIA+ afLg0UK5XsB0l7YUAMOtOY9Kk8Y8aAvgam4C8VOq2JThFbF8MgtjcDZzKSZa7Ww/+uTN jxIL04xUChxb49s5b9KC6qAivIcy8jgdKjXWV9oVg0UQ+qe9TjrZwidiubE9MyKwSw7L Yc95YQ4aQsb4IPksu03aspiFxON8JDLhmU0WPxAxD7BPAmD54b629p6/eE3e6z1OboTc 0r5zpFcgw3v6HYr46DmAMrisEU3HQoOFjDHTsExNvnZHUiZ02yQGt30sDUXppkIxNMEm rslg== 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 i9si7099439plb.284.2019.07.12.02.13.42; Fri, 12 Jul 2019 02:13:42 -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 S1726642AbfGLJNk (ORCPT + 29 others); Fri, 12 Jul 2019 05:13:40 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:55529 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbfGLJNk (ORCPT ); Fri, 12 Jul 2019 05:13:40 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.145]) with ESMTPA (Nemesis) id 1M9Evp-1hsCKR1COV-006PUz; Fri, 12 Jul 2019 11:12:52 +0200 From: Arnd Bergmann To: Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org Cc: Arnd Bergmann , "H. Peter Anvin" , Sean Christopherson , Junaid Shahid , Vitaly Kuznetsov , Lan Tianyu , Wei Yang , Kai Huang , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH 2/2] x86: kvm: avoid constant-conversion warning Date: Fri, 12 Jul 2019 11:12:30 +0200 Message-Id: <20190712091239.716978-2-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190712091239.716978-1-arnd@arndb.de> References: <20190712091239.716978-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:Lplw8L9pjitxjn8uvfCtJoBisPCqjfQiaYB9KiT+KGN1cMhK+5D n/9/tW1nGJzdBVxSoYqav3BS7V4RGgkHR9YN1LINgAaPvva1Qx26lH9nTlTY0zHaSxEilMg 7BtKZwd+0GWrh2mAZH3cn8oejeDl9a8Z3+ymWV/e/eayCEFlWogVmsUcdOYdm5qnm+NBhsR n2mHbJLBE2Pxwf82SAbNg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:2gJTX7oQrfo=:8iwkhuTEo+aTunqSalJZf8 Q6TlLUW7RDKJjjaEFe/LtwCj+w+S1LIDwMgftl5hzuEmGu78NLrJ6rjNPQ+PCnv3x8M01DBtJ kr4jFC1wHR+yZRHhnM1cO/JxZY4WiHPAj4iolh6XhfxmFuBsAH5SustbQ0CTas3HLR2ALH9tZ wV3WWWK98AxQbfA4C8/6ZucpZUhlALfb830BGO2VDlJVhIzksURR6aIJnoVTUJ1CBsOzyk8O1 gdTnbaTyC/pzW0jBPGZQWF3bXlkT7f82LtTKK6+zItWA32Da5/WZKUiaFSkGnReQLZwtgQR2J eYo/ybJzbKOWiMxJ7qafwBu//eoIUIE47EMpmM6xk3ePWbYYVGXSWQlJMoQEazPt7et24kda5 h9rdQMTI5qzrTyPLKIm4SE9K05jqIzfvkEGRrUs0XlUp6KmZYaSXUj3TSu08dNpuQRSUL6ra2 C/qoXTHIUtajn2IxHWyVRwTlL98MM0ocEzNAW68X9CMNU3Y5crQdfYXGxbbb89nFjow0SmSMo IS9pp53s0pu1u/X7zy/lfNDCs5F+7sQgxedbE26LcuBQ4ystfEEsSfQdnzpUPKH3XM6q66aoc YyLVPpYXg5CPjZTBhr/XxuupeehfNOZXyvpQvMbzqRQqHHvdoRoGG/ylPLIbYlD0iuCVbkeTr QoWLFKMVmb1pNQfR71sQpUzCa7E8YTn/4DH7TvvaqHWcdoMOrCLPwQ7zRADZWuZkoTH0vOSXg tLUPwuZbP10mwEDPt4R8TKxhIgimKY9b1Q+pAg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org clang finds a contruct suspicious that converts an unsigned character to a signed integer and back, causing an overflow: arch/x86/kvm/mmu.c:4605:39: error: implicit conversion from 'int' to 'u8' (aka 'unsigned char') changes value from -205 to 51 [-Werror,-Wconstant-conversion] u8 wf = (pfec & PFERR_WRITE_MASK) ? ~w : 0; ~~ ^~ arch/x86/kvm/mmu.c:4607:38: error: implicit conversion from 'int' to 'u8' (aka 'unsigned char') changes value from -241 to 15 [-Werror,-Wconstant-conversion] u8 uf = (pfec & PFERR_USER_MASK) ? ~u : 0; ~~ ^~ arch/x86/kvm/mmu.c:4609:39: error: implicit conversion from 'int' to 'u8' (aka 'unsigned char') changes value from -171 to 85 [-Werror,-Wconstant-conversion] u8 ff = (pfec & PFERR_FETCH_MASK) ? ~x : 0; ~~ ^~ Add an explicit cast to tell clang that everything works as intended here. Signed-off-by: Arnd Bergmann --- arch/x86/kvm/mmu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.20.0 diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 17ece7b994b1..aea7f969ecb8 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -4602,11 +4602,11 @@ static void update_permission_bitmask(struct kvm_vcpu *vcpu, */ /* Faults from writes to non-writable pages */ - u8 wf = (pfec & PFERR_WRITE_MASK) ? ~w : 0; + u8 wf = (pfec & PFERR_WRITE_MASK) ? (u8)~w : 0; /* Faults from user mode accesses to supervisor pages */ - u8 uf = (pfec & PFERR_USER_MASK) ? ~u : 0; + u8 uf = (pfec & PFERR_USER_MASK) ? (u8)~u : 0; /* Faults from fetches of non-executable pages*/ - u8 ff = (pfec & PFERR_FETCH_MASK) ? ~x : 0; + u8 ff = (pfec & PFERR_FETCH_MASK) ? (u8)~x : 0; /* Faults from kernel mode fetches of user pages */ u8 smepf = 0; /* Faults from kernel mode accesses of user pages */