From: Yury Norov <ynorov@nvidia.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "Thomas Gleixner" <tglx@kernel.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
"Andy Lutomirski" <luto@kernel.org>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Ping-Ke Shih" <pkshih@realtek.com>,
"Richard Cochran" <richardcochran@gmail.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
"Yury Norov" <yury.norov@gmail.com>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Hans de Goede" <hansg@kernel.org>,
"Linus Walleij" <linusw@kernel.org>,
"Sakari Ailus" <sakari.ailus@linux.intel.com>,
"Salah Triki" <salah.triki@gmail.com>,
"Achim Gratz" <Achim.Gratz@stromeko.de>,
"Ben Collins" <bcollins@watter.com>,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
linux-rtc@vger.kernel.org
Subject: Re: [PATCH 2/9] x86/extable: switch to using FIELD_GET_SIGNED()
Date: Mon, 20 Apr 2026 13:18:47 -0400 [thread overview]
Message-ID: <aeZf98xjbxdHvZOS@yury> (raw)
In-Reply-To: <20260420112428.GF3102624@noisy.programming.kicks-ass.net>
On Mon, Apr 20, 2026 at 01:24:28PM +0200, Peter Zijlstra wrote:
> On Fri, Apr 17, 2026 at 01:36:13PM -0400, Yury Norov wrote:
> > The EX_DATA register is laid out such that EX_DATA_IMM occupied MSB.
> > It's done to make sure that FIELD_GET() will sign-extend the IMM
> > field during extraction.
> >
> > To enforce that, all EX_DATA masks are made signed integers. This
> > works, but relies on the particular implementation of FIELD_GET(),
> > i.e. masking then shifting, not vice versa; and the particular
> > placement of the fields in the register.
>
> I don't think the order of the mask and shift matters in this case. If
> we were to first shift down and then mask, it would still work (after
> all, the mask would also need to be shifted and would also get sign
> extended, effectively ending up as -1).
FIELD_GET() doesn't require mask to be signed when a reg is signed, so
shifting mask may become zero-extended in an alternative implementation:
(reg >> __bf_shf(mask)) & (mask >> __bf_shf(mask)
This all is hypothetical, anyways.
> But yes, this very much depends on the signed field being the topmost
> field and including the MSB.
This is the part I dislike mostly. This would look just like undefined
behavior for the API user: depending on fields placement or type of the
inputs, sometimes FIELD_GET() sign-extendeds the field, and sometimes
not.
We could likely force FIELD_GET() to treat both reg and mask as unsigned
types, and state that explicitly in the documentation.
next prev parent reply other threads:[~2026-04-20 17:18 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-17 17:36 [PATCH 0/9] bitfield: add FIELD_GET_SIGNED() Yury Norov
2026-04-17 17:36 ` [PATCH 1/9] " Yury Norov
2026-04-17 18:12 ` Andy Shevchenko
2026-04-17 19:43 ` David Laight
2026-04-17 21:09 ` Yury Norov
2026-04-20 8:43 ` Johannes Berg
2026-04-20 11:19 ` Peter Zijlstra
2026-04-20 17:54 ` Yury Norov
2026-04-17 17:36 ` [PATCH 2/9] x86/extable: switch to using FIELD_GET_SIGNED() Yury Norov
2026-04-20 11:24 ` Peter Zijlstra
2026-04-20 17:18 ` Yury Norov [this message]
2026-04-20 22:00 ` David Laight
2026-04-17 17:36 ` [PATCH 3/9] iio: intel_dc_ti_adc: " Yury Norov
2026-04-19 13:18 ` Jonathan Cameron
2026-04-17 17:36 ` [PATCH 4/9] iio: magnetometer: yas530: " Yury Norov
2026-04-19 13:20 ` Jonathan Cameron
2026-04-19 20:11 ` Linus Walleij
2026-04-17 17:36 ` [PATCH 5/9] iio: pressure: bmp280: " Yury Norov
2026-04-19 13:21 ` Jonathan Cameron
2026-04-17 17:36 ` [PATCH 6/9] iio: mcp9600: " Yury Norov
2026-04-19 13:21 ` Jonathan Cameron
2026-04-17 17:36 ` [PATCH 7/9] wifi: rtw89: " Yury Norov
2026-04-20 7:49 ` Ping-Ke Shih
2026-04-20 17:59 ` Yury Norov
2026-04-17 17:36 ` [PATCH 8/9] rtc: rv3032: " Yury Norov
2026-04-17 17:36 ` [PATCH 9/9] ptp: " Yury Norov
2026-04-17 18:23 ` [PATCH 0/9] bitfield: add FIELD_GET_SIGNED() Andy Shevchenko
2026-04-17 19:21 ` Yury Norov
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=aeZf98xjbxdHvZOS@yury \
--to=ynorov@nvidia.com \
--cc=Achim.Gratz@stromeko.de \
--cc=alexandre.belloni@bootlin.com \
--cc=andrew+netdev@lunn.ch \
--cc=andy@kernel.org \
--cc=bcollins@watter.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=dlechner@baylibre.com \
--cc=edumazet@google.com \
--cc=hansg@kernel.org \
--cc=hpa@zytor.com \
--cc=jic23@kernel.org \
--cc=kuba@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=pabeni@redhat.com \
--cc=peterz@infradead.org \
--cc=pkshih@realtek.com \
--cc=richardcochran@gmail.com \
--cc=sakari.ailus@linux.intel.com \
--cc=salah.triki@gmail.com \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
--cc=yury.norov@gmail.com \
/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