Messages in this thread | | | 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 |
| |
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
| |