From 0e78fc5fb7fbf0badb38a756612d811320d31235 Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 10 Jun 2026 11:00:10 +0800 Subject: [PATCH 1/2] dep: Downgrade rust version to 1.86.0. --- .gitignore | 4 +++- os/Cargo.toml | 2 +- os/src/syscall/net.rs | 2 +- os/src/syscall/process.rs | 2 +- rust-toolchain.toml | 2 +- user/rust-toolchain.toml | 2 +- user/src/bin/tcp_echo_server.rs | 2 +- user/src/net.rs | 5 +++-- 8 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 6d534595..a2ef51d9 100644 --- a/.gitignore +++ b/.gitignore @@ -32,4 +32,6 @@ kernel-rv kernel-la sdcard-rv.img second-easyfs.img -second-fat32.img \ No newline at end of file +second-fat32.img +bootloader/loongarch64-direct/target/* +sdcard-la.img \ No newline at end of file diff --git a/os/Cargo.toml b/os/Cargo.toml index d7bf479f..0f9ada1c 100644 --- a/os/Cargo.toml +++ b/os/Cargo.toml @@ -16,7 +16,7 @@ xmas-elf = "0.7.0" virtio-drivers = "0.12.0" fs = { path = "../fs" } hashbrown = "0.12.3" -smoltcp = { git = "https://github.com/KyleMao2023/smoltcp", branch = "udp-fix", default-features = false, features = [ +smoltcp = { git = "https://github.com/KyleMao2023/smoltcp", branch = "os", default-features = false, features = [ "alloc", "medium-ethernet", "proto-ipv4", diff --git a/os/src/syscall/net.rs b/os/src/syscall/net.rs index 6dc1d3aa..a8e26bd3 100644 --- a/os/src/syscall/net.rs +++ b/os/src/syscall/net.rs @@ -370,7 +370,7 @@ fn append_cmsg(buf: &mut Vec, level: i32, ty: i32, payload: &[u8]) { } fn parse_rights_payload(payload: &[u8]) -> Result>, ERRNO> { - if !payload.len().is_multiple_of(size_of::()) { + if !payload.len() % size_of::() == 0 { return Err(ERRNO::EINVAL); } diff --git a/os/src/syscall/process.rs b/os/src/syscall/process.rs index 28220d57..c189aa47 100644 --- a/os/src/syscall/process.rs +++ b/os/src/syscall/process.rs @@ -398,7 +398,7 @@ pub fn sys_shmat(shmid: usize, shmaddr: usize, shmflg: i32) -> isize { let _ = chosen_end; chosen } else { - if !shmaddr.is_multiple_of(crate::config::PAGE_SIZE) { + if !shmaddr % crate::config::PAGE_SIZE == 0 { ipc::detach_segment(shmid); return Err(ERRNO::EINVAL); } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index ad59d504..b5587fa2 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,6 +1,6 @@ [toolchain] profile = "minimal" # use the nightly version of the last stable toolchain, see -channel = "nightly-2025-10-14" +channel = "nightly-2025-01-18" components = ["rust-src", "llvm-tools-preview", "rustfmt", "clippy"] targets = ["riscv64gc-unknown-none-elf"] diff --git a/user/rust-toolchain.toml b/user/rust-toolchain.toml index 1cb91fb8..675388b6 100644 --- a/user/rust-toolchain.toml +++ b/user/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] profile = "minimal" # use the nightly version of the last stable toolchain, see -channel = "nightly-2025-10-14" +channel = "nightly-2025-01-18" components = ["rust-src", "llvm-tools-preview", "rustfmt", "clippy"] diff --git a/user/src/bin/tcp_echo_server.rs b/user/src/bin/tcp_echo_server.rs index 9cbc41ab..d1fce179 100644 --- a/user/src/bin/tcp_echo_server.rs +++ b/user/src/bin/tcp_echo_server.rs @@ -72,7 +72,7 @@ struct WorkerCtx { } fn fmt_peer(peer: &SockAddrIn) -> ([u8; 4], u16) { - let ip = peer.sin_addr.to_be_bytes(); + let ip = peer.ipv4(); let port = u16::from_be(peer.sin_port); (ip, port) } diff --git a/user/src/net.rs b/user/src/net.rs index 20a7ddc6..2c79c1ef 100644 --- a/user/src/net.rs +++ b/user/src/net.rs @@ -100,14 +100,15 @@ impl SockAddrIn { Self { sin_family: AF_INET as u16, sin_port: port.to_be(), - sin_addr: u32::from_be_bytes(ip), + // Store the integer so the raw struct bytes match network order. + sin_addr: u32::from_ne_bytes(ip), sin_zero: [0; 8], } } /// Return IPv4 octets in host byte order. pub fn ipv4(&self) -> [u8; 4] { - self.sin_addr.to_be_bytes() + self.sin_addr.to_ne_bytes() } /// Return port in host byte order. From 72ea31967a39c59ba834cd315b20a7a2e3ded853 Mon Sep 17 00:00:00 2001 From: Kyle Date: Wed, 10 Jun 2026 11:31:23 +0800 Subject: [PATCH 2/2] dep: Change version to `nightly-2025-01-17`. --- rust-toolchain.toml | 2 +- user/rust-toolchain.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b5587fa2..25a66473 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,6 +1,6 @@ [toolchain] profile = "minimal" # use the nightly version of the last stable toolchain, see -channel = "nightly-2025-01-18" +channel = "nightly-2025-01-17" components = ["rust-src", "llvm-tools-preview", "rustfmt", "clippy"] targets = ["riscv64gc-unknown-none-elf"] diff --git a/user/rust-toolchain.toml b/user/rust-toolchain.toml index 675388b6..c027a33c 100644 --- a/user/rust-toolchain.toml +++ b/user/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] profile = "minimal" # use the nightly version of the last stable toolchain, see -channel = "nightly-2025-01-18" +channel = "nightly-2025-01-17" components = ["rust-src", "llvm-tools-preview", "rustfmt", "clippy"]