Skip to content

Commit

Permalink
Merge pull request #362 from YdrMaster/main
Browse files Browse the repository at this point in the history
fix(kernel-hal): vdso version string 可能超过 64 字节
  • Loading branch information
shzhxh authored Aug 4, 2022
2 parents ba54f45 + 18c883e commit dea9b80
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 31 deletions.
50 changes: 25 additions & 25 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions kernel-hal/src/common/vdso.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ pub struct Features {
impl VdsoConstants {
/// Set version string.
pub fn set_version_string(&mut self, s: &str) {
let len = s.len().min(64);
let bytes = s.as_bytes();
let len = bytes.len().min(64);
self.version_string_len = len as u64;
self.version_string.0[..len].copy_from_slice(s.as_bytes());
self.version_string.0[..len].copy_from_slice(&bytes[..len]);
}
}

Expand Down
16 changes: 12 additions & 4 deletions zCore/src/platform/riscv/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::{
consts::{kernel_mem_info, MAX_HART_NUM, STACK_PAGES_PER_HART},
};
use core::arch::asm;
use dtb_walker::{Dtb, DtbObj, Property, Str, WalkOperation::*};
use dtb_walker::{Dtb, DtbObj, HeaderError::*, Property, Str, WalkOperation::*};
use kernel_hal::KernelConfig;

/// 内核入口。
Expand Down Expand Up @@ -49,15 +49,19 @@ static mut BOOT_PAGE_TABLE: BootPageTable = BootPageTable::ZERO;
extern "C" fn primary_rust_main(hartid: usize, device_tree_paddr: usize) -> ! {
// 清零 bss 段
zero_bss();
let secondary_hart_start = secondary_hart_start as usize;
// 使能启动页表
let sstatus = unsafe {
BOOT_PAGE_TABLE.init();
BOOT_PAGE_TABLE.launch(hartid)
};
// 检查设备树
// 副核启动完成前跳板页一直存在,所以可以使用物理地址直接访问设备树
let dtb = unsafe { Dtb::from_raw_parts_unchecked(device_tree_paddr as _) };
let dtb = unsafe {
Dtb::from_raw_parts_filtered(device_tree_paddr as _, |e| {
matches!(e, Misaligned(4) | LastCompVersion(_))
})
}
.unwrap();
let mem_info = kernel_mem_info();
// 打印启动信息
println!(
Expand All @@ -74,7 +78,11 @@ device tree: {device_tree_paddr:016x}..{:016x}
device_tree_paddr + dtb.total_size(),
);
// 启动副核
boot_secondary_harts(hartid, dtb, secondary_hart_start);
boot_secondary_harts(
hartid,
dtb,
secondary_hart_start as usize - mem_info.offset(),
);
// 转交控制权
crate::primary_main(KernelConfig {
phys_to_virt_offset: mem_info.offset(),
Expand Down

0 comments on commit dea9b80

Please sign in to comment.