File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -70,10 +70,6 @@ pub fn load_apps() {
70
70
let num_app_ptr = _num_app as usize as * const usize ;
71
71
let num_app = get_num_app ( ) ;
72
72
let app_start = unsafe { core:: slice:: from_raw_parts ( num_app_ptr. add ( 1 ) , num_app + 1 ) } ;
73
- // clear i-cache first
74
- unsafe {
75
- asm ! ( "fence.i" ) ;
76
- }
77
73
// load apps
78
74
for i in 0 ..num_app {
79
75
let base_i = get_base_i ( i) ;
@@ -87,6 +83,15 @@ pub fn load_apps() {
87
83
let dst = unsafe { core:: slice:: from_raw_parts_mut ( base_i as * mut u8 , src. len ( ) ) } ;
88
84
dst. copy_from_slice ( src) ;
89
85
}
86
+ // Memory fence about fetching the instruction memory
87
+ // It is guaranteed that a subsequent instruction fetch must
88
+ // observes all previous writes to the instruction memory.
89
+ // Therefore, fence.i must be executed after we have loaded
90
+ // the code of the next app into the instruction memory.
91
+ // See also: riscv non-priv spec chapter 3, 'Zifencei' extension.
92
+ unsafe {
93
+ asm ! ( "fence.i" ) ;
94
+ }
90
95
}
91
96
92
97
/// get app info with entry and sp and save `TrapContext` in kernel stack
You can’t perform that action at this time.
0 commit comments