From c025be0e445f70d92622cd21d40e38ac6db62bad Mon Sep 17 00:00:00 2001 From: manchangfengxu <1848953550@qq.com> Date: Tue, 22 Apr 2025 22:07:18 +0800 Subject: [PATCH 1/2] bench-kernel: replace #[naked] with #[unsafe(naked)] for stable Rust Replace the #[naked] attribute with #[unsafe(naked)] in the bench-kernel module to ensure compatibility with the latest stable Rust compiler. This follows the stabilization in rust-lang/rust#134213 and avoids build failures when using the stable Rust toolchain. Specific changes include: - Replace `#[naked]` with `#[unsafe(naked)]` across all relevant functions. - Remove `#![feature(naked_functions, asm_const)]` as they are no longer needed on stable with `#[unsafe(naked)]`. - Switch to the `naked_asm!` macro to comply with new naked function requirements introduced alongside `#[unsafe(naked)]`. - Remove `options(noreturn)`, which is disallowed within `naked_asm!`. - Update `put_char` and `put_str` implementations in `impl rcore_console::Console for Console` to avoid errors from creating shared references to mutable statics. - Update GitHub Actions workflow files to use `ubuntu-22.04` instead of `ubuntu-20.04` for CI compatibility. The changes build and pass tests successfully on both stable and nightly Rust. Fix: https://github.com/rustsbi/rustsbi/issues/63 Refs: - Issue: https://github.com/rustsbi/rustsbi/issues/63 - Upstream PR: https://github.com/rust-lang/rust/pull/134213 Signed-off-by: manchangfengxu <1848953550@qq.com> --- .github/workflows/workflow.yml | 2 +- CHANGELOG.md | 13 +++++++++++++ bench-kernel/src/main.rs | 16 ++++++++++------ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 63b725f..d2214bc 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -7,7 +7,7 @@ on: jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index 61d9a21..6759429 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Fixes on usage of CLINT peripheral, thanks to @duskmoon314 - Numerous fixes to HSM module implementation, more documents +## [0.1.1] - 2025-04-22 + +### Modified +- Replaced #[naked] with #[unsafe(naked)] across all relevant functions. +- Removed `#![feature(naked_functions, asm_const)]` as they are no longer needed. +- Switched to the `naked_asm!` macro to comply with new naked function requirements. +- Removed `options(noreturn)`, which is not allowed in `naked_asm!`. +- Updated implementations of `put_char` and `put_str` in + `impl rcore_console::Console for Console` to avoid errors caused by + creating shared references to mutable statics. +- Updated GitHub Actions YAML workflow files to replace `ubuntu-20.04` with + `ubuntu-22.04` for CI compatibility. + [Unreleased]: https://github.com/rustsbi/rustsbi-qemu/compare/v0.1.1...HEAD [0.1.1]: https://github.com/rustsbi/rustsbi-qemu/compare/v0.1.0...v0.1.1 [0.1.0]: https://github.com/rustsbi/rustsbi-qemu/releases/tag/v0.1.0 diff --git a/bench-kernel/src/main.rs b/bench-kernel/src/main.rs index 572dbf3..6086228 100644 --- a/bench-kernel/src/main.rs +++ b/bench-kernel/src/main.rs @@ -1,6 +1,5 @@ #![no_std] #![no_main] -#![feature(naked_functions, asm_const)] #![deny(warnings)] use rcore_console::log; @@ -8,7 +7,7 @@ use riscv::register::*; use sbi_rt::*; use uart16550::Uart16550; -#[naked] +#[unsafe(naked)] #[no_mangle] #[link_section = ".text.entry"] unsafe extern "C" fn _start(hartid: usize, device_tree_paddr: usize) -> ! { @@ -17,13 +16,12 @@ unsafe extern "C" fn _start(hartid: usize, device_tree_paddr: usize) -> ! { #[link_section = ".bss.uninit"] static mut STACK: [u8; STACK_SIZE] = [0u8; STACK_SIZE]; - core::arch::asm!( + core::arch::naked_asm!( "la sp, {stack} + {stack_size}", "j {main}", stack_size = const STACK_SIZE, stack = sym STACK, main = sym rust_main, - options(noreturn), ) } @@ -127,11 +125,17 @@ impl Uart16550Map { impl rcore_console::Console for Console { #[inline] fn put_char(&self, c: u8) { - unsafe { UART.get().write(core::slice::from_ref(&c)) }; + unsafe { + let mut_ref_uart = (*(&raw mut UART)).get(); + mut_ref_uart.write(core::slice::from_ref(&c)) + }; } #[inline] fn put_str(&self, s: &str) { - unsafe { UART.get().write(s.as_bytes()) }; + unsafe { + let mut_ref_uart = (*(&raw mut UART)).get(); + mut_ref_uart.write(s.as_bytes()) + }; } } From b7942c4754b19c8b1ec9bdd7c21375c66620e73b Mon Sep 17 00:00:00 2001 From: manchangfengxu <1848953550@qq.com> Date: Tue, 22 Apr 2025 22:48:26 +0800 Subject: [PATCH 2/2] ci: update GitHub Actions workflows to use ubuntu-22.04 Update `runs-on` directives in GitHub Actions workflow files, replacing `ubuntu-20.04` with `ubuntu-22.04`. This is necessary as the `ubuntu-20.04` runner image was retired on April 15, 2025. Migrating to `ubuntu-22.04` ensures CI jobs continue to run on a supported and up-to-date environment. Refs: https://github.com/actions/runner-images/issues/11101 Signed-off-by: manchangfengxu <1848953550@qq.com> --- .github/workflows/workflow.yml | 2 +- CHANGELOG.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index d2214bc..5e6778b 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -19,7 +19,7 @@ jobs: test: needs: build - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 strategy: matrix: base-img: [slim] diff --git a/CHANGELOG.md b/CHANGELOG.md index 6759429..4c59363 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,7 +67,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), creating shared references to mutable statics. - Updated GitHub Actions YAML workflow files to replace `ubuntu-20.04` with `ubuntu-22.04` for CI compatibility. - +- Updated GitHub Actions YAML workflow files to replace `ubuntu-20.04` with + `ubuntu-22.04` for CI test. + [Unreleased]: https://github.com/rustsbi/rustsbi-qemu/compare/v0.1.1...HEAD [0.1.1]: https://github.com/rustsbi/rustsbi-qemu/compare/v0.1.0...v0.1.1 [0.1.0]: https://github.com/rustsbi/rustsbi-qemu/releases/tag/v0.1.0