From 6a553568c56146f3084e361a7194c8a0762b58da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Wed, 19 Jul 2023 16:48:15 +0200 Subject: [PATCH] kernel/mem: Assert ABITS is not below wide_log2 Later in the check() code we check the bottom wide_log2 bits on the address port are zeroed out. If the address port is too narrow, we crash due to out of bounds access. Explicitly assert the address port is wide enough, so we don't crash on input such as read_rtlil <= port.wide_log2); log_assert(GetSize(port.data) == (width << port.wide_log2)); log_assert(GetSize(port.init_value) == (width << port.wide_log2)); log_assert(GetSize(port.arst_value) == (width << port.wide_log2)); @@ -484,6 +485,7 @@ void Mem::check() { log_assert(GetSize(port.clk) == 1); log_assert(GetSize(port.en) == (width << port.wide_log2)); log_assert(GetSize(port.data) == (width << port.wide_log2)); + log_assert(GetSize(port.addr) >= port.wide_log2); for (int j = 0; j < port.wide_log2; j++) { log_assert(port.addr[j] == State::S0); }