From: James Raphael Tiovalen <jamestiotio@gmail.com>
To: opensbi@lists.infradead.org
Cc: andrew.jones@linux.dev, atishp@rivosinc.com,
James Raphael Tiovalen <jamestiotio@gmail.com>
Subject: [PATCH] lib: sbi: pmu: Return SBI_EINVAL if cidx_mask is 0 in ctr_cfg_match
Date: Mon, 12 May 2025 15:16:48 +0800 [thread overview]
Message-ID: <20250512071648.89151-1-jamestiotio@gmail.com> (raw)
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
next reply other threads:[~2025-05-12 7:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-12 7:16 James Raphael Tiovalen [this message]
2025-05-12 8:19 ` [PATCH] lib: sbi: pmu: Return SBI_EINVAL if cidx_mask is 0 in ctr_cfg_match James R T
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250512071648.89151-1-jamestiotio@gmail.com \
--to=jamestiotio@gmail.com \
--cc=andrew.jones@linux.dev \
--cc=atishp@rivosinc.com \
--cc=opensbi@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.