From: "Jürgen Groß" <jgross@suse.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-ide@vger.kernel.org, dlemoal@kernel.org, cassel@kernel.org
Subject: Re: [PATCH 20/32] drivers/ata: Stop using 32-bit MSR interfaces
Date: Mon, 29 Jun 2026 09:28:06 +0200 [thread overview]
Message-ID: <9a55d4e7-23d2-4a1e-9ae9-ab60104cc9e1@suse.com> (raw)
In-Reply-To: <20260629062359.61A821F000E9@smtp.kernel.org>
[-- Attachment #1.1.1: Type: text/plain, Size: 2610 bytes --]
On 29.06.26 08:23, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [Critical] The change to `wrmsrq()` in `cs5535_set_piomode` introduces a critical sign-extension bug, writing `0xFFFFFFFF` to the upper 32 bits of the MSR.
> - [Low] The commit message is incomplete and truncated mid-sentence.
> --
>
> commit 9a4c6821b4ef60316ec2b36e0f505f4148809966
> Author: Juergen Gross <jgross@suse.com>
>
> drivers/ata: Stop using 32-bit MSR interfaces
>
> The 32-bit MSR interfaces rdmsr() and wrmsr() are planned to be removed.
> This patch switches the pata_cs5535 and pata_cs5536 drivers to use the
> 64-bit variants instead.
>
>> In drivers/ata/pata_cs5536.c don't redefine rdmsr() and wrmsr() as
>> empty macros for avoiding misuse, but guard the affected code via
>
> [Severity: Low]
> This isn't a bug, but the commit message appears to be truncated mid-sentence.
Oh, sorry, will update.
>
>> diff --git a/drivers/ata/pata_cs5535.c b/drivers/ata/pata_cs5535.c
>> index d793fc441b467..da98390cc49e8 100644
>> --- a/drivers/ata/pata_cs5535.c
>> +++ b/drivers/ata/pata_cs5535.c
>> @@ -102,16 +102,16 @@ static void cs5535_set_piomode(struct ata_port *ap, struct ata_device *adev)
>> cmdmode = min(mode, pairmode);
>> /* Write the other drive timing register if it changed */
>> if (cmdmode < pairmode)
>> - wrmsr(ATAC_CH0D0_PIO + 2 * pair->devno,
>> - pio_cmd_timings[cmdmode] << 16 | pio_timings[pairmode], 0);
>> + wrmsrq(ATAC_CH0D0_PIO + 2 * pair->devno,
>> + pio_cmd_timings[cmdmode] << 16 | pio_timings[pairmode]);
>> }
>> /* Write the drive timing register */
>> - wrmsr(ATAC_CH0D0_PIO + 2 * adev->devno,
>> - pio_cmd_timings[cmdmode] << 16 | pio_timings[mode], 0);
>> + wrmsrq(ATAC_CH0D0_PIO + 2 * adev->devno,
>> + pio_cmd_timings[cmdmode] << 16 | pio_timings[mode]);
>
> [Severity: Critical]
> Will these wrmsrq() calls write 0xFFFFFFFF into the upper 32 bits of the
> MSR for PIO mode 0?
>
> Because pio_cmd_timings contains u16 values, C integer promotion rules will
> promote pio_cmd_timings[cmdmode] to a signed 32-bit int before the shift.
>
> For PIO mode 0 (0xF7F4), the shift results in a negative 32-bit integer
> (0xF7F40000).
>
> Since wrmsrq() takes a u64 parameter, this negative 32-bit int is implicitly
> sign-extended to 64 bits (0xFFFFFFFFF7F4XXXX). This corrupts the upper
> 32 bits of the timing registers, which could trigger a General Protection
> Fault.
>
Right, will fix that.
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
next prev parent reply other threads:[~2026-06-29 7:28 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 6:04 [PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces Juergen Gross
2026-06-29 6:05 ` [PATCH 20/32] drivers/ata: Stop using " Juergen Gross
2026-06-29 6:23 ` sashiko-bot
2026-06-29 7:28 ` Jürgen Groß [this message]
2026-07-03 11:25 ` [PATCH v2 " Juergen Gross
2026-06-29 6:05 ` [PATCH 31/32] treewide: convert rdmsrq() from a macro to an inline function Juergen Gross
2026-06-29 6:24 ` sashiko-bot
2026-06-29 6:52 ` [PATCH 00/32] x86/msr: Drop 32-bit MSR interfaces Arnd Bergmann
2026-06-29 7:01 ` Jürgen Groß
2026-06-29 8:06 ` Arnd Bergmann
2026-06-29 8:15 ` Jürgen Groß
2026-06-29 8:38 ` Arnd Bergmann
2026-06-30 20:06 ` H. Peter Anvin
2026-06-29 11:19 ` Ingo Molnar
2026-06-30 18:59 ` Sean Christopherson
2026-07-01 8:33 ` Jürgen Groß
2026-07-02 10:07 ` Ingo Molnar
2026-07-02 11:03 ` Juergen Gross
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=9a55d4e7-23d2-4a1e-9ae9-ab60104cc9e1@suse.com \
--to=jgross@suse.com \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=linux-ide@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