From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934268AbdBQOnj (ORCPT ); Fri, 17 Feb 2017 09:43:39 -0500 Received: from mx2.suse.de ([195.135.220.15]:60914 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933963AbdBQOni (ORCPT ); Fri, 17 Feb 2017 09:43:38 -0500 Subject: Re: [PATCH 2/2] x86/xen: use capabilities instead of fake cpuid values To: Boris Ostrovsky , linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, x86@kernel.org References: <20170217073625.13418-1-jgross@suse.com> <20170217073625.13418-3-jgross@suse.com> <1f923425-47f5-5e6d-5bca-e4c98d54ced5@suse.com> Cc: hpa@zytor.com, tglx@linutronix.de, mingo@redhat.com From: Juergen Gross Message-ID: Date: Fri, 17 Feb 2017 15:43:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/02/17 15:30, Boris Ostrovsky wrote: > > > On 02/17/2017 09:19 AM, Juergen Gross wrote: >> On 17/02/17 15:05, Boris Ostrovsky wrote: >>> >>> >>> On 02/17/2017 02:36 AM, Juergen Gross wrote: >>>> When running as pv domain xen_cpuid() is being used instead of >>>> native_cpuid(). In xen_cpuid() the aperf/mperf feature is indicated >>>> as not being present by special casing the related cpuid leaf. >>>> >>>> Instead of delivering fake cpuid values clear the cpu capability bit >>>> for aperf/mperf instead. >>>> >>>> Signed-off-by: Juergen Gross >>>> --- >>>> arch/x86/xen/enlighten.c | 11 +++-------- >>>> 1 file changed, 3 insertions(+), 8 deletions(-) >>>> >>>> diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c >>>> index 83399ce..0eebb75 100644 >>>> --- a/arch/x86/xen/enlighten.c >>>> +++ b/arch/x86/xen/enlighten.c >>>> @@ -301,9 +301,6 @@ xen_running_on_version_or_later(unsigned int >>>> major, unsigned int minor) >>>> return false; >>>> } >>>> >>>> -#define CPUID_THERM_POWER_LEAF 6 >>>> -#define APERFMPERF_PRESENT 0 >>>> - >>>> static __read_mostly unsigned int cpuid_leaf1_edx_mask = ~0; >>>> static __read_mostly unsigned int cpuid_leaf1_ecx_mask = ~0; >>>> >>>> @@ -337,11 +334,6 @@ static void xen_cpuid(unsigned int *ax, unsigned >>>> int *bx, >>>> *dx = cpuid_leaf5_edx_val; >>>> return; >>>> >>>> - case CPUID_THERM_POWER_LEAF: >>>> - /* Disabling APERFMPERF for kernel usage */ >>>> - maskecx = ~(1 << APERFMPERF_PRESENT); >>>> - break; >>>> - >>> >>> >>> But now APERF/MPERF will be reported as supported by CPUID, won't it? >> >> Yes. But this shouldn't be a problem as the kernel is always testing >> X86_FEATURE_APERFMPERF for testing the support. > > > But X86_FEATURE_APERFMPERF cap is set based on CPUID query. Right. And setup_clear_cpu_cap() will result in removing the feature from the capabilities (removes it from boot cpu capabilities at once and is setting it in the mask which is negated and anded into the capabilities after issuing the cpuid queries). Juergen