On Tue, Jun 21, 2022 at 02:58:46PM +1000, Jonathan Gray wrote:
> Intel CPUs used to have strings like
> cpu0: Intel(R) Pentium(R) M processor 1200MHz ("GenuineIntel" 686-class) 1.20 
> GHz
> cpu0: Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz, 2494.61 MHz, 06-3d-04
> recent CPUs use
> cpu0: 11th Gen Intel(R) Core(TM) i5-1130G7 @ 1.10GHz, 30009.37 MHz, 06-8c-01
> cpu0: 12th Gen Intel(R) Core(TM) i5-12400, 4390.71 MHz, 06-97-02
> cpu0: 12th Gen Intel(R) Core(TM) i7-1260P, 1995.55 MHz, 06-9a-03
> 
> Index: patterns.c
> ===================================================================
> RCS file: /cvs/src/usr.sbin/fw_update/patterns.c,v
> retrieving revision 1.3
> diff -u -p -r1.3 patterns.c
> --- patterns.c        10 Mar 2022 07:12:13 -0000      1.3
> +++ patterns.c        21 Jun 2022 04:31:24 -0000
> @@ -94,7 +94,7 @@ main(void)
>       printf("%s\n", "bwfm");
>       printf("%s\n", "bwi");
>       printf("%s\n", "intel");
> -     printf("%s\n", "intel ^cpu0: Intel");
> +     printf("%s\n", "intel ^cpu0:*Intel(R)");
>       printf("%s\n", "inteldrm");
>       print_devices("inteldrm", i915_devices, nitems(i915_devices));
>       printf("%s\n", "ipw");
> 

If I properly understood the way patterns file is used in fw_update, having a 
'*' in the middle of the searched string could be hasardous and will result in 
possible false positive (installing a firmware whereas not need).

With the pattern "intel ^cpu0:*Intel(R)", the search is done using:

        _d="intel"
        _m="^cpu0:*Intel(R)"
        _nl=$(echo)             # newline: \n

        [ "$_m" ]             || _m="${_nl}${_d}[0-9] at "      # no change
        [ "$_m" = "${_m#^}" ] || _m="${_nl}${_m#^}"             # changed to 
_m="\ncpu0:*Intel(R)"

        if [[ ${_dmesgtail} = *$_m* ]] ; then
                echo "$_d"
        fi

The final searched string (glob) is "*\ncpu0:*Intel(R)*".

It means that if the dmesg contains "\ncpu0:" and "Intel(R)" (in this order, 
but 
not necessary on the same line) it will match.

On dmesglog, I found only few candidates for "Intel(R)" string not on a "cpuX:" 
line:

        bios0: Intel(R) Client Systems NUC8i5BEH
        ugen0 at uhub2 port 2 "Intel Corporation Intel(R) Centrino(R) 
Wireless-N + WiMAX 6150" rev 2.00/0.00 addr 3
        ugen0 at uhub2 port 6 "Intel(R) Corporation Intel(R) Centrino(R) 
Advanced-N + WiMAX 6250" rev 2.00/0.00 addr 4
        uhidev0 at uhub2 port 1 configuration 1 interface 0 "Intel Corporation 
Intel(R) Sensor Solution" rev 2.00/0.01 addr 3

the bios0 entry is *before* cpu0, so it will not match. But the others entries 
will match (assuming the dmesg contains a cpu0: line, which somehow expected).

Below an alternative diff to match the Intel cpu without using '*':

diff 5177244f5c04ec0ff6b9b724b540740d62d2dcfa /home/semarie/repos/openbsd/src
blob - d7cbab70c1654d8dc6ca067cea55b440fd70d426
file + usr.sbin/fw_update/patterns.c
--- usr.sbin/fw_update/patterns.c
+++ usr.sbin/fw_update/patterns.c
@@ -95,6 +95,7 @@ main(void)
        printf("%s\n", "bwi");
        printf("%s\n", "intel");
        printf("%s\n", "intel ^cpu0: Intel");
+       printf("%s\n", "intel ^cpu0: [0-9][0-9]th Gen Intel");
        printf("%s\n", "inteldrm");
        print_devices("inteldrm", i915_devices, nitems(i915_devices));
        printf("%s\n", "ipw");

Comments ?
-- 
Sebastien Marie

Reply via email to