Update to latest toolchain.

Multi-core is slightly broken when using the latest version of spin
(0.9.2). I believe this is because Once used to do SeqCst loads/stores
everywhere, which might have made any possible data race much harder to
come by.
This commit is contained in:
4lDO2
2022-03-06 11:35:47 +01:00
parent 80376a95dc
commit 6255bea143
15 changed files with 56 additions and 95 deletions

77
Cargo.lock generated
View File

@@ -4,9 +4,9 @@ version = 3
[[package]]
name = "autocfg"
version = "1.0.1"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bit_field"
@@ -22,9 +22,9 @@ checksum = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719"
[[package]]
name = "bitflags"
version = "1.2.1"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "byteorder"
@@ -34,9 +34,9 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "cc"
version = "1.0.68"
version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"
[[package]]
name = "cfg-if"
@@ -47,7 +47,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "fdt"
version = "0.1.0"
source = "git+https://gitlab.redox-os.org/thomhuds/fdt.git#baca9b0070c281dc99521ee901efcb10e5f84218"
source = "git+https://gitlab.redox-os.org/thomhuds/fdt.git#7358607679114ccab5f97e14894ed3b59c5d42d6"
dependencies = [
"byteorder",
]
@@ -72,10 +72,10 @@ dependencies = [
"cc",
"fdt",
"goblin",
"linked_list_allocator 0.9.0",
"linked_list_allocator 0.9.1",
"log",
"memoffset",
"raw-cpuid 10.2.0",
"raw-cpuid",
"redox_syscall",
"rmm",
"rustc-cfg",
@@ -96,18 +96,18 @@ dependencies = [
[[package]]
name = "linked_list_allocator"
version = "0.9.0"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0b725207570aa16096962d0b20c79f8a543df2280bd3c903022b9b0b4d7ea68"
checksum = "549ce1740e46b291953c4340adcd74c59bcf4308f4cac050fd33ba91b7168f4a"
dependencies = [
"spinning_top",
]
[[package]]
name = "lock_api"
version = "0.4.4"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb"
checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b"
dependencies = [
"scopeguard",
]
@@ -123,9 +123,9 @@ dependencies = [
[[package]]
name = "memoffset"
version = "0.6.4"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9"
checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
dependencies = [
"autocfg",
]
@@ -136,17 +136,6 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
[[package]]
name = "raw-cpuid"
version = "7.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "beb71f708fe39b2c5e98076204c3cc094ee5a4c12c4cdb119a2b72dc34164f41"
dependencies = [
"bitflags",
"cc",
"rustc_version",
]
[[package]]
name = "raw-cpuid"
version = "10.2.0"
@@ -158,7 +147,7 @@ dependencies = [
[[package]]
name = "redox_syscall"
version = "0.2.11"
version = "0.2.12"
dependencies = [
"bitflags",
]
@@ -175,18 +164,9 @@ checksum = "56a596b5718bf5e059d59a30af12f7f462a152de147aa462b70892849ee18704"
[[package]]
name = "rustc-demangle"
version = "0.1.19"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "410f7acf3cb3a44527c5d9546bad4bf4e6c460915d5f9f2fc524498bfe8f70ce"
[[package]]
name = "rustc_version"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
dependencies = [
"semver",
]
checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342"
[[package]]
name = "scopeguard"
@@ -200,21 +180,6 @@ version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fda28d4b4830b807a8b43f7b0e6b5df875311b3e7621d84577188c175b6ec1ec"
[[package]]
name = "semver"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
dependencies = [
"semver-parser",
]
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "slab_allocator"
version = "0.3.1"
@@ -255,11 +220,11 @@ dependencies = [
[[package]]
name = "x86"
version = "0.32.0"
version = "0.47.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8cc872a9a776500ccc6f49799729858738c946b8865fa7e3d6b47cc5dc3a8a7"
checksum = "55b5be8cc34d017d8aabec95bc45a43d0f20e8b2a31a453cabc804fe996f8dca"
dependencies = [
"bit_field",
"bitflags",
"raw-cpuid 7.0.4",
"raw-cpuid",
]

View File

@@ -21,7 +21,8 @@ log = "0.4"
memoffset = { version = "0.6", features = ["unstable_const"] }
redox_syscall = { path = "syscall" }
slab_allocator = { path = "slab_allocator", optional = true }
spin = "0.9"
# FIXME: There is some undefined behavior probably in the kernel, which forces us to use spin 0.9.0 and not 0.9.2.
spin = "=0.9.0"
rmm = { path = "rmm", default-features = false }
[dependencies.goblin]
@@ -39,7 +40,7 @@ fdt = { git = "https://gitlab.redox-os.org/thomhuds/fdt.git", default-features =
[target.'cfg(target_arch = "x86_64")'.dependencies]
raw-cpuid = "10.2.0"
x86 = { version = "0.32.0", default-features = false }
x86 = { version = "0.47.0", default-features = false }
[features]
default = ["acpi", "multi_core", "serial_debug"]

2
rmm

Submodule rmm updated: 37e88ff4d3...e2648005ba

View File

@@ -132,7 +132,7 @@ interrupt_error!(protection, |stack| {
interrupt_error!(page, |stack| {
let cr2: usize;
asm!("mov {}, cr2", out(reg) cr2);
core::arch::asm!("mov {}, cr2", out(reg) cr2);
println!("Page fault: {:>016X}", cr2);
println!(" Present: {}", stack.code & 1 << 0 != 0);
println!(" Write: {}", stack.code & 1 << 1 != 0);

View File

@@ -131,7 +131,7 @@ impl InterruptStack {
let cs: usize;
unsafe {
asm!("mov {}, cs", out(reg) cs);
core::arch::asm!("mov {}, cs", out(reg) cs);
}
if self.iret.cs & CPL_MASK == cs & CPL_MASK {
@@ -140,7 +140,7 @@ impl InterruptStack {
+ mem::size_of::<Self>() // disregard Self
- mem::size_of::<usize>() * 2; // well, almost: rsp and ss need to be excluded as they aren't present
unsafe {
asm!("mov {}, ss", out(reg) all.ss);
core::arch::asm!("mov {}, ss", out(reg) all.ss);
}
} else {
all.rsp = self.iret.rsp;
@@ -406,7 +406,7 @@ macro_rules! interrupt_stack {
$code
}
}
asm!(concat!(
core::arch::asm!(concat!(
// Backup all userspace registers to stack
$save1!(),
"push rax\n",
@@ -462,7 +462,7 @@ macro_rules! interrupt {
$code
}
asm!(concat!(
core::arch::asm!(concat!(
// Backup all userspace registers to stack
swapgs_iff_ring3_fast!(),
"push rax\n",
@@ -517,7 +517,7 @@ macro_rules! interrupt_error {
}
}
asm!(concat!(
core::arch::asm!(concat!(
swapgs_iff_ring3_fast_errorcode!(),
// Move rax into code's place, put code in last instead (to be
// compatible with InterruptStack)

View File

@@ -24,7 +24,7 @@ unsafe fn ps2_interrupt(_index: usize) {
let data: u8;
let status: u8;
asm!("
core::arch::asm!("
sti
nop
cli

View File

@@ -18,13 +18,13 @@ pub use super::device::local_apic::bsp_apic_id;
/// Clear interrupts
#[inline(always)]
pub unsafe fn disable() {
asm!("cli", options(nomem, nostack));
core::arch::asm!("cli", options(nomem, nostack));
}
/// Set interrupts
#[inline(always)]
pub unsafe fn enable() {
asm!("sti", options(nomem, nostack));
core::arch::asm!("sti", options(nomem, nostack));
}
/// Set interrupts and halt
@@ -32,7 +32,7 @@ pub unsafe fn enable() {
/// Performing enable followed by halt is not guaranteed to be atomic, use this instead!
#[inline(always)]
pub unsafe fn enable_and_halt() {
asm!("sti; hlt", options(nomem, nostack));
core::arch::asm!("sti; hlt", options(nomem, nostack));
}
/// Set interrupts and nop
@@ -40,18 +40,18 @@ pub unsafe fn enable_and_halt() {
/// Simply enabling interrupts does not gurantee that they will trigger, use this instead!
#[inline(always)]
pub unsafe fn enable_and_nop() {
asm!("sti; nop", options(nomem, nostack));
core::arch::asm!("sti; nop", options(nomem, nostack));
}
/// Halt instruction
#[inline(always)]
pub unsafe fn halt() {
asm!("hlt", options(nomem, nostack));
core::arch::asm!("hlt", options(nomem, nostack));
}
/// Pause instruction
/// Safe because it is similar to a NOP, and has no memory effects
#[inline(always)]
pub fn pause() {
unsafe { asm!("pause", options(nomem, nostack)); }
unsafe { core::arch::asm!("pause", options(nomem, nostack)); }
}

View File

@@ -52,7 +52,7 @@ pub unsafe extern "C" fn __inner_syscall_instruction(stack: *mut InterruptStack)
with_interrupt_stack!(|stack| {
// Set a restore point for clone
let rbp;
asm!("mov {}, rbp", out(reg) rbp);
core::arch::asm!("mov {}, rbp", out(reg) rbp);
let scratch = &stack.scratch;
syscall::syscall(scratch.rax, scratch.rdi, scratch.rsi, scratch.rdx, scratch.r10, scratch.r8, rbp, stack)
@@ -61,7 +61,7 @@ pub unsafe extern "C" fn __inner_syscall_instruction(stack: *mut InterruptStack)
#[naked]
pub unsafe extern "C" fn syscall_instruction() {
asm!(concat!(
core::arch::asm!(concat!(
// Yes, this is magic. No, you don't need to understand
"
swapgs // Set gs segment to TSS
@@ -154,7 +154,7 @@ interrupt_stack!(syscall, |stack| {
// Set a restore point for clone
let rbp;
asm!("mov {}, rbp", out(reg) rbp);
core::arch::asm!("mov {}, rbp", out(reg) rbp);
let scratch = &stack.scratch;
syscall::syscall(scratch.rax, stack.preserved.rbx, scratch.rcx, scratch.rdx, scratch.rsi, scratch.rdi, rbp, stack)
@@ -163,7 +163,7 @@ interrupt_stack!(syscall, |stack| {
#[naked]
pub unsafe extern "C" fn clone_ret() {
asm!(concat!(
core::arch::asm!(concat!(
// The address of this instruction is injected by `clone` in process.rs, on
// top of the stack syscall->inner in this file, which is done using the rbp
// register we save there.

View File

@@ -9,7 +9,7 @@ use crate::paging::{ActivePageTable, TableKind, VirtualAddress};
#[inline(never)]
pub unsafe fn stack_trace() {
let mut rbp: usize;
asm!("mov {}, rbp", out(reg) rbp);
core::arch::asm!("mov {}, rbp", out(reg) rbp);
println!("TRACE: {:>016X}", rbp);
//Maximum 64 frames

View File

@@ -350,11 +350,10 @@ macro_rules! restore_fsgsbase(
);
#[naked]
#[inline(never)]
// TODO: AbiCompatBool
pub unsafe extern "C" fn usermode(_ip: usize, _sp: usize, _arg: usize, _is_singlestep: usize) -> ! {
// rdi, rsi, rdx, rcx
asm!(
core::arch::asm!(
concat!("
shl rcx, {shift_singlestep}
or rcx, {flag_interrupts}

View File

@@ -20,9 +20,11 @@ pub unsafe extern fn kreset() -> ! {
}
// Use triple fault to guarantee reset
asm!("cli");
asm!("lidt cs:0");
asm!("int $3");
core::arch::asm!("
cli
lidt cs:0
int $3
");
unreachable!();
}
@@ -87,6 +89,6 @@ pub unsafe extern fn kstop() -> ! {
// Magic code for VMWare. Also a hard lock.
println!("Shutdown with cli hlt");
loop {
asm!("cli; hlt");
core::arch::asm!("cli; hlt");
}
}

View File

@@ -202,12 +202,11 @@ macro_rules! switch_fsgsbase(
/// Switch to the next context by restoring its stack and registers
/// Check disassembly!
#[inline(never)]
#[naked]
pub unsafe extern "C" fn switch_to(_prev: &mut Context, _next: &mut Context) {
use Context as Cx;
asm!(
core::arch::asm!(
// As a quick reminder for those who are unfamiliar with the System V ABI (extern "C"):
//
// - the current parameters are passed in the registers `rdi`, `rsi`,
@@ -339,7 +338,7 @@ unsafe extern fn signal_handler_wrapper() {
}
// Push scratch registers
asm!(
core::arch::asm!(
"
push rax
push rcx

View File

@@ -43,16 +43,12 @@
#![deny(unused_must_use)]
#![feature(allocator_api)]
#![feature(asm)] // TODO: Relax requirements of most asm invocations
#![feature(asm_const, asm_sym)] // TODO: Relax requirements of most asm invocations
#![cfg_attr(target_arch = "aarch64", feature(llvm_asm))] // TODO: Rewrite using asm!
#![feature(concat_idents)]
#![feature(const_btree_new)]
#![feature(const_maybe_uninit_as_ptr)]
#![feature(const_panic)]
#![feature(const_ptr_offset_from)]
#![feature(const_raw_ptr_deref)]
#![feature(core_intrinsics)]
#![feature(global_asm)]
#![feature(integer_atomics)]
#![feature(lang_items)]
#![feature(naked_functions)]

Submodule syscall updated: 87ffd8b862...94de991da2

View File

@@ -19,11 +19,10 @@
"relocation-model": "pic",
"code-model": "kernel",
"disable-redzone": true,
"eliminate-frame-pointer": false,
"frame-pointer": "always",
"exe-suffix": "",
"has-rpath": false,
"no-compiler-rt": true,
"no-default-libraries": true,
"position-independent-executables": false,
"has-elf-tls": true
"tls-model": "global-dynamic"
}