From: "Radim Krčmář" <rkrcmar@ventanamicro.com>
To: <cp0613@linux.alibaba.com>
Cc: <anup@brainfault.org>, <guoren@kernel.org>,
<opensbi@lists.infradead.org>,
"opensbi" <opensbi-bounces@lists.infradead.org>
Subject: Re: [PATCH v3] lib: sbi: Enable Ssqosid Ext using mstateen0
Date: Mon, 10 Nov 2025 15:41:13 +0100 [thread overview]
Message-ID: <DE53DAU3LAAK.2FGKTU66OSUEX@ventanamicro.com> (raw)
In-Reply-To: <20251110123116.496-1-cp0613@linux.alibaba.com>
2025-11-10T20:31:15+08:00, <cp0613@linux.alibaba.com>:
> On 2025-11-10 08:32 AM, Radim Krčmář wrote:
>> (I missed that this isn't the first version, please try to maintain a
>> changelog when posting subsequent modifications.)
>
> Thanks for the reminder, I will keep a changelog in the next patch.
(Appreciated. I would have searched mailbox before posting if I noticed
the v3 in the header, but having it summarized is even better.)
>> >> > 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.
>>
>> Does it? There is even a non-normative note:
>>
>> The Ssqosid extension does not require that S-mode mode be implemented.
>>
>> I think it's because srmcfg has effect on M-mode, so the extension is
>> completely independent to allow it in pure M systems.
>>
>> (We enable srmcfg in mstateen regardless of S version, so there is a
>> potential bug where we wouldn't correctly context switch the csr, given
>> a system with weird combination of extensions.)
We might have taked past each other here.
I'm arguing that RISC-V allows a hart with ISA S1p11_Ssqosid to exist,
because Ssqosid doesn't depend on S, so opensbi should context switch
srmcfg on such potential (albeit unlikely) machine.
Otherwise domains could observe srmcfg set by other domains.
> I have a different opinion on this point. This extension is basically unrelated
> to M-mode, instead, it runs in S-mode. It may be necessary to consider the background
> of ssqosid's introduction. This is to ensure that certain critical business processes
> can obtain sufficient hardware resources to run and thus guarantee service quality.
>
> Similar technologies include Intel-RDT and ARM MPAM. On the Linux side, Drew has already
> submitted relevant patches [1]. It can be seen that in the future, it will inevitably be
> used in conjunction with Linux resctrl,
Yeah, I'm planning to look at the patches as well, because Ssqosid's
design has a lot of potential for side-channels.
> so there is no need to consider the execution
> situation in M-mode, it is only necessary to enable the relevant permissions.
The execution of M-mode is affected by srmcfg, so we have to be
extremely careful about isolation in opensbi too, especially when
juggling multiple domains.
(I think we might be fine now, but having opensbi switch to a srmcfg
that isn't controlled by S-mode will result in a lot less headaches...)
Thanks.
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
next prev parent reply other threads:[~2025-11-10 14:41 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
2025-11-10 8:32 ` Radim Krčmář
2025-11-10 12:31 ` cp0613
2025-11-10 14:41 ` Radim Krčmář [this message]
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=DE53DAU3LAAK.2FGKTU66OSUEX@ventanamicro.com \
--to=rkrcmar@ventanamicro.com \
--cc=anup@brainfault.org \
--cc=cp0613@linux.alibaba.com \
--cc=guoren@kernel.org \
--cc=opensbi-bounces@lists.infradead.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox