Re: [PATCH v4 2/6] KVM: x86: Move guest_mode helpers to x86.h

Yosry Ahmed
2026-03-26T23:18:37Z

On Thu, Mar 26, 2026 at 3:49 PM kernel test robot <lkp@intel.com> wrote:
>
> Hi Yosry,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on 3d6cdcc8883b5726513d245eef0e91cabfc397f7]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Yosry-Ahmed/KVM-x86-Move-enable_pmu-enable_mediated_pmu-to-pmu-h-and-pmu-c/20260326-191518
> base: 3d6cdcc8883b5726513d245eef0e91cabfc397f7
> patch link: https://lore.kernel.org/r/20260326031150.3774017-3-yosry%40kernel.org
> patch subject: [PATCH v4 2/6] KVM: x86: Move guest_mode helpers to x86.h
> config: x86_64-buildonly-randconfig-004-20260327 (https://download.01.org/0day-ci/archive/20260327/202603270611.WB2i1rjQ-lkp@intel.com/config)
> compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260327/202603270611.WB2i1rjQ-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202603270611.WB2i1rjQ-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
> In file included from arch/x86/kvm/svm/svm_onhyperv.c:11:
> >> arch/x86/kvm/svm/svm.h:520:6: error: call to undeclared function 'is_guest_mode'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
> 520 | if (is_guest_mode(&svm->vcpu))
> | ^
> arch/x86/kvm/svm/svm.h:578:6: error: call to undeclared function 'is_guest_mode'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
> 578 | if (is_guest_mode(&svm->vcpu) && !nested_vgif_enabled(svm))
> | ^
> arch/x86/kvm/svm/svm.h:639:6: error: call to undeclared function 'is_guest_mode'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
> 639 | if (is_guest_mode(&svm->vcpu))
> | ^
> arch/x86/kvm/svm/svm.h:802:9: error: call to undeclared function 'is_guest_mode'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
> 802 | return is_guest_mode(vcpu) && (svm->nested.ctl.int_ctl & V_INTR_MASKING_MASK);
> | ^
> In file included from arch/x86/kvm/svm/svm_onhyperv.c:12:
> In file included from arch/x86/kvm/svm/svm_ops.h:7:
> >> arch/x86/kvm/x86.h:169:20: error: conflicting types for 'is_guest_mode'
> 169 | static inline bool is_guest_mode(struct kvm_vcpu *vcpu)
> | ^
> arch/x86/kvm/svm/svm.h:520:6: note: previous implicit declaration is here
> 520 | if (is_guest_mode(&svm->vcpu))
> | ^
> 5 errors generated.

Sashiko caught this first :)
https://sashiko.dev/#/patchset/20260326031150.3774017-1-yosry%40kernel.org

I think we just need to fold in including x86.h in svm.h, this fixes it for me:

diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
index ff1e4b4dc9986..2d55c6bf15b32 100644
--- a/arch/x86/kvm/svm/svm.h
+++ b/arch/x86/kvm/svm/svm.h
@@ -24,6 +24,7 @@

#include "cpuid.h"
#include "kvm_cache_regs.h"
+#include "x86.h"

/*
* Helpers to convert to/from physical addresses for pages whose address is