From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Laight Subject: RE: [PATCH v2] kvm: x86: mmu: Add cast to negated bitmasks in update_permission_bitmask() Date: Mon, 25 Jun 2018 16:02:40 +0000 Message-ID: References: <20180619192504.180479-1-mka@chromium.org> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 8BIT Cc: "x86@kernel.org" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Nick Desaulniers , Joe Perches To: 'Matthias Kaehlcke' , Paolo Bonzini , =?iso-8859-2?Q?Radim_Kr=E8m=E1=F8?= , Thomas Gleixner , "H . Peter Anvin" Return-path: In-Reply-To: <20180619192504.180479-1-mka@chromium.org> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org From: Matthias Kaehlcke > Sent: 19 June 2018 20:25 > To: Paolo Bonzini; Radim Krèmáø; Thomas Gleixner; H . Peter Anvin > Cc: x86@kernel.org; kvm@vger.kernel.org; linux-kernel@vger.kernel.org; Nick Desaulniers; Joe Perches; > Matthias Kaehlcke > Subject: [PATCH v2] kvm: x86: mmu: Add cast to negated bitmasks in update_permission_bitmask() > > update_permission_bitmask() negates u8 bitmask values and assigns them > to variables of type u8. Since the MSB is set in the bitmask values the > compiler expands the negated values to int, which then is assigned to > an u8 variable. Cast the negated value back to u8. > > This fixes several warnings like this when building with clang: > > arch/x86/kvm/mmu.c:4266: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; > ~~ ^~ Shoot the compiler writer - or turn off that warning. Or try 'w ^ 0xff'. David