mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Gaosheng Cui <cuigaosheng1@huawei.com>
Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
	tony.luck@intel.com, pawan.kumar.gupta@linux.intel.com,
	pbonzini@redhat.com, chenyi.qiang@intel.com,
	jithu.joseph@intel.com, alexs@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/cpu: fix undefined behavior in bit shift for intel_detect_tlb
Date: Mon, 31 Oct 2022 13:32:40 +0100	[thread overview]
Message-ID: <Y1/AaJOcgIc/INtv@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <Y1/AAegYuyZPxH04@hirez.programming.kicks-ass.net>

On Mon, Oct 31, 2022 at 01:30:57PM +0100, Peter Zijlstra wrote:
> On Mon, Oct 31, 2022 at 07:43:40PM +0800, Gaosheng Cui wrote:
> > Shifting signed 32-bit value by 31 bits is undefined, so changing
> > significant bit to unsigned. The UBSAN warning calltrace like below:
> > 
> > UBSAN: shift-out-of-bounds in arch/x86/kernel/cpu/intel.c:948:21
> > left shift of 1 by 31 places cannot be represented in type 'int'
> 
> Is it really? Shouldn't -fstrict-overflow define this case?

-fno-strict-overflow that is, which implies -fwrapv which ensures 2s
complement, at which point shifting signed numbers is fully defined.

  reply	other threads:[~2022-10-31 12:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-31 11:43 Gaosheng Cui
2022-10-31 12:04 ` Alex Shi
2022-10-31 12:30 ` Peter Zijlstra
2022-10-31 12:32   ` Peter Zijlstra [this message]
2022-11-01 11:48     ` 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=Y1/AaJOcgIc/INtv@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=alexs@kernel.org \
    --cc=bp@alien8.de \
    --cc=chenyi.qiang@intel.com \
    --cc=cuigaosheng1@huawei.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jithu.joseph@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=pbonzini@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --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

all inboxes | Powered by JetHome®