Re: [PATCH v2 1/2] x86/msr: Document I/O-like MSR semantics in /dev/cpu/*/msr driver

From: Tim Wiederhake

Date: Fri Jun 26 2026 - 16:35:26 EST


On Fri, 2026-06-26 at 22:23 +0200, Tim Wiederhake wrote:
> Explain why msr_write and msr_read do not advance the index.
>
> Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
> ---
>  arch/x86/kernel/msr.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
> index 4469c784eaa0..cc719a6b2ba3 100644
> --- a/arch/x86/kernel/msr.c
> +++ b/arch/x86/kernel/msr.c
> @@ -13,6 +13,9 @@
>   * and then read/write in chunks of 8 bytes.  A larger size means
> multiple
>   * reads or writes of the same register.
>   *
> + * Writing the same register multiple times can be useful for MSRs
> with
> + * I/O-like semantics, e.g. a virtual MSR that accepts logging
> information.
> + *
>   * This driver uses /dev/cpu/%d/msr where %d is the minor number,
> and on
>   * an SMP box will direct the access to CPU %d.
>   */

I think I did something wrong with git send-email. The cover letter got
lost:

[PATCH v2 0/2] x86/msr: Clarify and restrict /dev/cpu/*/msr read
behavior

This is v2 of a patch originally sent in May 2023 [1] and resent
against v7.1 [2].

v1 removed the loops from both msr_read() and msr_write(). H. Peter
Anvin pointed out [3] that MSRs with I/O-like semantics (e.g. a virtual
MSR that accepts logging information) make the write loop useful.

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.

[1] https://lkml.org/lkml/2023/5/23/1230
[2]
https://lore.kernel.org/lkml/20260626174037.1128563-1-twiederh@xxxxxxxxxx/
[3]
https://lore.kernel.org/lkml/33F430D0-EFE6-471F-B4A1-D5D20E1F65AD@xxxxxxxxx/

Tim Wiederhake (2):
x86/msr: Document I/O-like MSR semantics in /dev/cpu/*/msr driver
x86/msr: Restrict /dev/cpu/*/msr read to a single MSR per call

arch/x86/kernel/msr.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)

--
2.52.0