Re: [RFC PATCH v2] tools/x86: add kcpuid tool to show raw CPU features

From: Feng Tang
Date: Fri Sep 25 2020 - 03:22:30 EST


On Tue, Sep 22, 2020 at 12:38:30PM -0700, Dave Hansen wrote:
> On 9/21/20 10:27 PM, Feng Tang wrote:
> > +static void parse_text(void)
> > +{
> > + FILE *file;
> > + char *line = NULL;
> > + size_t len = 0;
> > + int ret;
> > +
> > + file = fopen("cpuid.txt", "r");
> > + if (!file) {
> > + printf("Error in opening 'cpuid.txt'\n");
> > + return;
> > + }
>
> This mostly looks fine to me. A few things about cpuid.txt, though...
> It needs to be read out of *some* location which is not the current
> directory. Maybe:
>
> /usr/share/hwdata/cpu.ids

Good point! User won't run it inside a kernel source tree folder. And yes,
there are already similar pci.ids and usb.ids in the same folder, we coud
do this in the 'install' part of Makefile

> or something. It also needs a "-f" argument to override this default
> location.

Ok, will add.

> I don't know if there's a better per-kernel place to put this
> file, though.

Device tree's dtb file may be similar, but it's also outside of bzImage.

Thanks,
Feng