Re: [PATCH v2 12/14] platform/x86/intel/ifs: Add current_batch sysfs entry

From: Tony Luck
Date: Sun Nov 13 2022 - 16:33:59 EST


On Sun, Nov 13, 2022 at 07:27:26PM +0100, Borislav Petkov wrote:
> On Sun, Nov 13, 2022 at 09:55:00AM -0800, Joseph, Jithu wrote:
> > Then we were told not to specify a filename via sysfs file (apologies
> > for being repetitive)
>
> Yeah, I'm unclear on why that is either and am hoping that Greg will
> clarify. He fears that there will be file path resolution which I'm not
> even thinking about.

Summarizing the competing proposals here:

Option 1 (patches as currently posted)

User writes the batch number to the sysfs file:

# echo 4 > /sys/devices/virtual/misc/intel_ifs_0/current_batch

Driver turns that into a *partial* path (with test type, family-model-stepping
and batch number filled in):

"intel/ifs_%d/%02x-%02x-%02x-%02x.scan"

Feeds that to request_firmware_direct() (which looks in /lib/firmware)

Option 2 (proposed by Boris)

User writes a filename to the sysfs file:

# echo 06-8f-06-04.scan > /sys/devices/virtual/misc/intel_ifs_0/current_batch

Driver parses that:
If family-mode-stepping does not match current CPU, then
fail with -EINVAL
If filename doesn't end with a ".scan" suffix, also
fails with -EINVAL

Otherwise proceeds in similar manner to above. Constructs partial
pathname (just fills in test type and filename:

"intel/ifs_%d/%s"

Feeds that to request_firmware_direct() (which looks in /lib/firmware)


IMHO option 1 is following the microcode precedent of having the kernel
construct the filename based on the {x86,model,stepping} fields of
struct cpuinfo_x86.

I think option 2 isn't really doing the user any favors. Having them
feed all the *.scan files they find in /lib/firmware/intel/ifs_0 to the
driver to see which ones work becomes progressively worse in every CPU
generation. Any script/app running tests is likely to do the ff-mm-ss
filter itself ... so why have the kernel do it too?

-Tony