Re: [PATCH] perf kvm stat: Fix build error
From: Ian Rogers
Date: Thu Feb 26 2026 - 01:36:44 EST
On Wed, Feb 25, 2026 at 5:56 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>
> Hi Ian,
>
> On Fri, Feb 06, 2026 at 11:00:20AM +0000, Leo Yan wrote:
> > Since commit ceea279f9376 ("perf kvm stat: Remove use of the arch
> > directory"), a native build on Arm64 machine reports:
> >
> > util/kvm-stat-arch/kvm-stat-x86.c:7:10: fatal error: asm/svm.h: No such file or directory
> > 7 | #include <asm/svm.h>
> > | ^~~~~~~~~~~
> > compilation terminated.
> >
> > The build fails to find x86's asm headers when building for Arm64. Fix
> > this by including asm headers with relative path instead.
> >
> > Fixes: ceea279f9376 ("perf kvm stat: Remove use of the arch directory")
> > Signed-off-by: Leo Yan <leo.yan@xxxxxxx>
>
> Probably not from this patch, but this change seems to introduce this
> error on my i386.
>
> In file included from util/kvm-stat-arch/kvm-stat-x86.c:4:
> /linux/tools/include/../../arch/x86/include/uapi/asm/svm.h:137:32: error: conversion from 'long long unsigned int' to 'long unsigned int' changes value from '18446744073709551615' to '4294967295' [-Werror=overflow]
> 137 | #define SVM_EXIT_ERR -1ull
> | ^
> util/kvm-stat-arch/kvm-stat-x86.c:13:1: note: in expansion of macro 'define_exit_reasons_table'
> 13 | define_exit_reasons_table(svm_exit_reasons, SVM_EXIT_REASONS);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~
> /linux/tools/include/../../arch/x86/include/uapi/asm/svm.h:249:11: note: in expansion of macro 'SVM_EXIT_ERR'
> 249 | { SVM_EXIT_ERR, "invalid_guest_state" }
> | ^~~~~~~~~~~~
> util/kvm-stat-arch/kvm-stat-x86.c:13:45: note: in expansion of macro 'SVM_EXIT_REASONS'
> 13 | define_exit_reasons_table(svm_exit_reasons, SVM_EXIT_REASONS);
> | ^~~~~~~~~~~~~~~~
Hmm.. it looks like something has gone screwy with the include paths.
The header you've gotten is:
https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/arch/x86/include/uapi/asm/svm.h#n137
rather than:
https://web.git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git/tree/tools/arch/x86/include/uapi/asm/svm.h#n137
where the value differs between -1ull and -1.
In Leo's change he has the include path as:
#include "../../arch/x86/include/uapi/asm/svm.h"
but I think that is off by one and should be:
#include "../../../arch/x86/include/uapi/asm/svm.h"
Making the include path this should prioritize finding the tool's
version of the file over using the include paths. Could you try adding
the missing "../" to the paths, I wasn't able to reproduce locally
building with -m32.
Longer term maybe a macro like UINT64_C should be used to avoid these
kinds of long long vs long problems.
Thanks,
Ian
> Thanks,
> Namhyung
>
> > ---
> > tools/perf/util/kvm-stat-arch/kvm-stat-x86.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c b/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c
> > index 1cf541385a4bdee4930b67a054906ccade7301fd..43275d25b6cbccc477ba45a901d69c67422847ae 100644
> > --- a/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c
> > +++ b/tools/perf/util/kvm-stat-arch/kvm-stat-x86.c
> > @@ -4,9 +4,9 @@
> > #include "../kvm-stat.h"
> > #include "../evsel.h"
> > #include "../env.h"
> > -#include <asm/svm.h>
> > -#include <asm/vmx.h>
> > -#include <asm/kvm.h>
> > +#include "../../arch/x86/include/uapi/asm/svm.h"
> > +#include "../../arch/x86/include/uapi/asm/vmx.h"
> > +#include "../../arch/x86/include/uapi/asm/kvm.h"
> > #include <subcmd/parse-options.h>
> >
> > define_exit_reasons_table(vmx_exit_reasons, VMX_EXIT_REASONS);
> >
> > ---
> > base-commit: 84cb36da81413c2dff805150b9f4db1524460269
> > change-id: 20260206-perf_fix_kvm_stat_error-a795a1dd67a2
> >
> > Best regards,
> > --
> > Leo Yan <leo.yan@xxxxxxx>
> >