public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Matthias Kaehlcke <mka@chromium.org>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"H . Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Nick Desaulniers" <ndesaulniers@google.com>,
	"Joe Perches" <joe@perches.com>
Subject: Re: [PATCH v2] kvm: x86: mmu: Add cast to negated bitmasks in update_permission_bitmask()
Date: Tue, 26 Jun 2018 11:08:26 +0200	[thread overview]
Message-ID: <f8df7ae5-e1e8-72b3-2f01-49d016b75719@redhat.com> (raw)
In-Reply-To: <20180625173502.GD129942@google.com>

On 25/06/2018 19:35, Matthias Kaehlcke wrote:
> commit e2a5dca753d1cdc3212519023ed8a13e13f5495b
> Author: Borislav Petkov <bp@suse.de>
> Date:   Thu Nov 23 10:19:51 2017 +0100
> 
>     x86/umip: Fix insn_get_code_seg_params()'s return value

So this is the closest thing to a bug (it could have been a real bug
if the caller checked ret < 0 instead of ret == -EINVAL).  *However*
the warning there is a bit misleading too.

The compiler does absolutely nothing to tell you that the return value
is in the [-EINVAL,132] range and therefore it should have been int.
_That_ would have been a useful warning.  Instead, it says:

      arch/x86/lib/insn-eval.c:780:10: warning: implicit conversion from 'int' to 'char'
              changes value from 132 to -124 [-Wconstant-conversion]
                      return INSN_CODE_SEG_PARAMS(4, 8);
                      ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~
      ./arch/x86/include/asm/insn-eval.h:16:57: note: expanded from macro 'INSN_CODE_SEG_PARAMS'
      #define INSN_CODE_SEG_PARAMS(oper_sz, addr_sz) (oper_sz | (addr_sz << 4))
    
If you changed the return value from char to u8, you'd break the "return
-EINVAL;" case.  The compiler would probably complain in turn that this
is not the right fix, by signaling a warning on "return -EINVAL;", but the
warning could really be done better.

Thanks,

Paolo

      parent reply	other threads:[~2018-06-26  9:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19 19:25 [PATCH v2] kvm: x86: mmu: Add cast to negated bitmasks in update_permission_bitmask() Matthias Kaehlcke
2018-06-25 16:02 ` David Laight
2018-06-25 16:05 ` Paolo Bonzini
2018-06-25 16:47   ` Nick Desaulniers
2018-06-25 17:01     ` Paolo Bonzini
2018-06-25 17:05     ` Joe Perches
2018-06-25 17:12       ` Nick Desaulniers
2018-06-25 17:34         ` Joe Perches
2018-06-25 17:35   ` Matthias Kaehlcke
2018-06-25 17:50     ` Joe Perches
2018-06-25 19:05       ` Nick Desaulniers
2018-06-26  9:08     ` Paolo Bonzini [this message]

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=f8df7ae5-e1e8-72b3-2f01-49d016b75719@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=hpa@zytor.com \
    --cc=joe@perches.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mka@chromium.org \
    --cc=ndesaulniers@google.com \
    --cc=rkrcmar@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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