lkml.org 
[lkml]   [2018]   [Jun]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v2] kvm: x86: mmu: Add cast to negated bitmasks in update_permission_bitmask()
Date
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

\
 
 \ /
  Last update: 2018-06-25 18:02    [W:0.128 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site