[PATCH 2/7] lib: sbi: detect the number of PMP entries first

Anup Patel anup at brainfault.org
Mon Dec 11 23:45:26 PST 2023


On Fri, Dec 8, 2023 at 3:34 AM Yangyu Chen <cyy at cyyself.name> wrote:
>
> To further probe each PMP entry whether is locked or not, we should
> detect the number of PMP entries first.
>
> Signed-off-by: Yangyu Chen <cyy at cyyself.name>
> ---
>  lib/sbi/sbi_hart.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
> index 49d1454..eaa69ad 100644
> --- a/lib/sbi/sbi_hart.c
> +++ b/lib/sbi/sbi_hart.c
> @@ -868,6 +868,9 @@ static int hart_detect_features(struct sbi_scratch *scratch)
>         __check_csr_32(__csr + 0, __rdonly, __wrval, __field, __skip)   \
>         __check_csr_32(__csr + 32, __rdonly, __wrval, __field, __skip)
>
> +       /* Detect number of PMP regions. At least PMPADDR0 should be implemented*/
> +       __check_csr_64(CSR_PMPADDR0, true, 0, pmp_count, __pmp_count_probed);
> +__pmp_count_probed:

Add a newline here.

>         /**
>          * Detect the allowed address bits & granularity. At least PMPADDR0
>          * should be implemented.
> @@ -876,10 +879,7 @@ static int hart_detect_features(struct sbi_scratch *scratch)
>         if (val) {
>                 hfeatures->pmp_gran =  1 << (sbi_ffs(val) + 2);
>                 hfeatures->pmp_addr_bits = sbi_fls(val) + 1;
> -               /* Detect number of PMP regions. At least PMPADDR0 should be implemented*/
> -               __check_csr_64(CSR_PMPADDR0, true, 0, pmp_count, __pmp_skip);
>         }
> -__pmp_skip:

Add a newline here as well.

>         /* Detect number of MHPM counters */
>         __check_hpm_csr(CSR_MHPMCOUNTER3, mhpm_mask);
>         hfeatures->mhpm_bits = hart_mhpm_get_allowed_bits();
> --
> 2.43.0
>
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi

Otherwise, it looks good to me.

Reviewed-by: Anup Patel <anup at brainfault.org>

Regards,
Anup



More information about the opensbi mailing list