lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YWht7v/1RuAiHIvC@archlinux-ax161>
Date:   Thu, 14 Oct 2021 10:50:38 -0700
From:   Nathan Chancellor <nathan@...nel.org>
To:     Jim Mattson <jmattson@...gle.com>
Cc:     Nick Desaulniers <ndesaulniers@...gle.com>,
        Paolo Bonzini <pbonzini@...hat.com>, torvic9@...lbox.org,
        "seanjc@...gle.com" <seanjc@...gle.com>,
        "vkuznets@...hat.com" <vkuznets@...hat.com>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "bp@...en8.de" <bp@...en8.de>
Subject: Re: [BUG] [5.15] Compilation error in arch/x86/kvm/mmu/spte.h with
 clang-14

On Mon, Oct 04, 2021 at 10:12:33AM -0700, Jim Mattson wrote:
> On Mon, Oct 4, 2021 at 9:13 AM Nick Desaulniers <ndesaulniers@...gle.com> wrote:
> >
> > On Mon, Oct 4, 2021 at 2:49 AM Paolo Bonzini <pbonzini@...hat.com> wrote:
> > >
> > > On 04/10/21 11:30, torvic9@...lbox.org wrote:
> > > >
> > > >> Paolo Bonzini <pbonzini@...hat.com> hat am 04.10.2021 11:26 geschrieben:
> > > >>
> > > >>
> > > >> On 04/10/21 11:08, torvic9@...lbox.org wrote:
> > > >>> I encounter the following issue when compiling 5.15-rc4 with clang-14:
> > > >>>
> > > >>> In file included from arch/x86/kvm/mmu/mmu.c:27:
> > > >>> arch/x86/kvm/mmu/spte.h:318:9: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
> > > >>>           return __is_bad_mt_xwr(rsvd_check, spte) |
> > > >>>                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > > >>>                                                    ||
> > > >>> arch/x86/kvm/mmu/spte.h:318:9: note: cast one or both operands to int to silence this warning
> > > >>
> > > >> The warning is wrong, as mentioned in the line right above:
> 
> Casting the bool to an int doesn't seem that onerous.

Alternatively, could we just change both of the functions to return u64?
I understand that they are being used in boolean contexts only but it
seems like this would make it clear that a boolean or bitwise operator
on them is acceptable.

diff --git a/arch/x86/kvm/mmu/spte.h b/arch/x86/kvm/mmu/spte.h
index eb7b227fc6cf..0ca215bfe3a3 100644
--- a/arch/x86/kvm/mmu/spte.h
+++ b/arch/x86/kvm/mmu/spte.h
@@ -295,14 +295,14 @@ static inline u64 get_rsvd_bits(struct rsvd_bits_validate *rsvd_check, u64 pte,
 	return rsvd_check->rsvd_bits_mask[bit7][level-1];
 }
 
-static inline bool __is_rsvd_bits_set(struct rsvd_bits_validate *rsvd_check,
-				      u64 pte, int level)
+static inline u64 __is_rsvd_bits_set(struct rsvd_bits_validate *rsvd_check,
+				     u64 pte, int level)
 {
 	return pte & get_rsvd_bits(rsvd_check, pte, level);
 }
 
-static inline bool __is_bad_mt_xwr(struct rsvd_bits_validate *rsvd_check,
-				   u64 pte)
+static inline u64 __is_bad_mt_xwr(struct rsvd_bits_validate *rsvd_check,
+				  u64 pte)
 {
 	return rsvd_check->bad_mt_xwr & BIT_ULL(pte & 0x3f);
 }

> > > > So it's an issue with clang-14 then?
> > > > (I add Nick and Nathan)
> > >
> > > My clang here doesn't have the option, so I'm going to ask---are you
> > > using W=1?  I can see why clang is warning for KVM's code, but in my
> > > opinion such a check should only be in -Wextra.
> >
> > This is a newly added warning in top of tree clang.
> >
> > >
> > > Paolo
> > >
> > > >>
> > > >>           /*
> > > >>            * Use a bitwise-OR instead of a logical-OR to aggregate the reserved
> > > >>            * bits and EPT's invalid memtype/XWR checks to avoid an extra Jcc
> > > >>            * (this is extremely unlikely to be short-circuited as true).
> > > >>            */
> > > >>
> > > >> Paolo
> > > >
> > >
> >
> >
> > --
> > Thanks,
> > ~Nick Desaulniers
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ