Commit Graph
2289 Commits
Author SHA1 Message Date
Xianbin Zhu b223774f20 platform: generic: spacemit: k1: refactor platform support
K3 shares cache-control CSRs, PMU idle fields, cluster sizing, and the
CCI-550 programming sequence with K1. Keeping these definitions and the
CCI helper in K1-specific files would either duplicate them or make K3
depend on K1 support.

Add a hidden PLATFORM_SPACEMIT option and move the shared definitions to
spacemit/common.h. Move cci_enable_snoop_dvm_reqs() to spacemit.c while
keeping each SoC's CCI topology and boot flow in its own platform driver.

Rename the PMU idle fields to match the K1 and K3 User Manuals. Keep the
K1 power-down mask at 0x1b, so K1 power-management behavior remains
unchanged. Keep the K1 HSM implementation K1-specific and switch it to
the shared definitions.

This is a non-functional refactoring that prepares the common support
used by K3.

Signed-off-by: Xianbin Zhu <xianbin.zhu@linux.spacemit.com>
Tested-by: E Shattow <e@freeshell.de>
Co-developed-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20261028-spacemit-k3-v6-4-01d984f60941@linux.spacemit.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-29 11:24:04 +05:30
Troy Mitchell acc2508c47 platform: generic: spacemit: k1: move hart init to nascent hook
cold_boot_allowed() is a policy query and should not modify per-hart
state. The K1 callback currently programs ML2SETUP as a side effect.

Move the ML2SETUP programming to nascent_init(), which runs on every
hart before common initialization. Chain generic_nascent_init() to keep
the generic per-hart setup intact.

Fixes: 1f84ec2ac2 ("platform: generic: spacemit: add K1")
Reported-by: Bo Gan <ganboing@gmail.com>
Link: https://lore.kernel.org/r/56220293-88e3-451f-833e-8251656a83d9@gmail.com
Reviewed-by: Bo Gan <ganboing@gmail.com>
Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Tested-by: E Shattow <e@freeshell.de>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20261028-spacemit-k3-v6-3-01d984f60941@linux.spacemit.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-29 11:24:02 +05:30
Xianbin Zhu 2c4172cd3c platform: generic: spacemit: k1: rename cache flush operation
MRAOP_ICACHE_INVALID is used to flush the local D-cache before a hart
stops, so the name incorrectly describes I-cache invalidation. Rename
it to MRAOP_CACHE_FLUSH without changing its encoded value.

Signed-off-by: Xianbin Zhu <xianbin.zhu@linux.spacemit.com>
Reviewed-by: E Shattow <e@freeshell.de>
Co-developed-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Tested-by: E Shattow <e@freeshell.de>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20261028-spacemit-k3-v6-2-01d984f60941@linux.spacemit.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-29 11:24:00 +05:30
Troy Mitchell 5dd2a0619e lib: sbi: select expected trap handler per hart
The expected trap handler is selected once by the cold boot hart. This
breaks heterogeneous systems where the cold boot hart implements H but
another hart does not, because the H-aware handler accesses mtval2 and
mtinst.

Store the handler in each hart's feature data and select it from that
hart's MISA before feature detection. Load the address without function
calls, avoiding stack-protector instrumentation in the CSR probing and
unprivileged memory access paths.

Early M-mode CSR probes, such as those in the IMSIC nascent hook, can run
before hart feature data is ready. Use the non-H handler until the current
hart's handler has been initialized, and publish the feature-data offset
only after every hart's storage has been cleared. This leaves the fixed
scratch layout and allocator unchanged.

Fixes: 1de66d170e ("lib: Optimize unpriv load/store implementation")
Reported-by: Bo Gan <ganboing@gmail.com>
Link: https://lore.kernel.org/r/e702f291-dde8-4b99-a65e-182d2b847720@gmail.com
Suggested-by: Bo Gan <ganboing@gmail.com>
Cc: Alvin Chang <alvinga@andestech.com>
Link: https://lore.kernel.org/r/20260831022156.2060561-1-alvinga@andestech.com
Signed-off-by: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Tested-by: E Shattow <e@freeshell.de>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20261028-spacemit-k3-v6-1-01d984f60941@linux.spacemit.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-29 11:22:51 +05:30
Fengwei Tan 2bbee7d82a lib: sbi_pmu: Fix fixed-counter events reported as unsupported
OpenSBI assigns SBI_PMU_HW_CPU_CYCLES and SBI_PMU_HW_INSTRUCTIONS to
fixed counters during PMU initialization. sbi_pmu_ctr_cfg_match()
recognizes these events without searching hw_event_map[].

However, sbi_pmu_event_get_info() only checks hw_event_map[] when
determining whether a hardware event is supported. As a result, these
fixed-counter events are reported as unsupported when no riscv,pmu
device tree node is provided.

Check fixed-counter events separately using pmu_ctr_find_fixed_hw() and
report them as supported.

Fixes: e434584216 ("lib: sbi_pmu: Implement SBI PMU event info function")
Signed-off-by: Fengwei Tan <tfx2001@outlook.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/SY8P300MB0041D04649621E79FE950B43B58E2@SY8P300MB0041.AUSP300.PROD.OUTLOOK.COM
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-29 11:06:47 +05:30
Evgenii Prokopiev d28bc6f898 lib: sbi_hart: Retrun zero length of mhpmcounter when probing failed
If writing access is not allowed, it will raise a trap, but we increase
the number of allowed bits to 32 in this approach, which isn't right.
There must be a write of 0.

Move the operation of increasing allowed bits into the 'if' condition.

Signed-off-by: Evgenii Prokopiev <eestelle0626@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260910182026.6776-1-eestelle0626@gmail.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-27 17:28:45 +05:30
Evgenii Prokopiev 3a51dc070e lib: sbi_hart: Reset mhpmcounter after probing its bits
Writting mhpmcounter3 (and 3H) to determine the allowed bit width
has a side effect: the counter starts counting.

Explicitly clear the counter right after the probe so the probing
writes do not leave any persistent hardware side effect.

Signed-off-by: Evgenii Prokopiev <eestelle0626@gmail.com>
Link: https://lore.kernel.org/r/20260910180217.3256-1-eestelle0626@gmail.com
Signed-off-by: Anup Patel <anup@brainfault.org>
Reviewed-by: Anup Patel <anup@brainfault.org>
2026-10-27 13:58:47 +05:30
Indrek Kruusa f5622b4bb4 platform: generic: allwinner: Support the D1s as well
The Allwinner D1s SoC is a stripped-down version of the D1 and D1s
boards use "allwinner,sun20i-d1s" as their root compatible string
instead of "allwinner,sun20i-d1". So, currently the sun20i override is
not selected on them.

Add the D1s compatible to the match table.

Tested on the MangoPi MQ board with the Allwinner F133-A (D1s) SoC.

Signed-off-by: Indrek Kruusa <indrek.kruusa@gmail.com>
Link: https://lore.kernel.org/r/20260921182017.999610-1-indrek.kruusa@gmail.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-27 13:46:09 +05:30
Maxim Kochetkov 113d719547 Makefile: Speed up parallel build
Parallel build is extremely slow when using vars (O, I,
PLATFORM_DIR+PLATFORM). And all this is because the variables are
calculated continuously, with the simultaneous invocation of
the $(shell ...). So use "Simply expanded variables" to
calculate value and call $(shell ...) just once.

Signed-off-by: Maxim Kochetkov <fido_max@inbox.ru>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260924060133.294142-1-fido_max@inbox.ru
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-27 13:34:29 +05:30
Nia Su a0531af7ad lib: sbi: Fix stale prev_context in RNMI handler
An earlier SBI trap may have already used the same M-mode exception
stack slot to save its trap context before an RNMI is taken.
sbi_trap_rnmi_handler() never initializes prev_context before
sbi_trap_error() walks it to print trap diagnostics, so it can read
whatever stale value happens to be left in that slot.

Link prev_context on entry and restore it on exit, the same way
sbi_trap_handler() does. This also lets an exception taken while
already inside RNMI handling chain back to the RNMI's own trap
context instead of dropping it, so sbi_trap_error() prints every
nested context correctly, including the RNMI's.

Fixes: 00fec20b49 ("firmware: Add RNMI handler infrastructure")
Suggested-by: Nick Hu <nick.hu@sifive.com>
Signed-off-by: Nia Su <nia.su@sifive.com>
Reviewed-by: Evgeny Voevodin <evvoevod@tenstorrent.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260914-trap-context-fix-v2-2-3a6bedc6fcf0@sifive.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-27 13:26:22 +05:30
Nia Su f84bdb9877 firmware: Clear scratch->trap_context on warm boot
sbi_trap_handler() links tcntx->prev_context on entry and restores
scratch->trap_context on exit, forming a stack that unwinds through
the same path it was pushed from.

Non-retentive suspend/resume breaks that unwind: the SBI call
requesting suspend jumps straight to warm boot (jump_warmboot())
instead of returning through the normal exit path, leaving
scratch->trap_context stale. Since each hart's scratch space sits at
a fixed address, the next trap taken after warm boot resume reads
that same stale scratch->trap_context as its prev_context, which
sbi_trap_error() then walks to print trap diagnostics -- producing a
broken trap dump.

Clear trap_context in the scratch space on warm boot entry.

Fixes: 60ffc154c8 ("include: sbi: Add trap_context pointer in struct sbi_scratch")
Signed-off-by: Nia Su <nia.su@sifive.com>
Reviewed-by: Evgeny Voevodin <evvoevod@tenstorrent.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260914-trap-context-fix-v2-1-3a6bedc6fcf0@sifive.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-27 13:26:22 +05:30
liutong 2afa777592 lib: sbi_mpxy: fix integer overflow in attribute range endpoint
sbi_mpxy_read_attrs() and sbi_mpxy_write_attrs() compute the end of the
requested range as a u32:

  end_id = base_attr_id + attr_count - 1;

Message protocol attribute ids extend to
SBI_MPXY_ATTR_MSGPROTO_ATTR_END (0xffffffff), so the guard
"end_id > SBI_MPXY_ATTR_MSGPROTO_ATTR_END" cannot hold for a u32 and
never rejects anything.

Such a request then reaches the message protocol driver, which computes
the same endpoint in a u32 and so passes its own range check as well,
and indexes its attribute array with attr_id2index(base_attr_id). For
base_attr_id 0xffffffff that is index 0x7fffffff, an out-of-bounds read
whose result is copied into the shared memory.

Widen end_id to u64 so the endpoint is exact and such a request is
rejected before a driver runs. The standard attribute path is not
affected, since attr_count is already limited to the shared memory size
there.

Fixes: 7939bf1329 ("lib: sbi: Add SBI Message Proxy (MPXY) framework")
Signed-off-by: liutong <liutong@iscas.ac.cn>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260910052629.3359493-5-liutong@iscas.ac.cn
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-26 11:43:21 +05:30
liutong f45b9433ed lib: sbi_pmu: fix integer overflow and zero-address in event_get_info
sbi_pmu_event_get_info() computes the shared memory size as
num_events * sizeof(struct sbi_pmu_event_info) before num_events is
validated. The product can wrap, in which case the domain check runs
against a truncated size while the loop below still iterates over the
original count, that is, past the region that was checked.

Check num_events against the largest value that cannot wrap, and reject
a zero address, both before the multiplication.

Fixes: e434584216 ("lib: sbi_pmu: Implement SBI PMU event info function")
Signed-off-by: liutong <liutong@iscas.ac.cn>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260910052629.3359493-3-liutong@iscas.ac.cn
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-26 10:28:28 +05:30
liutong a14e4d24a1 lib: sbi: dbtr: fix integer overflow in read_trig bounds check
In sbi_dbtr_read_trig(), the range check is:

  if (trig_idx_base + trig_count >= hs->total_trigs)

When trig_idx_base and trig_count are both unsigned long values supplied
by S-mode, their sum can wrap past ULONG_MAX to a small value, making
the check pass. For example trig_idx_base=1, trig_count=ULONG_MAX wraps
to 0, which is less than total_trigs.

This allows the subsequent for_each_trig_entry loop to access trigger
entries far beyond the triggers[] array, corrupting M-mode heap memory
via CSR read-back writes and leaking M-mode internal state to S-mode
shared memory.

Rewrite the condition as trig_count >= total_trigs - trig_idx_base. The
subtraction is safe because the preceding check already guarantees
trig_idx_base < total_trigs.

Fixes: 97f234f15c ("lib: sbi: Introduce the SBI debug triggers extension support")
Signed-off-by: liutong <liutong@iscas.ac.cn>
Reviewed-by: Himanshu Chauhan <himanshu.chauhan@oss.qualcomm.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260910052629.3359493-2-liutong@iscas.ac.cn
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-26 10:27:20 +05:30
Nickolai Zeldovich bcf587a987 lib: sbi_timer: Insert timer event before the later event
The per-HART event list is kept sorted by expiry time: the head is the
event programmed into the timer device by __sbi_timer_update_device(),
and sbi_timer_process() stops at the first unexpired entry.

__sbi_timer_event_start() finds the first event that expires after the
new one, but then inserts the new event with sbi_list_add(), i.e. after
that event instead of before it.  Starting an event at time 50 while an
event at time 1000 is pending yields the list [1000, 50]: the device is
programmed for 1000 and the earlier event fires 950 ticks late.

Today each HART only ever has its S-mode timer event on the list, so
the misordering needs a second timer event user to show up.  Once there
is one, on HARTs without Sstc an S-mode timer programmed while a later
M-mode event is pending is delivered only when that later event
expires.

Use sbi_list_add_tail() so the new event goes in front of next_ev.

Fixes: b7fa8a246c ("lib: sbi_timer: Add support for timer events")
Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu>
Assisted-By: Claude Fable 5.1
Reviewe-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20261011222412.769530-1-nickolai@csail.mit.edu
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 15:05:29 +05:30
Anup Patel 8c04100096 lib: utils/mpxy: Use domain notifier for deferred creation of MPXY RPMI
The owner domain may not be available at the time of creating MPXY RPMI
instance so use domain notifier for deferred creation.

Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
Reviewed-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Tested-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260923032359.4041876-12-anup.patel@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 14:32:38 +05:30
Oza Pawandeep f4ed5aa8b7 lib: sbi_domain: Add domain notifier infrastructure
Introduce a notifier callback mechanism that allows subsystems to
register interest in domain events (such as registration). Whenever
such events happen for a domain, all registered notifiers are invoked.

The following public interfaces are added to sbi_domain.h:

  - sbi_domain_register_notifier(): registers a notifier callback.
    Duplicate (fn, event, priv) pairs are silently ignored.

  - sbi_domain_unregister_notifier(): removes a previously registered
    notifier callback.

Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
Signed-off-by: Oza Pawandeep <pawandeep.oza@oss.qualcomm.com>
Reviewed-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Tested-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260923032359.4041876-11-anup.patel@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 14:30:46 +05:30
Anup Patel f909590830 lib: utils/mpxy: Add domain parameter to setup_group() callback
The MPXY channels can be domain specific so the setup_group() callback
must know which domain the MPXY RPMI instance is associated with.

Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
Reviewed-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Tested-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260923032359.4041876-10-anup.patel@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 14:30:46 +05:30
Anup Patel c4f098bfa3 lib: sbi_domain: Allow adding memrange to a particular domain from drivers
Currently, memregions of non-root domain only populated at domain creation
time which not flexible for drivers which create domain specific resources
(such as MPXY channels). Add new sbi_domain_add_memrange() function which
allows adding memrange to any domain at boot time.

Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
Reviewed-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Tested-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260923032359.4041876-9-anup.patel@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 14:30:46 +05:30
Anup Patel 145bd4ccc0 lib: sbi_domain: Make domain regions as fixed array
Instead of separately allocating domain regions, let us have a fixed
size array so that regions are automatically allocated along with
domain allocation and one SBI_DOMAIN_MEMREGION_MAX macro defines
maximum number of regions for all domains.

Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
Reviewed-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Tested-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260923032359.4041876-8-anup.patel@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 14:30:46 +05:30
Anup Patel 89b3afb16f lib: utils/mpxy: Simplify fdt_mpxy_rpmi.h by moving things to fdt_mpxy_rpmi.c
Currently, the fdt_mpxy_rpmi.h has lot things which are not used by
any of MPXY RPMI drivers so simplify fdt_mpxy_rpmi.h by moving such
things to fdt_mpxy_rpmi.c.

Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
Reviewed-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Tested-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260923032359.4041876-7-anup.patel@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 14:30:46 +05:30
Anup Patel dc8ceae9d0 lib: utils/mpxy: Introduce mpxy_rpmi_no_mbox_init() function
Add new mpxy_rpmi_no_mbox_init() function to instantiate MPXY RPMI
channel without any mailbox channel backing. This new function can
be used by MPXY RPMI drivers that want to emulate MPXY channels in
software.

Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
Reviewed-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Tested-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260923032359.4041876-6-anup.patel@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 14:30:46 +05:30
Anup Patel bdd7874991 lib: sbi_domain: Introduce sbi_domain_find_by_name() function
Add sbi_domain_find_by_name() to allow driver locate domain instance
using domain name. This also means domain names must be unique.

Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
Reviewed-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Tested-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260923032359.4041876-5-anup.patel@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 14:30:46 +05:30
Anup Patel db877c0908 lib: utils/mpxy: Introduce get_attribute_group() for MPXY RPMI data
Fully emulated MPXY channels need a custom way to provide RPMI attributes
so introduce optional get_attribute_group() callback in MPXY RPMI data
for this purpose.

Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
Reviewed-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Tested-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260923032359.4041876-4-anup.patel@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 14:30:46 +05:30
Anup Patel fa2bbaf349 lib: utils/mpxy: Setup group early in fdt_mpxy_rpmi_init()
Instead of setting group late in fdt_mpxy_rpmi_init(), it is better
to do it as early as possible right after requesting mailbox channel
so that we define new callback for channel attributes.

Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
Reviewed-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Tested-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260923032359.4041876-3-anup.patel@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 14:30:46 +05:30
Anup Patel 0298a2c343 lib: utils/mpxy: Rename fdt_mpxy_rpmi_mbox to fdt_mpxy_rpmi
The common fdt_mpxy_rpmi_mbox driver is being upgraded to support emulated
MPXY channels hence drop term "mbox" from fdt_mpxy_rpmi_mbox everywhere.

Signed-off-by: Anup Patel <anup.patel@oss.qualcomm.com>
Reviewed-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Tested-by: Pawandeep Oza <pawandeep.oza@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260923032359.4041876-2-anup.patel@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 14:30:46 +05:30
Prajwal N fde5dfe96f include: sbi_utils/mailbox/rpmi_msgprot: Fix warm reboot failure
When sbi_system_reset() is invoked with SBI_SRST_RESET_TYPE_WARM_REBOOT,
the RPMI system reset driver reports warm reboot as unsupported.

The driver was checking the wrong bit in the FLAGS field returned
by rpmi_sysreset_get_attributes().

To fix this, check the correct bit to detect warm reboot support.

Fixes: 6a26726e08 (lib/utils: reset: Add RPMI System Reset driver)
Signed-off-by: Prajwal N <prajwal.n@oss.qualcomm.com>
Reviewed-by: Rahul Pathak <rahul.pathak@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20261001084412.1383854-1-prajwal.n@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 14:22:06 +05:30
Prajwal N 97bf679708 lib: utils/irqchip/imsic: Fix the MSI capability assignment
The struct sbi_irqchip_device is copied to the struct imsic_data
and the MSI capability is set in sbi_irqchip_device. Since the
struct assignment is not a pointer, the MSI capability setting
does not take effect.

Set the MSI capability directly in the struct imsic_data to
ensure it takes effect.

Fixes: 193b1d9e7e ("lib: utils/irqchip/imsic:migrate to irqchip framework")
Signed-off-by: Prajwal N <prajwal.n@oss.qualcomm.com>
Reviewed-by: Rahul Pathak <rahul.pathak@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20261001060820.1267933-1-prajwal.n@oss.qualcomm.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 14:19:19 +05:30
Sebastian Alba Vives 0ce50ae8fa lib: sbi_pmu: unmap shared memory on the early exit in event_get_info
sbi_pmu_event_get_info() maps the caller's shared memory into M-mode with
sbi_hart_protection_temp_map_range(). The must-be-zero check added inside the
event loop returns straight to the supervisor without reaching the matching
temp_unmap_range() at the end of the function, so the mapping is left behind.

This has a security impact beyond leaking a mapping. Under Smepmp the
temporary mapping is a single reserved PMP entry, SBI_SMEPMP_RESV_ENTRY.
sbi_hart_smepmp_temp_map_range() refuses to reprogram that entry while it is
already enabled:

	if (sbi_hart_is_pmp_enabled(SBI_SMEPMP_RESV_ENTRY))
		return SBI_ENOSPC;

and no caller in the tree checks that return value. sbi_pmu.c, sbi_sse.c,
sbi_mpxy.c, sbi_dbtr.c and sbi_ecall_dbcn.c all discard it. So once the entry
is left behind, every later shared memory ecall on that hart runs with PMP 0
still covering the previous region, and M-mode faults the first time it
dereferences the new buffer.

A supervisor triggers this with one ecall carrying a reserved bit in the first
event_idx. The next SBI_EXT_DBCN_CONSOLE_WRITE then takes an M-mode load
access fault on the console buffer and the firmware stops making forward
progress, taking DBCN, SSE, MPXY and DBTR down with it on that hart. It also
breaks the Smepmp invariant that M-mode does not retain standing access to
supervisor memory.

Confirmed on qemu virt with a bare metal S-mode payload, QEMU 8.2.2:

  build                 -cpu                protection   result
  master 6ad246a1       rv64                pmp          completes
  master 6ad246a1       rv64,smepmp=true    epmp         firmware dies
  master + this patch   rv64,smepmp=true    epmp         completes

The middle row leaves this as the last entry in the QEMU exception trace,
where the epc is inside nputs() in M-mode and the tval is the supervisor
console buffer:

  cause:0000000000000005, epc:0x000000008000204c,
  tval:0x0000000080500000, desc=fault_load

Without Smepmp the map and unmap pair compiles down to nothing, which is why
the first row survives.

This only affects master. v1.9 and earlier have the same map and unmap pair
but no return between them, so no released version needs a backport.

Route the early exit through the existing unmap.

Fixes: d97cfb33ae ("lib: sbi_pmu: Return invalid param error for reserved event_idx bits")
Signed-off-by: Sebastian Alba Vives <sebasjosue84@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20261012022033.1165060-1-sebasjosue84@gmail.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 14:07:17 +05:30
Sebastian Alba Vives 663786edae lib: sbi_trap_v_ldst: fix mask buffer overflow on VLEN > 128
mask_len counts mask bits: it is derived from vlenb * 8, and the mask
indexing below divides by 8 to turn a bit index into a byte index.
get_vreg() counts bytes: its size argument feeds "vsetvli x0, %0, e8,
m8" and a vse8.v, both of which operate on 8-bit elements.

Both emulators pass mask_len directly as get_vreg()'s size, so the
firmware writes eight times more than intended into mask[], a
MASK_BUFFLEN / 8 == 128 byte stack buffer. The write stays in bounds
only while vlenb * 8 <= 128, that is VLEN <= 128. Above that it runs
past the end of the buffer and corrupts the M-mode stack, including the
saved return address.

The pre-rework code passed vlenb, a byte count, which was correct; the
chunked version replaced it with a bit count.

Reachable from S-mode or U-mode with a single masked, misaligned vector
load or store on a hart whose VLEN exceeds 128 bits. Observed on
qemu-system-riscv64 with -cpu rv64,v=true,vlen=256,zicclsm=false: the
firmware takes an instruction access fault in M-mode with mepc and ra
both zero. The same payload at vlen=128 enters the emulator and
completes normally.

Convert pos and size to bytes at both call sites. mask_len is a power of
two and at least 8, and pos is already a multiple of mask_len, so both
divisions are exact.

Fixes: a8be5e94 ("lib: sbi: Rework misaligned vector load/store")
Signed-off-by: Sebastian Alba Vives <sebasjosue84@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260922030633.10886-1-sebasjosue84@gmail.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 14:01:44 +05:30
Jakub Janeczko 16fa280b69 lib: sbi_pmu: Fix race on pmu_ctr_write_hw
On platforms where a bit of mcountinhibit cannot be set to 1,
and when on rv32, pmu_ctr_write_hw() was given value whose lower
bits were close to 2^32, the write could miss the lower bit overflow.

Signed-off-by: Jakub Janeczko <kuba@ev1.pl>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20261024195739.585621-1-kuba@ev1.pl
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 13:42:21 +05:30
Pengpeng Hou 9f37e25f80 lib: sbi: reject PMU skip-match counter class mismatches
SKIP_MATCH selects the first counter in the caller-provided set, but the
current path checks only that the index exists and is active.  A supervisor
can select an active hardware counter for a firmware event.  CLEAR_VALUE or
AUTO_START then indexes firmware-counter state with
ctr_idx - num_hw_ctrs, which underflows.  The inverse mismatch sends a
firmware-counter index to hardware-counter operations.

Reject the selected counter when its hardware/firmware class cannot monitor
the requested event.  Return SBI_ENOTSUPP, matching the PMU specification's
case where the selected counter cannot monitor that event.

Fixes: 13d40f21d5 ("lib: sbi: Add PMU support")
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Tested-by: Sebastian Alba Vives <sebasjosue84@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260827115718.50124-1-pengpeng@iscas.ac.cn
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-25 11:20:03 +05:30
Pengpeng Hou 131bda9447 lib: sbi_hsm: Validate state before updating start context
sbi_hsm_hart_start() acquires the target hart's start ticket, then
writes next_arg1, next_addr and next_mode before checking whether the
target is stopped.

A start request for a non-retentively suspended hart is rejected, but
those writes have already replaced the resume context consumed by
sbi_hsm_hart_resume_finish(). The same ordering also lets other rejected
start requests modify target scratch state.

Check the state immediately after acquiring the start ticket and before
updating the scratch context. The ticket serializes start requests for
the target; retain the cmpxchg as the publication barrier and defensive
state check.

Fixes: e8e9ed3790 ("lib: sbi: Set the state of a hart to START_PENDING after the hart is ready")
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260831130817.54625-1-pengpeng@iscas.ac.cn
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-23 17:27:48 +05:30
Pengpeng Hou 5930665a17 lib: sbi_timer: Restart events from the restart list
Timer callbacks can request that an expired event be restarted. Such
events are moved to a local restart_list, but the restart loop tests that
list while reading its first entry from tstate->event_list.

If the main event list is empty, the loop treats its list head as a timer
event. Otherwise it repeatedly removes and reinserts the wrong event
while restart_list remains nonempty, so timer processing cannot
complete.

No in-tree callback currently requests a restart, but the timer-event
callback interface exposes this path to OpenSBI library and platform
users.

Read the event from restart_list, matching the loop condition and the
list that owns the entry.

Fixes: b7fa8a246c ("lib: sbi_timer: Add support for timer events")
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260831130641.54100-1-pengpeng@iscas.ac.cn
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-23 13:55:43 +05:30
Pengpeng Hou 9bc841226d lib: utils/mailbox: Reject invalid RPMI queue indices
The RPMI shared-memory helpers validate a queue index before using it
to select queue_ctx_tbl, but the current comparison accepts queue_id
equal to queue_count.

Only entries 0 through queue_count - 1 are initialized from the device
tree. Accepting queue_count can therefore use an uninitialized queue
context when a protocol operation selects a queue omitted by the
description.

Reject queue_id greater than or equal to queue_count in both transfer
directions.

Fixes: 91f46fb47e ("lib/utils: Add RPMI messaging protocol and shared memory transport support")
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260831130444.53629-1-pengpeng@iscas.ac.cn
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-23 13:18:45 +05:30
Pengpeng Hou 95c7980851 lib: utils/mailbox: reject undersized RPMI shmem queues
The RPMI shared-memory mailbox transport derives qctx->num_slots from the
device-tree queue window size and the riscv,slot-size property. The current
initialization only checks that the queue window is nonzero before
subtracting the two RPMI header slots.

Reject queue windows that cannot provide the two header slots plus at least
two data ring slots. A zero data-slot count would later be used as a modulo
divisor, and a one-slot ring is also unusable with the current full/empty
convention because one empty slot is reserved to distinguish the two
states.

Also reject data-slot counts that cannot be represented by qctx->num_slots.

Fixes: 91f46fb47e ("lib/utils: Add RPMI messaging protocol and shared memory transport support")
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260828142521.14267-1-pengpeng@iscas.ac.cn
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-23 13:06:37 +05:30
Pengpeng Hou 9dcd9f9365 lib: sbi: use unsigned masks for HPM counter 31
The HPM feature detector and CSR emulator build mhpm_mask bits with a
plain signed 1. Both macro families expand through counter 31, so the
last expansion evaluates 1 << 31 and shifts a signed int into its sign
bit.

Use BIT() at both sites. The mask is unsigned and bit 31 is part of the
represented HPM counter set.

Fixes: c744ed77b1 ("lib: sbi_pmu: Enable noncontigous hpm event and counters")
Fixes: ee1f83ca84 ("lib: sbi_pmu: remove mhpm_count field in hart feature")
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260828142354.13035-1-pengpeng@iscas.ac.cn
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-10-23 12:59:53 +05:30
Alvin Chang 10b5ac7222 firmware: payload: test: Relocate GOT entries before calling C code
The test payload is linked as a PIE but, unlike fw_base.S, its startup
code never processed its own dynamic relocations. Nothing in the payload
needed a GOT so far, so this went unnoticed.

CONFIG_STACK_PROTECTOR_ALL=y changes that. GCC derives the
__stack_chk_guard reference from an artificial declaration with default
visibility, so under -fPIE it always loads the guard address through the
GOT. The linker zeroes that entry and records an R_RISCV_RELATIVE
relocation instead, which nobody applies. test_main() then reads the
canary from a NULL pointer before the first sbi_ecall_console_puts(), so
the payload hangs silently right after the OpenSBI boot banner. The other
two configurations emit no canary in the payload, leaving .rela.dyn
empty, which is why only this one breaks.

Keep .rela.dyn in the payload image and apply the R_RISCV_RELATIVE
entries at the top of _start, reusing the code from fw_base.S. The loop
is skipped when .rela.dyn is empty.

Fixes: edfbc1285d ("firmware: Initial compiler built-in stack protector support")
Reported-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Alvin Chang <alvinga@andestech.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260821101339.3563598-1-alvinga@andestech.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-09-28 18:55:22 +05:30
Benoît Monin 6ad246a149 platform: generic: metanoia/mt2824: configure PMA for DSP memory regions
Set up the memory attribute for the XOR RAM, MRAS memory, and RSC table
used by the DSPs as non-cacheable and bufferable during final init.

Signed-off-by: Benoît Monin <benoit.monin@bootlin.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260902-mt2824-pma-v1-1-ada8f836365d@bootlin.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-09-28 18:06:25 +05:30
Shibo Zhu 2de7dfb681 lib: sbi_mpxy: Fix shared memory size rounding
The sbi_mpxy_register_channel() currently performs ceiling division by
PAGE_SIZE but stores the resulting page count in mpxy_shmem_size. All
consumers interpret mpxy_shmem_size as a byte count, so channels requiring
more than one page get an undersized shared memory value.

Address the above issue by using ROUNDUP() to keep the rounded value in
bytes.

Fixes: ec09918426 ("lib: sbi: Update MPXY framework and SBI extension as per latest spec")
Signed-off-by: Shibo Zhu <3499129952@qq.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/tencent_14AA3BA0083001905C262A5CD64E442FC205@qq.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-09-28 17:42:15 +05:30
Chen Pei 0ffaa1bc65 lib/utils/fdt: Reserve exactly enough FDT space for fdt_cpu_fixup
fdt_cpu_fixup() reserves a hardcoded 32 extra bytes, plus 16 more per
HART inside the "zicntr" loop. Those 32 bytes also have to cover every
"status" property rewritten to "disabled", so once more than a handful
of HARTs are disabled the fixups fail with FDT_ERR_NOSPACE (-3).

Bumping the reservation to a fixed worst case is not safe either:
fdt_open_into() cannot know how much space the caller's buffer really
has, it just trusts the requested size. As OpenSBI does not own the
memory following a device tree passed in by the previous booting stage,
over-declaring the blob risks corrupting whatever follows it.

Walk the HART nodes once without modifying them instead, and reserve
exactly what the fixups need. The read-only decision logic is factored
into fdt_cpu_fixup_needed() so the sizing and fixup passes cannot drift
apart, which also makes the per-HART fdt_open_into() redundant. Check
the return values of fdt_setprop_string() and fdt_appendprop_string()
as well, as running out of space used to fail silently.

Fixes: dd9439fbac ("lib: utils: Add a fdt_cpu_fixup() helper")
Signed-off-by: Chen Pei <cp0613@linux.alibaba.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260817084303.1232-1-cp0613@linux.alibaba.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-09-28 11:41:25 +05:30
Trevor Gamblin 5b1e739428 Makefile: don't grep when setting CC_SUPPORT_SAVE_RESTORE
Check exit status from the compiler/linker check directly (similar to
OPENSBI_LD_PIE), rather than using grep to search for a pattern. This
avoids potential unrelated matches in the command.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260923-makefile_extension_grep-v2-3-0eb97b8ac076@baylibre.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-09-28 11:03:50 +05:30
Trevor Gamblin f3ed2c4e5c Makefile: don't grep when setting CC_SUPPORT_STRICT_ALIGN
Check exit status from the compiler/linker check directly (similar to
OPENSBI_LD_PIE), rather than using grep to search for a pattern. This
avoids potential unrelated matches in the command.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260923-makefile_extension_grep-v2-2-0eb97b8ac076@baylibre.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-09-28 11:03:50 +05:30
Trevor Gamblin 7b4c152c8f Makefile: don't grep when setting CC_SUPPORT_ZICSR_ZIFENCEI
Check exit status from the compiler/linker check directly (similar to
OPENSBI_LD_PIE), rather than using grep to search for a pattern. This
avoids potential unrelated matches in the command.

Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260923-makefile_extension_grep-v2-1-0eb97b8ac076@baylibre.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-09-28 11:03:50 +05:30
Zong Li 5a17501726 docs: firmware: document the OpenSBI firmware header
Add docs/firmware/fw_header.md describing the layout of the 128-byte
OpenSBI firmware header, the a0/a1/a2 override flags, what a previous
booting stage is expected to put in each register, and an example of how
to patch the header. Also point at it from fw.md, next to the
description of the registers the previous booting stage passes.

Signed-off-by: Zong Li <zong.li@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260918081313.659655-4-zong.li@sifive.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-09-18 16:52:39 +05:30
Zong Li f83d6a730b firmware: fw_base.S: override a0, a1 and a2 from the firmware header
Wire up the flags word and the three override values in the OpenSBI
firmware header. When the previous booting stage sets one of the
FW_HEADER_FLAGS_OVERRIDE_A[012] bits, the cold boot path replaces the
matching register with the value stored in the header before doing
anything else with the boot arguments.

This lets a previous booting stage which cannot pass the boot arguments
in registers hand them over by patching a few words in the firmware
image instead. For example, a booting stage running on a dedicated boot
processor can load the OpenSBI image, patch the header with the hart id,
the DTB address and, for FW_DYNAMIC, the address of a struct
fw_dynamic_info it built somewhere in DRAM, and then release the hart
that runs OpenSBI, without ever being able to set up that hart's
registers itself.

The flags word is zero in a freshly built image, so nothing is
overridden and every existing booting stage keeps passing a0, a1 and a2
in registers as before.

Suggested-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Zong Li <zong.li@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260918081313.659655-3-zong.li@sifive.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-09-18 16:52:39 +05:30
Zong Li 1854901adc firmware: fw_base.S: add a formatted OpenSBI firmware header
Add a fixed 128-byte header at the very beginning of every OpenSBI
firmware image, regardless of the firmware type. The header lets the
previous booting stage identify an OpenSBI image and, more importantly,
gives it a well-known place inside the image to hand over information
to OpenSBI by patching a few words instead of setting up registers.

This first patch only introduces the layout:

  - a 4-byte jump over the header to _start_real, so that _start stays
    the entry point of the image. The jump is assembled with
    '.option norvc' so that the fields behind it are always at a fixed
    offset, even for a build with compressed instructions enabled,

  - the 'OSBI' magic, a header version, the XLEN the firmware was built
    for and the size of the firmware image, so that the previous booting
    stage can validate the image and figure out how much memory it
    occupies,

  - a flags word and three 8-byte override values, which are unused
    (and zero) for now and are wired up by the next patch.

The layout is deliberately identical for RV32 and RV64 so that the
previous booting stage can parse the header without knowing the XLEN of
the firmware upfront. Each override value is followed by a reserved
8-byte slot so that the same layout can be extended to RV128 later.

Suggested-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Zong Li <zong.li@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260918081313.659655-2-zong.li@sifive.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-09-18 16:52:39 +05:30
Carlos López 9476b78361 Makefile: enable Thread Safety Analysis
Now that all locking code has been properly annotated, enable clang's
Thread Safety Analysis.

Two flags are available, -Wthread-safety, and the more recent
-Wthread-safety-pointer. The former was introduced before clang gained
RISC-V support, so it is guaranteed to be available. The latter was
introduced in clang 21, so check if the provided compiler supports it
before enabling it.

Signed-off-by: Carlos López <carlos.lopezr4096@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260909162322.29778-16-carlos.lopezr4096@gmail.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-09-16 09:48:30 +05:30
Carlos López 92b24d6acb lib: test: disable TSA for spinlock tests
The spinlock tests deliberately use unconventional locking patterns to
test edge cases. Disable thread safety analysis for them so that they
don't generate false positives when the feature is enabled.

Signed-off-by: Carlos López <carlos.lopezr4096@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260909162322.29778-15-carlos.lopezr4096@gmail.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-09-16 09:48:30 +05:30
Carlos López 8f80b2651f lib: sbi_sse: add TSA annotations
Now that the lock relationship between an event and its owner hart is
explicit, add TSA annotations for the SSE handling code. This includes
indicating which fields are protected by a spinlock, as well as
annotating which functions need to run under a spinlock.

Exclude sse_local_init(), which initializes the spinlock to be acquired,
and sse_event_get() / sse_event_put(), which perform conditional locking
that TSA is not able to follow properly.

Signed-off-by: Carlos López <carlos.lopezr4096@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20260909162322.29778-14-carlos.lopezr4096@gmail.com
Signed-off-by: Anup Patel <anup@brainfault.org>
2026-09-16 09:48:30 +05:30