From badd5906d5d279deba144db70ba8de82d1224efe Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Mon, 18 Jul 2022 16:14:50 +0200 Subject: [PATCH] Page-align size in physmap. --- xhcid/src/xhci/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xhcid/src/xhci/mod.rs b/xhcid/src/xhci/mod.rs index 083cd281bc..7d7918fe9e 100644 --- a/xhcid/src/xhci/mod.rs +++ b/xhcid/src/xhci/mod.rs @@ -449,14 +449,18 @@ impl Xhci { }; PhysBox::new_with_flags(byte_count, flags) } + fn page_align(size: usize) -> usize { + // TODO: PAGE_SIZE + (size+4095)/4096*4096 + } pub unsafe fn alloc_dma_zeroed_raw(ac64: bool) -> Result> { - Ok(Dma::from_physbox_zeroed(Self::alloc_phys(ac64, mem::size_of::())?)?.assume_init()) + Ok(Dma::from_physbox_zeroed(Self::alloc_phys(ac64, Self::page_align(mem::size_of::()))?)?.assume_init()) } pub unsafe fn alloc_dma_zeroed(&self) -> Result> { Self::alloc_dma_zeroed_raw(self.cap.ac64()) } pub unsafe fn alloc_dma_zeroed_unsized_raw(ac64: bool, count: usize) -> Result> { - Ok(Dma::from_physbox_zeroed_unsized(Self::alloc_phys(ac64, mem::size_of::() * count)?, count)?.assume_init()) + Ok(Dma::from_physbox_zeroed_unsized(Self::alloc_phys(ac64, Self::page_align(mem::size_of::() * count))?, count)?.assume_init()) } pub unsafe fn alloc_dma_zeroed_unsized(&self, count: usize) -> Result> { Self::alloc_dma_zeroed_unsized_raw(self.cap.ac64(), count)