Commit Graph

50 Commits

Author SHA1 Message Date
David Arcari d22405f058 platform/x86/intel/ifs: Remove unnecessary initialization of 'ret'
JIRA: https://issues.redhat.com/browse/RHEL-35194

commit 682c259a849610c7864cc75d52415c782c78653a
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Date:   Thu Jan 25 15:03:28 2024 +0200

    platform/x86/intel/ifs: Remove unnecessary initialization of 'ret'

    The ret variable is unconditionally assigned in ifs_load_firmware().
    Therefore, remove its unnecessary initialization.

    Reviewed-by: Ashok Raj <ashok.raj@intel.com>
    Link: https://lore.kernel.org/r/20240125130328.11253-1-ilpo.jarvinen@linux.intel.com
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-05-01 17:30:33 -04:00
David Arcari 530bf6fd5b platform/x86/intel/ifs: Add an entry rendezvous for SAF
JIRA: https://issues.redhat.com/browse/RHEL-35194

commit ad630f5d92717632a15e1d0b92e5421e6eac7c8d
Author: Ashok Raj <ashok.raj@intel.com>
Date:   Thu Jan 25 00:22:54 2024 -0800

    platform/x86/intel/ifs: Add an entry rendezvous for SAF

    The activation for Scan at Field (SAF) includes a parameter to make
    microcode wait for both threads to join. It's preferable to perform an
    entry rendezvous before the activation to ensure that they start the
    `wrmsr` close enough to each other. In some cases it has been observed
    that one of the threads might be just a bit late to arrive. An entry
    rendezvous reduces the likelihood of these cases occurring.

    Add an entry rendezvous to ensure the activation on both threads happen
    close enough to each other.

    Signed-off-by: Ashok Raj <ashok.raj@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Link: https://lore.kernel.org/r/20240125082254.424859-6-ashok.raj@intel.com
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-05-01 17:30:33 -04:00
David Arcari 9d8711fb6b platform/x86/intel/ifs: Replace the exit rendezvous with an entry rendezvous for ARRAY_BIST
JIRA: https://issues.redhat.com/browse/RHEL-35194

commit ea15f34d5fb77a0db0dd9f983b647fe5b613cf73
Author: Ashok Raj <ashok.raj@intel.com>
Date:   Thu Jan 25 00:22:53 2024 -0800

    platform/x86/intel/ifs: Replace the exit rendezvous with an entry rendezvous for ARRAY_BIST

    ARRAY_BIST requires the test to be invoked only from one of the HT
    siblings of a core.  If the other sibling was in mwait(), that didn't
    permit the test to complete and resulted in several retries before the
    test could finish.

    The exit rendezvous was introduced to keep the HT sibling busy until
    the primary CPU completed the test to avoid those retries. What is
    actually needed is to ensure that both the threads rendezvous *before*
    the wrmsr to trigger the test to give good chance to complete the test.

    The `stop_machine()` function returns only after all the CPUs complete
    running the function, and provides an exit rendezvous implicitly.

    In kernel/stop_machine.c::multi_cpu_stop(), every CPU in the mask
    needs to complete reaching MULTI_STOP_RUN. When all CPUs complete, the
    state machine moves to next state, i.e MULTI_STOP_EXIT. Thus the
    underlying API stop_core_cpuslocked() already provides an exit
    rendezvous.

    Add the rendezvous earlier in order to ensure the wrmsr is triggered
    after all CPUs reach the do_array_test(). Remove the exit rendezvous
    since stop_core_cpuslocked() already guarantees that.

    Signed-off-by: Ashok Raj <ashok.raj@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Link: https://lore.kernel.org/r/20240125082254.424859-5-ashok.raj@intel.com
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-05-01 17:30:33 -04:00
David Arcari 4ee51ca833 platform/x86/intel/ifs: Add current batch number to trace output
JIRA: https://issues.redhat.com/browse/RHEL-35194

commit e272d1e1188e55259dd0e3ba2f8f744a531fdd59
Author: Ashok Raj <ashok.raj@intel.com>
Date:   Thu Jan 25 00:22:52 2024 -0800

    platform/x86/intel/ifs: Add current batch number to trace output

    Add the current batch number in the trace output. When there are
    failures, it's important to know which test content resulted in failure.

    #           TASK-PID     CPU#  |||||  TIMESTAMP  FUNCTION
    #              | |         |   |||||     |         |
         migration/0-18      [000] d..1. 527287.084668: ifs_status: batch: 02, start: 0000, stop: 007f, status: 0000000000007f80
       migration/128-785     [128] d..1. 527287.084669: ifs_status: batch: 02, start: 0000, stop: 007f, status: 0000000000007f80

    Signed-off-by: Ashok Raj <ashok.raj@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Link: https://lore.kernel.org/r/20240125082254.424859-4-ashok.raj@intel.com
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-05-01 17:30:33 -04:00
David Arcari 5feb1c3592 platform/x86/intel/ifs: Trace on all HT threads when executing a test
JIRA: https://issues.redhat.com/browse/RHEL-35194

commit def1ed0db2a66eed5de593748ffe131615edb45e
Author: Ashok Raj <ashok.raj@intel.com>
Date:   Thu Jan 25 00:22:51 2024 -0800

    platform/x86/intel/ifs: Trace on all HT threads when executing a test

    Enable the trace function on all HT threads.  Currently, the trace is
    called from some arbitrary CPU where the test was invoked.

    This change gives visibility to the exact errors as seen by each
    participating HT threads, and not just what was seen from the primary
    thread.

    Sample output below.

    #           TASK-PID     CPU#  |||||  TIMESTAMP  FUNCTION
    #              | |         |   |||||     |         |
         migration/0-18      [000] d..1. 527287.084668: start: 0000, stop: 007f, status: 0000000000007f80
       migration/128-785     [128] d..1. 527287.084669: start: 0000, stop: 007f, status: 0000000000007f80

    Signed-off-by: Ashok Raj <ashok.raj@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Link: https://lore.kernel.org/r/20240125082254.424859-3-ashok.raj@intel.com
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-05-01 17:30:33 -04:00
Prarit Bhargava cf500aa2ee Change DEFINE_SEMAPHORE() to take a number argument
JIRA: https://issues.redhat.com/browse/RHEL-25415

Conflicts: Minor drift issues.

commit 48380368dec14859723b9e3fbd43e042638d9a76
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Wed Mar 29 12:14:42 2023 +0200

    Change DEFINE_SEMAPHORE() to take a number argument

    Fundamentally semaphores are a counted primitive, but
    DEFINE_SEMAPHORE() does not expose this and explicitly creates a
    binary semaphore.

    Change DEFINE_SEMAPHORE() to take a number argument and use that in the
    few places that open-coded it using __SEMAPHORE_INITIALIZER().

    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    [mcgrof: add some tribal knowledge about why some folks prefer
     binary sempahores over mutexes]
    Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
    Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
    Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
2024-03-20 09:43:05 -04:00
Steve Best 1bb3b0661f platform/x86/intel/ifs: Call release_firmware() when handling errors.
JIRA: https://issues.redhat.com/browse/RHEL-23312

Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=58502477

Tested: Successful run of ifs platform test on Intel system(intel-eaglestream-spr-12).

commit 8c898ec07a2fc1d4694e81097a48e94a3816308d
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Thu Jan 25 00:22:50 2024 -0800

    platform/x86/intel/ifs: Call release_firmware() when handling errors.

    Missing release_firmware() due to error handling blocked any future image
    loading.

    Fix the return code and release_fiwmare() to release the bad image.

    Fixes: 25a76dbb36dd ("platform/x86/intel/ifs: Validate image size")
    Reported-by: Pengfei Xu <pengfei.xu@intel.com>
    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Signed-off-by: Ashok Raj <ashok.raj@intel.com>
    Tested-by: Pengfei Xu <pengfei.xu@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Link: https://lore.kernel.org/r/20240125082254.424859-2-ashok.raj@intel.com
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: Steve Best <sbest@redhat.com>
2024-01-30 15:21:41 -05:00
David Arcari 393db34c60 x86/microcode/intel: Rework intel_find_matching_signature()
JIRA: https://issues.redhat.com/browse/RHEL-15512
Conflicts: asm/cpu.h differs from upstream, integrity of the change
	   was maintained.

commit b7fcd995b261c9976e05f47554529c98a0f1cbb0
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Mon Oct 2 13:59:50 2023 +0200

    x86/microcode/intel: Rework intel_find_matching_signature()

    Take a cpu_signature argument and work from there. Move the match()
    helper next to the callsite as there is no point for having it in
    a header.

    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
    Link: https://lore.kernel.org/r/20231002115902.797820205@linutronix.de

Signed-off-by: David Arcari <darcari@redhat.com>
2023-12-05 11:56:53 -05:00
David Arcari 75a8341da2 x86/microcode/intel: Rework intel_cpu_collect_info()
JIRA: https://issues.redhat.com/browse/RHEL-15512

commit 164aa1ca537238c46923ccacd8995b4265aee47b
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Tue Oct 17 23:23:45 2023 +0200

    x86/microcode/intel: Rework intel_cpu_collect_info()

    Nothing needs struct ucode_cpu_info. Make it take struct cpu_signature,
    let it return a boolean and simplify the implementation. Rename it now
    that the silly name clash with collect_cpu_info() is gone.

    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
    Link: https://lore.kernel.org/r/20231017211722.851573238@linutronix.de

Signed-off-by: David Arcari <darcari@redhat.com>
2023-12-05 11:56:53 -05:00
David Arcari c3d2486b80 platform/x86/intel/ifs: ARRAY BIST for Sierra Forest
JIRA: https://issues.redhat.com/browse/RHEL-15512

commit 06d65b2bc532fc9af1c55aa7a18cfd237ce46588
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Thu Oct 5 12:51:37 2023 -0700

    platform/x86/intel/ifs: ARRAY BIST for Sierra Forest

    Array BIST MSR addresses, bit definition and semantics are different for
    Sierra Forest. Branch into a separate Array BIST flow on Sierra Forest
    when user invokes Array Test.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Tested-by: Pengfei Xu <pengfei.xu@intel.com>
    Link: https://lore.kernel.org/r/20231005195137.3117166-10-jithu.joseph@intel.com
    [ij: ARRAY_GEN_* -> ARRAY_GEN* for consistency]
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-12-05 11:56:53 -05:00
David Arcari 404f241cd5 platform/x86/intel/ifs: Add new error code
JIRA: https://issues.redhat.com/browse/RHEL-15512

commit b9aa9e4c8b4e52b6f2f5986b27e97f4b6163f0bf
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Thu Oct 5 12:51:36 2023 -0700

    platform/x86/intel/ifs: Add new error code

    Make driver aware of a newly added error code so that it can provide a
    more appropriate error message.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Tested-by: Pengfei Xu <pengfei.xu@intel.com>
    Link: https://lore.kernel.org/r/20231005195137.3117166-9-jithu.joseph@intel.com
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-12-05 11:56:53 -05:00
David Arcari dad0791fdc platform/x86/intel/ifs: Add new CPU support
JIRA: https://issues.redhat.com/browse/RHEL-15512

commit e6483a0b59026ded36a6f5eba1425a6b0965984a
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Thu Oct 5 12:51:35 2023 -0700

    platform/x86/intel/ifs: Add new CPU support

    Add Granite Rapids(GNR) and Sierra Forest(SRF) cpuids to x86 match table
    so that IFS driver can be loaded for those.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Tested-by: Pengfei Xu <pengfei.xu@intel.com>
    Link: https://lore.kernel.org/r/20231005195137.3117166-8-jithu.joseph@intel.com
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-12-05 11:56:53 -05:00
David Arcari 3f0e311e79 platform/x86/intel/ifs: Metadata validation for start_chunk
JIRA: https://issues.redhat.com/browse/RHEL-15512

commit 60d2e1b37d530d6b1f8b7773cebaf8bbc1536b28
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Thu Oct 5 12:51:34 2023 -0700

    platform/x86/intel/ifs: Metadata validation for start_chunk

    Add an additional check to validate IFS image metadata field prior to
    loading the test image.

    If start_chunk is not a multiple of chunks_per_stride error out.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Tested-by: Pengfei Xu <pengfei.xu@intel.com>
    Link: https://lore.kernel.org/r/20231005195137.3117166-7-jithu.joseph@intel.com
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-12-05 11:56:53 -05:00
David Arcari 2da1981b7a platform/x86/intel/ifs: Validate image size
JIRA: https://issues.redhat.com/browse/RHEL-15512

commit 25a76dbb36dd58ad4df7f6a4dc43061a10b0d817
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Thu Oct 5 12:51:33 2023 -0700

    platform/x86/intel/ifs: Validate image size

    Perform additional validation prior to loading IFS image.

    Error out if the size of the file being loaded doesn't match the size
    specified in the header.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Tested-by: Pengfei Xu <pengfei.xu@intel.com>
    Link: https://lore.kernel.org/r/20231005195137.3117166-6-jithu.joseph@intel.com
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-12-05 11:56:53 -05:00
David Arcari 0f4cf20dd2 platform/x86/intel/ifs: Gen2 Scan test support
JIRA: https://issues.redhat.com/browse/RHEL-15512

commit 72b96ee29ed6f7670bbb180ba694816e33d361d1
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Thu Oct 5 12:51:32 2023 -0700

    platform/x86/intel/ifs: Gen2 Scan test support

    Width of chunk related bitfields is ACTIVATE_SCAN and SCAN_STATUS MSRs
    are different in newer IFS generation compared to gen0.

    Make changes to scan test flow such that MSRs are populated
    appropriately based on the generation supported by hardware.

    Account for the 8/16 bit MSR bitfield width differences between gen0 and
    newer generations for the scan test trace event too.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Tested-by: Pengfei Xu <pengfei.xu@intel.com>
    Link: https://lore.kernel.org/r/20231005195137.3117166-5-jithu.joseph@intel.com
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-12-05 11:56:53 -05:00
David Arcari d7813940c0 platform/x86/intel/ifs: Gen2 scan image loading
JIRA: https://issues.redhat.com/browse/RHEL-15512

commit 07f47c01b3bc2a42c4d4da35831edab10aa60449
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Thu Oct 5 12:51:31 2023 -0700

    platform/x86/intel/ifs: Gen2 scan image loading

    Scan image loading flow for newer IFS generations are slightly different
    from that of current generation. In newer schemes, loading need not be
    done once for each socket as was done in gen0.

    Also the width of NUM_CHUNKS bitfield in SCAN_HASHES_STATUS MSR has
    increased from 8 -> 16 bits. Similarly there are width differences for
    CHUNK_AUTHENTICATION_STATUS too.

    Further the parameter to AUTHENTICATE_AND_COPY_CHUNK is passed
    differently in newer generations.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Tested-by: Pengfei Xu <pengfei.xu@intel.com>
    Link: https://lore.kernel.org/r/20231005195137.3117166-4-jithu.joseph@intel.com
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-12-05 11:56:53 -05:00
David Arcari 5876274f00 platform/x86/intel/ifs: Refactor image loading code
JIRA: https://issues.redhat.com/browse/RHEL-15512

commit a138ac2656d1329c3994a227769b7ba3926818a7
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Thu Oct 5 12:51:30 2023 -0700

    platform/x86/intel/ifs: Refactor image loading code

    IFS image loading flow is slightly different for newer IFS generations.

    In preparation for adding support for newer IFS generations, refactor
    portions of existing image loading code for reuse.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Tested-by: Pengfei Xu <pengfei.xu@intel.com>
    Link: https://lore.kernel.org/r/20231005195137.3117166-3-jithu.joseph@intel.com
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-12-05 11:56:53 -05:00
David Arcari 1b0fe0315e platform/x86/intel/ifs: Store IFS generation number
JIRA: https://issues.redhat.com/browse/RHEL-15512

commit 97a5e801b3045c1e800f76bc0fb544972538089d
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Thu Oct 5 12:51:29 2023 -0700

    platform/x86/intel/ifs: Store IFS generation number

    IFS generation number is reported via MSR_INTEGRITY_CAPS.  As IFS
    support gets added to newer CPUs, some differences are expected during
    IFS image loading and test flows.

    Define MSR bitmasks to extract and store the generation in driver data,
    so that driver can modify its MSR interaction appropriately.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Tested-by: Pengfei Xu <pengfei.xu@intel.com>
    Link: https://lore.kernel.org/r/20231005195137.3117166-2-jithu.joseph@intel.com
    Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-12-05 11:56:53 -05:00
David Arcari 067e09c3af platform/x86/intel/ifs: release cpus_read_lock()
JIRA: https://issues.redhat.com/browse/RHEL-15512

commit 2545deba314eec91dc5ca1a954fe97f91ef1cf07
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Wed Sep 27 11:48:24 2023 -0700

    platform/x86/intel/ifs: release cpus_read_lock()

    Couple of error paths in do_core_test() was returning directly without
    doing a necessary cpus_read_unlock().

    Following lockdep warning was observed when exercising these scenarios
    with PROVE_RAW_LOCK_NESTING enabled:

    [  139.304775] ================================================
    [  139.311185] WARNING: lock held when returning to user space!
    [  139.317593] 6.6.0-rc2ifs01+ #11 Tainted: G S      W I
    [  139.324499] ------------------------------------------------
    [  139.330908] bash/11476 is leaving the kernel with locks still held!
    [  139.338000] 1 lock held by bash/11476:
    [  139.342262]  #0: ffffffffaa26c930 (cpu_hotplug_lock){++++}-{0:0}, at:
    do_core_test+0x35/0x1c0 [intel_ifs]

    Fix the flow so that all scenarios release the lock prior to returning
    from the function.

    Fixes: 5210fb4e1880 ("platform/x86/intel/ifs: Sysfs interface for Array BIST")
    Cc: stable@vger.kernel.org
    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Link: https://lore.kernel.org/r/20230927184824.2566086-1-jithu.joseph@intel.com
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-12-05 11:56:52 -05:00
David Arcari e115078356 x86/microcode/intel: Rename get_datasize() since its used externally
JIRA: https://issues.redhat.com/browse/RHEL-15512

commit b0e67db12d769cc308a50c1c0ac3721c4f6aead7
Author: Ashok Raj <ashok.raj@intel.com>
Date:   Sat Aug 12 21:58:45 2023 +0200

    x86/microcode/intel: Rename get_datasize() since its used externally

    Rename get_datasize() to intel_microcode_get_datasize() and make it an inline.

      [ tglx: Make the argument typed and fix up the IFS code ]

    Suggested-by: Boris Petkov <bp@alien8.de>
    Signed-off-by: Ashok Raj <ashok.raj@intel.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
    Link: https://lore.kernel.org/r/20230812195727.894165745@linutronix.de

Signed-off-by: David Arcari <darcari@redhat.com>
2023-12-05 11:28:05 -05:00
David Arcari 4956c00d68 x86/microcode: Include vendor headers into microcode.h
JIRA: https://issues.redhat.com/browse/RHEL-15512
Conflicts: RHEL commit 6534009420

commit 82ad097b02b6ab7985375b925efd06ac042caf1d
Author: Ashok Raj <ashok.raj@intel.com>
Date:   Sat Aug 12 21:58:42 2023 +0200

    x86/microcode: Include vendor headers into microcode.h

    Currently vendor specific headers are included explicitly when used in
    common code. Instead, include the vendor specific headers in
    microcode.h, and include that in all usages.

    No functional change.

    Suggested-by: Boris Petkov <bp@alien8.de>
    Signed-off-by: Ashok Raj <ashok.raj@intel.com>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
    Link: https://lore.kernel.org/r/20230812195727.776541545@linutronix.de

Signed-off-by: David Arcari <darcari@redhat.com>
2023-12-05 11:28:05 -05:00
David Arcari e5b353c4d9 platform/x86/intel/ifs: Annotate work queue on stack so object debug does not complain
Bugzilla: https://bugzilla.redhat.com/2209290

commit 3279decb2c3c8d58cb0b70ed5235c480735a36ee
Author: David Arcari <darcari@redhat.com>
Date:   Tue May 23 06:54:00 2023 -0400

    platform/x86/intel/ifs: Annotate work queue on stack so object debug does not complain

    Object Debug results in the following warning while attempting to load
    ifs firmware:

    [  220.007422] ODEBUG: object 000000003bf952db is on stack 00000000e843994b, but NOT annotated.
    [  220.007459] ------------[ cut here ]------------
    [  220.007461] WARNING: CPU: 0 PID: 11774 at lib/debugobjects.c:548 __debug_object_init.cold+0x22e/0x2d5
    [  220.137476] RIP: 0010:__debug_object_init.cold+0x22e/0x2d5
    [  220.254774] Call Trace:
    [  220.257641]  <TASK>
    [  220.265606]  scan_chunks_sanity_check+0x368/0x5f0 [intel_ifs]
    [  220.288292]  ifs_load_firmware+0x2a3/0x400 [intel_ifs]
    [  220.332793]  current_batch_store+0xea/0x160 [intel_ifs]
    [  220.357947]  kernfs_fop_write_iter+0x355/0x530
    [  220.363048]  new_sync_write+0x28e/0x4a0
    [  220.381226]  vfs_write+0x62a/0x920
    [  220.385160]  ksys_write+0xf9/0x1d0
    [  220.399421]  do_syscall_64+0x59/0x90
    [  220.440635]  entry_SYSCALL_64_after_hwframe+0x63/0xcd
    [  220.566845] ---[ end trace 3a01b299db142b41 ]---

    Correct this by calling INIT_WORK_ONSTACK instead of INIT_WORK.

    Fixes: 684ec215706d ("platform/x86/intel/ifs: Authenticate and copy to secured memory")

    Signed-off-by: David Arcari <darcari@redhat.com>
    Cc: Jithu Joseph <jithu.joseph@intel.com>
    Cc: Ashok Raj <ashok.raj@intel.com>
    Cc: Tony Luck <tony.luck@intel.com>
    Cc: Hans de Goede <hdegoede@redhat.com>
    Cc: Mark Gross <markgross@kernel.org>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Dan Williams <dan.j.williams@intel.com>
    Cc: linux-kernel@vger.kernel.org
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20230523105400.674152-1-darcari@redhat.com
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-26 07:41:36 -04:00
David Arcari 16e0c423be platform/x86/intel/ifs: Update IFS doc
Bugzilla: https://bugzilla.redhat.com/2153901

commit 2b965dc05dc14bbe00efa3038aa1a3932ca30880
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Tue Mar 21 17:33:58 2023 -0700

    platform/x86/intel/ifs: Update IFS doc

    Array BIST is the second test supported by IFS. Modify IFS doc
    entry to be more general.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Link: https://lore.kernel.org/r/20230322003359.213046-9-jithu.joseph@intel.com
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-24 12:56:09 -04:00
David Arcari ac38b67a0c platform/x86/intel/ifs: Implement Array BIST test
Bugzilla: https://bugzilla.redhat.com/2153901

commit fed696ce13662de882c8708ea7d0664d8e9e178b
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Tue Mar 21 17:33:57 2023 -0700

    platform/x86/intel/ifs: Implement Array BIST test

    Array BIST test (for a particular core) is triggered by writing
    to MSR_ARRAY_BIST from one sibling of the core.

    This will initiate a test for all supported arrays on that
    CPU. Array BIST test may be aborted before completing all the
    arrays in the event of an interrupt or other reasons.
    In this case, kernel will restart the test from that point
    onwards. Array test will also be aborted when the test fails,
    in which case the test is stopped immediately without further
    retry.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Link: https://lore.kernel.org/r/20230322003359.213046-8-jithu.joseph@intel.com
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-24 12:56:09 -04:00
David Arcari c1a58ef11c platform/x86/intel/ifs: Sysfs interface for Array BIST
Bugzilla: https://bugzilla.redhat.com/2153901

commit 5210fb4e18806648b5e87ecc206f1b35e1253401
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Tue Mar 21 17:33:56 2023 -0700

    platform/x86/intel/ifs: Sysfs interface for Array BIST

    The interface to trigger Array BIST test and obtain its result
    is similar to the existing scan test. The only notable
    difference is that, Array BIST doesn't require any test content
    to be loaded. So binary load related options are not needed for
    this test.

    Add sysfs interface for array BIST test, the testing support will
    be added by subsequent patch.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Link: https://lore.kernel.org/r/20230322003359.213046-7-jithu.joseph@intel.com
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-24 12:56:08 -04:00
David Arcari eb2e4377bf platform/x86/intel/ifs: Introduce Array Scan test to IFS
Bugzilla: https://bugzilla.redhat.com/2153901

commit d31bbdf42b46cb8dc81deb48c4bf5234dd63d939
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Tue Mar 21 17:33:55 2023 -0700

    platform/x86/intel/ifs: Introduce Array Scan test to IFS

    Array BIST is a new type of core test introduced under the Intel Infield
    Scan (IFS) suite of tests.

    Emerald Rapids (EMR) is the first CPU to support Array BIST.
    Array BIST performs tests on some portions of the core logic such as
    caches and register files. These are different portions of the silicon
    compared to the parts tested by the first test type
    i.e Scan at Field (SAF).

    Make changes in the device driver init flow to register this new test
    type with the device driver framework. Each test will have its own
    sysfs directory (intel_ifs_0 , intel_ifs_1) under misc hierarchy to
    accommodate for the differences in test type and how they are initiated.

    Upcoming patches will add actual support.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Link: https://lore.kernel.org/r/20230322003359.213046-6-jithu.joseph@intel.com
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-24 12:56:08 -04:00
David Arcari dc4d85aad7 platform/x86/intel/ifs: IFS cleanup
Bugzilla: https://bugzilla.redhat.com/2153901

commit d847eddf0ee9c7112003becebe53fd8bf10d8671
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Tue Mar 21 17:33:53 2023 -0700

    platform/x86/intel/ifs: IFS cleanup

    Cleanup incorporating misc review comments

     - Remove the subdirectory intel_ifs/0 for devicenode [1]
     - Make plat_ifs_groups non static and use it directly without using a
        function [2]

    Link: https://lore.kernel.org/lkml/Y+4kQOtrHt5pdsSO@kroah.com/ [1]
    Link: https://lore.kernel.org/lkml/Y9nyxNesVHCUXAcH@kroah.com/  [2]

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20230322003359.213046-4-jithu.joseph@intel.com
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-24 12:56:08 -04:00
David Arcari 85ef078c67 platform/x86/intel/ifs: Reorganize driver data
Bugzilla: https://bugzilla.redhat.com/2153901

commit 54c9fcd187dd3bbc151cff9e5be01dda4f23dd0d
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Tue Mar 21 17:33:52 2023 -0700

    platform/x86/intel/ifs: Reorganize driver data

    The struct holding device driver data contained both read only(ro)
    and read write(rw) fields.

    Separating ro fields from rw fields was recommended as
    a preferable design pattern during review[1].

    Group ro fields into a separate const struct. Associate it to
    the miscdevice being registered by keeping its pointer in the
    same container struct as the miscdevice.

    Link: https://lore.kernel.org/lkml/Y+9H9otxLYPqMkUh@kroah.com/ [1]

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Link: https://lore.kernel.org/r/20230322003359.213046-3-jithu.joseph@intel.com
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-24 12:56:07 -04:00
David Arcari d61a02b9f8 platform/x86/intel/ifs: Separate ifs_pkg_auth from ifs_data
Bugzilla: https://bugzilla.redhat.com/2153901

commit 67f88ffa6d35d6b4e776f98ea64aab0bc026e2a2
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Tue Mar 21 17:33:51 2023 -0700

    platform/x86/intel/ifs: Separate ifs_pkg_auth from ifs_data

    In preparation to supporting additional tests, remove ifs_pkg_auth
    from per-test scope, as it is only applicable for one test type.

    This will simplify ifs_init() flow when multiple tests are added.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Link: https://lore.kernel.org/r/20230322003359.213046-2-jithu.joseph@intel.com
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-24 12:56:07 -04:00
David Arcari 6768cee5a6 platform/x86/intel/ifs: Add missing kernel-doc entry
Bugzilla: https://bugzilla.redhat.com/1971938

commit 09265345cc8900cd0bf10c2ff98e51b495b2c5b2
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Fri Dec 2 21:24:45 2022 -0800

    platform/x86/intel/ifs: Add missing kernel-doc entry

    Document the test_num member of struct ifs_data.

    Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
    Acked-by: Randy Dunlap <rdunlap@infradead.org>
    Link: https://lore.kernel.org/lkml/774fd22a-aaee-758d-8195-77bac783ecbc@infradead.org/

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:57 -04:00
David Arcari 8125ccb194 Revert "platform/x86/intel/ifs: Mark as BROKEN"
Bugzilla: https://bugzilla.redhat.com/1971938

commit 1a63b58082869273bfbab1b945007193f7bd3a78
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Wed Nov 16 19:59:35 2022 -0800

    Revert "platform/x86/intel/ifs: Mark as BROKEN"

    Issues with user interface [1] to load scan test images have been
    addressed so remove the dependency on BROKEN.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Sohil Mehta <sohil.mehta@intel.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/lkml/26102aca-a730-ddf8-d024-2e7367696757@redhat.com/ [1]
    Link: https://lore.kernel.org/r/20221117035935.4136738-17-jithu.joseph@intel.com

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:57 -04:00
David Arcari 1d11f05e58 platform/x86/intel/ifs: Add current_batch sysfs entry
Bugzilla: https://bugzilla.redhat.com/1971938

commit 4fb858f3dcd25cf568e35ff53ce8fa8a660fc372
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Wed Nov 16 19:59:33 2022 -0800

    platform/x86/intel/ifs: Add current_batch sysfs entry

    Initial implementation assumed a single IFS test image file with a
    fixed name ff-mm-ss.scan. (where ff, mm, ss refers to family, model and
    stepping of the core).

    Subsequently, it became evident that supporting more than one test
    image file is needed to provide more comprehensive test coverage. (Test
    coverage in this scenario refers to testing more transistors in the core
    to identify faults).

    The other alternative of increasing the size of a single scan test image
    file would not work as the  upper bound is limited by the size of memory
    area reserved by BIOS for loading IFS test image.

    Introduce "current_batch" file which accepts a number. Writing a
    number to the current_batch file would load the test image file by
    name ff-mm-ss-<xy>.scan, where <xy> is the number written to the
    "current_batch" file in hex. Range check of the input is done to verify
    it not greater than 0xff.

    For e.g if the scan test image comprises of 6 files, they would be named:

      06-8f-06-01.scan
      06-8f-06-02.scan
      06-8f-06-03.scan
      06-8f-06-04.scan
      06-8f-06-05.scan
      06-8f-06-06.scan

    And writing 3 to current_batch would result in loading 06-8f-06-03.scan
    above. The file can also be read to know the currently loaded file.

    And testing a system looks like:

      for each scan file
      do
            load the IFS test image file (write to the batch file)
            for each core
            do
                    test the core with this set of tests
            done
      done

    Qualify few error messages with the test image file suffix to provide
    better context.

      [ bp: Massage commit message. Add link to the discussion. ]

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Sohil Mehta <sohil.mehta@intel.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20221107225323.2733518-13-jithu.joseph@intel.com

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:57 -04:00
David Arcari d355071ca3 platform/x86/intel/ifs: Remove reload sysfs entry
Bugzilla: https://bugzilla.redhat.com/1971938

commit bf835ee852be38e9fab1fdb330eccdd9728aec34
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Wed Nov 16 19:59:32 2022 -0800

    platform/x86/intel/ifs: Remove reload sysfs entry

    Reload sysfs entry will be replaced by current_batch, drop it.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Sohil Mehta <sohil.mehta@intel.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20221117035935.4136738-14-jithu.joseph@intel.com

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:57 -04:00
David Arcari d857db2bd3 platform/x86/intel/ifs: Add metadata validation
Bugzilla: https://bugzilla.redhat.com/1971938

commit 48c6e7dc19051c5ef725490cf8673d768cda7748
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Thu Nov 17 15:04:08 2022 -0800

    platform/x86/intel/ifs: Add metadata validation

    The data portion of a IFS test image file contains a metadata region
    containing possibly multiple metadata structures in addition to test
    data and hashes.

        IFS Metadata layout
       +----------------------+  0
       |META_TYPE_IFS (=1)    |
       +----------------------+
       |meta_size             |
       +----------------------+
       |test type             |
       +----------------------+
       |fusa info             |
       +----------------------+
       |total images          |
       +----------------------+
       |current image#        |
       +----------------------+
       |total chunks          |
       +----------------------+
       |starting chunk        |
       +----------------------+
       |size per chunk        |
       +----------------------+
       |chunks per stride     |
       +----------------------+
       |Reserved[54]          |
       +----------------------+ 256
       |                      |
       |  Test Data/Chunks    |
       |                      |
       +----------------------+  meta_size
       |   META_TYPE_END (=0) |
       +----------------------+  meta_size + 4
       |   size of end (=8)   |
       +----------------------+  meta_size + 8

    Introduce the layout of this meta_data structure and validate
    the sanity of certain fields of the new image before loading.

    Tweak references to IFS test image chunks to reflect the updated
    layout of the test image.

      [ bp: Massage commit message. ]

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Sohil Mehta <sohil.mehta@intel.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20221117230408.30331-1-jithu.joseph@intel.com

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:57 -04:00
David Arcari d901481623 platform/x86/intel/ifs: Use generic microcode headers and functions
Bugzilla: https://bugzilla.redhat.com/1971938

commit aa63e0fda85edf9a8431fc31a2b2d4f3f40592f9
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Thu Nov 17 14:50:39 2022 -0800

    platform/x86/intel/ifs: Use generic microcode headers and functions

    Existing implementation (broken) of IFS used a header format (for IFS
    test images) which was very similar to microcode format, but didn’t
    accommodate extended signatures. This meant same IFS test image had to
    be duplicated for different steppings and the validation code in the
    driver was only looking at the primary header parameters. Going forward,
    IFS test image headers have been tweaked to become fully compatible with
    the microcode format.

    Newer IFS test image headers will use header version 2 in order to
    distinguish it from microcode images and older IFS test images.

    In light of the above, reuse struct microcode_header_intel directly in
    the IFS driver and reuse microcode functions for validation and sanity
    checking.

      [ bp: Massage commit message. ]

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Sohil Mehta <sohil.mehta@intel.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20221117225039.30166-1-jithu.joseph@intel.com

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:57 -04:00
David Arcari 707d9939b2 platform/x86/intel/ifs: Add metadata support
Bugzilla: https://bugzilla.redhat.com/1971938

commit 8382fee3bb86526bde1bfb1a06834f056140e0dd
Author: Ashok Raj <ashok.raj@intel.com>
Date:   Wed Nov 16 19:59:29 2022 -0800

    platform/x86/intel/ifs: Add metadata support

    One of the existing reserved fields in the microcode header has been
    allocated to indicate the size of metadata structures.

    The location of metadata section within microcode header is as shown
    below:

        Microcode Blob Format
       +----------------------+  Base
       |Header Version        |
       +----------------------+
       |Update revision       |
       +----------------------+
       |Date DDMMYYYY         |
       +----------------------+
       |Sig                   |
       +----------------------+
       |Checksum              |
       +----------------------+
       |Loader Version        |
       +----------------------+
       |Processor Flags       |
       +----------------------+
       |Data Size             |
       +----------------------+
       |Total Size            |
       +----------------------+
       |Meta Size             |
       +----------------------+
       |Reserved              |
       +----------------------+
       |Reserved              |
       +----------------------+  Base+48
       |                      |
       |    Microcode         |
       |     Data             |
       |                      |
       +----------------------+  Base+48+data_size-
       |                      |     meta_size
       |   Meta Data          |
       |   structure(s)       |
       |                      |
       +----------------------+  Base+48+data_size
       |                      |
       |   Extended Signature |
       |        Table         |
       |                      |
       +----------------------+  Base+total_size

    Add an accessor function which will return a pointer to the start of a
    specific meta_type being queried.

      [ bp: Massage commit message. ]

    Signed-off-by: Ashok Raj <ashok.raj@intel.com>
    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Sohil Mehta <sohil.mehta@intel.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20221117035935.4136738-11-jithu.joseph@intel.com

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:56 -04:00
David Arcari 1096df0431 platform/x86/intel/ifs: Remove memory allocation from load path
Bugzilla: https://bugzilla.redhat.com/1971938

commit cb5eceee816bf05667089869d822b9cbc919465a
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Thu Nov 17 11:59:57 2022 -0800

    platform/x86/intel/ifs: Remove memory allocation from load path

    IFS requires tests to be authenticated once for each CPU socket on a
    system.

    scan_chunks_sanity_check() was dynamically allocating memory to store
    the state of whether tests have been authenticated on each socket for
    every load operation.

    Move the memory allocation to init path and store the pointer in
    ifs_data struct.

    Also rearrange the adjacent error checking in init for a more simplified
    and natural flow.

    Suggested-by: Borislav Petkov <bp@alien8.de>
    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20221117195957.28225-1-jithu.joseph@intel.com

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:56 -04:00
David Arcari 8e05445bd2 platform/x86/intel/ifs: Remove image loading during init
Bugzilla: https://bugzilla.redhat.com/1971938

commit a4c30fa4ead5e6628e5ff5a45664ba7181acf6f1
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Wed Nov 16 19:59:22 2022 -0800

    platform/x86/intel/ifs: Remove image loading during init

    IFS test image is unnecessarily loaded during driver initialization.
    Drop image loading during ifs_init() and improve module load time. With
    this change, user has to load one when starting the tests.

    As a consequence, make ifs_sem static as it is only used within sysfs.c

    Suggested-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Sohil Mehta <sohil.mehta@intel.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20221117035935.4136738-4-jithu.joseph@intel.com

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:55 -04:00
David Arcari 1401188376 platform/x86/intel/ifs: Return a more appropriate error code
Bugzilla: https://bugzilla.redhat.com/1971938

commit f4e209e956b5d66f0e6e34e89f19811c2c1e596e
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Wed Nov 16 19:59:21 2022 -0800

    platform/x86/intel/ifs: Return a more appropriate error code

    scan_chunks_sanity_check() returns -ENOMEM if it encounters an error
    while copying IFS test image from memory to Secure Memory.

    Return -EIO in this scenario, as it is more appropriate.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Sohil Mehta <sohil.mehta@intel.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20221117035935.4136738-3-jithu.joseph@intel.com

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:55 -04:00
David Arcari 09e4523b00 platform/x86/intel/ifs: Remove unused selection
Bugzilla: https://bugzilla.redhat.com/1971938

commit 10d4853e4c5cd64b9ef1e5579bb2e89bceab4175
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Wed Nov 16 19:59:20 2022 -0800

    platform/x86/intel/ifs: Remove unused selection

    CONFIG_INTEL_IFS_DEVICE is not used anywhere. The selection in
    Kconfig is therefore pointless. Delete it.

    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Reviewed-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Sohil Mehta <sohil.mehta@intel.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Link: https://lore.kernel.org/r/20221117035935.4136738-2-jithu.joseph@intel.com

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:55 -04:00
David Arcari ac8e807f82 platform/x86/intel/ifs: Mark as BROKEN
Bugzilla: https://bugzilla.redhat.com/1971938

commit c483e7ea10fa889f9da5012753a6766be6e11309
Author: Hans de Goede <hdegoede@redhat.com>
Date:   Sun Jul 10 16:07:36 2022 +0200

    platform/x86/intel/ifs: Mark as BROKEN

    A recent suggested change to the IFS code has shown that the userspace
    API needs a bit more work, see:
    https://lore.kernel.org/platform-driver-x86/20220708151938.986530-1-jithu.joseph@intel.com/

    Mark it as BROKEN before 5.19 ships, to give ourselves one more
    kernel-devel cycle to get the userspace API right.

    Link: https://lore.kernel.org/platform-driver-x86/20220708151938.986530-1-jithu.joseph@intel.com/
    Cc: Jithu Joseph <jithu.joseph@intel.com>
    Cc: Ashok Raj <ashok.raj@intel.com>
    Cc: Tony Luck <tony.luck@intel.com>
    Suggested-by: Greg KH <gregkh@linuxfoundation.org>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Link: https://lore.kernel.org/r/20220710140736.6492-1-hdegoede@redhat.com

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:52 -04:00
David Arcari 652ab46d82 platform/x86/intel/ifs: Add CPU_SUP_INTEL dependency
Bugzilla: https://bugzilla.redhat.com/1971938

commit badb81a58b9e66ca8c15405476f5134e45b57dee
Author: Borislav Petkov <bp@suse.de>
Date:   Thu May 19 16:57:15 2022 +0200

    platform/x86/intel/ifs: Add CPU_SUP_INTEL dependency

    The driver is using functions from a compilation unit which is enabled
    by CONFIG_CPU_SUP_INTEL. Add that dependency to Kconfig explicitly
    otherwise:

      drivers/platform/x86/intel/ifs/load.o: in function `ifs_load_firmware':
      load.c:(.text+0x3b8): undefined reference to `intel_cpu_collect_info'

    Reported-by: Randy Dunlap <rdunlap@infradead.org>
    Signed-off-by: Borislav Petkov <bp@suse.de>
    Link: https://lore.kernel.org/r/YoZay8YR0zRGyVu+@zn.tnic
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:52 -04:00
David Arcari f09c75a61f Documentation: In-Field Scan
Bugzilla: https://bugzilla.redhat.com/1971938

commit 34604d28916710070390036118fcd21217b0f597
Author: Tony Luck <tony.luck@intel.com>
Date:   Fri May 6 15:54:10 2022 -0700

    Documentation: In-Field Scan

    Add documentation for In-Field Scan (IFS). This documentation
    describes the basics of IFS, the loading IFS image, chunk
    authentication, running scan and how to check result via sysfs.

    The CORE_CAPABILITIES MSR enumerates whether IFS is supported.

    The full  github location for distributing the IFS images is
    still being decided. So just a placeholder included for now
    in the documentation.

    Future CPUs will support more than one type of test. Plan for
    that now by using a "_0" suffix on the ABI directory names.
    Additional test types will use "_1", etc.

    Reviewed-by: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: Tony Luck <tony.luck@intel.com>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Link: https://lore.kernel.org/r/20220506225410.1652287-13-tony.luck@intel.com
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:52 -04:00
David Arcari e4875ce588 trace: platform/x86/intel/ifs: Add trace point to track Intel IFS operations
Bugzilla: https://bugzilla.redhat.com/1971938

commit 51af802fc05152e84727a4293ccaa7e7e1b64d7e
Author: Tony Luck <tony.luck@intel.com>
Date:   Fri May 6 15:54:08 2022 -0700

    trace: platform/x86/intel/ifs: Add trace point to track Intel IFS operations

    Add tracing support which may be useful for debugging systems that fail to complete
    In Field Scan tests.

    Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
    Reviewed-by: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: Tony Luck <tony.luck@intel.com>
    Acked-by: Hans de Goede <hdegoede@redhat.com>
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Link: https://lore.kernel.org/r/20220506225410.1652287-11-tony.luck@intel.com
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:52 -04:00
David Arcari afb882771f platform/x86/intel/ifs: Add IFS sysfs interface
Bugzilla: https://bugzilla.redhat.com/1971938

commit 6f33a92b92f9cc37f31137cd5a2060ec714d486b
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Fri May 6 15:54:07 2022 -0700

    platform/x86/intel/ifs: Add IFS sysfs interface

    Implement sysfs interface to trigger ifs test for a specific cpu.
    Additional interfaces related to checking the status of the
    scan test and seeing the version of the loaded IFS binary
    are also added.

    The basic usage is as below.
       - To start test, for example on cpu5:
           echo 5 > /sys/devices/platform/intel_ifs/run_test
       - To see the status of the last test
           cat /sys/devices/platform/intel_ifs/status
       - To see the version of the loaded scan binary
           cat /sys/devices/platform/intel_ifs/image_version

    Reviewed-by: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Co-developed-by: Tony Luck <tony.luck@intel.com>
    Signed-off-by: Tony Luck <tony.luck@intel.com>
    Acked-by: Hans de Goede <hdegoede@redhat.com>
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Link: https://lore.kernel.org/r/20220506225410.1652287-10-tony.luck@intel.com
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:51 -04:00
David Arcari ee1761d9b0 platform/x86/intel/ifs: Add scan test support
Bugzilla: https://bugzilla.redhat.com/1971938

commit 2b40e654b73ae061f1acbe28fbec6007914ba8d8
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Fri May 6 15:54:06 2022 -0700

    platform/x86/intel/ifs: Add scan test support

    In a core, the scan engine is shared between sibling cpus.

    When a Scan test (for a particular core) is triggered by the user,
    the scan chunks are executed on all the threads on the core using
    stop_core_cpuslocked.

    Scan may be aborted by some reasons. Scan test will be aborted in certain
    circumstances such as when interrupt occurred or cpu does not have enough
    power budget for scan. In this case, the kernel restart scan from the chunk
    where it stopped. Scan will also be aborted when the test is failed. In
    this case, the test is immediately stopped without retry.

    Reviewed-by: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Co-developed-by: Tony Luck <tony.luck@intel.com>
    Signed-off-by: Tony Luck <tony.luck@intel.com>
    Acked-by: Hans de Goede <hdegoede@redhat.com>
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Link: https://lore.kernel.org/r/20220506225410.1652287-9-tony.luck@intel.com
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:51 -04:00
David Arcari 5b462f9524 platform/x86/intel/ifs: Authenticate and copy to secured memory
Bugzilla: https://bugzilla.redhat.com/1971938

commit 684ec215706d449f78da232aae125c0bc14f22a9
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Fri May 6 15:54:05 2022 -0700

    platform/x86/intel/ifs: Authenticate and copy to secured memory

    The IFS image contains hashes that will be used to authenticate the ifs
    test chunks. First, use WRMSR to copy the hashes and enumerate the number
    of test chunks, chunk size and the maximum number of cores that can run
    scan test simultaneously.

    Next, use WRMSR to authenticate each and every scan test chunk which is
    stored in the IFS image. The CPU will check if the test chunks match
    the hashes, otherwise failure is indicated to system software. If the test
    chunk is authenticated, it is automatically copied to secured memory.

    Use schedule_work_on() to perform the hash copy and authentication. Note
    this needs only be done on the first logical cpu of each socket.

    Reviewed-by: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Co-developed-by: Tony Luck <tony.luck@intel.com>
    Signed-off-by: Tony Luck <tony.luck@intel.com>
    Acked-by: Hans de Goede <hdegoede@redhat.com>
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Link: https://lore.kernel.org/r/20220506225410.1652287-8-tony.luck@intel.com
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:51 -04:00
David Arcari cc547c389d platform/x86/intel/ifs: Check IFS Image sanity
Bugzilla: https://bugzilla.redhat.com/1971938

commit 846e751ff37e8ab2d161de04314435f9c1d729ca
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Fri May 6 15:54:04 2022 -0700

    platform/x86/intel/ifs: Check IFS Image sanity

    IFS image is designed specifically for a given family, model and
    stepping of the processor. Like Intel microcode header, the IFS image
    has the Processor Signature, Checksum and Processor Flags that must be
    matched with the information returned by the CPUID.

    Reviewed-by: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Co-developed-by: Tony Luck <tony.luck@intel.com>
    Signed-off-by: Tony Luck <tony.luck@intel.com>
    Acked-by: Hans de Goede <hdegoede@redhat.com>
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Link: https://lore.kernel.org/r/20220506225410.1652287-7-tony.luck@intel.com
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:51 -04:00
David Arcari 6821892a9f platform/x86/intel/ifs: Read IFS firmware image
Bugzilla: https://bugzilla.redhat.com/1971938

commit fb57fc785ed3b71a3e8188d4914471bd1360bc53
Author: Jithu Joseph <jithu.joseph@intel.com>
Date:   Fri May 6 15:54:03 2022 -0700

    platform/x86/intel/ifs: Read IFS firmware image

    Driver probe routine allocates structure to communicate status
    and parameters between functions in the driver. Also call
    load_ifs_binary() to load the scan image file.

    There is a separate scan image file for each processor family,
    model, stepping combination. This is read from the static path:

      /lib/firmware/intel/ifs/{ff-mm-ss}.scan

    Step 1 in loading is to generate the correct path and use
    request_firmware_direct() to load into memory.

    Subsequent patches will use the IFS MSR interfaces to copy
    the image to BIOS reserved memory and validate the SHA256
    checksums.

    Reviewed-by: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
    Co-developed-by: Tony Luck <tony.luck@intel.com>
    Signed-off-by: Tony Luck <tony.luck@intel.com>
    Acked-by: Hans de Goede <hdegoede@redhat.com>
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Link: https://lore.kernel.org/r/20220506225410.1652287-6-tony.luck@intel.com
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:51 -04:00
David Arcari dad2dda0ec platform/x86/intel/ifs: Add stub driver for In-Field Scan
Bugzilla: https://bugzilla.redhat.com/1971938

commit 67896ef13c4db88082a914e96d958044cd3392e8
Author: Tony Luck <tony.luck@intel.com>
Date:   Fri May 6 15:54:02 2022 -0700

    platform/x86/intel/ifs: Add stub driver for In-Field Scan

    Cloud Service Providers that operate fleets of servers have reported
    [1] occasions where they can detect that a CPU has gone bad due to
    effects like electromigration, or isolated manufacturing defects.
    However, that detection method is A/B testing seemingly random
    application failures looking for a pattern. In-Field Scan (IFS) is
    a driver for a platform capability to load a crafted 'scan image'
    to run targeted low level diagnostics outside of the CPU's architectural
    error detection capabilities.

    Stub version of driver just does initial part of check for the IFS
    feature. MSR_IA32_CORE_CAPS must enumerate the presence of the
    MSR_INTEGRITY_CAPS MSR.

    [1]: https://www.youtube.com/watch?v=QMF3rqhjYuM

    Reviewed-by: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: Tony Luck <tony.luck@intel.com>
    Acked-by: Hans de Goede <hdegoede@redhat.com>
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Link: https://lore.kernel.org/r/20220506225410.1652287-5-tony.luck@intel.com
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2023-05-06 07:48:50 -04:00