From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755414AbbLDIXG (ORCPT ); Fri, 4 Dec 2015 03:23:06 -0500 Received: from casper.infradead.org ([85.118.1.10]:49963 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751519AbbLDIXE (ORCPT ); Fri, 4 Dec 2015 03:23:04 -0500 Date: Fri, 4 Dec 2015 09:22:56 +0100 From: Peter Zijlstra To: Ingo Molnar Cc: Borislav Petkov , Amy Wiles , "Rafael J. Wysocki" , LKML , Arnaldo Carvalho de Melo , "H. Peter Anvin" , Ingo Molnar , Jacob Pan , Thomas Gleixner Subject: Re: [PATCH] x86/rapl: Do not load in a guest Message-ID: <20151204082256.GC17308@twins.programming.kicks-ass.net> References: <1449167222-17562-1-git-send-email-bp@alien8.de> <20151204074206.GB24827@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151204074206.GB24827@gmail.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 04, 2015 at 08:42:06AM +0100, Ingo Molnar wrote: > > * Borislav Petkov wrote: > > > From: Borislav Petkov > > > > qemu/kvm doesn't support RAPL and RAPL doesn't have a CPUID feature bit > > so check whether we're in a guest instead. > > 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'. Also, yuck @ powercap/intel_rapl.c for doing rdmsr_on_cpu() + wrmsr_on_cpu() all over the place.