[PATCH v3 12/16] KVM: Move x86's perf guest info callbacks to generic KVM

Marc Zyngier maz at kernel.org
Mon Oct 11 02:35:48 PDT 2021


On Wed, 22 Sep 2021 01:05:29 +0100,
Sean Christopherson <seanjc at google.com> wrote:
> 
> Move x86's perf guest callbacks into common KVM, as they are semantically
> identical to arm64's callbacks (the only other such KVM callbacks).
> arm64 will convert to the common versions in a future patch.
> 
> Implement the necessary arm64 arch hooks now to avoid having to provide
> stubs or a temporary #define (from x86) to avoid arm64 compilation errors
> when CONFIG_GUEST_PERF_EVENTS=y.
> 
> Signed-off-by: Sean Christopherson <seanjc at google.com>
> ---
>  arch/arm64/include/asm/kvm_host.h |  8 +++++
>  arch/arm64/kvm/arm.c              |  5 +++
>  arch/x86/include/asm/kvm_host.h   |  3 ++
>  arch/x86/kvm/x86.c                | 53 +++++++------------------------
>  include/linux/kvm_host.h          | 10 ++++++
>  virt/kvm/kvm_main.c               | 44 +++++++++++++++++++++++++
>  6 files changed, 81 insertions(+), 42 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> index ed940aec89e0..828b6eaa2c56 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -673,6 +673,14 @@ int io_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa);
>  void kvm_perf_init(void);
>  void kvm_perf_teardown(void);
>  
> +#ifdef CONFIG_GUEST_PERF_EVENTS
> +static inline bool kvm_arch_pmi_in_guest(struct kvm_vcpu *vcpu)

Pardon my x86 ignorance, what is PMI? PMU Interrupt?

> +{
> +	/* Any callback while a vCPU is loaded is considered to be in guest. */
> +	return !!vcpu;
> +}
> +#endif

Do you really need this #ifdef?

> +
>  long kvm_hypercall_pv_features(struct kvm_vcpu *vcpu);
>  gpa_t kvm_init_stolen_time(struct kvm_vcpu *vcpu);
>  void kvm_update_stolen_time(struct kvm_vcpu *vcpu);
> diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
> index e9a2b8f27792..2b542fdc237e 100644
> --- a/arch/arm64/kvm/arm.c
> +++ b/arch/arm64/kvm/arm.c
> @@ -500,6 +500,11 @@ bool kvm_arch_vcpu_in_kernel(struct kvm_vcpu *vcpu)
>  	return vcpu_mode_priv(vcpu);
>  }
>  
> +unsigned long kvm_arch_vcpu_get_ip(struct kvm_vcpu *vcpu)
> +{
> +	return *vcpu_pc(vcpu);
> +}
> +
>  /* Just ensure a guest exit from a particular CPU */
>  static void exit_vm_noop(void *info)
>  {

The above nits notwithstanding,

Acked-by: Marc Zyngier <maz at kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.



More information about the linux-riscv mailing list