[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1069892: qemu: FTBFS on riscv64: error: macro "KVM_RISCV_GET_TIMER" requires 4 arguments, but only 3 given



Source: qemu
Version: 1:8.2.3+ds-1
Severity: important
Tags: upstream patch ftbfs
Justification: fails to build from source (but built successfully in the past)
X-Debbugs-Cc: debian-riscv@lists.debian.org

Dear maintainer,

qemu version 1:8.2.3+ds-1 fails to build from source on riscv64:

| FAILED: libqemu-riscv64-softmmu.fa.p/target_riscv_kvm_kvm-cpu.c.o 
| cc -Ilibqemu-riscv64-softmmu.fa.p -I. -I../.. -Itarget/riscv -I../../target/riscv -Iqapi -Itrace -Iui -Iui/shader -I/usr/include/pixman-1 -I/usr/include/capstone -I/usr/include/glib-2.0 -I/usr/lib/riscv64-linux-gnu/glib-2.0/include -fdiagnostics-color=auto -Wall -Winvalid-pch -std=gnu11 -O2 -g -fstack-protector-strong -Wundef -Wwrite-strings -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wold-style-declaration -Wold-style-definition -Wtype-limits -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wempty-body -Wnested-externs -Wendif-labels -Wexpansion-to-defined -Wimplicit-fallthrough=2 -Wmissing-format-attribute -Wno-missing-include-dirs -Wno-shift-negative-value -Wno-psabi -Wshadow=local -isystem /<<PKGBUILDDIR>>/linux-headers -isystem linux-headers -iquote . -iquote /<<PKGBUILDDIR>> -iquote /<<PKGBUILDDIR>>/include -iquote /<<PKGBUILDDIR>>/host/include/generic -iquote /<<PKGBUILDDIR>>/tcg/riscv -pthread -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fno-common -fwrapv -g -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -ffile-prefix-map=../../= -Wdate-time -D_FORTIFY_SOURCE=2 -fPIE -isystem../../linux-headers -isystemlinux-headers -DNEED_CPU_H '-DCONFIG_TARGET="riscv64-softmmu-config-target.h"' '-DCONFIG_DEVICES="riscv64-softmmu-config-devices.h"' -MD -MQ libqemu-riscv64-softmmu.fa.p/target_riscv_kvm_kvm-cpu.c.o -MF libqemu-riscv64-softmmu.fa.p/target_riscv_kvm_kvm-cpu.c.o.d -o libqemu-riscv64-softmmu.fa.p/target_riscv_kvm_kvm-cpu.c.o -c ../../target/riscv/kvm/kvm-cpu.c
| ../../target/riscv/kvm/kvm-cpu.c: In function ‘kvm_riscv_get_timebase_frequency’:
| ../../target/riscv/kvm/kvm-cpu.c:691:43: error: macro "KVM_RISCV_GET_TIMER" requires 4 arguments, but only 3 given
|   691 |     KVM_RISCV_GET_TIMER(cs, frequency, reg);
|       |                                           ^
| ../../target/riscv/kvm/kvm-cpu.c:104: note: macro "KVM_RISCV_GET_TIMER" defined here
|   104 | #define KVM_RISCV_GET_TIMER(cs, env, name, reg) \
|       | 
| ../../target/riscv/kvm/kvm-cpu.c:691:5: error: ‘KVM_RISCV_GET_TIMER’ undeclared (first use in this function); did you mean ‘KVM_RISCV_SBI_EXT_TIME’?
|   691 |     KVM_RISCV_GET_TIMER(cs, frequency, reg);
|       |     ^~~~~~~~~~~~~~~~~~~
|       |     KVM_RISCV_SBI_EXT_TIME
| ../../target/riscv/kvm/kvm-cpu.c:691:5: note: each undeclared identifier is reported only once for each function it appears in
| ninja: build stopped: subcommand failed.
| make: *** [debian/rules:229: b/qemu/built] Error 1
| dpkg-buildpackage: error: debian/rules binary-arch subprocess returned exit status 2

A full build log is available here:
https://buildd.debian.org/status/fetch.php?pkg=qemu&arch=riscv64&ver=1%3A8.2.3%2Bds-1&stamp=1714044943&raw=0

After investigation it appears to be an upstream issue, caused by a
patch backported to the 8.2 stable branch, which does not work as this
branch misses some refactoring commits:

| commit 1e4ec0958ec734ed6a194475e699c917ba950cb2
| Author: Yong-Xuan Wang <yongxuan.wang@sifive.com>
| Date:   Thu Mar 14 14:15:09 2024 +0800
| 
|     target/riscv/kvm: fix timebase-frequency when using KVM acceleration
|     
|     The timebase-frequency of guest OS should be the same with host
|     machine. The timebase-frequency value in DTS should be got from
|     hypervisor when using KVM acceleration.
|     
|     Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
|     Message-ID: <20240314061510.9800-1-yongxuan.wang@sifive.com>
|     Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
|     Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|     Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
|     Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
|     (cherry picked from commit 385e575cd5ab2436c123e4b7f8c9b383a64c0dbe)
|     Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
|     (Mjt: context fix due to missing other changes in this area in 8.2.x)

One way to fix that is to identify and backport the missing commits. I
know that 10f86d1b845087d14b58d65dd2a6e3411d1b6529 is one of them, but
is not enough. However the risk to break more things by backporting more
commits is important.

An alternative is to just fix the build issue with the following patch:

diff --git a/target/riscv/kvm/kvm-cpu.c b/target/riscv/kvm/kvm-cpu.c
index c1675158fe..f15a540f61 100644
--- a/target/riscv/kvm/kvm-cpu.c
+++ b/target/riscv/kvm/kvm-cpu.c
@@ -687,8 +687,9 @@ static void kvm_riscv_put_regs_timer(CPUState *cs)
 uint64_t kvm_riscv_get_timebase_frequency(CPUState *cs)
 {
     uint64_t reg;
+    CPURISCVState *env = &RISCV_CPU(cs)->env;
 
-    KVM_RISCV_GET_TIMER(cs, frequency, reg);
+    KVM_RISCV_GET_TIMER(cs, env, frequency, reg);
 
     return reg;
 }

I will let you, as the maintainer, choose the best option.

Regards
Aurelien

Reply to: