From: cp0613@linux.alibaba.com
To: rkrcmar@ventanamicro.com
Cc: anup@brainfault.org, guoren@kernel.org, opensbi@lists.infradead.org
Subject: Re: [PATCH v3] lib: sbi: Enable Ssqosid Ext using mstateen0
Date: Sat, 8 Nov 2025 19:22:00 +0800 [thread overview]
Message-ID: <20251108112202.26154-1-cp0613@linux.alibaba.com> (raw)
In-Reply-To: <DE2F2HVBYSBZ.13JTA8B6XR1W2@ventanamicro.com>
On 2025-11-07 11:13 AM, Radim Krčmář wrote:
> > diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h
> > @@ -79,6 +79,8 @@ enum sbi_hart_extensions {
> > SBI_HART_EXT_SMCTR,
> > /** HART has CTR S-mode CSRs */
> > SBI_HART_EXT_SSCTR,
> > + /** Hart has Ssqosid extension */
> > + SBI_HART_EXT_SSQOSID,
> Don't we also need something like
> __check_ext_csr(SBI_HART_PRIV_VER_UNKNOWN,
> CSR_SRMCFG, SBI_HART_EXT_SSQOSID);
> to detect the SSQOSID extension?
Hi Radim,
I added this detection mechanism in the first patch, but Anup said, "For newer
extensions, detecting from ISA strings is sufficient, so there's no need to
trap-n-detect here." Therefore, it has been removed here.
> > diff --git a/lib/sbi/sbi_domain_context.c b/lib/sbi/sbi_domain_context.c
> > @@ -143,8 +145,11 @@ static int switch_to_next_domain_context(struct hart_context *ctx,
> > ctx->satp = csr_swap(CSR_SATP, dom_ctx->satp);
> > if (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_10)
> > ctx->scounteren = csr_swap(CSR_SCOUNTEREN, dom_ctx->scounteren);
> > - if (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_12)
> > + if (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_12) {
> > ctx->senvcfg = csr_swap(CSR_SENVCFG, dom_ctx->senvcfg);
> > + if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SSQOSID))
> > + ctx->srmcfg = csr_swap(CSR_SRMCFG, dom_ctx->srmcfg);
> > + }
> Why would we want Ssqosid to depend on S >= 1.12?
I'm guessing you read the RISC-V Instruction Set Manual, which describes ssqoid as
requiring priv version 1.14. However, the highest priv version currently supported
by OpenSBI is 1.12. Therefore, this implementation is based on the current situation,
and the previous implementations such as CTR also follow this approach.
> > diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
> > @@ -112,6 +112,11 @@ static void mstatus_init(struct sbi_scratch *scratch)
> > else
> > mstateen_val &= ~SMSTATEEN0_CTR;
> >
> > + if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SSQOSID))
> > + mstateen_val |= (SMSTATEEN0_SRMCFG);
> (Style nit: please remove parentheses arounds SMSTATEEN0_SRMCFG.)
Thank you for pointing this out.
> > + else
> > + mstateen_val &= ~(SMSTATEEN0_SRMCFG);
> The else branch is pointless, because the bit is known to be 0.
> Thanks.
Here we need to consider the following scenario: even if HART supports the SSQOSID
extension, but the user doesn't want to use this feature and removes the ssqosid
field from the ISA string, then this bit needs to be explicitly cleared.
Thanks,
Pei
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
next prev parent reply other threads:[~2025-11-08 11:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-07 8:32 [PATCH v3] lib: sbi: Enable Ssqosid Ext using mstateen0 cp0613
2025-11-07 11:13 ` Radim Krčmář
2025-11-08 11:22 ` cp0613 [this message]
2025-11-10 8:32 ` Radim Krčmář
2025-11-10 12:31 ` cp0613
2025-11-10 14:41 ` Radim Krčmář
2025-11-11 9:49 ` cp0613
2025-11-11 10:18 ` Radim Krčmář
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=20251108112202.26154-1-cp0613@linux.alibaba.com \
--to=cp0613@linux.alibaba.com \
--cc=anup@brainfault.org \
--cc=guoren@kernel.org \
--cc=opensbi@lists.infradead.org \
--cc=rkrcmar@ventanamicro.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox