From: Tim Wiederhake <twiederh@redhat.com>
To: "H. Peter Anvin" <hpa@zytor.com>,
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, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] x86/msr: Document I/O-like MSR semantics in /dev/cpu/*/msr driver
Date: Mon, 29 Jun 2026 19:14:20 +0200 [thread overview]
Message-ID: <53927aa31cf56ec9270ffc64aec5a5e87f3f8b23.camel@redhat.com> (raw)
In-Reply-To: <C35F0DF2-DFF5-40FA-A3A0-3809809E9E2E@zytor.com>
On Mon, 2026-06-29 at 08:23 -0700, H. Peter Anvin wrote:
> On June 29, 2026 8:14:12 AM PDT, Tim Wiederhake <twiederh@redhat.com>
> wrote:
> > On Fri, 2026-06-26 at 14:42 -0700, H. Peter Anvin wrote:
> > > On 2026-06-26 13:33, Tim Wiederhake wrote:
> > > >
> > > > This version splits the change in two:
> > > >
> > > > 1/2 adds a comment explaining why the driver loops over the
> > > > same
> > > > register, so future readers don't have to rediscover the
> > > > rationale.
> > > > 2/2 removes only the read loop, where repeated access to the
> > > > same
> > > > register is less obviously useful.
> > > >
> > > The same applies to the read loop, although the use case(s) are
> > > obviously
> > > different.
> > >
> > > Either way, you risk breaking working tools for no reason.
> > >
> > > -hpa
> > While looking into this I also noticed that /dev/cpu/*/msr is the
> > only
> > register-addressed character device that doesn't advance ppos on
> > read.
> > /dev/cpu/*/cpuid, /dev/port, and /dev/nvram do. That causes ftell()
> > and
> > lseek(SEEK_CUR, 0) to disagree after an fread(). I don't know how
> > important that is though, and whether that is more of a glibc
> > issue.
> >
> > Can you please point me to a tool that uses the multiple-read
> > behavior?
> > I want to mention that in the file comment, but turbostat, rdmsr,
> > cpupower, coreboot's inteltool, all read exactly 8 bytes.
> >
> > Thanks for the review,
> > Tim
> >
> >
>
> /dev/ioport behave(d) that way as well, and was the model.
>
> However, you are barking up the wrong tree here: when you want to
> change a 25-year-old API for no technical reason — your only argument
> raised has been aestetics — then the burden of proof is on *you* that
> you won't break anything.
I find that behavior unexpected and would have loved to make it less
surprising, but you're right that I can't guarantee nothing breaks.
I'll resend the comment patch as v3.
Thanks for the /dev/ioport pointer.
Regards,
Tim
next prev parent reply other threads:[~2026-06-29 17:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 17:40 [PATCH] x86/msr: Restrict /dev/cpu/*/msr read and write to a single MSR per call Tim Wiederhake
2026-06-26 17:49 ` H. Peter Anvin
2026-06-26 20:17 ` Borislav Petkov
2026-06-26 20:23 ` [PATCH v2 1/2] x86/msr: Document I/O-like MSR semantics in /dev/cpu/*/msr driver Tim Wiederhake
2026-06-26 20:33 ` Tim Wiederhake
2026-06-26 21:42 ` H. Peter Anvin
2026-06-29 15:14 ` Tim Wiederhake
2026-06-29 15:23 ` H. Peter Anvin
2026-06-29 17:14 ` Tim Wiederhake [this message]
2026-06-26 20:23 ` [PATCH v2 2/2] x86/msr: Restrict /dev/cpu/*/msr read to a single MSR per call Tim Wiederhake
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=53927aa31cf56ec9270ffc64aec5a5e87f3f8b23.camel@redhat.com \
--to=twiederh@redhat.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@kernel.org \
--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
Powered by JetHome