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 */