From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Borislav Petkov <bp@alien8.de>
Cc: Matthew Whitehead <tedheadster@gmail.com>,
peterz@infradead.org, mingo@redhat.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/perf : Add check for CPUID instruction before using
Date: Fri, 2 Feb 2018 11:55:56 -0300 [thread overview]
Message-ID: <20180202145556.GE26905@kernel.org> (raw)
In-Reply-To: <20180202143731.ohtpa4kh4twtj7yo@pd.tnic>
Em Fri, Feb 02, 2018 at 03:37:31PM +0100, Borislav Petkov escreveu:
> On Fri, Feb 02, 2018 at 09:30:51AM -0500, Matthew Whitehead wrote:
> > We still officially support the ancient i486 cpu. First generation
> > versions of this processor do not have the CPUID instruction, though
> > later versions do. Therefore you must check that the cpu supports
> > it before using it. At present it fails with an "Illegal Instruction"
> > signal on the early processors.
> >
> > This code was based on similar code in the gcc package.
> >
> > Signed-off-by: Matthew Whitehead <tedheadster@gmail.com>
> > ---
> > tools/perf/arch/x86/util/header.c | 51 +++++++++++++++++++++++++++++++++++++++
> > tools/perf/util/header.h | 2 ++
> > 2 files changed, 53 insertions(+)
> >
> > diff --git a/tools/perf/arch/x86/util/header.c b/tools/perf/arch/x86/util/header.c
> > index fb0d71afee8b..d4d12894c64d 100644
> > --- a/tools/perf/arch/x86/util/header.c
> > +++ b/tools/perf/arch/x86/util/header.c
> > @@ -7,6 +7,54 @@
> >
> > #include "../../util/header.h"
> >
> > +/* This code based on gcc cpuid.h __get_cpuid_max() */
> > +unsigned int have_cpuid(void)
>
> You could've copied have_cpuid_p() from arch/x86/kernel/cpu/common.c
>
> > +{
> > + unsigned int __eax, __ebx;
> > +
> > +#ifndef __x86_64__
> > +/* See if we can use cpuid. On AMD64 we always can. */
> > +#if __GNUC__ >= 3
> > + __asm__ ("pushf{l|d}\n\t"
> > + "pushf{l|d}\n\t"
> > + "pop{l}\t%0\n\t"
> > + "mov{l}\t{%0, %1|%1, %0}\n\t"
> > + "xor{l}\t{%2, %0|%0, %2}\n\t"
> > + "push{l}\t%0\n\t"
> > + "popf{l|d}\n\t"
> > + "pushf{l|d}\n\t"
> > + "pop{l}\t%0\n\t"
> > + "popf{l|d}\n\t"
> > + : "=&r" (__eax), "=&r" (__ebx)
> > + : "i" (0x00200000));
> > +#else
> > +/* Host GCCs older than 3.0 weren't supporting Intel asm syntax
> > + * nor alternatives in i386 code.
>
> We don't support gcc < 3
>
> #if GCC_VERSION < 30200
> # error Sorry, your compiler is too old - please upgrade it.
> #endif
>
> There's even talk currently to raise the minimum version to 4.9 or so.
But this is for the kernel build process, right? If we don't have a
strict reason to forbid archeology... 8-)
- Arnaldo
next prev parent reply other threads:[~2018-02-02 14:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-02 14:30 [PATCH] x86/perf : Add check for CPUID instruction before using Matthew Whitehead
2018-02-02 14:37 ` Borislav Petkov
2018-02-02 14:55 ` Arnaldo Carvalho de Melo [this message]
2018-02-02 14:54 ` Arnaldo Carvalho de Melo
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=20180202145556.GE26905@kernel.org \
--to=acme@kernel.org \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tedheadster@gmail.com \
/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