From 55c3eb7c14b24ae12a4a9853642bab00e7446f6d Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Thu, 23 Jan 2020 14:55:47 +0100 Subject: [PATCH] vmm: fix GIC interrupt register bit shifts Ref #3620 --- repos/os/src/server/vmm/spec/arm_v8/gic.h | 4 ++-- repos/os/src/server/vmm/spec/arm_v8/gicv2.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/repos/os/src/server/vmm/spec/arm_v8/gic.h b/repos/os/src/server/vmm/spec/arm_v8/gic.h index 96b0158240..c8bda7bbae 100644 --- a/repos/os/src/server/vmm/spec/arm_v8/gic.h +++ b/repos/os/src/server/vmm/spec/arm_v8/gic.h @@ -377,11 +377,11 @@ class Vmm::Gic : public Vmm::Mmio_device struct Gicd_icfgr : Irq_reg { - Register read(Irq & irq) { return irq.level() ? 0 : 1; } + Register read(Irq & irq) { return irq.level() ? 0 : 2; } void write(Irq & irq, Register v) { irq.level(!v); } Gicd_icfgr() - : Irq_reg("GICD_ICFGR", Mmio_register::RW, 0xc00, 8, 1024) {} + : Irq_reg("GICD_ICFGR", Mmio_register::RW, 0xc00, 2, 1024) {} } _icfgr; struct Gicd_sgir : Genode::Register<32>, Mmio_register diff --git a/repos/os/src/server/vmm/spec/arm_v8/gicv2.cc b/repos/os/src/server/vmm/spec/arm_v8/gicv2.cc index 05bc1cc83d..98cddd0d2a 100644 --- a/repos/os/src/server/vmm/spec/arm_v8/gicv2.cc +++ b/repos/os/src/server/vmm/spec/arm_v8/gicv2.cc @@ -202,7 +202,7 @@ Register Gic::Irq_reg::read(Address_range & access, Cpu & cpu) Register bits_per_irq = size * 8 / irq_count; for (unsigned i = (access.start * 8) / bits_per_irq; i < ((access.start+access.size) * 8) / bits_per_irq; i++) - ret |= read(cpu.gic().irq(i)) << (i % 32/bits_per_irq); + ret |= read(cpu.gic().irq(i)) << ((i % (32/bits_per_irq) * bits_per_irq)); return ret; } @@ -213,7 +213,7 @@ void Gic::Irq_reg::write(Address_range & access, Cpu & cpu, Register value) Register irq_value_mask = (1<> (i % 32/bits_per_irq)) + write(cpu.gic().irq(i), (value >> ((i % (32/bits_per_irq))*bits_per_irq)) & irq_value_mask); }