From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>,
Jarred White <jarredwhite@linux.microsoft.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
Linux PM <linux-pm@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Easwar Hariharan <eahariha@linux.microsoft.com>
Subject: Re: [GIT PULL] ACPI fixes for v6.9-rc6
Date: Thu, 25 Apr 2024 21:45:24 +0200 [thread overview]
Message-ID: <CAJZ5v0j7Do94XvUQrLgA_mFFyxdeb2RO08JwUzL0_QErOOrrAQ@mail.gmail.com> (raw)
In-Reply-To: <CAHk-=wj52PUZ0xtoLs79B9uar6h7FVaKC0gbD-a_wZxDjH2ViQ@mail.gmail.com>
On Thu, Apr 25, 2024 at 9:18 PM Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> On Thu, 25 Apr 2024 at 11:58, Linus Torvalds
> <torvalds@linux-foundation.org> wrote:
> >
> > And maybe this time, it's not a buggy mess?
>
> Actually, even with MASK_VAL() fixed, I think it's *STILL* a buggy mess.
>
> Why? Beuse the *uses* of MASK_VAL() seem entirely bogus.
>
> In particular, we have this in cpc_write():
>
> if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
> val = MASK_VAL(reg, val);
>
> switch (size) {
> case 8:
> writeb_relaxed(val, vaddr);
> break;
> case 16:
> writew_relaxed(val, vaddr);
> break;
> ...
>
> and I strongly suspect that it needs to update the 'vaddr' too. Something like
>
> if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
> val = MASK_VAL(reg, val);
> #ifdef __LITTLE_ENDIAN
> vaddr += reg->bit_offset >> 3;
> if (reg->bit_offset & 7)
> return -EFAULT;
> #else
> /* Fixme if we ever care */
> if (reg->bit_offset)
> return -EFAULT;
> #endif
> }
>
> *might* be changing this in the right direction, but it's unclear and
> I neither know that CPC rules, nor did I think _that_ much about it.
This is a very nice catch, thank you!
> Anyway, the take-away should be that all this code is entirely broken
> and somebody didn't think enough about it.
>
> It's possible that that whole cpc_write() ACPI_ADR_SPACE_SYSTEM_MEMORY
> case should be done as a 64-bit "read-mask-write" sequence.
>
> Possibly with "reg->bit_offset == 0" and the 8/16/32/64-bit cases as a
> special case for "just do the write".
>
> Or, maybe writes with a non-zero bit offset shouldn't be allowed at
> all, and there are CPC rules that aren't checked. I don't know. I only
> know that the current code is seriously broken.
In any case, this needs to be taken care of (Jared?).
Thanks,
Rafael
next prev parent reply other threads:[~2024-04-25 19:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-25 17:45 [GIT PULL] ACPI fixes for v6.9-rc6 Rafael J. Wysocki
2024-04-25 18:58 ` Linus Torvalds
2024-04-25 19:01 ` Linus Torvalds
2024-04-25 19:18 ` Linus Torvalds
2024-04-25 19:45 ` Rafael J. Wysocki [this message]
2024-04-25 19:22 ` pr-tracker-bot
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=CAJZ5v0j7Do94XvUQrLgA_mFFyxdeb2RO08JwUzL0_QErOOrrAQ@mail.gmail.com \
--to=rafael@kernel.org \
--cc=eahariha@linux.microsoft.com \
--cc=jarredwhite@linux.microsoft.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=torvalds@linux-foundation.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).