mirror of
https://github.com/torvalds/linux.git
synced 2024-12-29 14:21:47 +00:00
faf01aef05
At the moment KVM on PPC creates 4 types of entries under the kvm debugfs:
1) "%pid-%fd" per a KVM instance (for all platforms);
2) "vm%pid" (for PPC Book3s HV KVM);
3) "vm%u_vcpu%u_timing" (for PPC Book3e KVM);
4) "kvm-xive-%p" (for XIVE PPC Book3s KVM, the same for XICS);
The problem with this is that multiple VMs per process is not allowed for
2) and 3) which makes it possible for userspace to trigger errors when
creating duplicated debugfs entries.
This merges all these into 1).
This defines kvm_arch_create_kvm_debugfs() similar to
kvm_arch_create_vcpu_debugfs().
This defines 2 hooks in kvmppc_ops that allow specific KVM implementations
add necessary entries, this adds the _e500 suffix to
kvmppc_create_vcpu_debugfs_e500() to make it clear what platform it is for.
This makes use of already existing kvm_arch_create_vcpu_debugfs() on PPC.
This removes no more used debugfs_dir pointers from PPC kvm_arch structs.
This stops removing vcpu entries as once created vcpus stay around
for the entire life of a VM and removed when the KVM instance is closed,
see commit d56f5136b0
("KVM: let kvm_destroy_vm_debugfs clean up vCPU
debugfs directories").
Suggested-by: Fabiano Rosas <farosas@linux.ibm.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220111005404.162219-1-aik@ozlabs.ru
100 lines
2.5 KiB
C
100 lines
2.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
*
|
|
* Copyright IBM Corp. 2008
|
|
*
|
|
* Authors: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
|
|
*/
|
|
|
|
#ifndef __POWERPC_KVM_EXITTIMING_H__
|
|
#define __POWERPC_KVM_EXITTIMING_H__
|
|
|
|
#include <linux/kvm_host.h>
|
|
|
|
#ifdef CONFIG_KVM_EXIT_TIMING
|
|
void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu);
|
|
void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu);
|
|
int kvmppc_create_vcpu_debugfs_e500(struct kvm_vcpu *vcpu,
|
|
struct dentry *debugfs_dentry);
|
|
|
|
static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type)
|
|
{
|
|
vcpu->arch.last_exit_type = type;
|
|
}
|
|
|
|
#else
|
|
/* if exit timing is not configured there is no need to build the c file */
|
|
static inline void kvmppc_init_timing_stats(struct kvm_vcpu *vcpu) {}
|
|
static inline void kvmppc_update_timing_stats(struct kvm_vcpu *vcpu) {}
|
|
static inline int kvmppc_create_vcpu_debugfs_e500(struct kvm_vcpu *vcpu,
|
|
struct dentry *debugfs_dentry)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline void kvmppc_set_exit_type(struct kvm_vcpu *vcpu, int type) {}
|
|
#endif /* CONFIG_KVM_EXIT_TIMING */
|
|
|
|
/* account the exit in kvm_stats */
|
|
static inline void kvmppc_account_exit_stat(struct kvm_vcpu *vcpu, int type)
|
|
{
|
|
/* type has to be known at build time for optimization */
|
|
|
|
/* The BUILD_BUG_ON below breaks in funny ways, commented out
|
|
* for now ... -BenH
|
|
BUILD_BUG_ON(!__builtin_constant_p(type));
|
|
*/
|
|
switch (type) {
|
|
case EXT_INTR_EXITS:
|
|
vcpu->stat.ext_intr_exits++;
|
|
break;
|
|
case DEC_EXITS:
|
|
vcpu->stat.dec_exits++;
|
|
break;
|
|
case EMULATED_INST_EXITS:
|
|
vcpu->stat.emulated_inst_exits++;
|
|
break;
|
|
case DSI_EXITS:
|
|
vcpu->stat.dsi_exits++;
|
|
break;
|
|
case ISI_EXITS:
|
|
vcpu->stat.isi_exits++;
|
|
break;
|
|
case SYSCALL_EXITS:
|
|
vcpu->stat.syscall_exits++;
|
|
break;
|
|
case DTLB_REAL_MISS_EXITS:
|
|
vcpu->stat.dtlb_real_miss_exits++;
|
|
break;
|
|
case DTLB_VIRT_MISS_EXITS:
|
|
vcpu->stat.dtlb_virt_miss_exits++;
|
|
break;
|
|
case MMIO_EXITS:
|
|
vcpu->stat.mmio_exits++;
|
|
break;
|
|
case ITLB_REAL_MISS_EXITS:
|
|
vcpu->stat.itlb_real_miss_exits++;
|
|
break;
|
|
case ITLB_VIRT_MISS_EXITS:
|
|
vcpu->stat.itlb_virt_miss_exits++;
|
|
break;
|
|
case SIGNAL_EXITS:
|
|
vcpu->stat.signal_exits++;
|
|
break;
|
|
case DBELL_EXITS:
|
|
vcpu->stat.dbell_exits++;
|
|
break;
|
|
case GDBELL_EXITS:
|
|
vcpu->stat.gdbell_exits++;
|
|
break;
|
|
}
|
|
}
|
|
|
|
/* wrapper to set exit time and account for it in kvm_stats */
|
|
static inline void kvmppc_account_exit(struct kvm_vcpu *vcpu, int type)
|
|
{
|
|
kvmppc_set_exit_type(vcpu, type);
|
|
kvmppc_account_exit_stat(vcpu, type);
|
|
}
|
|
|
|
#endif /* __POWERPC_KVM_EXITTIMING_H__ */
|