On 8/30/23 06:35, Daniel Henrique Barboza wrote:
Commit 6df0b37e2ab breaks a --enable-debug build in a non-KVM
environment with the following error:
/usr/bin/ld: libqemu-riscv64-softmmu.fa.p/hw_intc_riscv_aplic.c.o: in function
`riscv_kvm_aplic_request':
./qemu/build/../hw/intc/riscv_aplic.c:486: undefined reference to `kvm_set_irq'
collect2: error: ld returned 1 exit status
This happens because the debug build will poke into the
'if (is_kvm_aia(aplic->msimode))' block and fail to find a reference to
the KVM only function riscv_kvm_aplic_request().
There are multiple solutions to fix this. We'll go with the same
solution from the previous patch, i.e. add a kvm_enabled() conditional
to filter out the block. But there's a catch: riscv_kvm_aplic_request()
is a local function that would end up being used if the compiler crops
the block, and this won't work. Quoting Richard Henderson's explanation
in [1]:
"(...) the compiler won't eliminate entire unused functions with -O0"
We'll solve it by moving riscv_kvm_aplic_request() to kvm.c and add its
declaration in kvm_riscv.h, where all other KVM specific public
functions are already declared. Other archs handles KVM specific code in
this manner and we expect to do the same from now on.
[1]
https://lore.kernel.org/qemu-riscv/d2f1ad02-eb03-138f-9d08-db676deee...@linaro.org/
Signed-off-by: Daniel Henrique Barboza <dbarb...@ventanamicro.com>
---
hw/intc/riscv_aplic.c | 8 ++------
target/riscv/kvm.c | 5 +++++
target/riscv/kvm_riscv.h | 1 +
3 files changed, 8 insertions(+), 6 deletions(-)
Much better.
Reviewed-by: Richard Henderson <richard.hender...@linaro.org>
r~