mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
xen/riscv: rework the A/D bits comment in p2m_set_pte_flags()
The comment in p2m_set_pte_flags() quotes the spec at length to describe the two A/D bits schemes, and its TODO mixes two things: why A/D are preset today (OpenSBI delegates the resulting page faults to a lower privilege mode, so Xen would take them with no handler) and what remains to be done. Summarize the two schemes as a short list. The reason for presetting A/D is not future work, so move it out of the TODO, next to the schemes. The TODO now keeps only the later work, handling these page faults instead of presetting A/D, which only concerns Svade as A/D page faults cannot happen otherwise. Also note that presetting the A/D bits is harmless when the device tree advertises both Svade and Svadu and the platform uses hardware A/D updating. No functional change. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Baptiste Le Duc <baptiste.le-duc@vates.tech> Reviewed-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> Acked-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
73b802624a
commit
8a9a4bcd7c
1 file changed
+19
-26
+19
-26
@@ -591,35 +591,28 @@ static void p2m_set_pte_flags(pte_t *e, p2m_type_t t)
|
|||||||
e->pte |= PTE_USER;
|
e->pte |= PTE_USER;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Two schemes to manage the A and D bits are defined:
|
* A RISC-V implementation can either:
|
||||||
* • The Svade extension: when a virtual page is accessed and the A bit
|
* 1) Update the 'A' and 'D' PTE bits in hardware.
|
||||||
* is clear, or is written and the D bit is clear, a page-fault
|
* 2) Generate a page fault when 'A' and/or 'D' is clear, so that
|
||||||
* exception is raised.
|
* software can set them.
|
||||||
* • When the Svade extension is not implemented, the following scheme
|
|
||||||
* applies.
|
|
||||||
* When a virtual page is accessed and the A bit is clear, the PTE is
|
|
||||||
* updated to set the A bit. When the virtual page is written and the
|
|
||||||
* D bit is clear, the PTE is updated to set the D bit. When G-stage
|
|
||||||
* address translation is in use and is not Bare, the G-stage virtual
|
|
||||||
* pages may be accessed or written by implicit accesses to VS-level
|
|
||||||
* memory management data structures, such as page tables.
|
|
||||||
* Thereby to avoid a page-fault in case of Svade is available, it is
|
|
||||||
* necessary to set A and D bits.
|
|
||||||
*
|
*
|
||||||
* TODO: For now, it’s fine to simply set the A/D bits, since OpenSBI
|
* (1) needs nothing more as it is handled by hardware. For (2), set 'A'
|
||||||
* delegates page faults to a lower privilege mode and so OpenSBI
|
* and 'D' up front: OpenSBI delegates such page faults to a lower
|
||||||
* isn't expect to handle page-faults occured in lower modes.
|
* privilege mode, so they would be raised in Xen, which has no handler
|
||||||
* By setting the A/D bits here, page faults that would otherwise
|
* for them.
|
||||||
* be generated due to unset A/D bits will not occur in Xen.
|
|
||||||
*
|
*
|
||||||
* Currently, Xen on RISC-V does not make use of the information
|
* If both Svade and Svadu are advertised and the CPU updates A/D in
|
||||||
* that could be obtained from handling such page faults, which
|
* hardware, presetting them is harmless.
|
||||||
* could otherwise be useful for several use cases such as demand
|
|
||||||
* paging, cache-flushing optimizations, memory access tracking,etc.
|
|
||||||
*
|
*
|
||||||
* To support the more general case and the optimizations mentioned
|
* TODO: Xen on RISC-V currently makes no use of the information that
|
||||||
* above, it would be better to stop setting the A/D bits here and
|
* handling such page faults could provide, which would be useful
|
||||||
* instead handle page faults that occur due to unset A/D bits.
|
* for several use cases such as demand paging, cache-flushing
|
||||||
|
* optimizations, memory access tracking, etc.
|
||||||
|
*
|
||||||
|
* To support the more general case and the optimizations
|
||||||
|
* mentioned above, it would be better to stop setting the A/D
|
||||||
|
* bits here and instead handle the page faults that occur due to
|
||||||
|
* unset A/D bits.
|
||||||
*/
|
*/
|
||||||
if ( riscv_isa_extension_available(NULL, RISCV_ISA_EXT_svade) )
|
if ( riscv_isa_extension_available(NULL, RISCV_ISA_EXT_svade) )
|
||||||
e->pte |= PTE_ACCESSED | PTE_DIRTY;
|
e->pte |= PTE_ACCESSED | PTE_DIRTY;
|
||||||
|
|||||||