* [PATCH] lib: sbi: Fix mstatus_init() for RV32 when Sscofpmf is not available
@ 2022-04-28 7:48 Anup Patel
2022-04-28 13:53 ` Atish Patra
0 siblings, 1 reply; 3+ messages in thread
From: Anup Patel @ 2022-04-28 7:48 UTC (permalink / raw)
To: opensbi
The mhpmevent3h to mhpmevent31h CSRs are available on RV32 only when
Sscofpmf extension is available so mstatus_init() should set this
CSRs only when Sscofpmf extension is available.
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
lib/sbi/sbi_hart.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index a50b6e4..229c14a 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -82,7 +82,9 @@ static void mstatus_init(struct sbi_scratch *scratch)
for (cidx = 0; cidx < num_mhpm; cidx++) {
#if __riscv_xlen == 32
csr_write_num(CSR_MHPMEVENT3 + cidx, mhpmevent_init_val & 0xFFFFFFFF);
- csr_write_num(CSR_MHPMEVENT3H + cidx, mhpmevent_init_val >> BITS_PER_LONG);
+ if (sbi_hart_has_feature(scratch, SBI_HART_HAS_SSCOFPMF))
+ csr_write_num(CSR_MHPMEVENT3H + cidx,
+ mhpmevent_init_val >> BITS_PER_LONG);
#else
csr_write_num(CSR_MHPMEVENT3 + cidx, mhpmevent_init_val);
#endif
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH] lib: sbi: Fix mstatus_init() for RV32 when Sscofpmf is not available
2022-04-28 7:48 [PATCH] lib: sbi: Fix mstatus_init() for RV32 when Sscofpmf is not available Anup Patel
@ 2022-04-28 13:53 ` Atish Patra
2022-04-28 14:11 ` Anup Patel
0 siblings, 1 reply; 3+ messages in thread
From: Atish Patra @ 2022-04-28 13:53 UTC (permalink / raw)
To: opensbi
On Thu, Apr 28, 2022 at 12:49 AM Anup Patel <apatel@ventanamicro.com> wrote:
>
> The mhpmevent3h to mhpmevent31h CSRs are available on RV32 only when
> Sscofpmf extension is available so mstatus_init() should set this
> CSRs only when Sscofpmf extension is available.
>
> Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> ---
> lib/sbi/sbi_hart.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
> index a50b6e4..229c14a 100644
> --- a/lib/sbi/sbi_hart.c
> +++ b/lib/sbi/sbi_hart.c
> @@ -82,7 +82,9 @@ static void mstatus_init(struct sbi_scratch *scratch)
> for (cidx = 0; cidx < num_mhpm; cidx++) {
> #if __riscv_xlen == 32
> csr_write_num(CSR_MHPMEVENT3 + cidx, mhpmevent_init_val & 0xFFFFFFFF);
> - csr_write_num(CSR_MHPMEVENT3H + cidx, mhpmevent_init_val >> BITS_PER_LONG);
> + if (sbi_hart_has_feature(scratch, SBI_HART_HAS_SSCOFPMF))
> + csr_write_num(CSR_MHPMEVENT3H + cidx,
> + mhpmevent_init_val >> BITS_PER_LONG);
> #else
> csr_write_num(CSR_MHPMEVENT3 + cidx, mhpmevent_init_val);
> #endif
> --
> 2.34.1
>
Thanks for the fix.
Reviewed-by: Atish Patra <atishp@rivosinc.com>
--
Regards,
Atish
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH] lib: sbi: Fix mstatus_init() for RV32 when Sscofpmf is not available
2022-04-28 13:53 ` Atish Patra
@ 2022-04-28 14:11 ` Anup Patel
0 siblings, 0 replies; 3+ messages in thread
From: Anup Patel @ 2022-04-28 14:11 UTC (permalink / raw)
To: opensbi
On Thu, Apr 28, 2022 at 7:23 PM Atish Patra <atishp@atishpatra.org> wrote:
>
> On Thu, Apr 28, 2022 at 12:49 AM Anup Patel <apatel@ventanamicro.com> wrote:
> >
> > The mhpmevent3h to mhpmevent31h CSRs are available on RV32 only when
> > Sscofpmf extension is available so mstatus_init() should set this
> > CSRs only when Sscofpmf extension is available.
> >
> > Signed-off-by: Anup Patel <apatel@ventanamicro.com>
> > ---
> > lib/sbi/sbi_hart.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
> > index a50b6e4..229c14a 100644
> > --- a/lib/sbi/sbi_hart.c
> > +++ b/lib/sbi/sbi_hart.c
> > @@ -82,7 +82,9 @@ static void mstatus_init(struct sbi_scratch *scratch)
> > for (cidx = 0; cidx < num_mhpm; cidx++) {
> > #if __riscv_xlen == 32
> > csr_write_num(CSR_MHPMEVENT3 + cidx, mhpmevent_init_val & 0xFFFFFFFF);
> > - csr_write_num(CSR_MHPMEVENT3H + cidx, mhpmevent_init_val >> BITS_PER_LONG);
> > + if (sbi_hart_has_feature(scratch, SBI_HART_HAS_SSCOFPMF))
> > + csr_write_num(CSR_MHPMEVENT3H + cidx,
> > + mhpmevent_init_val >> BITS_PER_LONG);
> > #else
> > csr_write_num(CSR_MHPMEVENT3 + cidx, mhpmevent_init_val);
> > #endif
> > --
> > 2.34.1
> >
>
> Thanks for the fix.
> Reviewed-by: Atish Patra <atishp@rivosinc.com>
This is an urgent fix for RV32 so applying it sooner.
Applied this patch to the riscv/opensbi repo.
Regards,
Anup
>
> --
> Regards,
> Atish
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-28 14:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-28 7:48 [PATCH] lib: sbi: Fix mstatus_init() for RV32 when Sscofpmf is not available Anup Patel
2022-04-28 13:53 ` Atish Patra
2022-04-28 14:11 ` Anup Patel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox