// Allocate pages for RQ and SQ
let (rq_mp, rq_pa) = create_contiguous_mapping(rq_size_in_bytes, NIC_MAPPING_FLAGS)?;
let sq_pa = PhysicalAddress::new(rq_pa.value() + rq_size_in_bytes).ok_or("Could not create starting address for SQ")?;
let sq_mp = allocate_memory(sq_pa, sq_size_in_bytes)?;
// Allocate page for SQ/RQ doorbell
let (db_page, db_pa) = create_contiguous_mapping(4096, NIC_MAPPING_FLAGS)?;
This is the portion of code where the problem occurs. The resulting physical address values are:
rq_pa = 0x586b000
sq_pa = 0x587b000
db_pa = 0x587b000
I've traced the issue to the allocate_frames_deferred() function in the frame_allocator crate. It seems that when a physical address is provided to the function, it'll add the required frames to the FREE_RESERVED_FRAMES_LIST without checking if that frame is present in the FREE_FRAMES_LIST.
I'm not sure if the solution is to return an Error if a user requests a physical address that is not in the reserved portions, or to return AllocatedFrames from the FREE_FRAMES_LIST.
This is the portion of code where the problem occurs. The resulting physical address values are:
rq_pa = 0x586b000
sq_pa = 0x587b000
db_pa = 0x587b000
I've traced the issue to the
allocate_frames_deferred()function in the frame_allocator crate. It seems that when a physical address is provided to the function, it'll add the required frames to the FREE_RESERVED_FRAMES_LIST without checking if that frame is present in the FREE_FRAMES_LIST.I'm not sure if the solution is to return an Error if a user requests a physical address that is not in the reserved portions, or to return AllocatedFrames from the FREE_FRAMES_LIST.