Re: [tip:perf/core 12/17] arch/arm64/kvm/arm.c:499:15: warning: no previous prototype for function 'kvm_arch_vcpu_get_ip'

From: Sean Christopherson
Date: Mon Nov 22 2021 - 14:42:48 EST


+Peter, Marc

On Mon, Nov 22, 2021, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf/core
> head: a9f4a6e92b3b319296fb078da2615f618f6cd80c
> commit: e1bfc24577cc65c95dc519d7621a9c985b97e567 [12/17] KVM: Move x86's perf guest info callbacks to generic KVM
> All warnings (new ones prefixed by >>):
>
> >> arch/arm64/kvm/arm.c:499:15: warning: no previous prototype for function 'kvm_arch_vcpu_get_ip' [-Wmissing-prototypes]
> unsigned long kvm_arch_vcpu_get_ip(struct kvm_vcpu *vcpu)
> ^
> arch/arm64/kvm/arm.c:499:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
> unsigned long kvm_arch_vcpu_get_ip(struct kvm_vcpu *vcpu)
> ^
> static
> 1 warning generated.

Argh, the declaration is behind CONFIG_GUEST_PERF_EVENTS=y so that architectures
that don't support GUEST_PERF_EVENTS at all didn't need to provide implementations.

There are a few ways to solve this, none of which I particularly love. I think my
first choice would be to wrap arm's implementation with an #ifdef. Stubbing out a
getter like this feels all kinds of wrong, and moving the declaration outside of
CONFIG_GUEST_PERF_EVENTS=y will set someone up to try and use the helper when it's
not available.

---
arch/arm64/kvm/arm.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index 8129ee1ed3a4..e3b46951a92d 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -496,10 +496,12 @@ bool kvm_arch_vcpu_in_kernel(struct kvm_vcpu *vcpu)
return vcpu_mode_priv(vcpu);
}

+#ifdef CONFIG_GUEST_PERF_EVENTS
unsigned long kvm_arch_vcpu_get_ip(struct kvm_vcpu *vcpu)
{
return *vcpu_pc(vcpu);
}
+#endif

/* Just ensure a guest exit from a particular CPU */
static void exit_vm_noop(void *info)
--