Skip to content

feat(ssnpm): Add support for pointer masking - #354

Open
ninolomata wants to merge 6 commits into
bao-project:mainfrom
ninolomata:feat/ext-ssnpm
Open

feat(ssnpm): Add support for pointer masking#354
ninolomata wants to merge 6 commits into
bao-project:mainfrom
ninolomata:feat/ext-ssnpm

Conversation

@ninolomata

Copy link
Copy Markdown
Member

Summary

Add initial RISC-V Ssnpm support for programming the guest-visible PMM mode.

This change:

  • adds the HSTATUS_HUPMM field definitions
  • programs the guest-visible PMM mode in henvcfg during hypervisor init
    when CPU_EXT_SSNPM is enabled
  • adds platform configuration knobs for:
    • CPU_EXT_SSNPM
    • CPU_EXT_SSNPM_PMM_MODE

Dependency

This PR depends on:

It is intended to be reviewed and merged on top of that series, since it builds
on the related RISC-V extension plumbing already introduced there.

Implementation

The patch:

  • adds HSTATUS_HUPMM field definitions in the RISC-V CSR header
  • extends vmm_arch_init() to configure PMM mode when CPU_EXT_SSNPM is enabled
  • validates the selected mode at build time and rejects unsupported cases
  • adds platform macros to control whether Ssnpm is enabled and which PMM mode
    Bao should advertise

The following PMM modes are supported:

  • HENVCFG_PMM_DISABLED
  • HENVCFG_PMM_PMLEN_7
  • HENVCFG_PMM_PMLEN_16

On RV32, the build fails explicitly since Ssnpm is not available there.

Requirements to run

Running this support requires coordinated changes across Bao, the guest DT, and
QEMU.

Bao configuration

Enable cache-maintenance support in the Bao platform configuration for:

  • qemu-riscv32-virt
  • qemu-riscv64-virt

Set:

  • CPU_EXT_SSNPM = 1
  • set the mode (.e.g, CPU_EXT_SSNPM_PMM_M = HENVCFG_PMM_PMLEN_7)

Linux / Device Tree

It must also advertise the extensions in riscv,isa.

For RV32:

  • riscv,isa = "rv32imafdch_ssnpm_zicbom_zicboz_zicbop_zicntr_zicsr_zifencei_sstc";

For RV64:

  • riscv,isa = "rv64imafdch_ssnpm_zicbom_zicboz_zicbop_zicntr_zicsr_zifencei_sstc";

QEMU

A QEMU version with ssnpm support is required, set ssnpm=true on the `cpu.

  • RV32 QEMU:
    • use https://github.com/ninolomata/qemu-bao/tree/riscv-rv32-henvcfg-stateen-fixes
  • RV64 QEMU:
    • use the same version currently used in bao-demos (QEMU 10.0.2)

Signed-off-by: Bruno Sa <bruno.vilaca.sa@gmail.com>
Add the senvcfg CSR accessor and clear senvcfg during vCPU reset so
guest-visible environment configuration starts from a known state.

Signed-off-by: Bruno Sa <bruno.vilaca.sa@gmail.com>
Add RISC-V cache maintenance support around the Zicbom cache-block
management instructions and expose Zicboz/Zicbom guest configuration
through henvcfg when the platform enables those extensions.

Introduce cache block helpers, implement cache_flush_range() with
cbo.flush and ordering fences, and extend the RISC-V build flags to
include Zicbom support. Also add per-platform extension toggles so
ports can explicitly advertise or disable Zicboz/Zicbom support.

Signed-off-by: Bruno Sa <bruno.vilaca.sa@gmail.com>
Signed-off-by: Bruno Sa <bruno.vilaca.sa@gmail.com>
Signed-off-by: Bruno Sa <bruno.vilaca.sa@gmail.com>
Signed-off-by: Bruno Sa <bruno.vilaca.sa@gmail.com>
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.

1 participant