|
| 1 | +# yaml-language-server: $schema=../../../schemas/csr_schema.json |
| 2 | +$schema: csr_schema.json# |
| 3 | +kind: csr |
| 4 | +name: srmcfg |
| 5 | +long_name: Supervisor Resource Management Configuration |
| 6 | +address: 0x181 |
| 7 | +priv_mode: S |
| 8 | +length: SXLEN |
| 9 | +definedBy: Ssqosid |
| 10 | +description: |
| 11 | + - id: csr-srmcfg-purpose |
| 12 | + normative: true |
| 13 | + text: | |
| 14 | + The `srmcfg` register is used to configure a Resource Control ID (`RCID`) and a Monitoring Counter ID (`MCID`). |
| 15 | + Both `RCID` and `MCID` are WARL fields. |
| 16 | +
|
| 17 | + - id: csr-`srmcfg`-field-usage |
| 18 | + normative: true |
| 19 | + text: | |
| 20 | + The `RCID` and `MCID` accompany each request made by the hart to shared resource controllers. |
| 21 | + The `RCID` is used to determine the resource allocations (e.g., cache occupancy limits, memory bandwidth limits, etc.) to enforce. |
| 22 | + The `MCID` is used to identify a counter to monitor resource usage. |
| 23 | +
|
| 24 | + - id: csr-srmcfg-default-scope |
| 25 | + normative: true |
| 26 | + text: | |
| 27 | + The `RCID` and `MCID` configured in the `srmcfg` CSR apply to all privilege modes of software execution on that hart by default, |
| 28 | + but this behavior may be overridden by future extensions. |
| 29 | +
|
| 30 | + - id: csr-srmcfg-smstateen-interaction |
| 31 | + normative: true |
| 32 | + text: | |
| 33 | + If extension `Smstateen` is implemented together with `Ssqosid`, then `Ssqosid` also requires the `SRMCFG` bit in `mstateen0` to be implemented. |
| 34 | + If `mstateen0.SRMCFG` is `0`, attempts to access `srmcfg` in privilege modes less privileged than M-mode raise an illegal-instruction exception. |
| 35 | +
|
| 36 | + - id: csr-srmcfg-vsmode-exception |
| 37 | + normative: true |
| 38 | + text: | |
| 39 | + If `mstateen0.SRMCFG` is `1` or if extension `Smstateen` is not implemented, attempts to access `srmcfg` when `V=1` raise a virtual-instruction exception. |
| 40 | +
|
| 41 | + - id: csr-srmcfg-rcid-reset |
| 42 | + normative: false |
| 43 | + text: | |
| 44 | + A reset value of `0` is suggested for the `RCID` field, matching resource controllers' default behavior of associating all capacity with `RCID=0`. |
| 45 | +
|
| 46 | + - id: csr-srmcfg-mcid-reset |
| 47 | + normative: false |
| 48 | + text: | |
| 49 | + The `MCID` reset value does not affect functionality and may be implementation-defined. |
| 50 | +
|
| 51 | + - id: csr-srmcfg-id-bit-allocation |
| 52 | + normative: false |
| 53 | + text: | |
| 54 | + 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). |
| 55 | +
|
| 56 | + - id: csr-srmcfg-rcid-grouping |
| 57 | + normative: false |
| 58 | + text: | |
| 59 | + A common `RCID` is usually used to group apps or VMs, pooling resource allocations to meet collective SLAs. |
| 60 | +
|
| 61 | + - id: csr-srmcfg-mcid-granularity |
| 62 | + normative: false |
| 63 | + text: | |
| 64 | + If an SLA breach occurs, unique `MCID`s enable granular monitoring, aiding decisions on resource adjustment, |
| 65 | + associating a different `RCID` with a subset of members, or migrating members to other machines. |
| 66 | + The larger pool of `MCID`s speeds up this analysis. |
| 67 | +
|
| 68 | + - id: csr-srmcfg-privilege-behavior |
| 69 | + normative: false |
| 70 | + text: | |
| 71 | + The `RCID` and `MCID` in `srmcfg` apply across all privilege levels on the hart. |
| 72 | + Typically, higher-privilege modes don't modify `srmcfg`, as they often serve lower-privileged tasks. |
| 73 | + If differentiation is needed, higher privilege code can update `srmcfg` and restore it before returning to a lower privilege level. |
| 74 | +
|
| 75 | + - id: csr-srmcfg-vm-virtualization |
| 76 | + normative: false |
| 77 | + text: | |
| 78 | + In VM environments, hypervisors usually manage resource allocations, keeping the Guest OS out of QoS flows. |
| 79 | + If needed, the hypervisor can virtualize the `srmcfg` CSR for a VM using the virtual-instruction exceptions triggered upon Guest access. |
| 80 | +
|
| 81 | + - id: csr-srmcfg-vs-mode-future |
| 82 | + normative: false |
| 83 | + text: | |
| 84 | + If the direct selection of `RCID` and `MCID` by the VM becomes common and emulation overhead is an issue, |
| 85 | + 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. |
| 86 | +
|
| 87 | + - id: csr-srmcfg-context-switch |
| 88 | + normative: false |
| 89 | + text: | |
| 90 | + During context switches, the supervisor may choose to execute with the `srmcfg` of the outgoing context to attribute the execution to it. |
| 91 | + Prior to restoring the new context, it switches to the new VM’s `srmcfg`. |
| 92 | + The supervisor can also use a separate configuration for execution not to be attributed to either context. |
| 93 | +fields: |
| 94 | + RCID: |
| 95 | + location: 11-0 |
| 96 | + type: RW |
| 97 | + long_name: Resource Control ID |
| 98 | + description: | |
| 99 | + The `RCID` is used to determine the resource allocations (e.g., cache occupancy limits, |
| 100 | + memory bandwidth limits, etc.) to enforce. |
| 101 | + reset_value: UNDEFINED_LEGAL |
| 102 | + sw_write(csr_value): | |
| 103 | + if (implemented?(ExtensionName::Smstateen)) { |
| 104 | + if (mode() < PrivilegeMode::M && CSR[mstateen0].SRMCFG == 0) { |
| 105 | + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); |
| 106 | + } |
| 107 | + if (virtual_mode?() && CSR[mstateen0].SRMCFG == 1) { |
| 108 | + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); |
| 109 | + } |
| 110 | + } else { |
| 111 | + if (virtual_mode?()) { |
| 112 | + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); |
| 113 | + } |
| 114 | + } |
| 115 | + return csr_value.RCID & ((1 `<< RCID_WIDTH) - 1); |
| 116 | +
|
| 117 | + MCID: |
| 118 | + location: 27-16 |
| 119 | + type: RW |
| 120 | + long_name: Monitoring Counter ID |
| 121 | + description: | |
| 122 | + The `MCID` is used to identify a counter to monitor resource usage. |
| 123 | + reset_value: UNDEFINED_LEGAL |
| 124 | + sw_write(csr_value): | |
| 125 | + if (implemented?(ExtensionName::Smstateen)) { |
| 126 | + if (mode() < PrivilegeMode::M && CSR[mstateen0].SRMCFG == 0) { |
| 127 | + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); |
| 128 | + } |
| 129 | + if (virtual_mode?() && CSR[mstateen0].SRMCFG == 1) { |
| 130 | + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); |
| 131 | + } |
| 132 | + } else { |
| 133 | + if (virtual_mode?()) { |
| 134 | + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); |
| 135 | + } |
| 136 | + } |
| 137 | + return csr_value.MCID & ((1 `<< MCID_WIDTH) - 1); |
| 138 | +
|
| 139 | +sw_read(): | |
| 140 | + if (implemented?(ExtensionName::Smstateen)) { |
| 141 | + if (mode() < PrivilegeMode::M && CSR[mstateen0].SRMCFG == 0) { |
| 142 | + raise(ExceptionCode::IllegalInstruction, mode(), $encoding); |
| 143 | + } |
| 144 | + if (virtual_mode?() && CSR[mstateen0].SRMCFG == 1) { |
| 145 | + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); |
| 146 | + } |
| 147 | + } else { |
| 148 | + if (virtual_mode?()) { |
| 149 | + raise(ExceptionCode::VirtualInstruction, mode(), $encoding); |
| 150 | + } |
| 151 | + } |
| 152 | + return $bits(CSR[mstateen0]); |
0 commit comments