浏览代码

Kernel: Add a VERIFY() to make sure our DMA address is valid

This checks whether the address we're trying to use for DMA is low
enough so as not to overflow the I/O register.
Gunnar Beutner 4 年之前
父节点
当前提交
9b14a8605a
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      Kernel/Devices/SB16.cpp

+ 3 - 0
Kernel/Devices/SB16.cpp

@@ -200,6 +200,9 @@ void SB16::dma_start(uint32_t length)
 
     // Write the buffer
     IO::out8(0x8b, addr >> 16);
+    auto page_number = addr >> 16;
+    VERIFY(page_number <= NumericLimits<u8>::max());
+    IO::out8(0x8b, page_number);
 
     // Enable the DMA channel
     IO::out8(0xd4, (channel % 4));