* [PATCH] lib: sbi: pmu: Return SBI_EINVAL if cidx_mask is 0 in ctr_cfg_match
@ 2025-05-12 7:16 James Raphael Tiovalen
2025-05-12 8:19 ` James R T
0 siblings, 1 reply; 2+ messages in thread
From: James Raphael Tiovalen @ 2025-05-12 7:16 UTC (permalink / raw)
To: opensbi; +Cc: andrew.jones, atishp, James Raphael Tiovalen
When configuring a matching counter, if the cidx_mask value being passed
in is 0, return the SBI_ERR_INVALID_PARAM error code.
This also aligns OpenSBI's behavior with KVM's.
Signed-off-by: James Raphael Tiovalen <jamestiotio@gmail.com>
---
lib/sbi/sbi_pmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/sbi/sbi_pmu.c b/lib/sbi/sbi_pmu.c
index 5983a78..62ce770 100644
--- a/lib/sbi/sbi_pmu.c
+++ b/lib/sbi/sbi_pmu.c
@@ -840,7 +840,7 @@ int sbi_pmu_ctr_cfg_match(unsigned long cidx_base, unsigned long cidx_mask,
u32 event_code;
/* Do a basic sanity check of counter base & mask */
- if ((cidx_base + sbi_fls(cidx_mask)) >= total_ctrs)
+ if (!cidx_mask || ((cidx_base + sbi_fls(cidx_mask)) >= total_ctrs))
return SBI_EINVAL;
event_type = pmu_event_validate(phs, event_idx, event_data);
--
2.43.0
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] lib: sbi: pmu: Return SBI_EINVAL if cidx_mask is 0 in ctr_cfg_match
2025-05-12 7:16 [PATCH] lib: sbi: pmu: Return SBI_EINVAL if cidx_mask is 0 in ctr_cfg_match James Raphael Tiovalen
@ 2025-05-12 8:19 ` James R T
0 siblings, 0 replies; 2+ messages in thread
From: James R T @ 2025-05-12 8:19 UTC (permalink / raw)
To: opensbi; +Cc: andrew.jones, atishp
After some more thought, I have decided to update the commit message
of this patch to specify how OpenSBI's behavior changes with this
patch. That way, we can keep track of how OpenSBI's behavior has
changed in the Git history. I will do that in v2.
On Mon, May 12, 2025 at 3:16 PM James Raphael Tiovalen
<jamestiotio@gmail.com> wrote:
>
> When configuring a matching counter, if the cidx_mask value being passed
> in is 0, return the SBI_ERR_INVALID_PARAM error code.
>
> This also aligns OpenSBI's behavior with KVM's.
>
> Signed-off-by: James Raphael Tiovalen <jamestiotio@gmail.com>
> ---
> lib/sbi/sbi_pmu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/sbi/sbi_pmu.c b/lib/sbi/sbi_pmu.c
> index 5983a78..62ce770 100644
> --- a/lib/sbi/sbi_pmu.c
> +++ b/lib/sbi/sbi_pmu.c
> @@ -840,7 +840,7 @@ int sbi_pmu_ctr_cfg_match(unsigned long cidx_base, unsigned long cidx_mask,
> u32 event_code;
>
> /* Do a basic sanity check of counter base & mask */
> - if ((cidx_base + sbi_fls(cidx_mask)) >= total_ctrs)
> + if (!cidx_mask || ((cidx_base + sbi_fls(cidx_mask)) >= total_ctrs))
> return SBI_EINVAL;
>
> event_type = pmu_event_validate(phs, event_idx, event_data);
> --
> 2.43.0
>
Best regards,
James Raphael Tiovalen
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-05-12 8:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-12 7:16 [PATCH] lib: sbi: pmu: Return SBI_EINVAL if cidx_mask is 0 in ctr_cfg_match James Raphael Tiovalen
2025-05-12 8:19 ` James R T
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.