[PATCH v1 1/1] x86/kvm: Fix compilation warning in non-x86_64 builds

From: Leonardo Bras
Date: Thu Feb 17 2022 - 22:41:40 EST


On non-x86_64 builds, the helper gtod_is_based_on_tsc() is defined but
never used, which results in an warning with -Wunused-function, and
becomes an error if -Werror is present.

Add #ifdef so gtod_is_based_on_tsc() is only defined in x86_64 builds.

Reported-by: kernel test robot <lkp@xxxxxxxxx>
Signed-off-by: Leonardo Bras <leobras@xxxxxxxxxx>
---
arch/x86/kvm/x86.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index ca0fae020961..b389517aa6ed 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2363,10 +2363,12 @@ static u64 compute_guest_tsc(struct kvm_vcpu *vcpu, s64 kernel_ns)
return tsc;
}

+#ifdef CONFIG_X86_64
static inline int gtod_is_based_on_tsc(int mode)
{
return mode == VDSO_CLOCKMODE_TSC || mode == VDSO_CLOCKMODE_HVCLOCK;
}
+#endif

static void kvm_track_tsc_matching(struct kvm_vcpu *vcpu)
{
--
2.35.1