[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201119072055.GA112648@shbuild999.sh.intel.com>
Date: Thu, 19 Nov 2020 15:20:55 +0800
From: Feng Tang <feng.tang@...el.com>
To: Borislav Petkov <bp@...en8.de>
Cc: Peter Zijlstra <peterz@...radead.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H . Peter Anvin" <hpa@...or.com>,
Dave Hansen <dave.hansen@...el.com>, x86@...nel.org,
linux-kernel@...r.kernel.org, nivedita@...m.mit.edu,
thomas.lendacky@....com, yazen.ghannam@....com, wei.huang2@....com
Subject: Re: [RFC PATCH v3] tools/x86: add kcpuid tool to show raw CPU
features
Hi Borislav,
Thanks for reviewing and trying.
On Wed, Nov 18, 2020 at 08:15:29PM +0100, Borislav Petkov wrote:
> On Thu, Oct 22, 2020 at 01:21:23PM +0800, Feng Tang wrote:
> > diff --git a/tools/arch/x86/kcpuid/kcpuid.c b/tools/arch/x86/kcpuid/kcpuid.c
> > new file mode 100644
> > index 0000000..9bd35b7
> > --- /dev/null
> > +++ b/tools/arch/x86/kcpuid/kcpuid.c
> > @@ -0,0 +1,618 @@
> > +// SPDX-License-Identifier: GPL-2.0
>
> You need here:
>
> #define _GNU_SOURCE
Thanks for the fix.
> otherwise:
>
> cc -Wextra -O2 -Wall -I../../../include -o kcpuid kcpuid.c
> kcpuid.c: In function ‘parse_line’:
> kcpuid.c:324:6: warning: implicit declaration of function ‘strcasestr’; did you mean ‘strcasecmp’? [-Wimplicit-function-declaration]
> 324 | if (strcasestr(buf, "EAX"))
> | ^~~~~~~~~~
> | strcasecmp
> Also, options text needs fixing:
>
> usage: kcpuid [-abdfhr] [-l leaf] [-s subleaf]
> -a|--all Show info of all CPUID leafs and subleafs(default on)
> -b|--bitflags Show boolean flags only
> -d|--detail Show details of the flag/fields
> -f|--flags Show boolean flags only
>
> that f is user_csv, above in the "usage" line too.
>
> -h|--help Show usage info
> -l|--leaf=index Specify the leaf you want to check
> -r|--raw Show raw cpuid data
> -s|--subleaf=sub Specify the subleaf you want to check
Will fix.
> > +/*
> > + * Parse text file, and construct the array of all CPUID leafs and subleafs
> > + */
> > +static void parse_text(void)
> > +{
> > + FILE *file;
> > + char *filename, *line = NULL;
>
> Do here:
>
> char *filename = def_csv;
>
> > + size_t len = 0;
> > + int ret;
> > +
> > + if (show_raw)
> > + return;
> > +
> > + filename = user_csv ? user_csv : def_csv;
>
> And now you do:
>
> if (user_csv)
> filename = user_csv;
Ok, will change.
> But something's not working still. I've added debug output and it chokes
> on the test data:
>
> $ ./kcpuid -f cpuid.csv
> This platform has 51 CPUID leafs and subleafs.
>
> parse_text: filename: cpuid.csv
> open
> parsing [# The basic row format is:
> ]parsing [# LEAF,SUBLEAF,register_name,bits,short name,long description
> ]parsing [
> ]parsing [# Leaf 00H
> ]parsing [ 0, 0, EAX, 31:0, max_basic_leafs, Max input value for supported subleafs
> ]parsing [# Leaf 01H
> ]parsing [ 1, 0, ECX, 28, avx, AVX instruction supported
> ]parsing [ 1, 0, ECX, 29, f16c, 16-bit floating-point conversion instruction supported
> ]parsing [ 1, 0, ECX, 30, rdrand, RDRAND instruction supported
> ]parsing [
> ]parsing [#
> ]parsing [# !!! Test data for testing different options, will be updated in formal version
> ]parsing [#
> ]parsing [ 4, 0, ECX, 1, aaa, AAA
> Segmentation fault
I just tried the patch on one Debian 9 and 2 Ubuntus (16.04 & 20.10) with
different gcc versions, and haven't reproduced it yet. What's your distro
and gcc version? I will try to reproduce.
One thing I doubted is the getline() in parse_text() needs a accompany
free() according to its man page, but it can be added after the loop.
Anyway I attached one debug verison kcpuid.c which prints more info, thanks.
- Feng
> Thx.
>
> --
> Regards/Gruss,
> Boris.
>
> https://people.kernel.org/tglx/notes-about-netiquette
View attachment "kcpuid.c" of type "text/x-csrc" (12900 bytes)
Powered by blists - more mailing lists