Skip to content

Commit 5058a48

Browse files
bors[bot]mkroening
andauthored
Merge #651
651: Disable many unstable Rust features r=stlankes a=mkroening Co-authored-by: Martin Kröning <mkroening@posteo.net>
2 parents 5aa86e4 + c0cea62 commit 5058a48

File tree

12 files changed

+43
-86
lines changed

12 files changed

+43
-86
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ENV RUSTUP_HOME=/usr/local/rustup \
55
CARGO_HOME=/usr/local/cargo \
66
PATH=/usr/local/cargo/bin:$PATH \
77
# Manually sync this with rust-toolchain.toml!
8-
RUST_VERSION=nightly-2022-12-12 \
8+
RUST_VERSION=nightly-2023-02-07 \
99
RUST_COMPONENTS="llvm-tools-preview rust-src" \
1010
RUST_TARGETS="x86_64-unknown-none"
1111

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[toolchain]
22
# Manually sync this with Dockerfile!
3-
channel = "nightly-2022-12-12"
3+
channel = "nightly-2023-02-07"
44
components = [
55
"llvm-tools-preview",
66
"rust-src",

src/arch/x86_64/kernel/scheduler.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,7 @@ impl TaskTLS {
274274
// So the thread pointer needs to be `block_ptr + tls_offset`.
275275
// Allocating only tls_len bytes would be enough to hold the TLS block.
276276
// For the thread pointer to be sound though, we need it's value to be included in or one byte past the same allocation.
277-
let block = Box::<[u8]>::new_zeroed_slice(tls_offset);
278-
279-
// SAFETY: All u8s can hold the bit-pattern 0 as a valid value
280-
unsafe { block.assume_init() }
277+
vec![0; tls_offset].into_boxed_slice()
281278
};
282279

283280
// Initialize beginning of the TLS block with TLS initialization image

src/drivers/net/rtl8139.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -519,19 +519,8 @@ pub fn init_device(adapter: &pci::PciAdapter) -> Result<RTL8139Driver, DriverErr
519519
outl(iobase + TCR, TCR_IFG | TCR_MXDMA0 | TCR_MXDMA1 | TCR_MXDMA2);
520520
}
521521

522-
let rxbuffer = Box::<[u8]>::try_new_zeroed_slice(RX_BUF_LEN).map_err(|_| {
523-
error!("Unable to allocate buffers for RTL8139");
524-
DriverError::InitRTL8139DevFail(RTL8139Error::Unknown)
525-
})?;
526-
// SAFETY: All u8s can hold the bit-pattern 0 as a valid value
527-
let rxbuffer = unsafe { rxbuffer.assume_init() };
528-
529-
let txbuffer = Box::<[u8]>::try_new_zeroed_slice(NO_TX_BUFFERS * TX_BUF_LEN).map_err(|_| {
530-
error!("Unable to allocate buffers for RTL8139");
531-
DriverError::InitRTL8139DevFail(RTL8139Error::Unknown)
532-
})?;
533-
// SAFETY: All u8s can hold the bit-pattern 0 as a valid value
534-
let txbuffer = unsafe { txbuffer.assume_init() };
522+
let rxbuffer = vec![0; RX_BUF_LEN].into_boxed_slice();
523+
let txbuffer = vec![0; NO_TX_BUFFERS * TX_BUF_LEN].into_boxed_slice();
535524

536525
debug!(
537526
"Allocate TxBuffer at {:p} and RxBuffer at {:p}",

src/drivers/virtio/virtqueue/packed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ impl PackedVq {
10251025
if !self.dropped.borrow().is_empty() {
10261026
self.dropped
10271027
.borrow_mut()
1028-
.drain_filter(|tkn| tkn.state == TransferState::Finished);
1028+
.retain(|tkn| tkn.state != TransferState::Finished);
10291029
}
10301030
}
10311031

src/drivers/virtio/virtqueue/split.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl SplitVq {
271271
if !self.dropped.borrow().is_empty() {
272272
self.dropped
273273
.borrow_mut()
274-
.drain_filter(|tkn| tkn.state == TransferState::Finished);
274+
.retain(|tkn| tkn.state != TransferState::Finished);
275275
}
276276
}
277277

src/lib.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,13 @@
77
#![warn(clippy::transmute_ptr_to_ptr)]
88
#![allow(clippy::missing_safety_doc)]
99
#![allow(incomplete_features)]
10-
#![feature(abi_x86_interrupt)]
10+
#![cfg_attr(target_arch = "x86_64", feature(abi_x86_interrupt))]
1111
#![feature(allocator_api)]
12-
#![feature(atomic_mut_ptr)]
1312
#![feature(asm_const)]
14-
#![feature(const_mut_refs)]
1513
#![feature(linked_list_cursors)]
1614
#![feature(naked_functions)]
17-
#![feature(new_uninit)]
1815
#![feature(specialization)]
19-
#![feature(core_intrinsics)]
20-
#![feature(alloc_error_handler)]
21-
#![feature(vec_into_raw_parts)]
22-
#![feature(drain_filter)]
2316
#![feature(strict_provenance)]
24-
#![feature(map_try_insert)]
25-
#![feature(is_some_and)]
2617
#![cfg_attr(target_os = "none", no_std)]
2718
#![cfg_attr(target_os = "none", feature(custom_test_frameworks))]
2819
#![cfg_attr(all(target_os = "none", test), test_runner(crate::test_runner))]
@@ -82,8 +73,6 @@ pub(crate) mod fd;
8273
mod mm;
8374
#[cfg(feature = "tcp")]
8475
mod net;
85-
#[cfg(target_os = "none")]
86-
mod runtime_glue;
8776
mod scheduler;
8877
mod synch;
8978
mod syscalls;
@@ -385,3 +374,12 @@ fn application_processor_main() -> ! {
385374
// Run the scheduler loop.
386375
core_scheduler.run();
387376
}
377+
378+
#[cfg(target_os = "none")]
379+
#[panic_handler]
380+
fn panic(info: &core::panic::PanicInfo<'_>) -> ! {
381+
let core_id = crate::arch::core_local::core_id();
382+
println!("[{core_id}][PANIC] {info}");
383+
384+
crate::syscalls::shutdown(1)
385+
}

src/runtime_glue.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

src/scheduler/task.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,8 @@ impl TaskHandlePriorityQueue {
168168
/// Checks if the given task is in the queue. Returns `true` if the task
169169
/// was found.
170170
pub fn contains(&self, task: TaskHandle) -> bool {
171-
self.queues[task.priority.into() as usize]
172-
.as_ref()
173-
.is_some_and(|queue| queue.iter().any(|queued| queued.id == task.id))
171+
matches!(self.queues[task.priority.into() as usize]
172+
.as_ref(), Some(queue) if queue.iter().any(|queued| queued.id == task.id))
174173
}
175174

176175
/// Add a task handle by its priority to the queue

src/synch/futex.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ bitflags! {
2222
}
2323
}
2424

25+
fn addr(addr: &AtomicU32) -> usize {
26+
let ptr: *const _ = addr;
27+
ptr.addr()
28+
}
29+
2530
/// If the value at address matches the expected value, park the current thread until it is either
2631
/// woken up with `futex_wake` (returns 0) or the specified timeout elapses (returns -ETIMEDOUT).
2732
///
@@ -44,20 +49,17 @@ pub fn futex_wait(address: &AtomicU32, expected: u32, timeout: Option<u64>, flag
4449
let scheduler = core_scheduler();
4550
scheduler.block_current_task(wakeup_time);
4651
let handle = scheduler.get_current_task_handle();
47-
parking_lot
48-
.entry(address.as_mut_ptr().addr())
49-
.or_default()
50-
.push(handle);
52+
parking_lot.entry(addr(address)).or_default().push(handle);
5153
drop(parking_lot);
5254

5355
loop {
5456
scheduler.reschedule();
5557

5658
let mut parking_lot = PARKING_LOT.lock();
57-
if wakeup_time.is_some_and(|t| t <= get_timer_ticks()) {
59+
if matches!(wakeup_time, Some(t) if t <= get_timer_ticks()) {
5860
let mut wakeup = true;
5961
// Timeout occurred, try to remove ourselves from the waiting queue.
60-
if let Entry::Occupied(mut queue) = parking_lot.entry(address.as_mut_ptr().addr()) {
62+
if let Entry::Occupied(mut queue) = parking_lot.entry(addr(address)) {
6163
// If we are not in the waking queue, this must have been a wakeup.
6264
wakeup = !queue.get_mut().remove(handle);
6365
if queue.get().is_empty() {
@@ -72,9 +74,8 @@ pub fn futex_wait(address: &AtomicU32, expected: u32, timeout: Option<u64>, flag
7274
}
7375
} else {
7476
// If we are not in the waking queue, this must have been a wakeup.
75-
let wakeup = !parking_lot
76-
.get(&address.as_mut_ptr().addr())
77-
.is_some_and(|queue| queue.contains(handle));
77+
let wakeup = !matches!(parking_lot
78+
.get(&addr(address)), Some(queue) if queue.contains(handle));
7879

7980
if wakeup {
8081
return 0;
@@ -97,7 +98,7 @@ pub fn futex_wake(address: &AtomicU32, count: i32) -> i32 {
9798
}
9899

99100
let mut parking_lot = PARKING_LOT.lock();
100-
let mut queue = match parking_lot.entry(address.as_mut_ptr().addr()) {
101+
let mut queue = match parking_lot.entry(addr(address)) {
101102
Entry::Occupied(entry) => entry,
102103
Entry::Vacant(_) => return 0,
103104
};

0 commit comments

Comments
 (0)