diff mbox series

[1/2] hw/intc/riscv_aplic.c fix non-KVM --enable-debug build

Message ID 20230829122144.464489-2-dbarboza@ventanamicro.com
State New
Headers show
Series riscv: fix --enable-debug in riscv-to-apply.next | expand

Commit Message

Daniel Henrique Barboza Aug. 29, 2023, 12:21 p.m. UTC
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().

Make riscv_kvm_aplic_request() a no-op if we're not building KVM.

Fixes: 6df0b37e2ab ("target/riscv: update APLIC and IMSIC to support KVM AIA")
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
 hw/intc/riscv_aplic.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Philippe Mathieu-Daudé Aug. 29, 2023, 2:17 p.m. UTC | #1
On 29/8/23 14:21, 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().
> 
> Make riscv_kvm_aplic_request() a no-op if we're not building KVM.
> 
> Fixes: 6df0b37e2ab ("target/riscv: update APLIC and IMSIC to support KVM AIA")
> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
> ---
>   hw/intc/riscv_aplic.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c
> index 592c3ce768..b634738bda 100644
> --- a/hw/intc/riscv_aplic.c
> +++ b/hw/intc/riscv_aplic.c
> @@ -483,7 +483,9 @@ static uint32_t riscv_aplic_idc_claimi(RISCVAPLICState *aplic, uint32_t idc)
>   
>   static void riscv_kvm_aplic_request(void *opaque, int irq, int level)
>   {
> +#ifdef CONFIG_KVM
>       kvm_set_irq(kvm_state, irq, !!level);
> +#endif
>   }

Can we use kvm_enabled() to let the compiler elide KVM code
when !CONFIG_KVM?

-- >8 --
diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c
index 592c3ce768..f28d0d3237 100644
@@ -155,7 +155,7 @@
   */
  static bool is_kvm_aia(bool msimode)
  {
-    return kvm_irqchip_in_kernel() && msimode;
+    return kvm_enabled() && kvm_irqchip_in_kernel() && msimode;
  }
---
Daniel Henrique Barboza Aug. 29, 2023, 10:35 p.m. UTC | #2
On 8/29/23 11:17, Philippe Mathieu-Daudé wrote:
> On 29/8/23 14:21, 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().
>>
>> Make riscv_kvm_aplic_request() a no-op if we're not building KVM.
>>
>> Fixes: 6df0b37e2ab ("target/riscv: update APLIC and IMSIC to support KVM AIA")
>> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
>> ---
>>   hw/intc/riscv_aplic.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c
>> index 592c3ce768..b634738bda 100644
>> --- a/hw/intc/riscv_aplic.c
>> +++ b/hw/intc/riscv_aplic.c
>> @@ -483,7 +483,9 @@ static uint32_t riscv_aplic_idc_claimi(RISCVAPLICState *aplic, uint32_t idc)
>>   static void riscv_kvm_aplic_request(void *opaque, int irq, int level)
>>   {
>> +#ifdef CONFIG_KVM
>>       kvm_set_irq(kvm_state, irq, !!level);
>> +#endif
>>   }
> 
> Can we use kvm_enabled() to let the compiler elide KVM code
> when !CONFIG_KVM?
> 
> -- >8 --
> diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c
> index 592c3ce768..f28d0d3237 100644
> @@ -155,7 +155,7 @@
>    */
>   static bool is_kvm_aia(bool msimode)
>   {
> -    return kvm_irqchip_in_kernel() && msimode;
> +    return kvm_enabled() && kvm_irqchip_in_kernel() && msimode;

Apparently we can't:


$ git diff
diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c
index b634738bda..f28d0d3237 100644
--- a/hw/intc/riscv_aplic.c
+++ b/hw/intc/riscv_aplic.c
@@ -155,7 +155,7 @@
   */
  static bool is_kvm_aia(bool msimode)
  {
-    return kvm_irqchip_in_kernel() && msimode;
+    return kvm_enabled() && kvm_irqchip_in_kernel() && msimode;
  }
  
  static uint32_t riscv_aplic_read_input_word(RISCVAPLICState *aplic,
@@ -483,9 +483,7 @@ static uint32_t riscv_aplic_idc_claimi(RISCVAPLICState *aplic, uint32_t idc)
  
  static void riscv_kvm_aplic_request(void *opaque, int irq, int level)
  {
-#ifdef CONFIG_KVM
      kvm_set_irq(kvm_state, irq, !!level);
-#endif
  }

Same error appears:


/usr/bin/ld: libqemu-riscv64-softmmu.fa.p/hw_intc_riscv_aplic.c.o: in function `riscv_kvm_aplic_request':
/home/danielhb/work/qemu/build/../hw/intc/riscv_aplic.c:486: undefined reference to `kvm_set_irq'
collect2: error: ld returned 1 exit status


Thanks,


Daniel



>   }
> ---
>
diff mbox series

Patch

diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c
index 592c3ce768..b634738bda 100644
--- a/hw/intc/riscv_aplic.c
+++ b/hw/intc/riscv_aplic.c
@@ -483,7 +483,9 @@  static uint32_t riscv_aplic_idc_claimi(RISCVAPLICState *aplic, uint32_t idc)
 
 static void riscv_kvm_aplic_request(void *opaque, int irq, int level)
 {
+#ifdef CONFIG_KVM
     kvm_set_irq(kvm_state, irq, !!level);
+#endif
 }
 
 static void riscv_aplic_request(void *opaque, int irq, int level)