From 23de87d808c615dc47620876a7daa112994bf948 Mon Sep 17 00:00:00 2001 From: Logan Gunthorpe Date: Tue, 20 Nov 2018 16:36:10 -0700 Subject: Fix the calculation for the number of interrupt enable words The number of interrupt enable words should be the number of devices divided by the number of bits per word (not the number of bytes per word) and it should round up. Without this fix, when using a larger number of interrupts, the user will see a number of errors in qemu of the form: plic: invalid register write: %08x Signed-off-by: Logan Gunthorpe --- machine/minit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'machine') diff --git a/machine/minit.c b/machine/minit.c index b8c9eac..4eee256 100644 --- a/machine/minit.c +++ b/machine/minit.c @@ -129,7 +129,8 @@ static void hart_plic_init() if (!plic_ndevs) return; - size_t ie_words = plic_ndevs / sizeof(uintptr_t) + 1; + size_t ie_words = (plic_ndevs + 8 * sizeof(uintptr_t) - 1) / + (8 * sizeof(uintptr_t)); for (size_t i = 0; i < ie_words; i++) { if (HLS()->plic_s_ie) { // Supervisor not always present -- cgit v1.1