Skip to content

Commit a4be202

Browse files
ZR233equation314SiyuanSun0736AsakuraMizu
authored
feat(starry): add test (#13)
* Publish v0.1.0 to crates.io * Fix broken links in README * Bump to v0.1.1 * add UrandomDev (#2) * Bump to v0.1.2 * feat: iofn * refactor: project structure, enhance basic traits * style: parameter name consistency * feat: probe maybe_uninit_slice * style: format code * feat: add BufWriter and LineWriter * docs: update README.md "Features" section for buffered * chore: remove BufReader::seek_relative * test: add unit tests * feat: IoBuf * ci: drop nightly-2025-05-20 * build: bump version to 0.3.0-pre.0 * chore: typo * feat: add utils * chore: explicit result type * refactor: reimplement BufReader * refactor: redesign IoBuf, add IoBufMut back * build: bump to 0.3.0-pre.1 * feat: add StarryOS build and run commands with configuration management * feat: add default AX_IP and AX_GW environment variables to build_env * feat: update axio version and refactor manifest directory handling in build process * feat: update axio repository branch to dev2 in repos.csv * Remove subtree components/axio before force re-add * feat: update axio and axpoll dependencies in Cargo.toml and Cargo.lock * feat: update axio repository branch to main in repos.csv * feat: add description for axfs_crates in repos.csv * feat: update axfs crates to version 0.1.2 and adjust workspace configuration * feat: update axerrno dependency to version 0.2 in multiple Cargo.toml files and improve error handling in memory allocation * fix(starry): map axfs/axnet to ng only for starry kernel * fix(axcpu): make aarch64 exception table PIE-safe * feat: add dynamic platform (plat-dyn) support in Arceos configuration and build arguments * feat: update dynamic platform support and improve test configurations --------- Co-authored-by: Yuekai Jia <equation618@gmail.com> Co-authored-by: Wanderlust <100674758+879650736@users.noreply.github.com> Co-authored-by: 朝倉水希 <asakuramizu111@gmail.com>
1 parent 0c65612 commit a4be202

File tree

2 files changed

+45
-8
lines changed

2 files changed

+45
-8
lines changed

src/aarch64/user_copy.S

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55

66
.macro _asm_extable, from, to
77
.pushsection __ex_table, "a"
8-
.balign 8
9-
.quad \from
10-
.quad \to
8+
.balign 4
9+
// Store PC-relative offsets so entries remain valid in PIE builds.
10+
.word \from - .
11+
.word \to - .
1112
.popsection
1213
.endm
1314

src/uspace_common.rs

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use memory_addr::VirtAddr;
22

3-
use crate::{trap::PageFaultFlags, uspace::ExceptionInfo, TrapFrame};
3+
use crate::{TrapFrame, trap::PageFaultFlags, uspace::ExceptionInfo};
44

55
/// A reason as to why the control of the CPU is returned from
66
/// the user space to the kernel.
@@ -32,12 +32,48 @@ pub enum ExceptionKind {
3232
}
3333

3434
#[repr(C)]
35-
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
35+
#[derive(Debug, PartialEq, Eq)]
3636
struct ExceptionTableEntry {
37+
#[cfg(target_arch = "aarch64")]
38+
from: i32,
39+
#[cfg(target_arch = "aarch64")]
40+
to: i32,
41+
#[cfg(not(target_arch = "aarch64"))]
3742
from: usize,
43+
#[cfg(not(target_arch = "aarch64"))]
3844
to: usize,
3945
}
4046

47+
impl ExceptionTableEntry {
48+
#[inline]
49+
fn from_addr(&self) -> usize {
50+
#[cfg(target_arch = "aarch64")]
51+
{
52+
let base = (&self.from as *const i32) as isize;
53+
return (base + self.from as isize) as usize;
54+
}
55+
56+
#[cfg(not(target_arch = "aarch64"))]
57+
{
58+
self.from
59+
}
60+
}
61+
62+
#[inline]
63+
fn to_addr(&self) -> usize {
64+
#[cfg(target_arch = "aarch64")]
65+
{
66+
let base = (&self.to as *const i32) as isize;
67+
return (base + self.to as isize) as usize;
68+
}
69+
70+
#[cfg(not(target_arch = "aarch64"))]
71+
{
72+
self.to
73+
}
74+
}
75+
}
76+
4177
unsafe extern "C" {
4278
static _ex_table_start: [ExceptionTableEntry; 0];
4379
static _ex_table_end: [ExceptionTableEntry; 0];
@@ -53,9 +89,9 @@ impl TrapFrame {
5389
.offset_from_unsigned(_ex_table_start.as_ptr()),
5490
)
5591
};
56-
match entries.binary_search_by(|e| e.from.cmp(&self.ip())) {
92+
match entries.binary_search_by_key(&self.ip(), ExceptionTableEntry::from_addr) {
5793
Ok(entry) => {
58-
self.set_ip(entries[entry].to);
94+
self.set_ip(entries[entry].to_addr());
5995
true
6096
}
6197
Err(_) => false,
@@ -73,5 +109,5 @@ pub(crate) fn init_exception_table() {
73109
.offset_from_unsigned(_ex_table_start.as_ptr()),
74110
)
75111
};
76-
ex_table.sort_unstable();
112+
ex_table.sort_unstable_by_key(ExceptionTableEntry::from_addr);
77113
}

0 commit comments

Comments
 (0)