public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
	seanjc@google.com, torvic9@mailbox.org,
	Jim Mattson <jmattson@google.com>,
	llvm@lists.linux.dev
Subject: Re: [PATCH] KVM: x86: avoid warning with -Wbitwise-instead-of-logical
Date: Fri, 15 Oct 2021 09:37:16 -0700	[thread overview]
Message-ID: <YWmuPOB6/rXWqXBH@archlinux-ax161> (raw)
In-Reply-To: <20211015085148.67943-1-pbonzini@redhat.com>

On Fri, Oct 15, 2021 at 04:51:48AM -0400, Paolo Bonzini wrote:
> This is a new warning in clang top-of-tree (will be 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
> 
> Reported-by: torvic9@mailbox.org
> Suggested-by: Jim Mattson <jmattson@google.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  arch/x86/kvm/mmu/spte.h | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/kvm/mmu/spte.h b/arch/x86/kvm/mmu/spte.h
> index eb7b227fc6cf..32bc7268c9ea 100644
> --- a/arch/x86/kvm/mmu/spte.h
> +++ b/arch/x86/kvm/mmu/spte.h
> @@ -314,9 +314,12 @@ static __always_inline bool is_rsvd_spte(struct rsvd_bits_validate *rsvd_check,
>  	 * 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).
> +	 *
> +	 * (int) avoids clang's "use of bitwise '|' with boolean operands"
> +	 * warning.
>  	 */
> -	return __is_bad_mt_xwr(rsvd_check, spte) |
> -	       __is_rsvd_bits_set(rsvd_check, spte, level);
> +	return (int)__is_bad_mt_xwr(rsvd_check, spte) |
> +	       (int)__is_rsvd_bits_set(rsvd_check, spte, level);
>  }
>  
>  static inline bool spte_can_locklessly_be_made_writable(u64 spte)
> -- 
> 2.27.0
> 
> 

       reply	other threads:[~2021-10-15 16:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20211015085148.67943-1-pbonzini@redhat.com>
2021-10-15 16:37 ` Nathan Chancellor [this message]
2021-10-15 17:46   ` [PATCH] KVM: x86: avoid warning with -Wbitwise-instead-of-logical Nick Desaulniers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YWmuPOB6/rXWqXBH@archlinux-ax161 \
    --to=nathan@kernel.org \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=torvic9@mailbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox