All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Ingo Molnar <mingo@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Amy Wiles <amy.l.wiles@intel.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ingo Molnar <mingo@redhat.com>,
	Jacob Pan <jacob.jun.pan@linux.intel.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH] x86/rapl: Do not load in a guest
Date: Fri, 4 Dec 2015 11:19:54 +0100	[thread overview]
Message-ID: <20151204101954.GA21177@pd.tnic> (raw)
In-Reply-To: <20151204082823.GA31591@gmail.com>

+ Paolo.

On Fri, Dec 04, 2015 at 09:28:23AM +0100, Ingo Molnar wrote:
> > > So when a hypervisor starts supporting RAPL we'll disable the driver erroneously?
> > > 
> > > Isn't there any better method to detect RAPL support?
> > > 
> > > So in particular in drivers/powercap/intel_rapl.c there's an enumerated list of 
> > > CPU models, which is used via a x86_match_cpu() call. That's still not ideal (it 
> > > does not work on hypervisors for example), but even better would be to detect RAPL 
> > > support in some other fashion, that does not rely on us statically enumerating CPU 
> > > models that support it.
> > 
> > RAPL isn't enumerated, the best we could do is attempt to write to one
> > of the writable MSRs and see if that 'works'.
> 
> Hm, bad - writing to MSRs like that is generally dangerous.
> 
> So we should at least provide a central 'is RAPL available' call instead of 
> spreading multiple X86_FEATURE_HYPERVISOR checks.

Well, looks like someone dropped the ball at the CPUID registrar. Other
features have more than one CPUID bit allocated to them, this one
doesn't have a single one.

And since there's no CPUID bit, I don't see any other way to detect the
RAPL presence. Poking at MSRs is a bad idea.

I wonder if we could go and allocate a bit in the kvm-emulated CPUID
leafs which says whether RAPL is supported or not.

Then we can go and check for that leaf on baremetal - if it is not
there, we do the vendor + fms check and if it is there, we know we're in
a guest and whether the guest supports it or not.

Dunno.

On the one hand, it looks like a bit too much to me.

On the other, it could be useful for other future feature checks where
we want baremetal and kvm to be synchronized wrt features and a single
method to be used by the kernel for checking features presence works
both on baremetal and virt.

Just a thought, anyway...

hpa, thoughts?

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

  reply	other threads:[~2015-12-04 10:20 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-03 18:27 [PATCH] x86/rapl: Do not load in a guest Borislav Petkov
2015-12-03 18:38 ` Jacob Pan
2015-12-03 18:42   ` Borislav Petkov
2015-12-03 18:59     ` Jacob Pan
2015-12-03 23:32       ` Rafael J. Wysocki
2015-12-03 23:25         ` Borislav Petkov
2015-12-04  1:00           ` Rafael J. Wysocki
2015-12-04  7:42 ` Ingo Molnar
2015-12-04  8:22   ` Peter Zijlstra
2015-12-04  8:28     ` Ingo Molnar
2015-12-04 10:19       ` Borislav Petkov [this message]
2015-12-04 10:41         ` Paolo Bonzini
2015-12-04 10:56           ` Borislav Petkov
2015-12-04 11:53             ` Ingo Molnar
2015-12-04 17:46               ` Jacob Pan
2015-12-04 17:52                 ` Paolo Bonzini
2015-12-04 18:04                 ` Borislav Petkov
2015-12-04 18:16                   ` Jacob Pan
2015-12-04 18:28                     ` Borislav Petkov
2015-12-04 18:37                       ` Jacob Pan
2015-12-04 19:41                         ` Borislav Petkov
2015-12-04 17:51     ` Jacob Pan
2015-12-04 22:14       ` Peter Zijlstra
2015-12-04 22:39         ` H. Peter Anvin

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=20151204101954.GA21177@pd.tnic \
    --to=bp@alien8.de \
    --cc=acme@kernel.org \
    --cc=amy.l.wiles@intel.com \
    --cc=hpa@zytor.com \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.