[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PULL v2 38/45] hw/riscv/virt.c: fix non-KVM --enable-debug build
From: |
Michael Tokarev |
Subject: |
Re: [PULL v2 38/45] hw/riscv/virt.c: fix non-KVM --enable-debug build |
Date: |
Mon, 11 Sep 2023 22:54:34 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 |
11.09.2023 09:43, Alistair Francis:
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
A build with --enable-debug and without KVM will fail as follows:
/usr/bin/ld: libqemu-riscv64-softmmu.fa.p/hw_riscv_virt.c.o: in function
`virt_machine_init':
./qemu/build/../hw/riscv/virt.c:1465: undefined reference to
`kvm_riscv_aia_create'
This happens because the code block with "if virt_use_kvm_aia(s)" isn't
being ignored by the debug build, resulting in an undefined reference to
a KVM only function.
Add a 'kvm_enabled()' conditional together with virt_use_kvm_aia() will
make the compiler crop the kvm_riscv_aia_create() call entirely from a
non-KVM build. Note that adding the 'kvm_enabled()' conditional inside
virt_use_kvm_aia() won't fix the build because this function would need
to be inlined multiple times to make the compiler zero out the entire
block.
While we're at it, use kvm_enabled() in all instances where
virt_use_kvm_aia() is checked to allow the compiler to elide these other
kvm-only instances as well.
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Fixes: dbdb99948e ("target/riscv: select KVM AIA in riscv virt machine")
This is probably commit 48c2c33c52, not dbdb99948e.
..
/* KVM AIA only has one APLIC instance */
- if (virt_use_kvm_aia(s)) {
+ if (kvm_enabled() && virt_use_kvm_aia(s)) {
create_fdt_socket_aplic(s, memmap, 0,
...
As has been discovered earlier (see "target/i386: Restrict system-specific
features from user emulation" threads), this is not enough, - compiler does
not always eliminate if (0 && foo) { bar; } construct, it's too fragile and
does not actually work. Either some #ifdef'fery is needed here or some other,
more explicit, way to eliminate such code, like introducing stub functions.
I know it's too late and this change is already in, but unfortunately that's
when I noticed this. While the "Fixes:" tag can't be changed anymore, a more
proper fix for the actual problem (with the proper Fixes tag now) can still
be applied on top of this fix.
/mjt
- [PULL v2 31/45] target/riscv: Create an KVM AIA irqchip, (continued)
- [PULL v2 31/45] target/riscv: Create an KVM AIA irqchip, Alistair Francis, 2023/09/11
- [PULL v2 32/45] target/riscv: update APLIC and IMSIC to support KVM AIA, Alistair Francis, 2023/09/11
- [PULL v2 33/45] target/riscv: select KVM AIA in riscv virt machine, Alistair Francis, 2023/09/11
- [PULL v2 35/45] target/riscv: Update CSR bits name for svadu extension, Alistair Francis, 2023/09/11
- [PULL v2 30/45] target/riscv: check the in-kernel irqchip support, Alistair Francis, 2023/09/11
- [PULL v2 34/45] hw/riscv: virt: Fix riscv,pmu DT node path, Alistair Francis, 2023/09/11
- [PULL v2 36/45] target/riscv: fix satp_mode_finalize() when satp_mode.supported = 0, Alistair Francis, 2023/09/11
- [PULL v2 24/45] target/riscv: Add Zihintntl extension ISA string to DTS, Alistair Francis, 2023/09/11
- [PULL v2 37/45] riscv: zicond: make non-experimental, Alistair Francis, 2023/09/11
- [PULL v2 38/45] hw/riscv/virt.c: fix non-KVM --enable-debug build, Alistair Francis, 2023/09/11
- Re: [PULL v2 38/45] hw/riscv/virt.c: fix non-KVM --enable-debug build,
Michael Tokarev <=
[PULL v2 39/45] hw/intc/riscv_aplic.c fix non-KVM --enable-debug build, Alistair Francis, 2023/09/11
[PULL v2 40/45] linux-user/riscv: Add new extensions to hwprobe, Alistair Francis, 2023/09/11
[PULL v2 41/45] target/riscv: Use accelerated helper for AES64KS1I, Alistair Francis, 2023/09/11
[PULL v2 42/45] target/riscv: Allocate itrigger timers only once, Alistair Francis, 2023/09/11
[PULL v2 43/45] target/riscv/pmp.c: respect mseccfg.RLB for pmpaddrX changes, Alistair Francis, 2023/09/11