Skip to content

[Deepin-Kernel-SIG] [linux 6.6-y] [Upstream] [Intel] Intel: support In Field Scan(IFS) SBAF on GNR #905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jul 1, 2025

Conversation

Avenger-285714
Copy link
Collaborator

@Avenger-285714 Avenger-285714 commented Jun 27, 2025

bugzilla: https://bugzilla.openanolis.cn/show_bug.cgi?id=10908

Intel In Field Scan (IFS) is a hardware feature to run circuit level tests on a CPU core to detect problems that are not caught by parity or ECC checks.

This PR is to support Intel In Field Scan(IFS) SBAF(Structural Based Functional Test at Field) on GNR platform.

Upstream commits from v6.9 to v6.12(18 commits):
1e70137 platform/x86/intel/ifs: Fix SBAF title underline length
3114f77 platform/x86/intel/ifs: Initialize union ifs_status to zero
61b7496 trace: platform/x86/intel/ifs: Add SBAF trace support
3c4d06b platform/x86/intel/ifs: Add SBAF test support
0a3e4e9 platform/x86/intel/ifs: Add SBAF test image loading support
7e597d4 platform/x86/intel/ifs: Refactor MSR usage in IFS test code
bb408da selftests: ifs: verify IFS ARRAY BIST functionality
3170f7a selftests: ifs: verify IFS scan test functionality
20cef30 selftests: ifs: verify test image loading functionality
8e51106 selftests: ifs: verify test interfaces are created by the driver
bd25a3f platform/x86/intel/ifs: Disable irq during one load stage
15b429f platform/x86/intel/ifs: trace: display batch num in hex
02153e5 platform/x86/intel/ifs: Classify error scenarios correctly
682c259 platform/x86/intel/ifs: Remove unnecessary initialization of 'ret'
ad630f5 platform/x86/intel/ifs: Add an entry rendezvous for SAF
ea15f34 platform/x86/intel/ifs: Replace the exit rendezvous with an entry rendezvous for ARRAY_BIST
e272d1e platform/x86/intel/ifs: Add current batch number to trace output
def1ed0 platform/x86/intel/ifs: Trace on all HT threads when executing a test

[ deepin: Drop ("platform/x86/intel/ifs: Initialize union ifs_status to zero") because of merged before. ]

One upstream commit is removed for compile issue:
490d573 platform/x86/intel/ifs: Switch to new Intel CPU model defines

Test
Built and run the kernel successfully.
Test is PASS on GNR platform.

Configs
CONFIG_INTEL_IFS = m

Link: https://gitee.com/anolis/cloud-kernel/pulls/3860

Summary by Sourcery

Backport Intel In Field Scan (IFS) SBAF support to the GNR platform by integrating upstream commits, introducing SBAF runtime logic, MSR definitions, trace events and selftests into the intel_ifs driver.

New Features:

  • Add Structural Based Functional Test at Field (SBAF) support in the Intel IFS driver with MSR definitions, activate/status unions, and error‐code handling
  • Implement multi‐threaded SBAF execution via dosbaf and ifs_sbaf_test_core and dispatch SBAF tests in do_core_test
  • Register SBAF as a new miscdevice entry and expose SBAF control through sysfs

Enhancements:

  • Introduce ifs_test_msrs abstraction to unify MSR accesses across scan and SBAF tests
  • Consolidate CPU sibling rendezvous logic into wait_for_sibling_cpu and apply it to scan, array and SBAF flows
  • Refactor runtest.c to use unified run_params structures for passing activation and status data
  • Generalize hash and chunk copy/authenticate operations in load.c to use test_msrs

Build:

  • Include the IFS driver in the selftests build targets

Documentation:

  • Document the SBAF feature and its operation in ifs.h
  • Add a new ifs_sbaf tracepoint and update existing trace events to report batch indices

Tests:

  • Add test_ifs.sh selftest script covering scan, array BIST and SBAF scenarios
  • Update selftests Makefiles to include drivers/platform/x86/intel/ifs tests

Chores:

  • Backport 18 upstream commits from v6.9–v6.12 and drop a duplicate union initialization commit
  • Remove a conflicting commit that introduced new CPU model defines due to compilation issues

ashok-raj and others added 17 commits June 28, 2025 07:24
ANBZ: #10908

commit def1ed0 upstream.

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

Intel-SIG: commit def1ed0 platform/x86/intel/ifs: Trace on all HT threads when executing a test
Backport to support Intel IFS(In Field Scan) SBAF(Structural Based Functional Test at Field)

Signed-off-by: Ashok Raj <[email protected]>
Reviewed-by: Tony Luck <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Ilpo Järvinen <[email protected]>
Signed-off-by: Ilpo Järvinen <[email protected]>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <[email protected]>
ANBZ: #10908

commit e272d1e upstream.

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

Intel-SIG: commit e272d1e platform/x86/intel/ifs: Add current batch number to trace output
Backport to support Intel IFS(In Field Scan) SBAF(Structural Based Functional Test at Field)

Signed-off-by: Ashok Raj <[email protected]>
Reviewed-by: Tony Luck <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Ilpo Järvinen <[email protected]>
Signed-off-by: Ilpo Järvinen <[email protected]>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <[email protected]>
…dezvous for ARRAY_BIST

ANBZ: #10908

commit ea15f34 upstream.

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.

Intel-SIG: commit ea15f34 platform/x86/intel/ifs: Replace the exit rendezvous with an entry rendezvous for ARRAY_BIST
Backport to support Intel IFS(In Field Scan) SBAF(Structural Based Functional Test at Field)

Signed-off-by: Ashok Raj <[email protected]>
Reviewed-by: Tony Luck <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Ilpo Järvinen <[email protected]>
Signed-off-by: Ilpo Järvinen <[email protected]>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <[email protected]>
ANBZ: #10908

commit ad630f5 upstream.

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.

Intel-SIG: commit ad630f5 platform/x86/intel/ifs: Add an entry rendezvous for SAF
Backport to support Intel IFS(In Field Scan) SBAF(Structural Based Functional Test at Field)

Signed-off-by: Ashok Raj <[email protected]>
Reviewed-by: Tony Luck <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Ilpo Järvinen <[email protected]>
Signed-off-by: Ilpo Järvinen <[email protected]>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <[email protected]>
ANBZ: #10908

commit 682c259 upstream.

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

Intel-SIG: commit 682c259 platform/x86/intel/ifs: Remove unnecessary initialization of 'ret'
Backport to support Intel IFS(In Field Scan) SBAF(Structural Based Functional Test at Field)

Reviewed-by: Ashok Raj <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Ilpo Järvinen <[email protected]>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <[email protected]>
ANBZ: #10908

commit 02153e5 upstream.

"Scan controller error" means that scan hardware encountered an error
prior to doing an actual test on the target CPU. It does not mean that
there is an actual cpu/core failure. "scan signature failure" indicates
that the test result on the target core did not match the expected value
and should be treated as a cpu failure.

Current driver classifies both these scenarios as failures. Modify
the driver to classify this situation with a more appropriate "untested"
status instead of "fail" status.

Intel-SIG: commit 02153e5 platform/x86/intel/ifs: Classify error scenarios correctly
Backport to support Intel IFS(In Field Scan) SBAF(Structural Based Functional Test at Field)

Signed-off-by: Jithu Joseph <[email protected]>
Reviewed-by: Tony Luck <[email protected]>
Reviewed-by: Ashok Raj <[email protected]>
Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Hans de Goede <[email protected]>
Signed-off-by: Hans de Goede <[email protected]>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <[email protected]>
ANBZ: #10908

commit 15b429f upstream.

In Field Scan test image files are named in ff-mm-ss-<batch02x>.scan
format. Current trace output, prints the batch number in decimal format.

Make it easier to correlate the trace line to a test image file by
showing the batch number also in hex format.

Add 0x prefix to all fields in the trace line to make the type explicit.

Intel-SIG: commit 15b429f platform/x86/intel/ifs: trace: display batch num in hex
Backport to support Intel IFS(In Field Scan) SBAF(Structural Based Functional Test at Field)

Signed-off-by: Jithu Joseph <[email protected]>
Reviewed-by: Tony Luck <[email protected]>
Reviewed-by: Ashok Raj <[email protected]>
Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Hans de Goede <[email protected]>
Signed-off-by: Hans de Goede <[email protected]>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <[email protected]>
ANBZ: #10908

commit bd25a3f upstream.

One of the stages in IFS image loading process involves loading individual
chunks (test patterns) from test image file to secure memory.

Driver issues a WRMSR(MSR_AUTHENTICATE_AND_COPY_CHUNK) operation to do
this. This operation can take up to 5 msec, and if an interrupt occurs
in between, the AUTH_AND_COPY_CHUNK u-code implementation aborts the
operation.

Interrupt sources such as NMI or SMI are handled by retrying. Regular
interrupts may occur frequently enough to prevent this operation from ever
completing. Disable irq on local cpu around the aforementioned WRMSR to
allow the operation to complete.

Intel-SIG: commit bd25a3f platform/x86/intel/ifs: Disable irq during one load stage
Backport to support Intel IFS(In Field Scan) SBAF(Structural Based Functional Test at Field)

Signed-off-by: Jithu Joseph <[email protected]>
Reviewed-by: Tony Luck <[email protected]>
Reviewed-by: Ashok Raj <[email protected]>
Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Hans de Goede <[email protected]>
Signed-off-by: Hans de Goede <[email protected]>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <[email protected]>
ANBZ: #10908

commit 8e51106 upstream.

IFS (In Field Scan) driver exposes its functionality via sysfs interfaces.
Applications prepare and exercise the tests by interacting with the
aforementioned sysfs files.

Verify that the necessary sysfs entries are created after loading the IFS
driver.

Initialize test variables needed for building subsequent kself-test cases.

Intel-SIG: commit 8e51106 selftests: ifs: verify test interfaces are created by the driver
Backport to support Intel IFS(In Field Scan) SBAF(Structural Based Functional Test at Field)

Reviewed-by: Jithu Joseph <[email protected]>
Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>
Co-developed-by: Ashok Raj <[email protected]>
Signed-off-by: Ashok Raj <[email protected]>
Signed-off-by: Pengfei Xu <[email protected]>
Acked-by: Jithu Joseph <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <[email protected]>
ANBZ: #10908

commit 20cef30 upstream.

Scan test image files have to be loaded before starting IFS test.

Verify that In Field scan driver is able to load valid test image files.

Also check if loading an invalid test image file fails.

Intel-SIG: commit 20cef30 selftests: ifs: verify test image loading functionality
Backport to support Intel IFS(In Field Scan) SBAF(Structural Based Functional Test at Field)

Reviewed-by: Jithu Joseph <[email protected]>
Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>
Co-developed-by: Ashok Raj <[email protected]>
Signed-off-by: Ashok Raj <[email protected]>
Signed-off-by: Pengfei Xu <[email protected]>
Acked-by: Jithu Joseph <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <[email protected]>
ANBZ: #10908

commit 3170f7a upstream.

Two selftests are added to verify IFS scan test feature:

1. Perform IFS scan test once on each CPU using all the available image
   files.
2. Perform IFS scan test with the default image on a random cpu for 3
   rounds.

Intel-SIG: commit 3170f7a selftests: ifs: verify IFS scan test functionality
Backport to support Intel IFS(In Field Scan) SBAF(Structural Based Functional Test at Field)

Reviewed-by: Jithu Joseph <[email protected]>
Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>
Co-developed-by: Ashok Raj <[email protected]>
Signed-off-by: Ashok Raj <[email protected]>
Signed-off-by: Pengfei Xu <[email protected]>
Acked-by: Jithu Joseph <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <[email protected]>
ANBZ: #10908

commit bb408da upstream.

There are two selftest scenarios for ARRAY BIST(Board Integrated System
Test) tests:

1. Perform IFS ARRAY BIST tests once on each CPU.
2. Perform IFS ARRAY BIST tests on a random CPU with 3 rounds.

These are not meant to be exhaustive, but are some minimal tests for
for checking IFS ARRAY BIST.

Intel-SIG: commit bb408da selftests: ifs: verify IFS ARRAY BIST functionality
Backport to support Intel IFS(In Field Scan) SBAF(Structural Based Functional Test at Field)

Reviewed-by: Jithu Joseph <[email protected]>
Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]>
Co-developed-by: Ashok Raj <[email protected]>
Signed-off-by: Ashok Raj <[email protected]>
Signed-off-by: Pengfei Xu <[email protected]>
Acked-by: Jithu Joseph <[email protected]>
Signed-off-by: Shuah Khan <[email protected]>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <[email protected]>
ANBZ: #10908

commit 7e597d4 upstream.

IFS tests such as Scan at Field (SAF) or Structural Based Functional
Test at Field (SBAF), require the user to load a test image. The image
loading process is similar across these tests, with the only difference
being MSR addresses used. To reuse the code between these tests, remove
the hard coding of MSR addresses and allow the driver to pass the MSR
addresses per IFS test (via driver device data).

Add a new structure named "struct ifs_test_msrs" to specify the
test-specific MSR addresses. Each IFS test will provide this structure,
enabling them to reuse the common code.

This is a preliminary patch in preparation for the addition of SBAF
support.

Intel-SIG: commit 7e597d4 platform/x86/intel/ifs: Refactor MSR usage in IFS test code
Backport to support Intel IFS(In Field Scan) SBAF(Structural Based Functional Test at Field)

Reviewed-by: Ashok Raj <[email protected]>
Reviewed-by: Tony Luck <[email protected]>
Reviewed-by: Ilpo Järvinen <[email protected]>
Signed-off-by: Kuppuswamy Sathyanarayanan <[email protected]>
Link: https://lore.kernel.org/r/20240801051814.1935149-2-sathyanarayanan.kuppuswamy@linux.intel.com
Signed-off-by: Hans de Goede <[email protected]>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <[email protected]>
ANBZ: #10908

commit 0a3e4e9 upstream.

Structural Based Functional Test at Field (SBAF) is a new type of
testing that provides comprehensive core test coverage complementing
existing IFS tests like Scan at Field (SAF) or ArrayBist.

SBAF device will appear as a new device instance (intel_ifs_2) under
/sys/devices/virtual/misc. The user interaction necessary to load the
test image and test a particular core is the same as the existing scan
test (intel_ifs_0).

During the loading stage, the driver will look for a file named
ff-mm-ss-<batch02x>.sbft in the /lib/firmware/intel/ifs_2 directory.
The hardware interaction needed for loading the image is similar to
SAF, with the only difference being the MSR addresses used. Reuse the
SAF image loading code, passing the SBAF-specific MSR addresses via
struct ifs_test_msrs in the driver device data.

Unlike SAF, the SBAF test image chunks are further divided into smaller
logical entities called bundles. Since the SBAF test is initiated per
bundle, cache the maximum number of bundles in the current image, which
is used for iterating through bundles during SBAF test execution.

Intel-SIG: commit 0a3e4e9 platform/x86/intel/ifs: Add SBAF test image loading support
Backport to support Intel IFS(In Field Scan) SBAF(Structural Based Functional Test at Field)

Reviewed-by: Ashok Raj <[email protected]>
Reviewed-by: Tony Luck <[email protected]>
Reviewed-by: Ilpo Järvinen <[email protected]>
Signed-off-by: Jithu Joseph <[email protected]>
Co-developed-by: Kuppuswamy Sathyanarayanan <[email protected]>
Signed-off-by: Kuppuswamy Sathyanarayanan <[email protected]>
Link: https://lore.kernel.org/r/20240801051814.1935149-3-sathyanarayanan.kuppuswamy@linux.intel.com
Signed-off-by: Hans de Goede <[email protected]>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <[email protected]>
ANBZ: #10908

commit 3c4d06b upstream.

In a core, the SBAF test engine is shared between sibling CPUs.

An SBAF test image contains multiple bundles. Each bundle is further
composed of subunits called programs. When a SBAF test (for a particular
core) is triggered by the user, each SBAF bundle from the loaded test
image is executed sequentially on all the threads on the core using
the stop_core_cpuslocked mechanism. Each bundle execution is initiated by
writing to MSR_ACTIVATE_SBAF.

SBAF test bundle execution may be aborted when an interrupt occurs or
if the CPU does not have enough power budget for the test. In these
cases the kernel restarts the test from the aborted bundle. SBAF
execution is not retried if the test fails or if the test makes no
forward progress after 5 retries.

Intel-SIG: commit 3c4d06b platform/x86/intel/ifs: Add SBAF test support
Backport to support Intel IFS(In Field Scan) SBAF(Structural Based Functional Test at Field)

Reviewed-by: Ashok Raj <[email protected]>
Reviewed-by: Tony Luck <[email protected]>
Reviewed-by: Ilpo Järvinen <[email protected]>
Signed-off-by: Jithu Joseph <[email protected]>
Signed-off-by: Kuppuswamy Sathyanarayanan <[email protected]>
Link: https://lore.kernel.org/r/20240801051814.1935149-4-sathyanarayanan.kuppuswamy@linux.intel.com
Signed-off-by: Hans de Goede <[email protected]>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <[email protected]>
ANBZ: #10908

commit 61b7496 upstream.

Add tracing support for the SBAF IFS tests, which may be useful for
debugging systems that fail these tests. Log details like test content
batch number, SBAF bundle ID, program index and the exact errors or
warnings encountered by each HT thread during the test.

Intel-SIG: commit 61b7496 trace: platform/x86/intel/ifs: Add SBAF trace support
Backport to support Intel IFS(In Field Scan) SBAF(Structural Based Functional Test at Field)

Reviewed-by: Ashok Raj <[email protected]>
Reviewed-by: Tony Luck <[email protected]>
Reviewed-by: Ilpo Järvinen <[email protected]>
Reviewed-by: Steven Rostedt (Google) <[email protected]>
Signed-off-by: Jithu Joseph <[email protected]>
Signed-off-by: Kuppuswamy Sathyanarayanan <[email protected]>
Link: https://lore.kernel.org/r/20240801051814.1935149-5-sathyanarayanan.kuppuswamy@linux.intel.com
Signed-off-by: Hans de Goede <[email protected]>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <[email protected]>
ANBZ: #10908

commit 1e70137 upstream.

In commit # 0a3e4e9 ("platform/x86/intel/ifs: Add SBAF test image
loading support"), the documentation for "Structural Based Functional
Test at Field (SBAF)" had an incomplete underline. This resulted in the
following build warning:

Documentation/arch/x86/ifs:2: drivers/platform/x86/intel/ifs/ifs.h:131: WARNING: Title underline too short.

Fix it by extending the dotted lines to match the length of the title.

Intel-SIG: commit 1e70137 platform/x86/intel/ifs: Fix SBAF title underline length
Backport to support Intel IFS(In Field Scan) SBAF(Structural Based Functional Test at Field)

Fixes: 0a3e4e9 ("platform/x86/intel/ifs: Add SBAF test image loading support")
Reported-by: Stephen Rothwell <[email protected]>
Closes: https://lore.kernel.org/lkml/[email protected]/T/#u
Signed-off-by: Kuppuswamy Sathyanarayanan <[email protected]>
Reviewed-by: Jithu Joseph <[email protected]>
Link: https://lore.kernel.org/r/20240823184337.2923179-1-sathyanarayanan.kuppuswamy@linux.intel.com
Signed-off-by: Hans de Goede <[email protected]>
[ Aichun Shi: amend commit log ]
Signed-off-by: Aichun Shi <[email protected]>
@Avenger-285714 Avenger-285714 requested review from opsiff and Copilot June 27, 2025 23:28
Copy link

sourcery-ai bot commented Jun 27, 2025

Reviewer's Guide

This PR integrates Intel IFS SBAF support on the GNR platform by introducing a new SBAF test mode, refactoring MSR handling via a unified test_msrs abstraction, consolidating CPU rendezvous logic, extending driver metadata and firmware loading, updating trace instrumentation, and adding comprehensive kselftest scripts.

Sequence diagram for SBAF test execution on a CPU core

sequenceDiagram
    participant User as actor User
    participant Kernel as Kernel
    participant IFS as IFS Driver
    participant CPU as CPU Core
    User->>Kernel: Initiate SBAF test via sysfs (intel_ifs_2)
    Kernel->>IFS: do_core_test(cpu, dev) with IFS_TYPE_SBAF
    IFS->>IFS: Prepare sbaf_run_params
    IFS->>CPU: stop_core_cpuslocked(cpu, dosbaf, &sbaf_run_params)
    CPU->>CPU: wait_for_sibling_cpu(&sbaf_cpus_in)
    CPU->>CPU: wrmsrl(MSR_ACTIVATE_SBAF, ...)
    CPU->>CPU: rdmsrl(MSR_SBAF_STATUS, ...)
    CPU->>IFS: Return SBAF status
    IFS->>IFS: Update scan_details, status
    IFS->>Kernel: Return test result
    Kernel->>User: Report SBAF test outcome
Loading

ER diagram for new and updated IFS device and test relationships

erDiagram
    IFS_DEVICE ||--o{ IFS_TEST_CAPS : uses
    IFS_DEVICE ||--o{ IFS_TEST_MSRS : uses
    IFS_DEVICE ||--o{ IFS_DATA : has
    IFS_DATA ||--o{ IFS_SBAF : uses
    IFS_DATA ||--o{ IFS_SBAF_STATUS : uses
    IFS_TEST_CAPS {
        int integrity_cap_bit
        int test_num
        char image_suffix
    }
    IFS_TEST_MSRS {
        u32 copy_hashes
        u32 copy_hashes_status
        u32 copy_chunks
        u32 copy_chunks_status
        u32 test_ctrl
    }
    IFS_DATA {
        int loaded_version
        int valid_chunks
        int loaded
        u32 status
        u64 scan_details
        u32 cur_batch
        u32 generation
        u32 chunk_size
        u32 array_gen
        u32 max_bundle
    }
    IFS_SBAF {
        u64 data
        u32 bundle_idx
        u32 pgm_idx
        u32 delay
    }
    IFS_SBAF_STATUS {
        u64 data
        u32 bundle_idx
        u32 pgm_idx
        u32 error_code
        u32 test_fail
        u32 sbaf_status
    }
Loading

Class diagram for new SBAF test execution parameters and flow

classDiagram
    class run_params {
        +ifs_data* ifsd
        +union ifs_scan* activate
        +union ifs_status status
    }
    class sbaf_run_params {
        +ifs_data* ifsd
        +int* retry_cnt
        +union ifs_sbaf* activate
        +union ifs_sbaf_status status
    }
    run_params --> ifs_data
    run_params --> ifs_scan
    run_params --> ifs_status
    sbaf_run_params --> ifs_data
    sbaf_run_params --> ifs_sbaf
    sbaf_run_params --> ifs_sbaf_status
Loading

File-Level Changes

Change Details Files
Implement SBAF test mode for Intel IFS
  • Define sbaf_run_params and dosbaf routine with WRMSR/trace operations
  • Add sbaf_message_not_tested/fail, sbaf_can_restart, sbaf_bundle_completed helpers
  • Introduce ifs_sbaf_test_core and dispatch IFS_TYPE_SBAF in do_core_test
  • Add MSR_ACTIVATE_SBAF and related SBAF MSR defines
runtest.c
ifs.h
core.c
arch/x86/include/asm/msr-index.h
Refactor MSR handling into unified ifs_test_msrs
  • Define struct ifs_test_msrs and ifs_get_test_msrs helper
  • Populate test_msrs in ifs_devices for SAF and SBAF
  • Replace direct MSR_* constants in load.c with msrs->copy_hashes, copy_chunks, test_ctrl
load.c
ifs.h
core.c
Consolidate CPU sibling rendezvous logic
  • Extract wait_for_sibling_cpu into common helper with atomic counters
  • Define atomic_t array_cpus_in, scan_cpus_in, sbaf_cpus_in
  • Remove duplicate SPINUNIT and wait loops
  • Update doscan and do_array_test to use new rendezvous
runtest.c
Extend driver metadata and firmware loading
  • Add image_suffix to ifs_test_caps and max_bundle to ifs_data
  • Append suffix to firmware filename in load and validate functions
  • Populate ifsd->max_bundle from metadata in load.c
ifs.h
load.c
Enhance trace instrumentation
  • Rename ifs_status trace event to use batch instead of CPU
  • Add new ifs_sbaf trace event with batch, bundle_idx, pgm_idx, status
trace/events/intel_ifs.h
Integrate kselftest for Intel IFS
  • Add test_ifs.sh script under tools/testing/selftests/drivers/...
  • Update selftests Makefiles and MAINTAINERS to include IFS tests
  • Define test target drivers/platform/x86/intel/ifs in top-level selftests
tools/testing/selftests/drivers/platform/x86/intel/ifs/test_ifs.sh
tools/testing/selftests/Makefile
MAINTAINERS

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR supports Intel In Field Scan (IFS) SBAF on the GNR platform by integrating upstream commits for both SAF and the new SBAF tests.

  • Added selftests and Makefile updates for IFS testing
  • Updated trace events and driver code (runtest.c, load.c, core.c, ifs.h) to support SBAF functionality
  • Modified MSR definitions and documentation to incorporate SBAF support

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/testing/selftests/drivers/platform/x86/intel/ifs/* Added new selftest script and Makefile changes
include/trace/events/intel_ifs.h Updated trace event definitions for batching
drivers/platform/x86/intel/ifs/runtest.c Refactored scan test code and added concurrency support
drivers/platform/x86/intel/ifs/load.c Adjusted MSR usage for SBAF-related operations
drivers/platform/x86/intel/ifs/ifs.h Added new SBAF MSR and bit field definitions
drivers/platform/x86/intel/ifs/core.c Integrated SBAF test support within core test routines
arch/x86/include/asm/msr-index.h Added SBAF integrity cap definitions
MAINTAINERS Updated file list for new selftest location
Comments suppressed due to low confidence (1)

drivers/platform/x86/intel/ifs/core.c:60

  • The image_suffix for the SBAF test is set to "sbft" but the PR title and description refer to SBAF. Consider verifying if the suffix should be updated to "sbaF" for consistency.
static const struct ifs_test_caps sbaf_test = {

Comment on lines +82 to +83
append_log "[$INFO] echo $on_off > \
${CPU_SYSFS}/cpu${i}/online"
Copy link
Preview

Copilot AI Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The logging statement using a backslash to continue the command on a new line may reduce readability. Consider reformatting the log message to be a single coherent line for clarity.

Suggested change
append_log "[$INFO] echo $on_off > \
${CPU_SYSFS}/cpu${i}/online"
append_log "[$INFO] echo $on_off > ${CPU_SYSFS}/cpu${i}/online"

Copilot uses AI. Check for mistakes.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from avenger-285714. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Avenger-285714 - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Avenger-285714
Copy link
Collaborator Author

@opsiff
Copy link
Member

opsiff commented Jul 1, 2025

commit 744a6a1
Author: Arnaldo Carvalho de Melo [email protected]
Date: Mon Sep 30 12:50:56 2024 -0300

tools arch x86: Sync the msr-index.h copy with the kernel sources

To pick up the changes from these csets:

  0a3e4e94d137daac ("platform/x86/intel/ifs: Add SBAF test image loading support")

That cause no changes to tooling:

  $ tools/perf/trace/beauty/tracepoints/x86_msr.sh > before
  $ cp arch/x86/include/asm/msr-index.h tools/arch/x86/include/asm/msr-index.h
  $ tools/perf/trace/beauty/tracepoints/x86_msr.sh > after
  $ diff -u before after
  $

Just silences this perf build warning:

  Warning: Kernel ABI header differences:
    diff -u tools/arch/x86/include/asm/msr-index.h arch/x86/include/asm/msr-index.h

Cc: Adrian Hunter <[email protected]>
Cc: Hans de Goede <[email protected]>
Cc: Ian Rogers <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Jithu Joseph <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: https://lore.kernel.org/lkml/ZvrJY68Btx3a_yV4@x1
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>

@opsiff opsiff merged commit b49f977 into deepin-community:linux-6.6.y Jul 1, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants