diff --git a/Cargo.lock b/Cargo.lock index 1e2bffd..75d8620 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -26,9 +26,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cc" -version = "1.0.67" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" +checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" [[package]] name = "cfg-if" @@ -115,22 +115,9 @@ dependencies = [ [[package]] name = "paste" -version = "0.1.18" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" -dependencies = [ - "paste-impl", - "proc-macro-hack", -] - -[[package]] -name = "paste-impl" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" -dependencies = [ - "proc-macro-hack", -] +checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" [[package]] name = "plain" @@ -138,12 +125,6 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - [[package]] name = "raw-cpuid" version = "7.0.4" diff --git a/Cargo.toml b/Cargo.toml index 2c38985..c7fb591 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ log = { version = "0.4" } redox_syscall = { path = "syscall" } slab_allocator = { path = "slab_allocator", optional = true } spin = "0.5.2" -paste = "0.1.18" +paste = "1" rmm = { path = "rmm", default-features = false } [dependencies.goblin] @@ -59,8 +59,5 @@ slab = ["slab_allocator"] # Kernel doesn't yet work great with debug mode :( opt-level = 3 -# LTO fixes some duplicate symbols of memcpy/memmove/etc -lto = true - [profile.release] lto = true diff --git a/src/arch/x86_64/interrupt/handler.rs b/src/arch/x86_64/interrupt/handler.rs index d5a93be..cde79a1 100644 --- a/src/arch/x86_64/interrupt/handler.rs +++ b/src/arch/x86_64/interrupt/handler.rs @@ -215,6 +215,8 @@ macro_rules! function { ".global ", stringify!($name), "\n", ".type ", stringify!($name), ", @function\n", ".section .text.", stringify!($name), ", \"ax\", @progbits\n", + // Align the function to a 16-byte boundary, padding with multi-byte NOPs. + ".p2align 4,,15\n", stringify!($name), ":\n", $($body),+, ".size ", stringify!($name), ", . - ", stringify!($name), "\n", @@ -325,15 +327,15 @@ macro_rules! interrupt_stack { ($name:ident, super_atomic: $is_super_atomic:ident!, |$stack:ident| $code:block) => { paste::item! { #[no_mangle] - unsafe extern "C" fn [<__interrupt_ $name>](stack: *mut $crate::arch::x86_64::interrupt::InterruptStack) { - // This inner function is needed because macros are buggy: - // https://github.com/dtolnay/paste/issues/7 - #[inline(always)] - unsafe fn inner($stack: &mut $crate::arch::x86_64::interrupt::InterruptStack) { + unsafe extern "C" fn [<__interrupt_ $name>]($stack: &mut $crate::arch::x86_64::interrupt::InterruptStack) { + let _guard = $crate::ptrace::set_process_regs($stack); + + // TODO: Force the declarations to specify unsafe? + + #[allow(unused_unsafe)] + unsafe { $code } - let _guard = $crate::ptrace::set_process_regs(stack); - inner(&mut *stack); } function!($name => { @@ -404,15 +406,13 @@ macro_rules! interrupt_error { ($name:ident, |$stack:ident| $code:block) => { paste::item! { #[no_mangle] - unsafe extern "C" fn [<__interrupt_ $name>](stack: *mut $crate::arch::x86_64::interrupt::handler::InterruptErrorStack) { - // This inner function is needed because macros are buggy: - // https://github.com/dtolnay/paste/issues/7 - #[inline(always)] - unsafe fn inner($stack: &mut $crate::arch::x86_64::interrupt::handler::InterruptErrorStack) { + unsafe extern "C" fn [<__interrupt_ $name>]($stack: &mut $crate::arch::x86_64::interrupt::handler::InterruptErrorStack) { + let _guard = $crate::ptrace::set_process_regs(&mut $stack.inner); + + #[allow(unused_unsafe)] + unsafe { $code } - let _guard = $crate::ptrace::set_process_regs(&mut (*stack).inner); - inner(&mut *stack); } function!($name => {