Merge branch 'less_unstable_features' into 'master'

Remove a couple of unstable feature uses

See merge request redox-os/bootstrap!6
This commit is contained in:
Jeremy Soller
2024-03-10 15:13:45 +00:00
4 changed files with 101 additions and 133 deletions
+32 -34
View File
@@ -18,42 +18,40 @@ static MAP: Map = Map {
address: STACK_START, // highest possible user address
};
#[naked]
#[no_mangle]
pub unsafe extern "C" fn ustart() {
core::arch::asm!(
"
// Setup a stack.
ldr x8, ={number}
ldr x0, ={fd}
ldr x1, ={map} // pointer to Map struct
ldr x2, ={map_size} // size of Map struct
svc 0
core::arch::global_asm!(
"
.globl ustart
ustart:
// Setup a stack.
ldr x8, ={number}
ldr x0, ={fd}
ldr x1, ={map} // pointer to Map struct
ldr x2, ={map_size} // size of Map struct
svc 0
// Failure if return value is zero
cbz x0, 1f
// Failure if return value is zero
cbz x0, 1f
// Failure if return value is negative
tbnz x0, 63, 1f
// Failure if return value is negative
tbnz x0, 63, 1f
// Set up stack frame
mov sp, x0
add sp, sp, #{stack_size}
mov fp, sp
// Set up stack frame
mov sp, x0
add sp, sp, #{stack_size}
mov fp, sp
// Stack has the same alignment as `size`.
bl start
// `start` must never return.
// Stack has the same alignment as `size`.
bl start
// `start` must never return.
// failure, emit undefined instruction
1:
udf #0
",
fd = const usize::MAX, // dummy fd indicates anonymous map
map = sym MAP,
map_size = const mem::size_of::<Map>(),
number = const SYS_FMAP,
stack_size = const STACK_SIZE,
options(noreturn),
);
}
// failure, emit undefined instruction
1:
udf #0
",
fd = const usize::MAX, // dummy fd indicates anonymous map
map = sym MAP,
map_size = const mem::size_of::<Map>(),
number = const SYS_FMAP,
stack_size = const STACK_SIZE,
options(noreturn),
);
+34 -41
View File
@@ -1,9 +1,5 @@
use core::mem;
use syscall::{
data::Map,
flag::MapFlags,
number::SYS_FMAP,
};
use syscall::{data::Map, flag::MapFlags, number::SYS_FMAP};
const STACK_SIZE: usize = 64 * 1024; // 64 KiB
pub const STACK_START: usize = 0x8000_0000 - STACK_SIZE;
@@ -12,44 +8,41 @@ static MAP: Map = Map {
offset: 0,
size: STACK_SIZE,
flags: MapFlags::PROT_READ
.union(MapFlags::PROT_WRITE)
.union(MapFlags::MAP_PRIVATE)
.union(MapFlags::MAP_FIXED_NOREPLACE),
.union(MapFlags::PROT_WRITE)
.union(MapFlags::MAP_PRIVATE)
.union(MapFlags::MAP_FIXED_NOREPLACE),
address: STACK_START, // highest possible user address
};
#[naked]
#[no_mangle]
pub unsafe extern "C" fn ustart() {
core::arch::asm!(
"
# Setup a stack.
mov eax, {number}
mov ebx, {fd}
mov ecx, offset {map} # pointer to Map struct
mov edx, {map_size} # size of Map struct
int 0x80
core::arch::global_asm!(
"
.globl ustart
ustart:
# Setup a stack.
mov eax, {number}
mov ebx, {fd}
mov ecx, offset {map} # pointer to Map struct
mov edx, {map_size} # size of Map struct
int 0x80
# Test for success (nonzero value).
cmp eax, 0
jg 1f
# (failure)
ud2
1:
# Subtract 16 since all instructions seem to hate non-canonical ESP values :)
lea esp, [eax+{stack_size}-16]
mov ebp, esp
# Test for success (nonzero value).
cmp eax, 0
jg 1f
# (failure)
ud2
1:
# Subtract 16 since all instructions seem to hate non-canonical ESP values :)
lea esp, [eax+{stack_size}-16]
mov ebp, esp
# Stack has the same alignment as `size`.
call start
# `start` must never return.
ud2
",
fd = const usize::MAX, // dummy fd indicates anonymous map
map = sym MAP,
map_size = const mem::size_of::<Map>(),
number = const SYS_FMAP,
stack_size = const STACK_SIZE,
options(noreturn),
);
}
# Stack has the same alignment as `size`.
call start
# `start` must never return.
ud2
",
fd = const usize::MAX, // dummy fd indicates anonymous map
map = sym MAP,
map_size = const mem::size_of::<Map>(),
number = const SYS_FMAP,
stack_size = const STACK_SIZE,
);
+1 -17
View File
@@ -1,11 +1,7 @@
#![no_std]
#![feature(
asm_const,
alloc_error_handler,
core_intrinsics,
lang_items,
naked_functions,
panic_info_message
)]
#[cfg(target_arch = "aarch64")]
@@ -41,22 +37,10 @@ fn panic_handler(info: &core::panic::PanicInfo) -> ! {
}
}
let _ = syscall::write(1, b"panic: ");
if let Some(message) = info.message() {
writeln!(&mut Writer, "{}", message).unwrap();
} else {
let _ = syscall::write(1, b"(explicit panic)\n");
}
let _ = writeln!(&mut Writer, "{}", info);
core::intrinsics::abort();
}
#[alloc_error_handler]
fn alloc_error_handler(_: core::alloc::Layout) -> ! {
core::intrinsics::abort();
}
#[lang = "eh_personality"]
extern "C" fn rust_eh_personality() {}
#[cfg(target_pointer_width = "32")]
const HEAP_OFF: usize = 0x4000_0000;
+34 -41
View File
@@ -1,9 +1,5 @@
use core::mem;
use syscall::{
data::Map,
flag::MapFlags,
number::SYS_FMAP,
};
use syscall::{data::Map, flag::MapFlags, number::SYS_FMAP};
const STACK_SIZE: usize = 64 * 1024; // 64 KiB
@@ -13,44 +9,41 @@ static MAP: Map = Map {
offset: 0,
size: STACK_SIZE,
flags: MapFlags::PROT_READ
.union(MapFlags::PROT_WRITE)
.union(MapFlags::MAP_PRIVATE)
.union(MapFlags::MAP_FIXED_NOREPLACE),
.union(MapFlags::PROT_WRITE)
.union(MapFlags::MAP_PRIVATE)
.union(MapFlags::MAP_FIXED_NOREPLACE),
address: STACK_START, // highest possible user address
};
#[naked]
#[no_mangle]
pub unsafe extern "C" fn ustart() {
core::arch::asm!(
"
# Setup a stack.
mov rax, {number}
mov rdi, {fd}
mov rsi, offset {map} # pointer to Map struct
mov rdx, {map_size} # size of Map struct
syscall
core::arch::global_asm!(
"
.globl ustart
ustart:
# Setup a stack.
mov rax, {number}
mov rdi, {fd}
mov rsi, offset {map} # pointer to Map struct
mov rdx, {map_size} # size of Map struct
syscall
# Test for success (nonzero value).
cmp rax, 0
jg 1f
# (failure)
ud2
1:
# Subtract 16 since all instructions seem to hate non-canonical RSP values :)
lea rsp, [rax+{stack_size}-16]
mov rbp, rsp
# Test for success (nonzero value).
cmp rax, 0
jg 1f
# (failure)
ud2
1:
# Subtract 16 since all instructions seem to hate non-canonical RSP values :)
lea rsp, [rax+{stack_size}-16]
mov rbp, rsp
# Stack has the same alignment as `size`.
call start
# `start` must never return.
ud2
",
fd = const usize::MAX, // dummy fd indicates anonymous map
map = sym MAP,
map_size = const mem::size_of::<Map>(),
number = const SYS_FMAP,
stack_size = const STACK_SIZE,
options(noreturn),
);
}
# Stack has the same alignment as `size`.
call start
# `start` must never return.
ud2
",
fd = const usize::MAX, // dummy fd indicates anonymous map
map = sym MAP,
map_size = const mem::size_of::<Map>(),
number = const SYS_FMAP,
stack_size = const STACK_SIZE,
);