RSDP validation and fixing a few clippy lints
This commit is contained in:
+21
-3
@@ -9,7 +9,7 @@ pub struct Rsdp {
|
||||
_oemid: [u8; 6],
|
||||
revision: u8,
|
||||
rsdt_address: u32,
|
||||
_length: u32,
|
||||
length: u32,
|
||||
xsdt_address: u64,
|
||||
_extended_checksum: u8,
|
||||
_reserved: [u8; 3],
|
||||
@@ -18,8 +18,26 @@ pub struct Rsdp {
|
||||
impl Rsdp {
|
||||
pub unsafe fn get_rsdp(already_supplied_rsdp: Option<*const u8>) -> Option<Rsdp> {
|
||||
already_supplied_rsdp.map(|rsdp_ptr| {
|
||||
// TODO: Validate
|
||||
unsafe { *(rsdp_ptr as *const Rsdp) }
|
||||
let rsdp = unsafe { *(rsdp_ptr as *const Rsdp) };
|
||||
|
||||
assert_eq!(rsdp.signature, *b"RSD PTR ", "RSDP signature check failed");
|
||||
|
||||
let mut sum: u8 = 0;
|
||||
for i in 0..20 {
|
||||
sum = sum.wrapping_add(unsafe { rsdp_ptr.add(i).read() });
|
||||
}
|
||||
assert_eq!(sum, 0, "RSDP checksum failed");
|
||||
|
||||
|
||||
if rsdp.revision >= 2 {
|
||||
let mut sum: u8 = 0;
|
||||
for i in 0..rsdp.length as usize {
|
||||
sum = sum.wrapping_add(unsafe { rsdp_ptr.add(i).read() });
|
||||
}
|
||||
assert_eq!(sum, 0, "XSDP checksum failed");
|
||||
}
|
||||
|
||||
rsdp
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -513,7 +513,7 @@ fn select_next_context(
|
||||
|
||||
if let Some((next_context_guard, addr_space)) = next_context_guard_opt {
|
||||
// We found a new process!
|
||||
return Some((next_context_guard, addr_space));
|
||||
Some((next_context_guard, addr_space))
|
||||
} else {
|
||||
if !was_idle && !Arc::ptr_eq(&prev_context_lock, &idle_context) {
|
||||
// We switch into the idle context
|
||||
|
||||
+1
-1
@@ -555,7 +555,7 @@ fn init_sections(mut allocator: BumpAllocator<RmmA>) {
|
||||
|
||||
assert_ne!(
|
||||
memory_map_area.size, 0,
|
||||
"RMM should enforce areas are not zeroed"
|
||||
"RMM should enforce areas are not of length 0"
|
||||
);
|
||||
|
||||
// TODO: Should RMM do this?
|
||||
|
||||
+2
-1
@@ -188,6 +188,7 @@ pub unsafe fn nmi_handler(stack: &InterruptStack) {
|
||||
|
||||
let mut len = 2;
|
||||
|
||||
#[expect(clippy::needless_range_loop)]
|
||||
for i in 2..32 {
|
||||
if bp < CurrentRmmArch::PHYS_OFFSET
|
||||
|| bp.saturating_add(16) >= CurrentRmmArch::PHYS_OFFSET + crate::PML4_SIZE
|
||||
@@ -303,7 +304,7 @@ pub fn maybe_run_profiling_helper_forever(cpu_id: LogicalCpuId) {
|
||||
let apic = &mut crate::arch::device::local_apic::the_local_apic();
|
||||
apic.set_lvt_timer((0b01 << 17) | 32);
|
||||
apic.set_div_conf(0b1011);
|
||||
apic.set_init_count(0xffff_f);
|
||||
apic.set_init_count(0x000f_ffff);
|
||||
|
||||
while ACK.load(Ordering::Relaxed) < NUM_ORDINARY_CPUS.load(Ordering::SeqCst) {
|
||||
core::hint::spin_loop();
|
||||
|
||||
@@ -37,6 +37,7 @@ pub fn debug_notify(token: &mut CleanLockToken) {
|
||||
|
||||
pub struct DebugScheme;
|
||||
|
||||
#[expect(clippy::enum_clike_unportable_variant)]
|
||||
#[repr(usize)]
|
||||
enum SpecialFds {
|
||||
Default = -1isize as usize,
|
||||
|
||||
@@ -19,7 +19,7 @@ pub fn resource(token: &mut CleanLockToken) -> Result<Vec<u8>> {
|
||||
let (contexts, mut token) = contexts.token_split();
|
||||
for context_ref in contexts.iter() {
|
||||
let context = context_ref.read(token.token());
|
||||
let addr_space = context.addr_space().map(|a| a.clone());
|
||||
let addr_space = context.addr_space().cloned();
|
||||
|
||||
let affinity = context.sched_affinity.to_string();
|
||||
let cpu_time_s = context.cpu_time / crate::time::NANOS_PER_SEC;
|
||||
|
||||
Reference in New Issue
Block a user