Skip to contentSkip to conversation

x86/kvm: Fix compilation warning in non-x86_64 builds

PATCH In review Leonardo Bras 2 participants 2 messages Feb 18, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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

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.

---
 arch/x86/kvm/x86.c | 2 ++
 1 file changed, 2 insertions(+)
arch/x86/kvm/x86.c +2 -0
index ca0fae020961..b389517aa6ed 100644
@@ -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)
 {
Signature · 1 line
2.35.1
maintainer
#1 lore raw
Quoted 19 lines · Leonardo Bras

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.

---
  arch/x86/kvm/x86.c | 2 ++
  1 file changed, 2 insertions(+)
arch/x86/kvm/x86.c +0 -0
index ca0fae020961..b389517aa6ed 100644
@@ -2363,10 +2363,12 @@ static u64 compute_guest_tsc(struct kvm_vcpu *vcpu, s64 kernel_ns)
  	return tsc;
  }

arch/x86/kvm/x86.c static u64 compute_guest_tsc(struct kvm_vcpu *vcpu, s64 kernel_ns) · line 2374

Quoted 10 lines
arch/x86/kvm/x86.c +2 -0
 
+#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)
  {

More precisely, this is an "inline" in a .c (main compilation unit) file. clang warns on them even though it doesn't do that on a .h (included) file.

I tend not to rewind kvm/master and kvm/next unless absolutely necessary, so I pushed an incremental fix for kvm_guest_supported_xfd() as well.

Paolo