public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Sultan Alsawaf <sultan@kerneltoast.com>,
	"Jason A. Donenfeld" <Jason@zx2c4.com>,
	kitsunyan <kitsunyan@airmail.cc>,
	"Brown, Len" <len.brown@intel.com>, X86 ML <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] x86/msr: do not warn on writes to OC_MAILBOX
Date: Tue, 20 Oct 2020 19:47:41 +0200	[thread overview]
Message-ID: <20201020174741.GJ11583@zn.tnic> (raw)
In-Reply-To: <ae3367ab7d4eb4778b51f798436ab975d7f8a303.camel@linux.intel.com>

On Tue, Oct 20, 2020 at 10:21:48AM -0700, Srinivas Pandruvada wrote:
> These command id are model specific. There is no guarantee that even
> meaning changes. So I don't think we should write any code in kernel
> which can't stick.

Ok, is there a common *set* of values present on all models?

A common set which we can abstract out from the MSR and have userspace
write them into sysfs and the kernel does the model-specific write?

The sysfs interface should simply provide the functionality, like, for
example say: "we have X valid undervolt indices, choose one".

Userspace doesn't have to deal with *how* that write happens and which
bits need to be set in the MSR and depend on the model - that's all
abstracted away by the kernel. All userspace needs to care about is
*what* it wants done to the hw. The *how exactly* is done by the kernel.

And then the differences are done with x86 model tests.

Does that make more sense?

> May be something like this:
> - Separate mailbox stuff from intel_turbo_max_3.c

Yah, that makes sense.

> - Create a standalone module which creates a debugfs interface
> - This debugs interface takes one 64 bit value from user space and use
> protocol to avoid contention

We can't make debugfs an API - debugfs can change at any point in time.
If you want an API, you put it in sysfs or in a separate fs.

> - Warns users on writes via new interfaces you suggested above

> > #define MSR_ADDR_TEMPERATURE 0x1a2
> Need to check use case for undervolt.

throttled uses it too. I asked them today to talk to us to design a
proper interface which satisfies their needs:

https://github.com/erpalma/throttled/issues/215

> > #define MSR_ADDR_UNITS 0x606
> Why not reuse powercap rapl interface. That interface will take care of
> units.

Sure.

Btw, you should have a look at those tools - they all poke at all kinds
of MSRs and correcting that is like a whack-a-mole game... ;-\

Oh, and the kernel pokes at them too so imagine the surprise one would have when
some kernel driver like

drivers/thermal/intel/int340x_thermal/processor_thermal_device.c

went and read some MSRs and then all of a sudden they changed because
some userspace daemon wrote them underneath it. Not good.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

  reply	other threads:[~2020-10-20 17:47 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-07  9:48 [PATCH] x86/msr: do not warn on writes to OC_MAILBOX Jason A. Donenfeld
2020-09-07 10:06 ` Borislav Petkov
2020-09-07 10:46   ` Jason A. Donenfeld
2020-09-07 11:11     ` Borislav Petkov
2020-09-07 11:15       ` Jason A. Donenfeld
2020-09-07 11:23         ` Borislav Petkov
2020-09-08 17:10   ` Srinivas Pandruvada
2020-09-08 17:12     ` Jason A. Donenfeld
2020-09-08 17:25       ` Borislav Petkov
2020-09-08 17:29         ` Jason A. Donenfeld
2020-09-08 17:36           ` Borislav Petkov
2020-09-08 17:42             ` Jason A. Donenfeld
2020-09-08 18:01               ` Borislav Petkov
2020-09-08 19:07                 ` Jason A. Donenfeld
2020-09-08 19:18                 ` Sultan Alsawaf
2020-09-08 19:30                   ` Borislav Petkov
2020-09-08 20:35                     ` Andy Lutomirski
2020-09-08 22:32                       ` Matthew Garrett
2020-09-09 23:56                         ` Andy Lutomirski
2020-09-09  1:02                     ` Srinivas Pandruvada
2020-09-10  0:08                       ` Andy Lutomirski
2020-10-19 17:15                       ` Borislav Petkov
2020-10-20 17:21                         ` Srinivas Pandruvada
2020-10-20 17:47                           ` Borislav Petkov [this message]
2020-10-20 18:40                             ` Srinivas Pandruvada
2020-10-20 19:40                               ` Dave Hansen
2020-10-21 13:11                                 ` Srinivas Pandruvada
2020-10-22 19:28                                   ` Borislav Petkov
2020-10-21 13:24                           ` Peter Zijlstra
2020-09-08 17:31     ` Borislav Petkov

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=20201020174741.GJ11583@zn.tnic \
    --to=bp@alien8.de \
    --cc=Jason@zx2c4.com \
    --cc=kitsunyan@airmail.cc \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=srinivas.pandruvada@linux.intel.com \
    --cc=sultan@kerneltoast.com \
    --cc=torvalds@linux-foundation.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