From 6fd7f88769d3b3b1bc964b9fbd505bcd776a5d7c Mon Sep 17 00:00:00 2001 From: syedowaisalishah Date: Wed, 23 Apr 2025 12:32:50 +0000 Subject: [PATCH 01/15] Add CSR YAML file for Ssqosid:srmcfg --- arch/csr/Ssqosid/srmcfg.yaml | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 arch/csr/Ssqosid/srmcfg.yaml diff --git a/arch/csr/Ssqosid/srmcfg.yaml b/arch/csr/Ssqosid/srmcfg.yaml new file mode 100644 index 000000000..4facbde31 --- /dev/null +++ b/arch/csr/Ssqosid/srmcfg.yaml @@ -0,0 +1,44 @@ +# yaml-language-server: $schema=../../../schemas/csr_schema.json +$schema: csr_schema.json# +kind: csr +name: srmcfg +long_name: Supervisor Resource Management Configuration +address: 0x5C0 #Until the extension is finalized and assigned an official address by the RISC-V Foundation, srmcfg will use a placeholder/custom address +priv_mode: S +length: SXLEN +definedBy: Ssqosid +description: | + The srmcfg register is an SXLEN-bit read/write register used to configure a Resource Control ID (RCID) and a Monitoring Counter ID (MCID). + Both RCID and MCID are WARL fields. + + The RCID and MCID accompany each request made by the hart to shared resource controllers. + The RCID is used to determine the resource allocations (e.g., cache occupancy limits, memory bandwidth limits, etc.) to enforce. + The MCID is used to identify a counter to monitor resource usage. + + The RCID and MCID configured in the srmcfg CSR apply to all privilege modes of software execution on that hart by default, + but this behavior may be overridden by future extensions. + + 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. + + A reset value of 0 is suggested for the RCID field matching resource controllers' default behavior of associating all capacity with RCID=0. + The MCID reset value does not affect functionality and may be implementation-defined. + +fields: + RCID: + location_rv32: 15-0 + location_rv64: 15-0 + type: RW + description: | + The RCID is used to determine the resource allocations (e.g., cache occupancy limits, + memory bandwidth limits, etc.) to enforce. + reset_value: 0 + + MCID: + location_rv32: 31-16 + location_rv64: 31-16 + type: RW + description: | + The MCID is used to identify a counter to monitor resource usage. + reset_value: 0 From 08084a318296ad9ceee5ca914e96da6bbdc7c268 Mon Sep 17 00:00:00 2001 From: syedowaisalishah Date: Wed, 23 Apr 2025 12:34:30 +0000 Subject: [PATCH 02/15] Add Extension YAML file for Ssqosid --- arch/ext/Ssqosid.yaml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 arch/ext/Ssqosid.yaml diff --git a/arch/ext/Ssqosid.yaml b/arch/ext/Ssqosid.yaml new file mode 100644 index 000000000..4cb20a796 --- /dev/null +++ b/arch/ext/Ssqosid.yaml @@ -0,0 +1,40 @@ +# yaml-language-server: $schema=../../schemas/ext_schema.json + +$schema: "ext_schema.json#" +kind: extension +name: Ssqosid +type: privileged +long_name: Quality-of-Service Identifiers +description: | + Quality of Service (QoS) is defined as the minimal end-to-end performance guaranteed in advance by a service level agreement (SLA) to a workload. + Performance metrics might include measures such as instructions per cycle (IPC), latency of service, etc. + + When multiple workloads execute concurrently on modern processors—equipped with large core counts, multiple cache hierarchies, and multiple memory + controllers—the performance of any given workload becomes less deterministic, or even non-deterministic, due to shared resource contention. + + To manage performance variability, system software needs resource allocation and monitoring capabilities. + These capabilities allow for the reservation of resources like cache and bandwidth, thus meeting individual performance targets while minimizing interference. + For resource management, hardware should provide monitoring features that allow system software to profile workload resource consumption and allocate resources accordingly. + + To facilitate this, 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. + + Additional metadata, like the nature of the memory access and the ID of the originating supervisor domain, + can accompany RCID and MCID. Resource controllers may use this metadata for differentiated service such as a different capacity allocation for code storage vs.data storage. + Resource controllers can use this data for security policies such as not exposing statistics of one security domain to another. + + These identifiers are crucial for the RISC-V Capacity and Bandwidth Controller QoS Register Interface (CBQRI) specification, + which provides methods for setting resource usage limits and monitoring resource consumption. + The RCID controls resource allocations, while the MCID is used for tracking resource usage. + + The Ssqosid extension does not require that S-mode mode be implemented. +versions: + - version: "1.0.0" + state: ratified + ratification_date: "2024-11" + url: "https://github.com/riscv/riscv-isa-manual/releases/tag/riscv-isa-release-5308687-2025-04-22" + requires: + allOf: + - name: S + version: ~> 1.13 From ffcce030ec5b1ccc85d0ffc9e01c99cd6d5eb36b Mon Sep 17 00:00:00 2001 From: syedowaisalishah Date: Sun, 27 Apr 2025 17:39:42 +0000 Subject: [PATCH 03/15] Add Extension YAML file for Ssqosid --- .gitignore | 2 ++ arch/ext/Ssqosid.yaml | 10 +++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index e0ca947a4..be823f946 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ __pycache__/ .pytest_cache/ *.bak *.log +__pycache__/ +*.pyc diff --git a/arch/ext/Ssqosid.yaml b/arch/ext/Ssqosid.yaml index 4cb20a796..84badf81d 100644 --- a/arch/ext/Ssqosid.yaml +++ b/arch/ext/Ssqosid.yaml @@ -21,20 +21,16 @@ description: | These identifiers accompany each request issued by the hart to shared resource controllers. Additional metadata, like the nature of the memory access and the ID of the originating supervisor domain, - can accompany RCID and MCID. Resource controllers may use this metadata for differentiated service such as a different capacity allocation for code storage vs.data storage. + can accompany RCID and MCID. Resource controllers may use this metadata for differentiated service such as a different capacity allocation for code storage vs. data storage. Resource controllers can use this data for security policies such as not exposing statistics of one security domain to another. These identifiers are crucial for the RISC-V Capacity and Bandwidth Controller QoS Register Interface (CBQRI) specification, which provides methods for setting resource usage limits and monitoring resource consumption. The RCID controls resource allocations, while the MCID is used for tracking resource usage. - The Ssqosid extension does not require that S-mode mode be implemented. versions: - version: "1.0.0" state: ratified - ratification_date: "2024-11" + ratification_date: "2024-06" url: "https://github.com/riscv/riscv-isa-manual/releases/tag/riscv-isa-release-5308687-2025-04-22" - requires: - allOf: - - name: S - version: ~> 1.13 + requires: { name: S, version: ~> 1.13 } From cdadf9895f5d12fb46ee58fc0ebff0dc4273eecf Mon Sep 17 00:00:00 2001 From: syedowaisalishah Date: Sun, 27 Apr 2025 17:40:42 +0000 Subject: [PATCH 04/15] Add CSR YAML file for Ssqosid:srmcfg --- arch/csr/Ssqosid/srmcfg.yaml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/csr/Ssqosid/srmcfg.yaml b/arch/csr/Ssqosid/srmcfg.yaml index 4facbde31..3e2fecb36 100644 --- a/arch/csr/Ssqosid/srmcfg.yaml +++ b/arch/csr/Ssqosid/srmcfg.yaml @@ -3,12 +3,12 @@ $schema: csr_schema.json# kind: csr name: srmcfg long_name: Supervisor Resource Management Configuration -address: 0x5C0 #Until the extension is finalized and assigned an official address by the RISC-V Foundation, srmcfg will use a placeholder/custom address +address: 0x5C0 # Until the extension is finalized and assigned an official address by the RISC-V Foundation, srmcfg will use a placeholder/custom address priv_mode: S length: SXLEN definedBy: Ssqosid description: | - The srmcfg register is an SXLEN-bit read/write register used to configure a Resource Control ID (RCID) and a Monitoring Counter ID (MCID). + The srmcfg register is used to configure a Resource Control ID (RCID) and a Monitoring Counter ID (MCID). Both RCID and MCID are WARL fields. The RCID and MCID accompany each request made by the hart to shared resource controllers. @@ -22,22 +22,21 @@ description: | 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. - A reset value of 0 is suggested for the RCID field matching resource controllers' default behavior of associating all capacity with RCID=0. + [Note] + A reset value of 0 is suggested for the RCID field, matching resource controllers' default behavior of associating all capacity with RCID=0. The MCID reset value does not affect functionality and may be implementation-defined. fields: RCID: - location_rv32: 15-0 - location_rv64: 15-0 + location: 11-0 type: RW description: | The RCID is used to determine the resource allocations (e.g., cache occupancy limits, - memory bandwidth limits, etc.) to enforce. + memory bandwidth limits, etc.) to enforce. reset_value: 0 MCID: - location_rv32: 31-16 - location_rv64: 31-16 + location: 27-16 type: RW description: | The MCID is used to identify a counter to monitor resource usage. From cefa26a9dbedb15409d2984256dbd63a51cbf135 Mon Sep 17 00:00:00 2001 From: syedowaisalishah Date: Wed, 30 Apr 2025 06:44:58 +0000 Subject: [PATCH 05/15] docs(csr): improve srmcfg register description and field details --- arch/csr/Ssqosid/srmcfg.yaml | 101 +++++++++++++++++++++++++++++------ 1 file changed, 84 insertions(+), 17 deletions(-) diff --git a/arch/csr/Ssqosid/srmcfg.yaml b/arch/csr/Ssqosid/srmcfg.yaml index 3e2fecb36..b125679ac 100644 --- a/arch/csr/Ssqosid/srmcfg.yaml +++ b/arch/csr/Ssqosid/srmcfg.yaml @@ -3,41 +3,108 @@ $schema: csr_schema.json# kind: csr name: srmcfg long_name: Supervisor Resource Management Configuration -address: 0x5C0 # Until the extension is finalized and assigned an official address by the RISC-V Foundation, srmcfg will use a placeholder/custom address +address: 0x181 priv_mode: S length: SXLEN definedBy: Ssqosid -description: | - The srmcfg register is used to configure a Resource Control ID (RCID) and a Monitoring Counter ID (MCID). - Both RCID and MCID are WARL fields. +description: + - id: csr-srmcfg-purpose + normative: true + text: | + The srmcfg register is used to configure a Resource Control ID (RCID) and a Monitoring Counter ID (MCID). + Both RCID and MCID are WARL fields. - The RCID and MCID accompany each request made by the hart to shared resource controllers. - The RCID is used to determine the resource allocations (e.g., cache occupancy limits, memory bandwidth limits, etc.) to enforce. - The MCID is used to identify a counter to monitor resource usage. + - id: csr-srmcfg-field-usage + normative: true + text: | + The RCID and MCID accompany each request made by the hart to shared resource controllers. + The RCID is used to determine the resource allocations (e.g., cache occupancy limits, memory bandwidth limits, etc.) to enforce. + The MCID is used to identify a counter to monitor resource usage. + + - id: csr-srmcfg-default-scope + normative: true + text: | + The RCID and MCID configured in the srmcfg CSR apply to all privilege modes of software execution on that hart by default, + but this behavior may be overridden by future extensions. + + - id: csr-srmcfg-smstateen-interaction + normative: true + text: | + 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. + + - id: csr-srmcfg-vsmode-exception + normative: true + text: | + If mstateen0.SRMCFG is 1 or if extension Smstateen is not implemented, attempts to access srmcfg when V=1 raise a virtual-instruction exception. + + - id: csr-srmcfg-rcid-reset + normative: false + text: | + A reset value of 0 is suggested for the RCID field, matching resource controllers' default behavior of associating all capacity with RCID=0. + + - id: csr-srmcfg-mcid-reset + normative: false + text: | + The MCID reset value does not affect functionality and may be implementation-defined. + + - id: csr-srmcfg-id-bit-allocation + normative: false + text: | + Typically, fewer bits are allocated for RCID (e.g., to support tens of RCIDs) than for MCID (e.g., to support hundreds of MCIDs). + + - id: csr-srmcfg-rcid-grouping + normative: false + text: | + A common RCID is usually used to group apps or VMs, pooling resource allocations to meet collective SLAs. + + - id: csr-srmcfg-mcid-granularity + normative: false + text: | + If an SLA breach occurs, unique MCIDs enable granular monitoring, aiding decisions on resource adjustment, + associating a different RCID with a subset of members, or migrating members to other machines. + The larger pool of MCIDs speeds up this analysis. + + - id: csr-srmcfg-privilege-behavior + normative: false + text: | + The RCID and MCID in srmcfg apply across all privilege levels on the hart. + Typically, higher-privilege modes don’t modify srmcfg, as they often serve lower-privileged tasks. + If differentiation is needed, higher privilege code can update srmcfg and restore it before returning to a lower privilege level. - The RCID and MCID configured in the srmcfg CSR apply to all privilege modes of software execution on that hart by default, - but this behavior may be overridden by future extensions. + - id: csr-srmcfg-vm-virtualization + normative: false + text: | + In VM environments, hypervisors usually manage resource allocations, keeping the Guest OS out of QoS flows. + If needed, the hypervisor can virtualize srmcfg CSR for a VM using the virtual-instruction exceptions triggered upon Guest access. - 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. + - id: csr-srmcfg-vs-mode-future + normative: false + text: | + If the direct selection of RCID and MCID by the VM becomes common and emulation overhead is an issue, + future extensions may allow VS-mode to use a selector for a hypervisor-configured set of CSRs holding RCID and MCID values designated for that Guest OS use. - [Note] - A reset value of 0 is suggested for the RCID field, matching resource controllers' default behavior of associating all capacity with RCID=0. - The MCID reset value does not affect functionality and may be implementation-defined. + - id: csr-srmcfg-context-switch + normative: false + text: | + During context switches, the supervisor may choose to execute with the srmcfg of the outgoing context to attribute the execution to it. + Prior to restoring the new context, it switches to the new VM’s srmcfg. + The supervisor can also use a separate configuration for execution not to be attributed to either context. fields: RCID: location: 11-0 type: RW + long_name: Resource Control ID description: | The RCID is used to determine the resource allocations (e.g., cache occupancy limits, memory bandwidth limits, etc.) to enforce. - reset_value: 0 + reset_value: UNDEFINED_LEGAL MCID: location: 27-16 type: RW + long_name: Monitoring Counter ID description: | The MCID is used to identify a counter to monitor resource usage. - reset_value: 0 + reset_value: UNDEFINED_LEGAL From 2693eec152d497477957119e44e7f8a49b8f9ad6 Mon Sep 17 00:00:00 2001 From: syedowaisalishah Date: Fri, 2 May 2025 02:59:43 +0000 Subject: [PATCH 06/15] docs(csr): improve srmcfg register description --- arch/csr/Ssqosid/srmcfg.yaml | 54 ++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/arch/csr/Ssqosid/srmcfg.yaml b/arch/csr/Ssqosid/srmcfg.yaml index b125679ac..355ea7fe9 100644 --- a/arch/csr/Ssqosid/srmcfg.yaml +++ b/arch/csr/Ssqosid/srmcfg.yaml @@ -11,84 +11,84 @@ description: - id: csr-srmcfg-purpose normative: true text: | - The srmcfg register is used to configure a Resource Control ID (RCID) and a Monitoring Counter ID (MCID). - Both RCID and MCID are WARL fields. + The `srmcfg` register is used to configure a Resource Control ID (`RCID`) and a Monitoring Counter ID (`MCID`). + Both `RCID` and `MCID` are WARL fields. - - id: csr-srmcfg-field-usage + - id: csr-`srmcfg`-field-usage normative: true text: | - The RCID and MCID accompany each request made by the hart to shared resource controllers. - The RCID is used to determine the resource allocations (e.g., cache occupancy limits, memory bandwidth limits, etc.) to enforce. - The MCID is used to identify a counter to monitor resource usage. + The `RCID` and `MCID` accompany each request made by the hart to shared resource controllers. + The `RCID` is used to determine the resource allocations (e.g., cache occupancy limits, memory bandwidth limits, etc.) to enforce. + The `MCID` is used to identify a counter to monitor resource usage. - id: csr-srmcfg-default-scope normative: true text: | - The RCID and MCID configured in the srmcfg CSR apply to all privilege modes of software execution on that hart by default, + The `RCID` and `MCID` configured in the `srmcfg` CSR apply to all privilege modes of software execution on that hart by default, but this behavior may be overridden by future extensions. - id: csr-srmcfg-smstateen-interaction normative: true text: | - 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 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. - id: csr-srmcfg-vsmode-exception normative: true text: | - If mstateen0.SRMCFG is 1 or if extension Smstateen is not implemented, attempts to access srmcfg when V=1 raise a virtual-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. - id: csr-srmcfg-rcid-reset normative: false text: | - A reset value of 0 is suggested for the RCID field, matching resource controllers' default behavior of associating all capacity with RCID=0. + A reset value of `0` is suggested for the `RCID` field, matching resource controllers' default behavior of associating all capacity with `RCID=0`. - id: csr-srmcfg-mcid-reset normative: false text: | - The MCID reset value does not affect functionality and may be implementation-defined. + The `MCID` reset value does not affect functionality and may be implementation-defined. - id: csr-srmcfg-id-bit-allocation normative: false text: | - Typically, fewer bits are allocated for RCID (e.g., to support tens of RCIDs) than for MCID (e.g., to support hundreds of MCIDs). + Typically, fewer bits are allocated for `RCID` (e.g., to support tens of `RCID`s) than for `MCID` (e.g., to support hundreds of `MCID`s). - id: csr-srmcfg-rcid-grouping normative: false text: | - A common RCID is usually used to group apps or VMs, pooling resource allocations to meet collective SLAs. + A common `RCID` is usually used to group apps or VMs, pooling resource allocations to meet collective SLAs. - id: csr-srmcfg-mcid-granularity normative: false text: | - If an SLA breach occurs, unique MCIDs enable granular monitoring, aiding decisions on resource adjustment, - associating a different RCID with a subset of members, or migrating members to other machines. - The larger pool of MCIDs speeds up this analysis. + If an SLA breach occurs, unique `MCID`s enable granular monitoring, aiding decisions on resource adjustment, + associating a different `RCID` with a subset of members, or migrating members to other machines. + The larger pool of `MCID`s speeds up this analysis. - id: csr-srmcfg-privilege-behavior normative: false text: | - The RCID and MCID in srmcfg apply across all privilege levels on the hart. - Typically, higher-privilege modes don’t modify srmcfg, as they often serve lower-privileged tasks. - If differentiation is needed, higher privilege code can update srmcfg and restore it before returning to a lower privilege level. + The `RCID` and `MCID` in `srmcfg` apply across all privilege levels on the hart. + Typically, higher-privilege modes don't modify `srmcfg`, as they often serve lower-privileged tasks. + If differentiation is needed, higher privilege code can update `srmcfg` and restore it before returning to a lower privilege level. - id: csr-srmcfg-vm-virtualization normative: false text: | In VM environments, hypervisors usually manage resource allocations, keeping the Guest OS out of QoS flows. - If needed, the hypervisor can virtualize srmcfg CSR for a VM using the virtual-instruction exceptions triggered upon Guest access. + If needed, the hypervisor can virtualize the `srmcfg` CSR for a VM using the virtual-instruction exceptions triggered upon Guest access. - id: csr-srmcfg-vs-mode-future normative: false text: | - If the direct selection of RCID and MCID by the VM becomes common and emulation overhead is an issue, - future extensions may allow VS-mode to use a selector for a hypervisor-configured set of CSRs holding RCID and MCID values designated for that Guest OS use. + If the direct selection of `RCID` and `MCID` by the VM becomes common and emulation overhead is an issue, + future extensions may allow VS-mode to use a selector for a hypervisor-configured set of CSRs holding `RCID` and `MCID` values designated for that Guest OS use. - id: csr-srmcfg-context-switch normative: false text: | - During context switches, the supervisor may choose to execute with the srmcfg of the outgoing context to attribute the execution to it. - Prior to restoring the new context, it switches to the new VM’s srmcfg. + During context switches, the supervisor may choose to execute with the `srmcfg` of the outgoing context to attribute the execution to it. + Prior to restoring the new context, it switches to the new VM’s `srmcfg`. The supervisor can also use a separate configuration for execution not to be attributed to either context. fields: @@ -97,7 +97,7 @@ fields: type: RW long_name: Resource Control ID description: | - The RCID is used to determine the resource allocations (e.g., cache occupancy limits, + The `RCID` is used to determine the resource allocations (e.g., cache occupancy limits, memory bandwidth limits, etc.) to enforce. reset_value: UNDEFINED_LEGAL @@ -106,5 +106,5 @@ fields: type: RW long_name: Monitoring Counter ID description: | - The MCID is used to identify a counter to monitor resource usage. + The `MCID` is used to identify a counter to monitor resource usage. reset_value: UNDEFINED_LEGAL From 9af87bea824a9ae7f8be48d072a448ea19f2977f Mon Sep 17 00:00:00 2001 From: Syed Owais Ali Shah <113125582+syedowaisalishah@users.noreply.github.com> Date: Fri, 2 May 2025 08:19:56 +0500 Subject: [PATCH 07/15] Update .gitignore Signed-off-by: Syed Owais Ali Shah <113125582+syedowaisalishah@users.noreply.github.com> --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e0ca947a4..543d159dd 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ __pycache__/ .pytest_cache/ *.bak *.log +sorbet From b22aea6e3ed261942d46544cd26dd0bbf0f72687 Mon Sep 17 00:00:00 2001 From: syedowaisalishah Date: Wed, 23 Apr 2025 12:32:50 +0000 Subject: [PATCH 08/15] Add CSR YAML file for Ssqosid:srmcfg --- arch/csr/Ssqosid/srmcfg.yaml | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 arch/csr/Ssqosid/srmcfg.yaml diff --git a/arch/csr/Ssqosid/srmcfg.yaml b/arch/csr/Ssqosid/srmcfg.yaml new file mode 100644 index 000000000..4facbde31 --- /dev/null +++ b/arch/csr/Ssqosid/srmcfg.yaml @@ -0,0 +1,44 @@ +# yaml-language-server: $schema=../../../schemas/csr_schema.json +$schema: csr_schema.json# +kind: csr +name: srmcfg +long_name: Supervisor Resource Management Configuration +address: 0x5C0 #Until the extension is finalized and assigned an official address by the RISC-V Foundation, srmcfg will use a placeholder/custom address +priv_mode: S +length: SXLEN +definedBy: Ssqosid +description: | + The srmcfg register is an SXLEN-bit read/write register used to configure a Resource Control ID (RCID) and a Monitoring Counter ID (MCID). + Both RCID and MCID are WARL fields. + + The RCID and MCID accompany each request made by the hart to shared resource controllers. + The RCID is used to determine the resource allocations (e.g., cache occupancy limits, memory bandwidth limits, etc.) to enforce. + The MCID is used to identify a counter to monitor resource usage. + + The RCID and MCID configured in the srmcfg CSR apply to all privilege modes of software execution on that hart by default, + but this behavior may be overridden by future extensions. + + 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. + + A reset value of 0 is suggested for the RCID field matching resource controllers' default behavior of associating all capacity with RCID=0. + The MCID reset value does not affect functionality and may be implementation-defined. + +fields: + RCID: + location_rv32: 15-0 + location_rv64: 15-0 + type: RW + description: | + The RCID is used to determine the resource allocations (e.g., cache occupancy limits, + memory bandwidth limits, etc.) to enforce. + reset_value: 0 + + MCID: + location_rv32: 31-16 + location_rv64: 31-16 + type: RW + description: | + The MCID is used to identify a counter to monitor resource usage. + reset_value: 0 From ee2520826b89b7101327d9971ceeeb852a6b5d65 Mon Sep 17 00:00:00 2001 From: syedowaisalishah Date: Wed, 23 Apr 2025 12:34:30 +0000 Subject: [PATCH 09/15] Add Extension YAML file for Ssqosid --- arch/ext/Ssqosid.yaml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 arch/ext/Ssqosid.yaml diff --git a/arch/ext/Ssqosid.yaml b/arch/ext/Ssqosid.yaml new file mode 100644 index 000000000..4cb20a796 --- /dev/null +++ b/arch/ext/Ssqosid.yaml @@ -0,0 +1,40 @@ +# yaml-language-server: $schema=../../schemas/ext_schema.json + +$schema: "ext_schema.json#" +kind: extension +name: Ssqosid +type: privileged +long_name: Quality-of-Service Identifiers +description: | + Quality of Service (QoS) is defined as the minimal end-to-end performance guaranteed in advance by a service level agreement (SLA) to a workload. + Performance metrics might include measures such as instructions per cycle (IPC), latency of service, etc. + + When multiple workloads execute concurrently on modern processors—equipped with large core counts, multiple cache hierarchies, and multiple memory + controllers—the performance of any given workload becomes less deterministic, or even non-deterministic, due to shared resource contention. + + To manage performance variability, system software needs resource allocation and monitoring capabilities. + These capabilities allow for the reservation of resources like cache and bandwidth, thus meeting individual performance targets while minimizing interference. + For resource management, hardware should provide monitoring features that allow system software to profile workload resource consumption and allocate resources accordingly. + + To facilitate this, 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. + + Additional metadata, like the nature of the memory access and the ID of the originating supervisor domain, + can accompany RCID and MCID. Resource controllers may use this metadata for differentiated service such as a different capacity allocation for code storage vs.data storage. + Resource controllers can use this data for security policies such as not exposing statistics of one security domain to another. + + These identifiers are crucial for the RISC-V Capacity and Bandwidth Controller QoS Register Interface (CBQRI) specification, + which provides methods for setting resource usage limits and monitoring resource consumption. + The RCID controls resource allocations, while the MCID is used for tracking resource usage. + + The Ssqosid extension does not require that S-mode mode be implemented. +versions: + - version: "1.0.0" + state: ratified + ratification_date: "2024-11" + url: "https://github.com/riscv/riscv-isa-manual/releases/tag/riscv-isa-release-5308687-2025-04-22" + requires: + allOf: + - name: S + version: ~> 1.13 From 084c743ba228a626275dedc6738ec98f5dbda008 Mon Sep 17 00:00:00 2001 From: syedowaisalishah Date: Sun, 27 Apr 2025 17:39:42 +0000 Subject: [PATCH 10/15] Add Extension YAML file for Ssqosid --- arch/ext/Ssqosid.yaml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/arch/ext/Ssqosid.yaml b/arch/ext/Ssqosid.yaml index 4cb20a796..84badf81d 100644 --- a/arch/ext/Ssqosid.yaml +++ b/arch/ext/Ssqosid.yaml @@ -21,20 +21,16 @@ description: | These identifiers accompany each request issued by the hart to shared resource controllers. Additional metadata, like the nature of the memory access and the ID of the originating supervisor domain, - can accompany RCID and MCID. Resource controllers may use this metadata for differentiated service such as a different capacity allocation for code storage vs.data storage. + can accompany RCID and MCID. Resource controllers may use this metadata for differentiated service such as a different capacity allocation for code storage vs. data storage. Resource controllers can use this data for security policies such as not exposing statistics of one security domain to another. These identifiers are crucial for the RISC-V Capacity and Bandwidth Controller QoS Register Interface (CBQRI) specification, which provides methods for setting resource usage limits and monitoring resource consumption. The RCID controls resource allocations, while the MCID is used for tracking resource usage. - The Ssqosid extension does not require that S-mode mode be implemented. versions: - version: "1.0.0" state: ratified - ratification_date: "2024-11" + ratification_date: "2024-06" url: "https://github.com/riscv/riscv-isa-manual/releases/tag/riscv-isa-release-5308687-2025-04-22" - requires: - allOf: - - name: S - version: ~> 1.13 + requires: { name: S, version: ~> 1.13 } From 8ff0e7ed8064c2b377edd988ffb04f822a3c49e1 Mon Sep 17 00:00:00 2001 From: syedowaisalishah Date: Sun, 27 Apr 2025 17:40:42 +0000 Subject: [PATCH 11/15] Add CSR YAML file for Ssqosid:srmcfg --- arch/csr/Ssqosid/srmcfg.yaml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/csr/Ssqosid/srmcfg.yaml b/arch/csr/Ssqosid/srmcfg.yaml index 4facbde31..3e2fecb36 100644 --- a/arch/csr/Ssqosid/srmcfg.yaml +++ b/arch/csr/Ssqosid/srmcfg.yaml @@ -3,12 +3,12 @@ $schema: csr_schema.json# kind: csr name: srmcfg long_name: Supervisor Resource Management Configuration -address: 0x5C0 #Until the extension is finalized and assigned an official address by the RISC-V Foundation, srmcfg will use a placeholder/custom address +address: 0x5C0 # Until the extension is finalized and assigned an official address by the RISC-V Foundation, srmcfg will use a placeholder/custom address priv_mode: S length: SXLEN definedBy: Ssqosid description: | - The srmcfg register is an SXLEN-bit read/write register used to configure a Resource Control ID (RCID) and a Monitoring Counter ID (MCID). + The srmcfg register is used to configure a Resource Control ID (RCID) and a Monitoring Counter ID (MCID). Both RCID and MCID are WARL fields. The RCID and MCID accompany each request made by the hart to shared resource controllers. @@ -22,22 +22,21 @@ description: | 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. - A reset value of 0 is suggested for the RCID field matching resource controllers' default behavior of associating all capacity with RCID=0. + [Note] + A reset value of 0 is suggested for the RCID field, matching resource controllers' default behavior of associating all capacity with RCID=0. The MCID reset value does not affect functionality and may be implementation-defined. fields: RCID: - location_rv32: 15-0 - location_rv64: 15-0 + location: 11-0 type: RW description: | The RCID is used to determine the resource allocations (e.g., cache occupancy limits, - memory bandwidth limits, etc.) to enforce. + memory bandwidth limits, etc.) to enforce. reset_value: 0 MCID: - location_rv32: 31-16 - location_rv64: 31-16 + location: 27-16 type: RW description: | The MCID is used to identify a counter to monitor resource usage. From 9e9d9f26826a476fe25b77f5e0e2c8ae024390e5 Mon Sep 17 00:00:00 2001 From: syedowaisalishah Date: Wed, 30 Apr 2025 06:44:58 +0000 Subject: [PATCH 12/15] docs(csr): improve srmcfg register description and field details --- arch/csr/Ssqosid/srmcfg.yaml | 101 +++++++++++++++++++++++++++++------ 1 file changed, 84 insertions(+), 17 deletions(-) diff --git a/arch/csr/Ssqosid/srmcfg.yaml b/arch/csr/Ssqosid/srmcfg.yaml index 3e2fecb36..b125679ac 100644 --- a/arch/csr/Ssqosid/srmcfg.yaml +++ b/arch/csr/Ssqosid/srmcfg.yaml @@ -3,41 +3,108 @@ $schema: csr_schema.json# kind: csr name: srmcfg long_name: Supervisor Resource Management Configuration -address: 0x5C0 # Until the extension is finalized and assigned an official address by the RISC-V Foundation, srmcfg will use a placeholder/custom address +address: 0x181 priv_mode: S length: SXLEN definedBy: Ssqosid -description: | - The srmcfg register is used to configure a Resource Control ID (RCID) and a Monitoring Counter ID (MCID). - Both RCID and MCID are WARL fields. +description: + - id: csr-srmcfg-purpose + normative: true + text: | + The srmcfg register is used to configure a Resource Control ID (RCID) and a Monitoring Counter ID (MCID). + Both RCID and MCID are WARL fields. - The RCID and MCID accompany each request made by the hart to shared resource controllers. - The RCID is used to determine the resource allocations (e.g., cache occupancy limits, memory bandwidth limits, etc.) to enforce. - The MCID is used to identify a counter to monitor resource usage. + - id: csr-srmcfg-field-usage + normative: true + text: | + The RCID and MCID accompany each request made by the hart to shared resource controllers. + The RCID is used to determine the resource allocations (e.g., cache occupancy limits, memory bandwidth limits, etc.) to enforce. + The MCID is used to identify a counter to monitor resource usage. + + - id: csr-srmcfg-default-scope + normative: true + text: | + The RCID and MCID configured in the srmcfg CSR apply to all privilege modes of software execution on that hart by default, + but this behavior may be overridden by future extensions. + + - id: csr-srmcfg-smstateen-interaction + normative: true + text: | + 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. + + - id: csr-srmcfg-vsmode-exception + normative: true + text: | + If mstateen0.SRMCFG is 1 or if extension Smstateen is not implemented, attempts to access srmcfg when V=1 raise a virtual-instruction exception. + + - id: csr-srmcfg-rcid-reset + normative: false + text: | + A reset value of 0 is suggested for the RCID field, matching resource controllers' default behavior of associating all capacity with RCID=0. + + - id: csr-srmcfg-mcid-reset + normative: false + text: | + The MCID reset value does not affect functionality and may be implementation-defined. + + - id: csr-srmcfg-id-bit-allocation + normative: false + text: | + Typically, fewer bits are allocated for RCID (e.g., to support tens of RCIDs) than for MCID (e.g., to support hundreds of MCIDs). + + - id: csr-srmcfg-rcid-grouping + normative: false + text: | + A common RCID is usually used to group apps or VMs, pooling resource allocations to meet collective SLAs. + + - id: csr-srmcfg-mcid-granularity + normative: false + text: | + If an SLA breach occurs, unique MCIDs enable granular monitoring, aiding decisions on resource adjustment, + associating a different RCID with a subset of members, or migrating members to other machines. + The larger pool of MCIDs speeds up this analysis. + + - id: csr-srmcfg-privilege-behavior + normative: false + text: | + The RCID and MCID in srmcfg apply across all privilege levels on the hart. + Typically, higher-privilege modes don’t modify srmcfg, as they often serve lower-privileged tasks. + If differentiation is needed, higher privilege code can update srmcfg and restore it before returning to a lower privilege level. - The RCID and MCID configured in the srmcfg CSR apply to all privilege modes of software execution on that hart by default, - but this behavior may be overridden by future extensions. + - id: csr-srmcfg-vm-virtualization + normative: false + text: | + In VM environments, hypervisors usually manage resource allocations, keeping the Guest OS out of QoS flows. + If needed, the hypervisor can virtualize srmcfg CSR for a VM using the virtual-instruction exceptions triggered upon Guest access. - 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. + - id: csr-srmcfg-vs-mode-future + normative: false + text: | + If the direct selection of RCID and MCID by the VM becomes common and emulation overhead is an issue, + future extensions may allow VS-mode to use a selector for a hypervisor-configured set of CSRs holding RCID and MCID values designated for that Guest OS use. - [Note] - A reset value of 0 is suggested for the RCID field, matching resource controllers' default behavior of associating all capacity with RCID=0. - The MCID reset value does not affect functionality and may be implementation-defined. + - id: csr-srmcfg-context-switch + normative: false + text: | + During context switches, the supervisor may choose to execute with the srmcfg of the outgoing context to attribute the execution to it. + Prior to restoring the new context, it switches to the new VM’s srmcfg. + The supervisor can also use a separate configuration for execution not to be attributed to either context. fields: RCID: location: 11-0 type: RW + long_name: Resource Control ID description: | The RCID is used to determine the resource allocations (e.g., cache occupancy limits, memory bandwidth limits, etc.) to enforce. - reset_value: 0 + reset_value: UNDEFINED_LEGAL MCID: location: 27-16 type: RW + long_name: Monitoring Counter ID description: | The MCID is used to identify a counter to monitor resource usage. - reset_value: 0 + reset_value: UNDEFINED_LEGAL From 04e166eed88f3be7e414ec52ddc7a57e9f401061 Mon Sep 17 00:00:00 2001 From: syedowaisalishah Date: Fri, 2 May 2025 02:59:43 +0000 Subject: [PATCH 13/15] docs(csr): improve srmcfg register description --- arch/csr/Ssqosid/srmcfg.yaml | 54 ++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/arch/csr/Ssqosid/srmcfg.yaml b/arch/csr/Ssqosid/srmcfg.yaml index b125679ac..355ea7fe9 100644 --- a/arch/csr/Ssqosid/srmcfg.yaml +++ b/arch/csr/Ssqosid/srmcfg.yaml @@ -11,84 +11,84 @@ description: - id: csr-srmcfg-purpose normative: true text: | - The srmcfg register is used to configure a Resource Control ID (RCID) and a Monitoring Counter ID (MCID). - Both RCID and MCID are WARL fields. + The `srmcfg` register is used to configure a Resource Control ID (`RCID`) and a Monitoring Counter ID (`MCID`). + Both `RCID` and `MCID` are WARL fields. - - id: csr-srmcfg-field-usage + - id: csr-`srmcfg`-field-usage normative: true text: | - The RCID and MCID accompany each request made by the hart to shared resource controllers. - The RCID is used to determine the resource allocations (e.g., cache occupancy limits, memory bandwidth limits, etc.) to enforce. - The MCID is used to identify a counter to monitor resource usage. + The `RCID` and `MCID` accompany each request made by the hart to shared resource controllers. + The `RCID` is used to determine the resource allocations (e.g., cache occupancy limits, memory bandwidth limits, etc.) to enforce. + The `MCID` is used to identify a counter to monitor resource usage. - id: csr-srmcfg-default-scope normative: true text: | - The RCID and MCID configured in the srmcfg CSR apply to all privilege modes of software execution on that hart by default, + The `RCID` and `MCID` configured in the `srmcfg` CSR apply to all privilege modes of software execution on that hart by default, but this behavior may be overridden by future extensions. - id: csr-srmcfg-smstateen-interaction normative: true text: | - 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 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. - id: csr-srmcfg-vsmode-exception normative: true text: | - If mstateen0.SRMCFG is 1 or if extension Smstateen is not implemented, attempts to access srmcfg when V=1 raise a virtual-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. - id: csr-srmcfg-rcid-reset normative: false text: | - A reset value of 0 is suggested for the RCID field, matching resource controllers' default behavior of associating all capacity with RCID=0. + A reset value of `0` is suggested for the `RCID` field, matching resource controllers' default behavior of associating all capacity with `RCID=0`. - id: csr-srmcfg-mcid-reset normative: false text: | - The MCID reset value does not affect functionality and may be implementation-defined. + The `MCID` reset value does not affect functionality and may be implementation-defined. - id: csr-srmcfg-id-bit-allocation normative: false text: | - Typically, fewer bits are allocated for RCID (e.g., to support tens of RCIDs) than for MCID (e.g., to support hundreds of MCIDs). + Typically, fewer bits are allocated for `RCID` (e.g., to support tens of `RCID`s) than for `MCID` (e.g., to support hundreds of `MCID`s). - id: csr-srmcfg-rcid-grouping normative: false text: | - A common RCID is usually used to group apps or VMs, pooling resource allocations to meet collective SLAs. + A common `RCID` is usually used to group apps or VMs, pooling resource allocations to meet collective SLAs. - id: csr-srmcfg-mcid-granularity normative: false text: | - If an SLA breach occurs, unique MCIDs enable granular monitoring, aiding decisions on resource adjustment, - associating a different RCID with a subset of members, or migrating members to other machines. - The larger pool of MCIDs speeds up this analysis. + If an SLA breach occurs, unique `MCID`s enable granular monitoring, aiding decisions on resource adjustment, + associating a different `RCID` with a subset of members, or migrating members to other machines. + The larger pool of `MCID`s speeds up this analysis. - id: csr-srmcfg-privilege-behavior normative: false text: | - The RCID and MCID in srmcfg apply across all privilege levels on the hart. - Typically, higher-privilege modes don’t modify srmcfg, as they often serve lower-privileged tasks. - If differentiation is needed, higher privilege code can update srmcfg and restore it before returning to a lower privilege level. + The `RCID` and `MCID` in `srmcfg` apply across all privilege levels on the hart. + Typically, higher-privilege modes don't modify `srmcfg`, as they often serve lower-privileged tasks. + If differentiation is needed, higher privilege code can update `srmcfg` and restore it before returning to a lower privilege level. - id: csr-srmcfg-vm-virtualization normative: false text: | In VM environments, hypervisors usually manage resource allocations, keeping the Guest OS out of QoS flows. - If needed, the hypervisor can virtualize srmcfg CSR for a VM using the virtual-instruction exceptions triggered upon Guest access. + If needed, the hypervisor can virtualize the `srmcfg` CSR for a VM using the virtual-instruction exceptions triggered upon Guest access. - id: csr-srmcfg-vs-mode-future normative: false text: | - If the direct selection of RCID and MCID by the VM becomes common and emulation overhead is an issue, - future extensions may allow VS-mode to use a selector for a hypervisor-configured set of CSRs holding RCID and MCID values designated for that Guest OS use. + If the direct selection of `RCID` and `MCID` by the VM becomes common and emulation overhead is an issue, + future extensions may allow VS-mode to use a selector for a hypervisor-configured set of CSRs holding `RCID` and `MCID` values designated for that Guest OS use. - id: csr-srmcfg-context-switch normative: false text: | - During context switches, the supervisor may choose to execute with the srmcfg of the outgoing context to attribute the execution to it. - Prior to restoring the new context, it switches to the new VM’s srmcfg. + During context switches, the supervisor may choose to execute with the `srmcfg` of the outgoing context to attribute the execution to it. + Prior to restoring the new context, it switches to the new VM’s `srmcfg`. The supervisor can also use a separate configuration for execution not to be attributed to either context. fields: @@ -97,7 +97,7 @@ fields: type: RW long_name: Resource Control ID description: | - The RCID is used to determine the resource allocations (e.g., cache occupancy limits, + The `RCID` is used to determine the resource allocations (e.g., cache occupancy limits, memory bandwidth limits, etc.) to enforce. reset_value: UNDEFINED_LEGAL @@ -106,5 +106,5 @@ fields: type: RW long_name: Monitoring Counter ID description: | - The MCID is used to identify a counter to monitor resource usage. + The `MCID` is used to identify a counter to monitor resource usage. reset_value: UNDEFINED_LEGAL From abcd342722b284f04fda7b871d0977d6be2f324d Mon Sep 17 00:00:00 2001 From: syedowaisalishah Date: Fri, 9 May 2025 20:53:41 +0000 Subject: [PATCH 14/15] feat(csr): add YAML file for Ssqosid:srmcfg --- arch/csr/Ssqosid/srmcfg.yaml | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/arch/csr/Ssqosid/srmcfg.yaml b/arch/csr/Ssqosid/srmcfg.yaml index 355ea7fe9..1fdae0635 100644 --- a/arch/csr/Ssqosid/srmcfg.yaml +++ b/arch/csr/Ssqosid/srmcfg.yaml @@ -108,3 +108,40 @@ fields: description: | The `MCID` is used to identify a counter to monitor resource usage. reset_value: UNDEFINED_LEGAL + sw_write(csr_value): | + if (implemented?(ExtensionName::Smstateen)) { + if (mode() < PrivilegeMode::M && CSR[mstateen0].SRMCFG == 0) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + if (virtual_mode?() && CSR[mstateen0].SRMCFG == 1) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } else { + if (virtual_mode?()) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + value = csr_value; + + rcid_mask = 0xFFF + mcid_mask = 0xFFF + + rcid = csr_value & rcid_mask + mcid = (csr_value >> 16) & mcid_mask + + value = (mcid << 16) | rcid + +sw_read(): | + if (implemented?(ExtensionName::Smstateen)) { + if (mode() < PrivilegeMode::M && CSR[mstateen0].SRMCFG == 0) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + if (virtual_mode?() && CSR[mstateen0].SRMCFG == 1) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } else { + if (virtual_mode?()) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + return value; From 12a4d9b80acaa2b2a1ca94016833b5e90158802d Mon Sep 17 00:00:00 2001 From: syedowaisalishah Date: Tue, 13 May 2025 01:26:33 +0000 Subject: [PATCH 15/15] feat(csr): add YAML file for Ssqosid:srmcfg --- arch/csr/Ssqosid/srmcfg.yaml | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/arch/csr/Ssqosid/srmcfg.yaml b/arch/csr/Ssqosid/srmcfg.yaml index 1fdae0635..fe4d48aa6 100644 --- a/arch/csr/Ssqosid/srmcfg.yaml +++ b/arch/csr/Ssqosid/srmcfg.yaml @@ -100,6 +100,20 @@ fields: The `RCID` is used to determine the resource allocations (e.g., cache occupancy limits, memory bandwidth limits, etc.) to enforce. reset_value: UNDEFINED_LEGAL + sw_write(csr_value): | + if (implemented?(ExtensionName::Smstateen)) { + if (mode() < PrivilegeMode::M && CSR[mstateen0].SRMCFG == 0) { + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); + } + if (virtual_mode?() && CSR[mstateen0].SRMCFG == 1) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } else { + if (virtual_mode?()) { + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); + } + } + return csr_value.RCID; MCID: location: 27-16 @@ -121,15 +135,7 @@ fields: raise(ExceptionCode::VirtualInstruction, mode(), $encoding); } } - value = csr_value; - - rcid_mask = 0xFFF - mcid_mask = 0xFFF - - rcid = csr_value & rcid_mask - mcid = (csr_value >> 16) & mcid_mask - - value = (mcid << 16) | rcid + return csr_value.MCID; sw_read(): | if (implemented?(ExtensionName::Smstateen)) { @@ -144,4 +150,4 @@ sw_read(): | raise(ExceptionCode::VirtualInstruction, mode(), $encoding); } } - return value; + return $bits(CSR[srmcfg]);