|
| 1 | +# yaml-language-server: $schema=../../schemas/ext_schema.json |
| 2 | + |
| 3 | +Svadu: |
| 4 | + long_name: Hardware Updating of PTE A/D Bits |
| 5 | + type: unprivileged |
| 6 | + description: | |
| 7 | + The Svadu extension adds support and CSR controls for hardware updating of PTE |
| 8 | + A/D bits. The A and D bits are managed by these extensions as follows: |
| 9 | +
|
| 10 | + * When a virtual page is accessed and the A bit is clear, the PTE is updated to |
| 11 | + set the A bit. When the virtual page is written and the D bit is clear, the |
| 12 | + PTE is updated to set the D bit. When G-stage address translation is in use |
| 13 | + and is not Bare, the G-stage virtual pages may be accessed or written by |
| 14 | + implicit accesses to VS-level memory management data structures, such as page |
| 15 | + tables. |
| 16 | +
|
| 17 | + * When two-stage address translation is in use, an explicit access may cause |
| 18 | + both VS-stage and G-stage PTEs to be updated. The following rules apply to all |
| 19 | + PTE updates caused by an explicit or an implicit memory accesses. + |
| 20 | + + |
| 21 | + The PTE update must be atomic with respect to other accesses to the PTE, and |
| 22 | + must atomically perform all tablewalk checks for that leaf PTE as part of, and |
| 23 | + before, conditionally updating the PTE value. Updates of the A bit may be |
| 24 | + performed as a result of speculation, even if the associated memory access |
| 25 | + ultimately is not performed architecturally. However, updates to the D bit, |
| 26 | + resulting from an explicit store, must be exact (i.e., non-speculative), and |
| 27 | + observed in program order by the local hart. When two-stage address |
| 28 | + translation is active, updates of the D bit in G-stage PTEs may be performed |
| 29 | + as a result of speculative updates of the A bit in VS-stage PTEs. + |
| 30 | + + |
| 31 | + The PTE update must appear in the global memory order before the memory access |
| 32 | + that caused the PTE update and before any subsequent explicit memory access to |
| 33 | + that virtual page by the local hart. The ordering on loads and stores provided |
| 34 | + by FENCE instructions and the acquire/release bits on atomic instructions also |
| 35 | + orders the PTE updates associated with those loads and stores as observed by |
| 36 | + remote harts. + |
| 37 | + + |
| 38 | + The PTE update is not required to be atomic with respect to the memory access |
| 39 | + that caused the update and a trap may occur between the PTE update and the |
| 40 | + memory access that caused the PTE update. If a trap occurs then the A and/or D |
| 41 | + bit may be updated but the memory access that caused the PTE update might not |
| 42 | + occur. The hart must not perform the memory access that caused the PTE update |
| 43 | + before the PTE update is globally visible. |
| 44 | +
|
| 45 | + [NOTE] |
| 46 | + ==== |
| 47 | + The PTE updates due to memory accesses ordered-after a FENCE are not themselves |
| 48 | + ordered by the FENCE. |
| 49 | +
|
| 50 | + Simpler implementations that cannot precisely order the PTE update before |
| 51 | + subsequent explicit memory accesses to the associated virtual page by the local |
| 52 | + hart may simply order the PTE update before all subsequent explicit memory |
| 53 | + accesses to any virtual page by the local hart. |
| 54 | + ==== |
| 55 | +
|
| 56 | + Svadu extension requires the page tables to be located in memory with hardware |
| 57 | + page-table write access and _RsrvEventual_ PMA. |
| 58 | +
|
| 59 | + <<< |
| 60 | +
|
| 61 | + The translation of virtual addresses (or guest physical addresses) to physical |
| 62 | + (or guest physical) addresses is accomplished with the same algorithm as |
| 63 | + specified in the Supervisor-Level ISA extension (section "Virtual Address |
| 64 | + Translation Process") and as modified by the hypervisor extension (section |
| 65 | + "Two-stage Address Translation"), except that step 7 of the translation process, |
| 66 | + instead of causing a page-fault exception due to A and/or D bits being 0 when |
| 67 | + required to be 1, continues as follows: |
| 68 | +
|
| 69 | + [start=7] |
| 70 | + . If `pte.a = 0`, or if the original memory access is a store and `pte.d = 0`: |
| 71 | + .. If a store to `pte` would violate a PMA or PMP check, raise an access-fault |
| 72 | + exception corresponding to the original access type. |
| 73 | + .. Perform the following steps atomically: |
| 74 | + ... Compare `pte` to the value of the PTE at address `a + va.vpn[i] * PTESIZE`. |
| 75 | + ... If the values match, set `pte.a` to 1 and, if the original memory access is |
| 76 | + a store, also set `pte.d` to 1. |
| 77 | + ... If the comparison fails, return to step 2 |
| 78 | +
|
| 79 | + The Svadu extension adds the `ADUE` bit (bit 61) to `menvcfg`. When |
| 80 | + `menvcfg.ADUE` is 1, hardware updating of PTE A/D bits is enabled during |
| 81 | + single-stage address translation. When the hypervisor extension is implemented, |
| 82 | + if `menvcfg.ADUE` is 1, hardware updating of PTE A/D bits is enabled during |
| 83 | + G-stage address translation. When `menvcfg.ADUE` is zero, the implementation |
| 84 | + behaves as though Svadu were not implemented. If Svadu is not implemented, |
| 85 | + `menvcfg.ADUE` is read-only zero. Furthermore, for implementations with the |
| 86 | + hypervisor extension, `henvcfg.ADUE` is read-only zero if `menvcfg.ADUE` is zero. |
| 87 | +
|
| 88 | + When the hypervisor extension is implemented, the Svadu extension adds the |
| 89 | + `ADUE` bit (bit 61) to `henvcfg`. When `henvcfg.ADUE` is 1, hardware updating of |
| 90 | + PTE A/D bits is enabled during VS-stage address translation. When `henvcfg.ADUE` |
| 91 | + is zero, the implementation behaves as though Svadu were not implemented for |
| 92 | + VS-stage address translation. |
| 93 | + versions: |
| 94 | + - version: 1.0 |
| 95 | + state: ratified |
| 96 | + ratification_date: 2023-11 |
| 97 | + url: https://github.com/riscvarchive/riscv-svadu/releases/download/v1.0/riscv-svadu.pdf |
| 98 | + repositories: |
| 99 | + - url: https://github.com/riscvarchive/riscv-svadu |
| 100 | + branch: main |
| 101 | + contributors: |
| 102 | + - name: Aaron Durbin |
| 103 | + company: Rivos, Inc. |
| 104 | + - name: Andrew Waterman |
| 105 | + company: SiFive |
| 106 | + - name: Earl Killian |
| 107 | + company: Aril |
| 108 | + - name: Greg Favor |
| 109 | + company: Ventana |
| 110 | + - name: John Ingalls |
| 111 | + company: SiFive |
| 112 | + - name: Ken Dockser |
| 113 | + company: Tenstorrent |
| 114 | + - name: Krste Asanovic |
| 115 | + company: SiFive |
| 116 | + - name: Paul Donahue |
| 117 | + - name: Ved Shanbhogue |
| 118 | + company: Rivos, Inc. |
| 119 | + conflicts: Svade |
| 120 | + doc_license: |
| 121 | + name: Creative Commons Attribution 4.0 International License (CC-BY 4.0) |
| 122 | + url: https://creativecommons.org/licenses/by/4.0/ |
| 123 | + |
0 commit comments