From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752867AbbFKOTT (ORCPT ); Thu, 11 Jun 2015 10:19:19 -0400 Received: from cantor2.suse.de ([195.135.220.15]:54667 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752351AbbFKOTR (ORCPT ); Thu, 11 Jun 2015 10:19:17 -0400 Date: Thu, 11 Jun 2015 16:19:04 +0200 From: Borislav Petkov To: Huang Rui Cc: Andy Lutomirski , Thomas Gleixner , Peter Zijlstra , "Rafael J. Wysocki" , Len Brown , John Stultz , =?utf-8?B?RnLDqWTDqXJpYw==?= Weisbecker , linux-kernel@vger.kernel.org, x86@kernel.org, Fengguang Wu , Aaron Lu , Suravee Suthikulanit , Tony Li , Ken Xue Subject: Re: [PATCH v3 1/2] x86, mwaitt: add monitorx and mwaitx instruction Message-ID: <20150611141904.GE30391@pd.tnic> References: <1434032051-1953-1-git-send-email-ray.huang@amd.com> <1434032051-1953-2-git-send-email-ray.huang@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1434032051-1953-2-git-send-email-ray.huang@amd.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 11, 2015 at 10:14:10PM +0800, Huang Rui wrote: > On AMD Carrizo processors (Family 15h, Model 60h-6fh), there is a new > feature called MWAITT (Mwait with a timer) as an extension of > Monitor/Mwait. > > MWAITT, another name is MWAITX (MWAIT with extensions), has a configurable > timer that causes MWAITX to exit on expiration. > > Compared with MONITOR/MWAIT, there are minor differences in opcode and > input parameters. > > MWAITX ECX[1]: enable timer if set > MWAITX EBX[31:0]: max wait time expressed in SW P0 clocks > > MWAIT MWAITX > opcode 0f 01 c9 | 0f 01 fb > ECX[0] value of RFLAGS.IF seen by instruction > ECX[1] unused/#GP if set | enable timer if set > ECX[31:2] unused/#GP if set > EAX unused (reserve for hint) > EBX[31:0] unused | max wait time (loops) > > MONITOR MONITORX > opcode 0f 01 c8 | 0f 01 fa > EAX (logical) address to monitor > ECX #GP if not zero > > The software P0 frequency is the same as the TSC frequency. > > Max timeout = EBX/(TSC frequency) As suggested last time, please put the description of MWAITX over __mwaitx() in the code as comments below. See below. > Signed-off-by: Huang Rui > --- > arch/x86/include/asm/cpufeature.h | 1 + > arch/x86/include/asm/mwait.h | 16 ++++++++++++++++ > 2 files changed, 17 insertions(+) > > diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h > index 3d6606f..3ef1f6e 100644 > --- a/arch/x86/include/asm/cpufeature.h > +++ b/arch/x86/include/asm/cpufeature.h > @@ -176,6 +176,7 @@ > #define X86_FEATURE_PERFCTR_NB ( 6*32+24) /* NB performance counter extensions */ > #define X86_FEATURE_BPEXT (6*32+26) /* data breakpoint extension */ > #define X86_FEATURE_PERFCTR_L2 ( 6*32+28) /* L2 performance counter extensions */ > +#define X86_FEATURE_MWAITT ( 6*32+29) /* Mwait extension (MonitorX/MwaitX) */ > > /* > * Auxiliary flags: Linux defined - For features scattered in various > diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h > index 653dfa7..ece8048 100644 > --- a/arch/x86/include/asm/mwait.h > +++ b/arch/x86/include/asm/mwait.h > @@ -23,6 +23,14 @@ static inline void __monitor(const void *eax, unsigned long ecx, > :: "a" (eax), "c" (ecx), "d"(edx)); > } > > +static inline void __monitorx(const void *eax, unsigned long ecx, > + unsigned long edx) > +{ > + /* "monitorx %eax, %ecx, %edx;" */ > + asm volatile(".byte 0x0f, 0x01, 0xfa;" > + :: "a" (eax), "c" (ecx), "d"(edx)); > +} > + > static inline void __mwait(unsigned long eax, unsigned long ecx) > { > /* "mwait %eax, %ecx;" */ > @@ -30,6 +38,14 @@ static inline void __mwait(unsigned long eax, unsigned long ecx) > :: "a" (eax), "c" (ecx)); > } > +static inline void __mwaitx(unsigned long eax, unsigned long ebx, > + unsigned long ecx) > +{ > + /* "mwaitx %eax, %ebx, %ecx;" */ > + asm volatile(".byte 0x0f, 0x01, 0xfb;" > + :: "a" (eax), "b" (ebx), "c" (ecx)); > +} > + > static inline void __sti_mwait(unsigned long eax, unsigned long ecx) > { > trace_hardirqs_on(); > -- > 1.9.1 > -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply. --