@@ -7,6 +7,34 @@ use page_table_entry::loongarch64::LA64PTE;
77
88use crate :: { PageTable64 , PageTable64Mut , PagingMetaData } ;
99
10+ #[ inline]
11+ fn local_flush_tlb ( vaddr : Option < memory_addr:: VirtAddr > ) {
12+ unsafe {
13+ if let Some ( vaddr) = vaddr {
14+ // <https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#_dbar>
15+ //
16+ // Only after all previous load/store access operations are completely
17+ // executed, the DBAR 0 instruction can be executed; and only after the
18+ // execution of DBAR 0 is completed, all subsequent load/store access
19+ // operations can be executed.
20+ //
21+ // <https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#_invtlb>
22+ //
23+ // formats: invtlb op, asid, addr
24+ //
25+ // op 0x5: Clear all page table entries with G=0 and ASID equal to the
26+ // register specified ASID, and VA equal to the register specified VA.
27+ //
28+ // When the operation indicated by op does not require an ASID, the
29+ // general register rj should be set to r0.
30+ asm ! ( "dbar 0; invtlb 0x05, $r0, {reg}" , reg = in( reg) vaddr. as_usize( ) ) ;
31+ } else {
32+ // op 0x0: Clear all page table entries
33+ asm ! ( "dbar 0; invtlb 0x00, $r0, $r0" ) ;
34+ }
35+ }
36+ }
37+
1038/// Metadata of LoongArch64 page tables.
1139#[ derive( Copy , Clone , Debug ) ]
1240pub struct LA64MetaData ;
@@ -51,30 +79,14 @@ impl PagingMetaData for LA64MetaData {
5179
5280 #[ inline]
5381 fn flush_tlb ( vaddr : Option < VirtAddr > ) {
54- unsafe {
55- if let Some ( vaddr) = vaddr {
56- // <https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#_dbar>
57- //
58- // Only after all previous load/store access operations are completely
59- // executed, the DBAR 0 instruction can be executed; and only after the
60- // execution of DBAR 0 is completed, all subsequent load/store access
61- // operations can be executed.
62- //
63- // <https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#_invtlb>
64- //
65- // formats: invtlb op, asid, addr
66- //
67- // op 0x5: Clear all page table entries with G=0 and ASID equal to the
68- // register specified ASID, and VA equal to the register specified VA.
69- //
70- // When the operation indicated by op does not require an ASID, the
71- // general register rj should be set to r0.
72- asm ! ( "dbar 0; invtlb 0x05, $r0, {reg}" , reg = in( reg) vaddr. as_usize( ) ) ;
73- } else {
74- // op 0x0: Clear all page table entries
75- asm ! ( "dbar 0; invtlb 0x00, $r0, $r0" ) ;
76- }
82+ #[ cfg( feature = "smp" ) ]
83+ {
84+ use crate :: __TlbFlushIf_mod;
85+ use crate_interface:: call_interface;
86+
87+ call_interface ! ( TlbFlushIf :: flush_all( vaddr) ) ;
7788 }
89+ local_flush_tlb ( vaddr) ;
7890 }
7991}
8092
0 commit comments