OSDN Git Service

hw/intc: sifive_plic: Avoid overflowing the addr_config buffer
authorAlistair Francis <alistair.francis@wdc.com>
Wed, 1 Jun 2022 01:36:31 +0000 (11:36 +1000)
committerAlistair Francis <alistair.francis@wdc.com>
Thu, 9 Jun 2022 23:31:42 +0000 (09:31 +1000)
commit40244040a7ac00d40db4dea02234d13502c30112
treedcda9e053d79419cb0cf24b7bb53ef545e464a56
parentf9a461b2d3b8ef4f36b7891eb4040693ee071719
hw/intc: sifive_plic: Avoid overflowing the addr_config buffer

Since commit ad40be27 "target/riscv: Support start kernel directly by
KVM" we have been overflowing the addr_config on "M,MS..."
configurations, as reported https://gitlab.com/qemu-project/qemu/-/issues/1050.

This commit changes the loop in sifive_plic_create() from iterating over
the number of harts to just iterating over the addr_config. The
addr_config is based on the hart_config, and will contain interrup details
for all harts. This way we can't iterate past the end of addr_config.

Fixes: ad40be27084536 ("target/riscv: Support start kernel directly by KVM")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1050
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Mingwang Li <limingwang@huawei.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20220601013631.196854-1-alistair.francis@opensource.wdc.com>
hw/intc/sifive_plic.c