[PATCH 2/2] lib: utils: Use SBI_DOMAIN_MMIO to check MMIO device permissions
Anup Patel
anup at brainfault.org
Mon Dec 8 03:32:56 PST 2025
On Sat, Nov 22, 2025 at 1:08 AM Samuel Holland
<samuel.holland at sifive.com> wrote:
>
> Drivers or platforms may create memory regions with the MMIO flag set
> that contain S-mode-accessible MMIO devices. This is strictly correct
> and should be allowed, along with the existing default case of
> S-mode-accessible MMIO devices appearing in non-MMIO memory regions.
> When passed SBI_DOMAIN_MMIO, sbi_domain_check_addr() will perform the
> correct set of permission checks.
>
> Signed-off-by: Samuel Holland <samuel.holland at sifive.com>
LGTM.
Reviewed-by: Anup Patel <anup at brainfault.org>
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
> ---
>
> lib/utils/fdt/fdt_fixup.c | 2 +-
> lib/utils/mpxy/fdt_mpxy_rpmi_sysmsi.c | 3 ++-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/lib/utils/fdt/fdt_fixup.c b/lib/utils/fdt/fdt_fixup.c
> index f3fe8af9..b0ed20c8 100644
> --- a/lib/utils/fdt/fdt_fixup.c
> +++ b/lib/utils/fdt/fdt_fixup.c
> @@ -185,7 +185,7 @@ static void fdt_domain_based_fixup_one(void *fdt, int nodeoff)
> return;
>
> if (!sbi_domain_check_addr(dom, reg_addr, dom->next_mode,
> - SBI_DOMAIN_READ | SBI_DOMAIN_WRITE)) {
> + SBI_DOMAIN_READ | SBI_DOMAIN_WRITE | SBI_DOMAIN_MMIO)) {
> rc = fdt_open_into(fdt, fdt, fdt_totalsize(fdt) + 32);
> if (rc < 0)
> return;
> diff --git a/lib/utils/mpxy/fdt_mpxy_rpmi_sysmsi.c b/lib/utils/mpxy/fdt_mpxy_rpmi_sysmsi.c
> index 94a5af8c..1dcc049e 100644
> --- a/lib/utils/mpxy/fdt_mpxy_rpmi_sysmsi.c
> +++ b/lib/utils/mpxy/fdt_mpxy_rpmi_sysmsi.c
> @@ -57,7 +57,8 @@ static int mpxy_rpmi_sysmis_xfer(void *context, struct mbox_chan *chan,
> sys_msi_address |= ((u64)le32_to_cpu(((u32 *)xfer->tx)[2])) << 32;
> if (!sbi_domain_check_addr_range(sbi_domain_thishart_ptr(),
> sys_msi_address, 0x4, PRV_S,
> - SBI_DOMAIN_READ | SBI_DOMAIN_WRITE)) {
> + SBI_DOMAIN_READ | SBI_DOMAIN_WRITE |
> + SBI_DOMAIN_MMIO)) {
> ((u32 *)xfer->rx)[0] = cpu_to_le32(RPMI_ERR_INVALID_ADDR);
> args->rx_data_len = sizeof(u32);
> break;
> --
> 2.47.2
>
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi
More information about the opensbi
mailing list