mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xie Bo <xb@ultrarisc.com>
To: linux-riscv@lists.infradead.org
Cc: pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu,
	alex@ghiti.fr, linux-kernel@vger.kernel.org,
	Xie Bo <xb@ultrarisc.com>
Subject: [RFC PATCH 0/3] riscv: Add supervisor pointer masking infrastructure
Date: Tue, 21 Jul 2026 15:58:09 +0800	[thread overview]
Message-ID: <20260721075812.82708-1-xb@ultrarisc.com> (raw)

RVA23 requires an Sspm execution environment to provide supervisor-mode
pointer masking with at least PMLEN=0 and PMLEN=7. SBI 3.0 FWFT provides
the standard per-hart interface for selecting that value.

This RFC adds the architecture-private lifecycle needed by a future
in-kernel tagged-pointer consumer. It deliberately does not enable pointer
masking at boot and adds no userspace ABI, DT binding, hwprobe key, HWCAP,
or cpuinfo token.

The consumer API performs an all-online-hart PMLEN=7 transaction. It only
publishes success after every online hart accepts the setting, rolls back
the complete mask before publishing failure, and rejects an incompatible
hart before it becomes online after successful enablement.

The lifecycle code also restores a known setting across CPU hotplug and
hibernation, clears retained state at boot, and clears every hart at its
final kexec handoff point so an older successor kernel cannot inherit
PMLEN=7. Returning to normal execution with an unknown retained PMLEN is
treated as fatal.

Patch 2 is an independent RISC-V kexec fix: KEXEC_FILE-only SMP builds
need HOTPLUG_CPU for machine_shutdown() to offline secondary harts. It
is placed before the Sspm lifecycle code because safe outgoing handoff
depends on that guarantee.

There is no tagged-pointer consumer in this series. I am sending this as an
RFC to get feedback on the API, lifecycle boundaries, failure policy, and
whether the infrastructure should instead be carried with its first
consumer.

Specifications:

  Pointer Masking Extensions, version 1.0
  https://docs.riscv.org/reference/isa/v20260120/priv/zpm.html

  RISC-V SBI specification, FWFT extension
  https://docs.riscv.org/reference/sbi/_attachments/riscv-sbi.pdf

Tested on Linux v7.2-rc4 with a RISC-V cross compiler:

  - W=1 builds with CONFIG_RISCV_ISA_SSPM=y and disabled
  - KEXEC_FILE=y, KEXEC=n SMP configuration selects HOTPLUG_CPU
  - strict checkpatch (apart from the generic new-file MAINTAINERS warning)
  - sequential git apply --check against v7.2-rc4

Runtime SBI 3.0 FWFT, CPU hotplug, hibernation, kexec, and crash-kexec
tests have not yet been performed.

Xie Bo (3):
  riscv: sbi: Add FWFT get helper
  riscv: kexec: Select HOTPLUG_CPU for KEXEC_FILE
  riscv: Add supervisor pointer masking control

 arch/riscv/Kconfig                |  23 ++++
 arch/riscv/include/asm/sbi.h      |   1 +
 arch/riscv/include/asm/sspm.h     |  78 ++++++++++++
 arch/riscv/kernel/Makefile        |   1 +
 arch/riscv/kernel/cpu-hotplug.c   |   3 +-
 arch/riscv/kernel/hibernate.c     |  12 ++
 arch/riscv/kernel/machine_kexec.c |  10 +-
 arch/riscv/kernel/sbi.c           |  29 +++++
 arch/riscv/kernel/setup.c         |   2 +
 arch/riscv/kernel/smp.c           |   2 +
 arch/riscv/kernel/smpboot.c       |  11 +-
 arch/riscv/kernel/sspm.c          | 202 ++++++++++++++++++++++++++++++
 12 files changed, 368 insertions(+), 6 deletions(-)
 create mode 100644 arch/riscv/include/asm/sspm.h
 create mode 100644 arch/riscv/kernel/sspm.c

base-commit: 1590cf0329716306e948a8fc29f1d3ee87d3989f
-- 
2.17.1


             reply	other threads:[~2026-07-21  7:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21  7:58 Xie Bo [this message]
2026-07-21  7:58 ` [RFC PATCH 1/3] riscv: sbi: Add FWFT get helper Xie Bo
2026-07-21  7:58 ` [RFC PATCH 2/3] riscv: kexec: Select HOTPLUG_CPU for KEXEC_FILE Xie Bo
2026-07-21  7:58 ` [RFC PATCH 3/3] riscv: Add supervisor pointer masking control Xie Bo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260721075812.82708-1-xb@ultrarisc.com \
    --to=xb@ultrarisc.com \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®