浏览代码

fix(FixEntry): make riscv64 fixup list entry correctly aligned and laid out

greatbridf 7 月之前
父节点
当前提交
d6dcfee4d2
共有 2 个文件被更改,包括 19 次插入23 次删除
  1. 3 3
      src/kernel/mem/mm_list/page_fault.rs
  2. 16 20
      src/kernel/user/dataflow.rs

+ 3 - 3
src/kernel/mem/mm_list/page_fault.rs

@@ -35,15 +35,15 @@ impl FixEntry {
 
     fn entries() -> &'static [FixEntry] {
         extern "C" {
-            static FIX_START: *const FixEntry;
-            static FIX_END: *const FixEntry;
+            fn FIX_START();
+            fn FIX_END();
         }
 
         unsafe {
             // SAFETY: `FIX_START` and `FIX_END` are defined in the
             //         linker script in `.rodata` section.
             core::slice::from_raw_parts(
-                FIX_START,
+                FIX_START as usize as *const FixEntry,
                 (FIX_END as usize - FIX_START as usize) / size_of::<FixEntry>(),
             )
         }

+ 16 - 20
src/kernel/user/dataflow.rs

@@ -142,11 +142,10 @@ impl CheckedUserPointer<'_> {
                 "3:",
                 "nop",
                 ".pushsection .fix, \"a\", @progbits",
-                ".align 16",
-                ".quad 2b",      // instruction address
-                ".quad 3b - 2b", // instruction length
-                ".quad 3b",      // fix jump address
-                ".quad 0x3",     // type: load
+                ".8byte 2b",      // instruction address
+                ".8byte 3b - 2b", // instruction length
+                ".8byte 3b",      // fix jump address
+                ".8byte 0x3",     // type: load
                 ".popsection",
                 inout("a0") total => error_bytes,
                 inout("a1") self.ptr => _,
@@ -203,11 +202,10 @@ impl CheckedUserPointer<'_> {
                 "3:",
                 "nop",
                 ".pushsection .fix, \"a\", @progbits",
-                ".align 16",
-                ".quad 2b",  // instruction address
-                ".quad 3b - 2b",  // instruction length
-                ".quad 3b",  // fix jump address
-                ".quad 0x1", // type: store
+                ".8byte 2b",  // instruction address
+                ".8byte 3b - 2b",  // instruction length
+                ".8byte 3b",  // fix jump address
+                ".8byte 0x1", // type: store
                 ".popsection",
                 inout("a0") total => error_bytes,
                 inout("a1") data => _,
@@ -263,11 +261,10 @@ impl CheckedUserPointer<'_> {
                 "3:",
                 "nop",
                 ".pushsection .fix, \"a\", @progbits",
-                ".align 16",
-                ".quad 2b",  // instruction address
-                ".quad 3b - 2b",  // instruction length
-                ".quad 3b",  // fix jump address
-                ".quad 0x1", // type: store
+                ".8byte 2b",  // instruction address
+                ".8byte 3b - 2b",  // instruction length
+                ".8byte 3b",  // fix jump address
+                ".8byte 0x1", // type: store
                 ".popsection",
                 inout("a0") self.len => error_bytes,
                 inout("a1") self.ptr => _,
@@ -370,11 +367,10 @@ impl<'lt> UserString<'lt> {
                 "3:",
                 "nop",
                 ".pushsection .fix, \"a\", @progbits",
-                ".align 16",
-                ".quad 2b",  // instruction address
-                ".quad 4b - 2b",  // instruction length
-                ".quad 3b",  // fix jump address
-                ".quad 0x2", // type: string
+                ".8byte 2b",  // instruction address
+                ".8byte 4b - 2b",  // instruction length
+                ".8byte 3b",  // fix jump address
+                ".8byte 0x2", // type: string
                 ".popsection",
                 out("t0") _,
                 inout("a0") MAX_LEN => result,