[PATCH 0/2] platform: mips: p8700: S-mode access to the CM performance counters

Vladimir Kondratiev vladimir.kondratiev at mobileye.com
Tue Oct 27 03:44:34 PDT 2026


The MIPS P8700 Coherence Manager (CM3) has a small performance counter
block (GCR.Debug, offsets 0x900-0x9ff of the GCR) which Linux drives
through the mips_p8700_cm_pmu perf driver. These registers live in the
same PMP granule as GCR registers that must stay M-mode only (L2 cache
operations, MMIO region programming, coherence control, ...), so the
whole GCR block is closed to S-mode and the PMU is unreachable from
Linux.

A vendor SBI extension would solve this but needs vendor-specific code
in Linux. Instead, this series uses trap-and-emulate: S-mode accesses
to the GCR already arrive in M-mode as load/store access faults, and
OpenSBI forwards them to the platform emulate_load/emulate_store hooks.
The platform translates the faulting address, checks it is inside the
PMU block of one of the CM instances, and performs the access on behalf
of S-mode. Everything else is redirected to S-mode as a genuine fault.
The Linux driver is a plain MMIO driver and needs no changes.

Patch 1 adds sbi_va_to_pa() to libsbi. The hooks receive the
S-mode virtual address (mtval) and RISC-V has no way to translate an
address on behalf of another mode, so this walks the satp page tables
with M-mode physical loads. It is generic (Sv32 and Sv39/48/57) and
usable by any platform emulator.

Patch 2 implements the P8700 hooks and enables them for EyeQ7H.

Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev at mobileye.com>
---
Vladimir Kondratiev (2):
      lib: sbi: Add sbi_va_to_pa() to translate S/U-mode addresses
      platform: generic: mips: p8700: Emulate S-mode access to CM PMU registers

 include/sbi/riscv_encoding.h          |  28 ++++++++
 include/sbi/sbi_unpriv.h              |  23 +++++++
 lib/sbi/sbi_unpriv.c                  |  78 +++++++++++++++++++++
 platform/generic/include/mips/p8700.h |  34 +++++++++
 platform/generic/mips/eyeq7h.c        |   2 +
 platform/generic/mips/objects.mk      |   2 +-
 platform/generic/mips/p8700_access.c  | 126 ++++++++++++++++++++++++++++++++++
 7 files changed, 292 insertions(+), 1 deletion(-)
---
base-commit: bcf587a987573057968a11b941729d70799947f4
change-id: 20261027-p8700-cm-pmu-21d07cecd8df

Best regards,
--  
Vladimir Kondratiev <vladimir.kondratiev at mobileye.com>




More information about the opensbi mailing list