From 97539dd760362a82a784f6da9172e96b05ddeca3 Mon Sep 17 00:00:00 2001 From: equation314 Date: Tue, 21 May 2019 00:45:56 +0800 Subject: [PATCH] aarch64: speed up page table map/unmap 1. update crate aarch64, call tlb_invalidate() instead of tlb_invalidate_all() in MapperFlush::flush(). 2. reduce user stack size to 1MiB. --- bootloader/Cargo.lock | 8 ++++---- bootloader/Cargo.toml | 2 +- kernel/Cargo.lock | 10 +++++----- kernel/Cargo.toml | 2 +- kernel/src/arch/aarch64/consts.rs | 2 +- kernel/src/arch/aarch64/paging.rs | 3 +-- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/bootloader/Cargo.lock b/bootloader/Cargo.lock index 2b8bee7c..ff6c78fe 100644 --- a/bootloader/Cargo.lock +++ b/bootloader/Cargo.lock @@ -2,8 +2,8 @@ # It is not intended for manual editing. [[package]] name = "aarch64" -version = "2.6.0" -source = "git+https://github.com/rcore-os/aarch64#72d8ac8fdf6e41c453cda8f9fd144ae2798b579c" +version = "2.6.1" +source = "git+https://github.com/rcore-os/aarch64#65d1453f11f3cc113247352dffa02d8dcdd34769" dependencies = [ "bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -104,7 +104,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "rcore-bootloader" version = "0.1.0" dependencies = [ - "aarch64 2.6.0 (git+https://github.com/rcore-os/aarch64)", + "aarch64 2.6.1 (git+https://github.com/rcore-os/aarch64)", "bcm2837 1.0.0 (git+https://github.com/rcore-os/bcm2837)", "cc 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", "fixedvec 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -211,7 +211,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] -"checksum aarch64 2.6.0 (git+https://github.com/rcore-os/aarch64)" = "" +"checksum aarch64 2.6.1 (git+https://github.com/rcore-os/aarch64)" = "" "checksum bcm2837 1.0.0 (git+https://github.com/rcore-os/bcm2837)" = "" "checksum bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed8765909f9009617974ab6b7d332625b320b33c326b1e9321382ef1999b5d56" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" diff --git a/bootloader/Cargo.toml b/bootloader/Cargo.toml index f3f34303..cacae222 100644 --- a/bootloader/Cargo.toml +++ b/bootloader/Cargo.toml @@ -9,7 +9,7 @@ xmas-elf = "0.6.2" fixedvec = "0.2.3" [target.'cfg(target_arch = "aarch64")'.dependencies] -aarch64 = { git = "https://github.com/rcore-os/aarch64", version = "2.6.0" } +aarch64 = { git = "https://github.com/rcore-os/aarch64", version = "2.6.1" } bcm2837 = { git = "https://github.com/rcore-os/bcm2837", version = "1.0.0" } [build-dependencies] diff --git a/kernel/Cargo.lock b/kernel/Cargo.lock index 678c4851..2f550181 100644 --- a/kernel/Cargo.lock +++ b/kernel/Cargo.lock @@ -2,8 +2,8 @@ # It is not intended for manual editing. [[package]] name = "aarch64" -version = "2.6.0" -source = "git+https://github.com/rcore-os/aarch64#72d8ac8fdf6e41c453cda8f9fd144ae2798b579c" +version = "2.6.1" +source = "git+https://github.com/rcore-os/aarch64#65d1453f11f3cc113247352dffa02d8dcdd34769" dependencies = [ "bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -44,7 +44,7 @@ name = "bcm2837" version = "1.0.0" source = "git+https://github.com/rcore-os/bcm2837#b29a8db5504b7eaa6f8adf2c3ff916d1ffd15194" dependencies = [ - "aarch64 2.6.0 (git+https://github.com/rcore-os/aarch64)", + "aarch64 2.6.1 (git+https://github.com/rcore-os/aarch64)", "volatile 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -353,7 +353,7 @@ dependencies = [ name = "rcore" version = "0.2.0" dependencies = [ - "aarch64 2.6.0 (git+https://github.com/rcore-os/aarch64)", + "aarch64 2.6.1 (git+https://github.com/rcore-os/aarch64)", "apic 0.1.0 (git+https://github.com/rcore-os/apic-rs)", "bcm2837 1.0.0 (git+https://github.com/rcore-os/bcm2837)", "bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -659,7 +659,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] -"checksum aarch64 2.6.0 (git+https://github.com/rcore-os/aarch64)" = "" +"checksum aarch64 2.6.1 (git+https://github.com/rcore-os/aarch64)" = "" "checksum apic 0.1.0 (git+https://github.com/rcore-os/apic-rs)" = "" "checksum array-init 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "23589ecb866b460d3a0f1278834750268c607e8e28a1b982c907219f3178cd72" "checksum bare-metal 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a3caf393d93b2d453e80638d0674597020cef3382ada454faacd43d1a55a735a" diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index f68c68c1..d46dc005 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -79,7 +79,7 @@ pc-keyboard = "0.5" riscv = { git = "https://github.com/rcore-os/riscv", features = ["inline-asm"] } [target.'cfg(target_arch = "aarch64")'.dependencies] -aarch64 = { git = "https://github.com/rcore-os/aarch64", version = "2.6.0" } +aarch64 = { git = "https://github.com/rcore-os/aarch64", version = "2.6.1" } bcm2837 = { git = "https://github.com/rcore-os/bcm2837", version = "1.0.0", optional = true } [target.'cfg(target_arch = "mips")'.dependencies] diff --git a/kernel/src/arch/aarch64/consts.rs b/kernel/src/arch/aarch64/consts.rs index 23cdafec..6b9e22d1 100644 --- a/kernel/src/arch/aarch64/consts.rs +++ b/kernel/src/arch/aarch64/consts.rs @@ -4,4 +4,4 @@ pub const PHYSICAL_MEMORY_OFFSET: usize = KERNEL_OFFSET - MEMORY_OFFSET; pub const KERNEL_HEAP_SIZE: usize = 8 * 1024 * 1024; pub const USER_STACK_OFFSET: usize = 0x0000_8000_0000_0000 - USER_STACK_SIZE; -pub const USER_STACK_SIZE: usize = 8 * 1024 * 1024; +pub const USER_STACK_SIZE: usize = 1 * 1024 * 1024; diff --git a/kernel/src/arch/aarch64/paging.rs b/kernel/src/arch/aarch64/paging.rs index edea1e0f..5e7cd942 100644 --- a/kernel/src/arch/aarch64/paging.rs +++ b/kernel/src/arch/aarch64/paging.rs @@ -86,8 +86,7 @@ pub enum MMIOType { impl Entry for PageEntry { fn update(&mut self) { - let addr = VirtAddr::new_unchecked((self as *const _ as u64) << 9); - tlb_invalidate(addr); + tlb_invalidate(self.1.start_address()); } fn present(&self) -> bool {