From: Peter Zijlstra <peterz@infradead.org>
To: Gaosheng Cui <cuigaosheng1@huawei.com>
Cc: seanjc@google.com, pbonzini@redhat.com, tglx@linutronix.de,
mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
x86@kernel.org, hpa@zytor.com, kvm@vger.kernel.org
Subject: Re: [PATCH v2] KVM: x86: fix undefined behavior in bit shift for __feature_bit
Date: Tue, 1 Nov 2022 09:44:53 +0100 [thread overview]
Message-ID: <Y2DchcVrZIMfk8Fv@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20221101022828.565075-1-cuigaosheng1@huawei.com>
On Tue, Nov 01, 2022 at 10:28:28AM +0800, Gaosheng Cui wrote:
> Shifting signed 32-bit value by 31 bits is undefined, so we fix it
> with the BIT() macro, at the same time, we change the input to
> unsigned, and replace "/ 32" with ">> 5".
>
> The UBSAN warning calltrace like below:
>
> UBSAN: shift-out-of-bounds in arch/x86/kvm/reverse_cpuid.h:101:11
> left shift of 1 by 31 places cannot be represented in type 'int'
Again; please go fix your toolchain and don't quote broken crap like
this to change the code.
I'm fine with the changes, but there is no UB here, don't pretend there
is.
next prev parent reply other threads:[~2022-11-01 8:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-01 2:28 [PATCH v2] KVM: x86: fix undefined behavior in bit shift for __feature_bit Gaosheng Cui
2022-11-01 8:44 ` Peter Zijlstra [this message]
2022-11-01 11:35 ` cuigaosheng
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=Y2DchcVrZIMfk8Fv@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bp@alien8.de \
--cc=cuigaosheng1@huawei.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.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