Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2759623ybh; Mon, 5 Aug 2019 06:24:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzB5l+C0Ypo3B0KjcGU7gjAQ4o+Ph8IYA6fT9TvI87WcQRC9Aqgh73i472WMgJBjceR05MC X-Received: by 2002:a17:90a:1aa4:: with SMTP id p33mr18515331pjp.27.1565011480175; Mon, 05 Aug 2019 06:24:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565011480; cv=none; d=google.com; s=arc-20160816; b=fIIpO5KBsTVL9wvEyng9l3sW8aJHtRfCfpkHVOYQjrl5i9DD5hvP1mAYUWfQOzGB0j jsXNT/L7e6pyZSSDPSoWp8LbdswCwOb37aBzmny7+nxVRTZl+Ls2rPRz1MGRpjzpsjTw p27rxCkee+PL4RzNE/IRlmmYLVWsF2laJ6U9NoezJmM2Co0yAHAbXtx73ykUMyLEOLGk oktsOtA5u+5i2w8CN8GWoXLp2bz+SLa46uWXlCDZVNIO3SP0boIQ8RiThceJNw9jPnwW BPxFe9CUMVy8VZqKFW1NfcgfNNXJ397At/6zmoqPLdU1qyG0DppqwkB8f+ai1ifNsnbq vQrw== 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=ZZeCOVoBNG98d23SJnHU3bTnkEfue7qyOvGYPF78UPs=; b=ics0ZRhXoPYePE41Pix5JIaWTrZE/CT++55d/k6Y5J2+Hk2inzLwBV0unWgNK7QGJ1 OYBtOOJRpInPZEgZ1ZJc0peJw+HPSvGknBJ+ogMl/qTsHH3l4CCPmiz9MtrkxfLDhj3I 1D5bzxomUBD+3fxId7vnOINZncapMDvEBDNRXJY6FgIFQywOWXhOFQg7/8y11glzQMqk hKguuQ+sG1dzsolGh1NVX6VQY6p6U9r071XdASt9f3MIE8EyQ/TzeLG5scYaT5SLgtkn 5d75BgjA8oplPEeeHUEKzldo5Z9U10c4YURo7qUgu6uhrrtd42Jru0qoVBjVXXoeWu4O 1lTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qZ1EyIHA; 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 31si40299092pld.245.2019.08.05.06.24.24; Mon, 05 Aug 2019 06:24:40 -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=qZ1EyIHA; 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 S1730698AbfHENWd (ORCPT + 99 others); Mon, 5 Aug 2019 09:22:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:58974 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730696AbfHENWa (ORCPT ); Mon, 5 Aug 2019 09:22:30 -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 29C4820657; Mon, 5 Aug 2019 13:22:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565011349; bh=7WcCz3o4e2Hfs+qAR5ZW1cCLpsX3jnj7fAZ4w3TKjwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qZ1EyIHAOTzBBh6pKBx5faL7y+4IZOl/5x5/WcVAgfV69WoYTPwVuVlfbm0CfSLAf PwTr/N5Fzaj6DZeo6D8otkpzKqHXF7y+ZivHBCl/xES8Vf+jlkXgqOnYCe1l3DSmeP ul9UjQe7tPzCk3BQWTelnMoMezTOIbkzYFMJbiyE= 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 5.2 042/131] x86: kvm: avoid constant-conversion warning Date: Mon, 5 Aug 2019 15:02:09 +0200 Message-Id: <20190805124954.252567220@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190805124951.453337465@linuxfoundation.org> References: <20190805124951.453337465@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 98f6e4f88b04c..8d95c81b2c821 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -4593,11 +4593,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