Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2751966ybh; Mon, 5 Aug 2019 06:17:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxe7/5MWjFUuQ3JudwyzbfC98Ir1kH7Ay0HAajsNsuxLTFJbvvBeLcNJ4jFkGvNZAVAtvQH X-Received: by 2002:aa7:8651:: with SMTP id a17mr72386614pfo.138.1565011055339; Mon, 05 Aug 2019 06:17:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565011055; cv=none; d=google.com; s=arc-20160816; b=suwcWEo93IG7vWvHJB6fmflghbiHQk0aYOfvWTKY2/12trnKzzd4SA12VaFJytbtuv xCTMsDtybREOT1h1DFvVTpgzW9/3idvaB0LG8H0x50q9bpJ8QJV3yPJe9VEH8V6NxRUN N7DFbT4X8ezxGQ9jpYYHH6Ew0JKWGPV3XjmAWg/kCkZS1/DREHwLoJYZf/Zm5qTqkAvW 3TTbbdAaIRMjNzLrgmMpjnC9MbAu20VjSygROpFnODtKVJwLXG94aTGeWDFKlf6N66/O G/XRftfr6OV2jlcXXfmS1ZK4/i0535PZCzWSs6oyUgm8DTIzHihMQJevmKJFwFOtyzrF b2wA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/hXQDiNUolxzLL/P+dsPf6puLE/tnpQ/HqeNUEGhU/s=; b=y8Nj5dQj3b2Jyhkv/r+dUiq5v8WPPr9X7mfC+34tQCHFUJii87U1XZSkNFXNyF0FBE juxY181rRSwxHzjwQYtmJ+Jo0lKpywVMdKZuwhktNslYiNPr3s+rmfmPe7Sz5opyRwnp /9q4TnYnmLSVkYAjwMiIdvomKM3uDWoE3y/ey4fIEOJLhRwpA+cAz//DRu0BEasLwGu2 Sjg6+182aWj2sjITgegvgtXYX8w/P5HAK9hPJM96icm019XAqllR3Rj+yHw02cyMs26A orewn3atzsR/3G82fijBHMCAfOcjncEHQTlefdLGHuRtWvXwhwhsgeG3Qh5d+SZHAbFV Vj9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BI3uZjsM; 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 v184si45149989pgv.566.2019.08.05.06.17.19; Mon, 05 Aug 2019 06:17:35 -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; dkim=pass header.i=@kernel.org header.s=default header.b=BI3uZjsM; 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 S1729754AbfHENPg (ORCPT + 99 others); Mon, 5 Aug 2019 09:15:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:44162 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729686AbfHENHB (ORCPT ); Mon, 5 Aug 2019 09:07:01 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A90362075B; Mon, 5 Aug 2019 13:06:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565010420; bh=PCg97u3p1U941e7BvgXoCYqVd4ZisV+e5YDO8vEZl8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BI3uZjsM6rHo9e/QdjMDx5qsQ6zW50f40nitM0Dmivbj8ZAr9gWQvmRArR2SFo1wq LeyI3Yfpb2nslLVavRpSImhFDymgozerYxyrHlofNcfoHnBQD6zK6cY5YbF9GfIeJn c8gal+JqifWm9UEKJp7uq8b33GRu20Yyi74eGRdU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Paolo Bonzini , Sasha Levin Subject: [PATCH 4.14 17/53] x86: kvm: avoid constant-conversion warning Date: Mon, 5 Aug 2019 15:02:42 +0200 Message-Id: <20190805124930.002378879@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124927.973499541@linuxfoundation.org> References: <20190805124927.973499541@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit a6a6d3b1f867d34ba5bd61aa7bb056b48ca67cff ] 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 Link: https://github.com/ClangBuiltLinux/linux/issues/95 Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/mmu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index f97b533bc6e68..87a0601b1c204 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -4313,11 +4313,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 */ -- 2.20.1