mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-12-16 12:11:32 +00:00
lib: sbi: Enable Ssqosid Ext using mstateen0
The QoS Identifiers extension (Ssqosid) introduces the srmcfg register, which configures a hart with two identifiers: a Resource Control ID (RCID) and a Monitoring Counter ID (MCID). These identifiers accompany each request issued by the hart to shared resource controllers. If extension Smstateen is implemented together with Ssqosid, then Ssqosid also requires the SRMCFG bit in mstateen0 to be implemented. If mstateen0.SRMCFG is 0, attempts to access srmcfg in privilege modes less privileged than M-mode raise an illegal-instruction exception. If mstateen0.SRMCFG is 1 or if extension Smstateen is not implemented, attempts to access srmcfg when V=1 raise a virtual-instruction exception. This extension can be found in the RISC-V Instruction Set Manual: https://github.com/riscv/riscv-isa-manual Changes in v5: - Remove SBI_HART_EXT_SSQOSID dependency SBI_HART_PRIV_VER_1_12 Changes in v4: - Remove extraneous parentheses around SMSTATEEN0_SRMCFG Changes in v3: - Check SBI_HART_EXT_SSQOSID when swapping SRMCFG Changes in v2: - Remove trap-n-detect - Context switch CSR_SRMCFG Signed-off-by: Chen Pei <cp0613@linux.alibaba.com> Reviewed-by: Radim Krčmář <rkrcmar@ventanamicro.com> Link: https://lore.kernel.org/r/20251114115722.1831-1-cp0613@linux.alibaba.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -45,6 +45,8 @@ struct hart_context {
|
||||
unsigned long scounteren;
|
||||
/** Supervisor environment configuration register */
|
||||
unsigned long senvcfg;
|
||||
/** Supervisor resource management configuration register */
|
||||
unsigned long srmcfg;
|
||||
|
||||
/** Reference to the owning domain */
|
||||
struct sbi_domain *dom;
|
||||
@@ -145,6 +147,8 @@ static int switch_to_next_domain_context(struct hart_context *ctx,
|
||||
ctx->scounteren = csr_swap(CSR_SCOUNTEREN, dom_ctx->scounteren);
|
||||
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);
|
||||
|
||||
/* Save current trap state and restore target domain's trap state */
|
||||
trap_ctx = sbi_trap_get_context(scratch);
|
||||
|
||||
@@ -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;
|
||||
else
|
||||
mstateen_val &= ~SMSTATEEN0_SRMCFG;
|
||||
|
||||
csr_write64(CSR_MSTATEEN0, mstateen_val);
|
||||
csr_write64(CSR_MSTATEEN1, SMSTATEEN_STATEN);
|
||||
csr_write64(CSR_MSTATEEN2, SMSTATEEN_STATEN);
|
||||
@@ -685,6 +690,7 @@ const struct sbi_hart_ext_data sbi_hart_ext[] = {
|
||||
__SBI_HART_EXT_DATA(ssdbltrp, SBI_HART_EXT_SSDBLTRP),
|
||||
__SBI_HART_EXT_DATA(smctr, SBI_HART_EXT_SMCTR),
|
||||
__SBI_HART_EXT_DATA(ssctr, SBI_HART_EXT_SSCTR),
|
||||
__SBI_HART_EXT_DATA(ssqosid, SBI_HART_EXT_SSQOSID),
|
||||
__SBI_HART_EXT_DATA(ssstateen, SBI_HART_EXT_SSSTATEEN),
|
||||
__SBI_HART_EXT_DATA(xsfcflushdlone, SBI_HART_EXT_XSIFIVE_CFLUSH_D_L1),
|
||||
__SBI_HART_EXT_DATA(xsfcease, SBI_HART_EXT_XSIFIVE_CEASE),
|
||||
|
||||
Reference in New Issue
Block a user