From 302b547a0d4e48349391a9c7afa28c89f33cee7b Mon Sep 17 00:00:00 2001 From: Zhang Junyang Date: Tue, 26 Dec 2023 18:16:08 +0800 Subject: [PATCH] Bump version to 0.3.0 --- .github/workflows/cargo_check.yml | 4 ++-- .github/workflows/integration_test.yml | 4 ++-- .github/workflows/unit_test.yml | 4 ++-- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 4 ++-- VERSION | 2 +- framework/libs/boot-wrapper/wrapper/src/main.rs | 2 +- .../boot-wrapper/wrapper/src/x86/amd64_efi/efi.rs | 5 +++-- .../boot-wrapper/wrapper/src/x86/amd64_efi/mod.rs | 2 ++ .../wrapper/src/x86/{ => amd64_efi}/paging.rs | 0 .../wrapper/src/x86/{ => amd64_efi}/relocation.rs | 13 +------------ .../wrapper/src/x86/legacy_i386/mod.rs | 6 ++---- framework/libs/boot-wrapper/wrapper/src/x86/mod.rs | 14 ++++++++++++-- 14 files changed, 32 insertions(+), 32 deletions(-) rename framework/libs/boot-wrapper/wrapper/src/x86/{ => amd64_efi}/paging.rs (100%) rename framework/libs/boot-wrapper/wrapper/src/x86/{ => amd64_efi}/relocation.rs (89%) diff --git a/.github/workflows/cargo_check.yml b/.github/workflows/cargo_check.yml index 24cd2c6e1..0a23e93aa 100644 --- a/.github/workflows/cargo_check.yml +++ b/.github/workflows/cargo_check.yml @@ -10,9 +10,9 @@ jobs: test: runs-on: ubuntu-latest timeout-minutes: 10 - container: asterinas/asterinas:0.2.3 + container: asterinas/asterinas:0.3.0 steps: - - run: echo "Running in asterinas/asterinas:0.2.3" + - run: echo "Running in asterinas/asterinas:0.3.0" - uses: actions/checkout@v3 diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index b5ba9bb22..4b8e9d471 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -10,9 +10,9 @@ jobs: test: runs-on: ubuntu-latest timeout-minutes: 30 - container: asterinas/asterinas:0.2.3 + container: asterinas/asterinas:0.3.0 steps: - - run: echo "Running in asterinas/asterinas:0.2.3" + - run: echo "Running in asterinas/asterinas:0.3.0" - uses: actions/checkout@v3 diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml index 9e7656f90..b120a6631 100644 --- a/.github/workflows/unit_test.yml +++ b/.github/workflows/unit_test.yml @@ -10,9 +10,9 @@ jobs: test: runs-on: ubuntu-latest timeout-minutes: 15 - container: asterinas/asterinas:0.2.3 + container: asterinas/asterinas:0.3.0 steps: - - run: echo "Running in asterinas/asterinas:0.2.3" + - run: echo "Running in asterinas/asterinas:0.3.0" - uses: actions/checkout@v3 diff --git a/Cargo.lock b/Cargo.lock index e601ae638..50f4a399b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -371,7 +371,7 @@ dependencies = [ [[package]] name = "asterinas" -version = "0.2.3" +version = "0.3.0" dependencies = [ "aster-frame", "aster-framebuffer", diff --git a/Cargo.toml b/Cargo.toml index fb4286d3b..7dfecf43c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "asterinas" -version = "0.2.3" +version = "0.3.0" edition = "2021" [[bin]] diff --git a/README.md b/README.md index 6747578c8..469e44db8 100644 --- a/README.md +++ b/README.md @@ -42,12 +42,12 @@ git clone [repository url] 2. After downloading the source code, run the following command to pull the development image. ```bash -docker pull asterinas/asterinas:0.2.3 +docker pull asterinas/asterinas:0.3.0 ``` 3. Start the development container. ```bash -docker run -it --privileged --network=host --device=/dev/kvm -v `pwd`:/root/asterinas asterinas/asterinas:0.2.3 +docker run -it --privileged --network=host --device=/dev/kvm -v `pwd`:/root/asterinas asterinas/asterinas:0.3.0 ``` **All build and test commands should be run inside the development container.** diff --git a/VERSION b/VERSION index 717903969..0d91a54c7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.3 +0.3.0 diff --git a/framework/libs/boot-wrapper/wrapper/src/main.rs b/framework/libs/boot-wrapper/wrapper/src/main.rs index abde5a0ba..7162fed6e 100644 --- a/framework/libs/boot-wrapper/wrapper/src/main.rs +++ b/framework/libs/boot-wrapper/wrapper/src/main.rs @@ -33,7 +33,7 @@ fn get_payload(boot_params: &BootParams) -> &'static [u8] { let hdr = &boot_params.hdr; // The payload_offset field is not recorded in the relocation table, so we need to // calculate the loaded offset manually. - let loaded_offset = x86::relocation::get_image_loaded_offset(); + let loaded_offset = x86::get_image_loaded_offset(); let payload_offset = (loaded_offset + hdr.payload_offset as isize) as usize; let payload_length = hdr.payload_length as usize; // Safety: the payload_offset and payload_length is valid if we assume that the diff --git a/framework/libs/boot-wrapper/wrapper/src/x86/amd64_efi/efi.rs b/framework/libs/boot-wrapper/wrapper/src/x86/amd64_efi/efi.rs index 21eafb822..aeeaa8cb5 100644 --- a/framework/libs/boot-wrapper/wrapper/src/x86/amd64_efi/efi.rs +++ b/framework/libs/boot-wrapper/wrapper/src/x86/amd64_efi/efi.rs @@ -6,7 +6,8 @@ use uefi::{ use linux_boot_params::BootParams; -use crate::x86::paging::{Ia32eFlags, PageNumber, PageTableCreator}; +use super::paging::{Ia32eFlags, PageNumber, PageTableCreator}; +use super::relocation::apply_rela_dyn_relocations; #[export_name = "efi_stub_entry"] extern "sysv64" fn efi_stub_entry(handle: Handle, mut system_table: SystemTable) -> ! { @@ -47,7 +48,7 @@ fn efi_phase_boot( unsafe { crate::console::init() }; // Safety: this is the right time to apply relocations. - unsafe { crate::x86::relocation::apply_rela_dyn_relocations() }; + unsafe { apply_rela_dyn_relocations() }; uefi_services::println!("[EFI stub] Relocations applied."); diff --git a/framework/libs/boot-wrapper/wrapper/src/x86/amd64_efi/mod.rs b/framework/libs/boot-wrapper/wrapper/src/x86/amd64_efi/mod.rs index 7f1cd2172..d1022586a 100644 --- a/framework/libs/boot-wrapper/wrapper/src/x86/amd64_efi/mod.rs +++ b/framework/libs/boot-wrapper/wrapper/src/x86/amd64_efi/mod.rs @@ -1,4 +1,6 @@ mod efi; +mod paging; +mod relocation; use core::arch::{asm, global_asm}; diff --git a/framework/libs/boot-wrapper/wrapper/src/x86/paging.rs b/framework/libs/boot-wrapper/wrapper/src/x86/amd64_efi/paging.rs similarity index 100% rename from framework/libs/boot-wrapper/wrapper/src/x86/paging.rs rename to framework/libs/boot-wrapper/wrapper/src/x86/amd64_efi/paging.rs diff --git a/framework/libs/boot-wrapper/wrapper/src/x86/relocation.rs b/framework/libs/boot-wrapper/wrapper/src/x86/amd64_efi/relocation.rs similarity index 89% rename from framework/libs/boot-wrapper/wrapper/src/x86/relocation.rs rename to framework/libs/boot-wrapper/wrapper/src/x86/amd64_efi/relocation.rs index 155979ab1..627019f3e 100644 --- a/framework/libs/boot-wrapper/wrapper/src/x86/relocation.rs +++ b/framework/libs/boot-wrapper/wrapper/src/x86/amd64_efi/relocation.rs @@ -1,15 +1,4 @@ -// This is enforced in the linker script. -const START_OF_SETUP32_VA: usize = 0x100000; - -/// The wrapper is a position-independent executable. We can get the loaded base -/// address from the symbol. -#[inline] -pub fn get_image_loaded_offset() -> isize { - extern "C" { - fn start_of_setup32(); - } - start_of_setup32 as isize - START_OF_SETUP32_VA as isize -} +use crate::x86::get_image_loaded_offset; struct Elf64Rela { r_offset: u64, diff --git a/framework/libs/boot-wrapper/wrapper/src/x86/legacy_i386/mod.rs b/framework/libs/boot-wrapper/wrapper/src/x86/legacy_i386/mod.rs index b75541470..3199c7bc2 100644 --- a/framework/libs/boot-wrapper/wrapper/src/x86/legacy_i386/mod.rs +++ b/framework/libs/boot-wrapper/wrapper/src/x86/legacy_i386/mod.rs @@ -17,8 +17,8 @@ extern "cdecl" fn trojan_entry(boot_params_ptr: u32) -> ! { // println!("[setup] bzImage loaded at {:#x}", x86::relocation::get_image_loaded_offset()); unsafe { - print_str("[setup] bzImage loaded at "); - print_hex(crate::x86::relocation::get_image_loaded_offset() as u64); + print_str("[setup] bzImage loaded offset: "); + print_hex(crate::x86::get_image_loaded_offset() as u64); print_str("\n"); } @@ -32,8 +32,6 @@ extern "cdecl" fn trojan_entry(boot_params_ptr: u32) -> ! { unsafe { call_aster_entrypoint(ASTER_ENTRY_POINT, boot_params_ptr.try_into().unwrap()) }; } -pub const ASTER_ENTRY_POINT: u32 = 0x8001000; - unsafe fn call_aster_entrypoint(entrypoint: u32, boot_params_ptr: u32) -> ! { asm!("mov esi, {}", in(reg) boot_params_ptr); asm!("mov eax, {}", in(reg) entrypoint); diff --git a/framework/libs/boot-wrapper/wrapper/src/x86/mod.rs b/framework/libs/boot-wrapper/wrapper/src/x86/mod.rs index 61f330087..42f7411af 100644 --- a/framework/libs/boot-wrapper/wrapper/src/x86/mod.rs +++ b/framework/libs/boot-wrapper/wrapper/src/x86/mod.rs @@ -8,5 +8,15 @@ cfg_if::cfg_if! { } } -pub mod paging; -pub mod relocation; +// This is enforced in the linker script of the wrapper. +const START_OF_SETUP32_VA: usize = 0x100000; + +/// The wrapper is a position-independent executable. We can get the loaded base +/// address from the symbol. +#[inline] +pub fn get_image_loaded_offset() -> isize { + extern "C" { + fn start_of_setup32(); + } + start_of_setup32 as isize - START_OF_SETUP32_VA as isize +}