Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH v3 5/8] linux/log2.h: Add 64-bit roundup/down_pow_of_two64() variants
Date: Tue, 13 Oct 2026 13:16:22 +0000	[thread overview]
Message-ID: <sashiko-outbox-169789@kernel.org> (raw)
In-Reply-To: <20261013130948.6231-6-ilpo.jarvinen@linux.intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] log2: 64-bit roundup/down_pow_of_two64() truncates and UBs on 32-bit archs
--

commit 56bd761df1693290739ce316beb7a19a30f72c63
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
linux/log2.h: Add 64-bit roundup/down_pow_of_two64() variants

This commit introduces new 64-bit variants of the power-of-two rounding
functions and macros to prevent unexpected truncation of 64-bit inputs
that occurs with the existing helpers.

[Severity: High]
In include/linux/log2.h, the newly added 64-bit functions
__roundup_pow_of_two64 at line 69, __rounddown_pow_of_two64 at line 89,
and their macro equivalents roundup_pow_of_two64 at line 198 and
rounddown_pow_of_two64 at line 231 all use 1UL as the base for their bit
shift operations.

Since these functions and macros are explicitly designed to process u64
values, can this cause undefined behavior and truncation on 32-bit
architectures?

On platforms where sizeof(unsigned long) is 4, shifting 1UL by 32 or
greater will result in undefined behavior, and the upper 32 bits will be
truncated before the result is promoted to u64.

Would it be safer to use 1ULL as the shift base to ensure correct 64-bit
math across all architectures?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261013130948.6231-1-ilpo.jarvinen@linux.intel.com?part=5

  reply	other threads:[~2026-10-13 13:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 13:09 [PATCH v3 0/8] PCI: Resource placement algorithm fixes Ilpo Järvinen
2026-10-13 13:09 ` [PATCH v3 1/8] resource: Mark free space assigned Ilpo Järvinen
2026-10-13 13:28   ` sashiko-bot
2026-10-13 13:09 ` [PATCH v3 2/8] PCI/parisc: Clean up resource debug print & use dynamic debug Ilpo Järvinen
2026-10-13 13:19   ` sashiko-bot
2026-10-13 13:09 ` [PATCH v3 3/8] PCI: Honor alignment overrides Ilpo Järvinen
2026-10-13 13:24   ` sashiko-bot
2026-10-13 14:08   ` Rodrigo Vivi
2026-10-13 13:09 ` [PATCH v3 4/8] PCI: Fix nesting windows with remainder at the left edge Ilpo Järvinen
2026-10-13 13:25   ` sashiko-bot
2026-10-13 13:09 ` [PATCH v3 5/8] linux/log2.h: Add 64-bit roundup/down_pow_of_two64() variants Ilpo Järvinen
2026-10-13 13:16   ` sashiko-bot [this message]
2026-10-13 13:09 ` [PATCH v3 6/8] PCI: Place resources to either edge of the window Ilpo Järvinen
2026-10-13 13:19   ` sashiko-bot
2026-10-13 13:09 ` [PATCH v3 7/8] PCI: Fix composite resource sizing Ilpo Järvinen
2026-10-13 13:26   ` sashiko-bot
2026-10-13 13:09 ` [PATCH v3 8/8] PCI/quirks: Avoid certain address on Genoa systems Ilpo Järvinen
2026-10-13 13:24   ` sashiko-bot
2026-10-13 17:00   ` Mario Limonciello
2026-10-13 17:03     ` Mario Limonciello
2026-10-13 17:26       ` Ilpo Järvinen
2026-10-13 18:59         ` Mario Limonciello

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=sashiko-outbox-169789@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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