Skip to content

Commit

Permalink
chore: update toolchain version to 2024-11-05 (#1031)
Browse files Browse the repository at this point in the history
* chore: update toolchain version to 2024-11-05

* update dragon reach to e945c217b3

* update dog to 6f2c0c8f12

---------

Co-authored-by: longjin <[email protected]>
  • Loading branch information
Godones and fslongjin authored Nov 11, 2024
1 parent 6971543 commit 7c28051
Show file tree
Hide file tree
Showing 99 changed files with 242 additions and 379 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/makefile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ jobs:
name: Format check ${{ matrix.arch }}
runs-on: ubuntu-latest
continue-on-error: true
container: dragonos/dragonos-dev:v1.5
container: dragonos/dragonos-dev:v1.6

strategy:
matrix:
arch: [x86_64, riscv64]

steps:
- run: echo "Running in dragonos/dragonos-dev:v1.5"
- run: echo "Running in dragonos/dragonos-dev:v1.6"
- uses: actions/checkout@v3

- name: Format check
Expand All @@ -35,14 +35,14 @@ jobs:
name: Kernel static test ${{ matrix.arch }}
runs-on: ubuntu-latest
continue-on-error: true
container: dragonos/dragonos-dev:v1.5
container: dragonos/dragonos-dev:v1.6

strategy:
matrix:
arch: [x86_64, riscv64]

steps:
- run: echo "Running in dragonos/dragonos-dev:v1.5"
- run: echo "Running in dragonos/dragonos-dev:v1.6"

- uses: actions/checkout@v3

Expand All @@ -56,10 +56,10 @@ jobs:
build-x86_64:

runs-on: ubuntu-latest
container: dragonos/dragonos-dev:v1.5
container: dragonos/dragonos-dev:v1.6

steps:
- run: echo "Running in dragonos/dragonos-dev:v1.5"
- run: echo "Running in dragonos/dragonos-dev:v1.6"

- uses: actions/checkout@v3
- name: build the DragonOS
Expand All @@ -78,10 +78,10 @@ jobs:
build-riscv64:

runs-on: ubuntu-latest
container: dragonos/dragonos-dev:v1.5
container: dragonos/dragonos-dev:v1.6

steps:
- run: echo "Running in dragonos/dragonos-dev:v1.5"
- run: echo "Running in dragonos/dragonos-dev:v1.6"

- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ fmt:
clean:
@cargo clean
check:
@cargo +nightly-2024-07-23 check --workspace $(CARGO_ZBUILD) --message-format=json
@cargo +nightly-2024-11-05 check --workspace $(CARGO_ZBUILD) --message-format=json
8 changes: 4 additions & 4 deletions kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ check: ECHO
# @echo "Checking kernel... ARCH=$(ARCH)"
# @exit 1
ifeq ($(ARCH), x86_64)
RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-07-23 check --workspace $(CARGO_ZBUILD) --message-format=json --target ./src/$(TARGET_JSON)
RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 check --workspace $(CARGO_ZBUILD) --message-format=json --target ./src/$(TARGET_JSON)
else ifeq ($(ARCH), riscv64)
RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-07-23 check --workspace $(CARGO_ZBUILD) --message-format=json --target $(TARGET_JSON)
RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 check --workspace $(CARGO_ZBUILD) --message-format=json --target $(TARGET_JSON)
endif

test:
# 测试内核库
RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-07-23 test --workspace --exclude dragonos_kernel rbpf
RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 test --workspace --exclude dragonos_kernel rbpf

test-rbpf:
cd crates/rbpf && RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-07-23 test --features=std,user,cranelift
cd crates/rbpf && RUSTFLAGS="$(RUSTFLAGS)" cargo +nightly-2024-11-05 test --features=std,user,cranelift
2 changes: 1 addition & 1 deletion kernel/crates/bitmap/src/alloc_bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct AllocBitmap {

impl AllocBitmap {
pub fn new(elements: usize) -> Self {
let data = vec![0usize; (elements + usize::BITS as usize - 1) / (usize::BITS as usize)];
let data = vec![0usize; elements.div_ceil(usize::BITS as usize)];
Self {
elements,
data,
Expand Down
12 changes: 6 additions & 6 deletions kernel/crates/bitmap/src/static_bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ use crate::{bitmap_core::BitMapCore, traits::BitMapOps};
#[derive(Debug, Clone)]
pub struct StaticBitmap<const N: usize>
where
[(); (N + usize::BITS as usize - 1) / (usize::BITS as usize)]:,
[(); N.div_ceil(usize::BITS as usize)]:,
{
pub data: [usize; (N + usize::BITS as usize - 1) / (usize::BITS as usize)],
pub data: [usize; N.div_ceil(usize::BITS as usize)],
core: BitMapCore<usize>,
}

impl<const N: usize> Default for StaticBitmap<N>
where
[(); (N + usize::BITS as usize - 1) / (usize::BITS as usize)]:,
[(); N.div_ceil(usize::BITS as usize)]:,
{
fn default() -> Self {
Self::new()
Expand All @@ -25,20 +25,20 @@ where

impl<const N: usize> StaticBitmap<N>
where
[(); (N + usize::BITS as usize - 1) / (usize::BITS as usize)]:,
[(); N.div_ceil(usize::BITS as usize)]:,
{
/// 创建一个新的静态位图
pub const fn new() -> Self {
Self {
data: [0; (N + usize::BITS as usize - 1) / (usize::BITS as usize)],
data: [0; N.div_ceil(usize::BITS as usize)],
core: BitMapCore::new(),
}
}
}

impl<const N: usize> BitMapOps<usize> for StaticBitmap<N>
where
[(); (N + usize::BITS as usize - 1) / (usize::BITS as usize)]:,
[(); N.div_ceil(usize::BITS as usize)]:,
{
#[inline]
fn get(&self, index: usize) -> Option<bool> {
Expand Down
1 change: 0 additions & 1 deletion kernel/crates/crc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![cfg_attr(not(test), no_std)]
#![feature(const_for)]
#![feature(const_mut_refs)]
#![feature(const_trait_impl)]
#![allow(clippy::needless_return)]

Expand Down
7 changes: 5 additions & 2 deletions kernel/crates/ida/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct EmptyIdaItemRef<'a> {
_marker: PhantomData<&'a EmptyIdaItem>,
}

impl<'a> Deref for EmptyIdaItemRef<'a> {
impl Deref for EmptyIdaItemRef<'_> {
type Target = EmptyIdaItem;

fn deref(&self) -> &Self::Target {
Expand All @@ -27,7 +27,10 @@ impl<'a> Deref for EmptyIdaItemRef<'a> {
struct EmptyIdaItem;

unsafe impl kdepends::xarray::ItemEntry for EmptyIdaItem {
type Ref<'a> = EmptyIdaItemRef<'a> where Self: 'a;
type Ref<'a>
= EmptyIdaItemRef<'a>
where
Self: 'a;

fn into_raw(self) -> *const () {
core::ptr::null()
Expand Down
1 change: 0 additions & 1 deletion kernel/crates/intertrait/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ mod item_type;
/// #[derive(std::fmt::Debug)]
/// struct Data;
/// ```
#[proc_macro_attribute]
pub fn cast_to(args: TokenStream, input: TokenStream) -> TokenStream {
match parse::<Targets>(args) {
Expand Down
1 change: 1 addition & 0 deletions kernel/crates/intertrait/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ static CASTER_MAP: once_cell::sync::Lazy<HashMap<(TypeId, TypeId), BoxedCaster,
static mut CASTER_MAP: Option<HashMap<(TypeId, TypeId), BoxedCaster, BuildFastHasher>> = None;

#[cfg(target_os = "none")]
#[allow(static_mut_refs)]
pub fn caster_map() -> &'static HashMap<(TypeId, TypeId), BoxedCaster, BuildFastHasher> {
return unsafe {
CASTER_MAP.as_ref().unwrap_or_else(|| {
Expand Down
1 change: 0 additions & 1 deletion kernel/crates/klog_types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![no_std]
#![feature(const_refs_to_cell)]
#![feature(const_size_of_val)]
#![allow(clippy::needless_return)]

Expand Down
48 changes: 24 additions & 24 deletions kernel/crates/rbpf/src/insn_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub trait IntoBytes {
}

/// General implementation of `IntoBytes` for `Instruction`
impl<'i, I: Instruction> IntoBytes for &'i I {
impl<I: Instruction> IntoBytes for &'_ I {
type Bytes = Vec<u8>;

/// transform immutable reference of `Instruction` into `Vec<u8>` with size of 8
Expand Down Expand Up @@ -347,7 +347,7 @@ impl<'i> Move<'i> {
}
}

impl<'i> Instruction for Move<'i> {
impl Instruction for Move<'_> {
fn opt_code_byte(&self) -> u8 {
let op_bits = self.op_bits as u8;
let src_bit = self.src_bit as u8;
Expand Down Expand Up @@ -415,7 +415,7 @@ impl<'i> SwapBytes<'i> {
}
}

impl<'i> Instruction for SwapBytes<'i> {
impl Instruction for SwapBytes<'_> {
fn opt_code_byte(&self) -> u8 {
self.endian as u8
}
Expand Down Expand Up @@ -456,20 +456,20 @@ impl<'i> Load<'i> {
}
}

impl<'i> Instruction for Load<'i> {
impl Instruction for Load<'_> {
fn opt_code_byte(&self) -> u8 {
let size = self.mem_size as u8;
let addressing = self.addressing as u8;
addressing | size | self.source
}

fn get_insn_mut(&mut self) -> &mut Insn {
&mut self.insn
}

fn get_insn(&self) -> &Insn {
&self.insn
}

fn get_insn_mut(&mut self) -> &mut Insn {
&mut self.insn
}
}

/// struct representation of STORE instructions
Expand All @@ -489,19 +489,19 @@ impl<'i> Store<'i> {
}
}

impl<'i> Instruction for Store<'i> {
impl Instruction for Store<'_> {
fn opt_code_byte(&self) -> u8 {
let size = self.mem_size as u8;
BPF_MEM | BPF_ST | size | self.source
}

fn get_insn_mut(&mut self) -> &mut Insn {
&mut self.insn
}

fn get_insn(&self) -> &Insn {
&self.insn
}

fn get_insn_mut(&mut self) -> &mut Insn {
&mut self.insn
}
}

#[derive(Copy, Clone)]
Expand Down Expand Up @@ -542,20 +542,20 @@ impl<'i> Jump<'i> {
}
}

impl<'i> Instruction for Jump<'i> {
impl Instruction for Jump<'_> {
fn opt_code_byte(&self) -> u8 {
let cmp: u8 = self.cond as u8;
let src_bit = self.src_bit as u8;
cmp | src_bit | BPF_JMP
}

fn get_insn_mut(&mut self) -> &mut Insn {
&mut self.insn
}

fn get_insn(&self) -> &Insn {
&self.insn
}

fn get_insn_mut(&mut self) -> &mut Insn {
&mut self.insn
}
}

#[derive(Copy, Clone, PartialEq, Eq)]
Expand Down Expand Up @@ -602,18 +602,18 @@ impl<'i> FunctionCall<'i> {
}
}

impl<'i> Instruction for FunctionCall<'i> {
impl Instruction for FunctionCall<'_> {
fn opt_code_byte(&self) -> u8 {
BPF_CALL | BPF_JMP
}

fn get_insn_mut(&mut self) -> &mut Insn {
&mut self.insn
}

fn get_insn(&self) -> &Insn {
&self.insn
}

fn get_insn_mut(&mut self) -> &mut Insn {
&mut self.insn
}
}

/// struct representation of EXIT instruction
Expand All @@ -631,7 +631,7 @@ impl<'i> Exit<'i> {
}
}

impl<'i> Instruction for Exit<'i> {
impl Instruction for Exit<'_> {
fn opt_code_byte(&self) -> u8 {
BPF_EXIT | BPF_JMP
}
Expand Down
4 changes: 4 additions & 0 deletions kernel/crates/rbpf/tests/ubpf_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2316,8 +2316,12 @@ fn test_vm_stdw() {
// If this case is not handled properly in check_mem(), then we may overflow when adding the
// context address and the offset, and make the thread panic with "attempt to add with overflow".
// Check that we panic with the expected out-of-bounds error.
//
// The new toolchain introduced `assert_unsafe_precondition` which panics with a different message and can't be
// caught by `#[should_panic]`. This is why we use `#[ignore]` here.
#[test]
#[should_panic(expected = "Error: out of bounds memory store (insn #1)")]
#[ignore]
fn test_vm_stdw_add_overflow() {
let prog = assemble(
"
Expand Down
6 changes: 4 additions & 2 deletions kernel/crates/rust-slabmalloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
//! # Implementing GlobalAlloc
//! See the [global alloc](https://github.com/gz/rust-slabmalloc/tree/master/examples/global_alloc.rs) example.
#![allow(unused_features)]
#![cfg_attr(feature = "unstable", feature(const_mut_refs))]
#![no_std]
#![crate_name = "slabmalloc"]
#![crate_type = "lib"]
#![feature(new_uninit)]
#![feature(maybe_uninit_as_bytes)]

extern crate alloc;
Expand Down Expand Up @@ -65,6 +63,8 @@ pub enum AllocationError {
/// Needs to adhere to safety requirements of a rust allocator (see GlobalAlloc et. al.).
pub unsafe trait Allocator<'a> {
fn allocate(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocationError>;
/// # Safety
/// The caller must ensure that the memory is valid and that the layout is correct.
unsafe fn deallocate(
&mut self,
ptr: NonNull<u8>,
Expand All @@ -85,5 +85,7 @@ pub unsafe trait Allocator<'a> {

/// 将slab_page归还Buddy的回调函数
pub trait CallBack: Send + Sync {
/// # Safety
/// The caller must ensure that the memory is valid and that the size is correct.
unsafe fn free_slab_page(&self, _: *mut u8, _: usize) {}
}
8 changes: 4 additions & 4 deletions kernel/crates/rust-slabmalloc/src/pages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,10 @@ impl<'a> ObjectPage<'a> {
}

// These needs some more work to be really safe...
unsafe impl<'a> Send for ObjectPage<'a> {}
unsafe impl<'a> Sync for ObjectPage<'a> {}
unsafe impl Send for ObjectPage<'_> {}
unsafe impl Sync for ObjectPage<'_> {}

impl<'a> AllocablePage for ObjectPage<'a> {
impl AllocablePage for ObjectPage<'_> {
const SIZE: usize = OBJECT_PAGE_SIZE;

fn bitfield(&self) -> &[AtomicU64; 8] {
Expand All @@ -331,7 +331,7 @@ impl<'a> Default for ObjectPage<'a> {
}
}

impl<'a> fmt::Debug for ObjectPage<'a> {
impl fmt::Debug for ObjectPage<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "ObjectPage")
}
Expand Down
Loading

0 comments on commit 7c28051

Please sign in to comment.