lkml.org 
[lkml]   [2021]   [Oct]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 12/16] KVM: Move x86's perf guest info callbacks to generic KVM
On Wed, 22 Sep 2021 01:05:29 +0100,
Sean Christopherson <seanjc@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@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@kernel.org>

M.

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

\
 
 \ /
  Last update: 2021-10-11 11:36    [W:0.367 / U:0.904 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site