To accommodate large user programs

increased user stack, kernel stack and heap
This commit is contained in:
Luoyuan Xiao 2022-05-12 16:35:35 +08:00
parent 0f658c8158
commit 9490e5d7a8
5 changed files with 13 additions and 9 deletions

View File

@ -8,6 +8,7 @@ use bitflags::bitflags;
use kernel_hal::context::UserContextField;
use linux_object::thread::{CurrentThreadExt, RobustList, ThreadExt};
use linux_object::{fs::INodeExt, loader::LinuxElfLoader};
use zircon_object::vm::USER_STACK_PAGES;
/// Syscalls for process.
///
@ -285,7 +286,7 @@ impl Syscall<'_> {
let (entry, sp) = LinuxElfLoader {
syscall_entry: self.syscall_entry,
stack_pages: 8,
stack_pages: USER_STACK_PAGES,
root_inode: proc.root_inode().clone(),
}
.load(&vmar, &data, args, envs, path)?;

View File

@ -11,7 +11,7 @@ use linux_object::fs::{vfs::FileSystem, INodeExt};
use linux_object::thread::{CurrentThreadExt, ThreadExt};
use linux_object::{loader::LinuxElfLoader, process::ProcessExt};
use zircon_object::task::{CurrentThread, Job, Process, Thread, ThreadState};
use zircon_object::{object::KernelObject, ZxError, ZxResult};
use zircon_object::{object::KernelObject, vm::USER_STACK_PAGES, ZxError, ZxResult};
/// Create and run main Linux process
pub fn run(args: Vec<String>, envs: Vec<String>, rootfs: Arc<dyn FileSystem>) -> Arc<Process> {
@ -22,7 +22,7 @@ pub fn run(args: Vec<String>, envs: Vec<String>, rootfs: Arc<dyn FileSystem>) ->
let thread = Thread::create_linux(&proc).unwrap();
let loader = LinuxElfLoader {
syscall_entry: kernel_hal::context::syscall_entry as usize,
stack_pages: 8,
stack_pages: USER_STACK_PAGES,
root_inode: rootfs.root_inode(),
};

View File

@ -11,5 +11,6 @@ cfg_if! {
}
pub const PHYSICAL_MEMORY_OFFSET: usize = KERNEL_OFFSET - PHYS_MEMORY_BASE;
pub const KERNEL_HEAP_SIZE: usize = 8 * 1024 * 1024; // 8 MB
pub const KERNEL_HEAP_SIZE: usize = 80 * 1024 * 1024; // 80 MB
pub const STACK_PAGES_PER_HART: usize = 32;
pub const MAX_HART_NUM: usize = 8;

View File

@ -1,4 +1,7 @@
use super::{boot_page_table::BootPageTable, consts::PHYSICAL_MEMORY_OFFSET};
use super::{
boot_page_table::BootPageTable,
consts::{MAX_HART_NUM, PHYSICAL_MEMORY_OFFSET, STACK_PAGES_PER_HART},
};
use core::arch::asm;
use device_tree::parse_smp;
use kernel_hal::{
@ -106,9 +109,6 @@ extern "C" fn secondary_rust_main(hartid: usize) -> ! {
/// 裸函数。
#[naked]
unsafe extern "C" fn select_stack(hartid: usize) {
const STACK_PAGES_PER_HART: usize = 16;
const MAX_HART_NUM: usize = 10;
const STACK_LEN_PER_HART: usize = 4096 * STACK_PAGES_PER_HART;
const STACK_LEN_TOTAL: usize = STACK_LEN_PER_HART * MAX_HART_NUM;

View File

@ -1009,6 +1009,8 @@ pub const USER_ASPACE_BASE: u64 = 0;
// pub const USER_ASPACE_BASE: u64 = 0x0000_0000_0100_0000;
/// The size of user address space
pub const USER_ASPACE_SIZE: u64 = (1u64 << 47) - 4096 - USER_ASPACE_BASE;
/// The default number of user stack pages
pub const USER_STACK_PAGES: usize = 128;
#[cfg(test)]
mod tests {