[PATCH 6/8] lib: sbi_domain: add SBI_DOMAIN_MEMREGION_FW memregion flag

Alvin Che-Chia Chang(張哲嘉) alvinga at andestech.com
Thu Aug 14 08:39:19 PDT 2025


Hi Peter,

> -----Original Message-----
> From: Yu-Chien Peter Lin <peter.lin at sifive.com>
> Sent: Thursday, August 14, 2025 7:05 PM
> To: opensbi at lists.infradead.org
> Cc: zong.li at sifive.com; greentime.hu at sifive.com; Alvin Che-Chia Chang(張哲
> 嘉) <alvinga at andestech.com>; Yu-Chien Peter Lin <peter.lin at sifive.com>
> Subject: [PATCH 6/8] lib: sbi_domain: add SBI_DOMAIN_MEMREGION_FW
> memregion flag
>
> [EXTERNAL MAIL]
>
> Add a new memregion flag, SBI_DOMAIN_MEMREGION_FW and mark the
> code and data sections of firmware.
>
> Signed-off-by: Yu-Chien Peter Lin <peter.lin at sifive.com>
> ---
>  include/sbi/sbi_domain.h | 1 +
>  lib/sbi/sbi_domain.c     | 8 ++++++--
>  2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/include/sbi/sbi_domain.h b/include/sbi/sbi_domain.h index
> 8a51f289..d71354c7 100644
> --- a/include/sbi/sbi_domain.h
> +++ b/include/sbi/sbi_domain.h
> @@ -157,6 +157,7 @@ struct sbi_domain_memregion {
>
> SBI_DOMAIN_MEMREGION_M_EXECUTABLE)
>
>  #define SBI_DOMAIN_MEMREGION_MMIO              (1UL << 31)
> +#define SBI_DOMAIN_MEMREGION_FW                        (1UL <<
> 32)

This exceeds "unsigned long" of RV32 which only has 32 bits.
Besides, why we need this new flag?
Isn't SBI_DOMAIN_MEMREGION_M_ONLY_ACCESS(__flags) enough?

>         unsigned long flags;
>  };
>
> diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c index
> d6566b12..ccfcc7f0 100644
> --- a/lib/sbi/sbi_domain.c
> +++ b/lib/sbi/sbi_domain.c
> @@ -541,6 +541,8 @@ void sbi_domain_dump(const struct sbi_domain *dom,
> const char *suffix)
>                 sbi_printf("M: ");
>                 if (reg->flags & SBI_DOMAIN_MEMREGION_MMIO)
>                         sbi_printf("%cI", (k++) ? ',' : '(');
> +               if (reg->flags & SBI_DOMAIN_MEMREGION_FW)
> +                       sbi_printf("%cF", (k++) ? ',' : '(');
>                 if (reg->flags &
> SBI_DOMAIN_MEMREGION_M_READABLE)
>                         sbi_printf("%cR", (k++) ? ',' : '(');
>                 if (reg->flags & SBI_DOMAIN_MEMREGION_M_WRITABLE)
> @@ -894,13 +896,15 @@ int sbi_domain_init(struct sbi_scratch *scratch, u32
> cold_hartid)
>         /* Root domain firmware memory region */
>         sbi_domain_memregion_init(scratch->fw_start,
> scratch->fw_rw_offset,
>
> (SBI_DOMAIN_MEMREGION_M_READABLE |
> -
> SBI_DOMAIN_MEMREGION_M_EXECUTABLE),
> +
> SBI_DOMAIN_MEMREGION_M_EXECUTABLE |
> +                                  SBI_DOMAIN_MEMREGION_FW),
>
> &root_memregs[root_memregs_count++]);
>
>         sbi_domain_memregion_init((scratch->fw_start +
> scratch->fw_rw_offset),
>                                   (scratch->fw_size -
> scratch->fw_rw_offset),
>
> (SBI_DOMAIN_MEMREGION_M_READABLE |
> -
> SBI_DOMAIN_MEMREGION_M_WRITABLE),
> +
> SBI_DOMAIN_MEMREGION_M_WRITABLE |
> +                                  SBI_DOMAIN_MEMREGION_FW),
>
> &root_memregs[root_memregs_count++]);
>
>         root.fw_region_inited = true;
> --
> 2.39.3

CONFIDENTIALITY NOTICE:

This e-mail (and its attachments) may contain confidential and legally privileged information or information protected from disclosure. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein is strictly prohibited. In this case, please immediately notify the sender by return e-mail, delete the message (and any accompanying documents) and destroy all printed hard copies. Thank you for your cooperation.

Copyright ANDES TECHNOLOGY CORPORATION - All Rights Reserved.


More information about the opensbi mailing list