mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-10-22 23:13:01 +02:00
RISC-V: KVM: Add new exit statstics for redirected traps
Currently, kvm doesn't delegate the few traps such as misaligned load/store, illegal instruction and load/store access faults because it is not expected to occur in the guest very frequently. Thus, kvm gets a chance to act upon it or collect statistics about it before redirecting the traps to the guest. Collect both guest and host visible statistics during the traps. Enable them so that both guest and host can collect the stats about them if required. Reviewed-by: Anup Patel <anup@brainfault.org> Signed-off-by: Atish Patra <atishp@rivosinc.com> Link: https://lore.kernel.org/r/20241224-kvm_guest_stat-v2-3-08a77ac36b02@rivosinc.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
parent
2f15b5eaff
commit
af79caa83f
|
@ -87,6 +87,11 @@ struct kvm_vcpu_stat {
|
|||
u64 csr_exit_kernel;
|
||||
u64 signal_exits;
|
||||
u64 exits;
|
||||
u64 instr_illegal_exits;
|
||||
u64 load_misaligned_exits;
|
||||
u64 store_misaligned_exits;
|
||||
u64 load_access_exits;
|
||||
u64 store_access_exits;
|
||||
};
|
||||
|
||||
struct kvm_arch_memory_slot {
|
||||
|
|
|
@ -34,7 +34,12 @@ const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = {
|
|||
STATS_DESC_COUNTER(VCPU, csr_exit_user),
|
||||
STATS_DESC_COUNTER(VCPU, csr_exit_kernel),
|
||||
STATS_DESC_COUNTER(VCPU, signal_exits),
|
||||
STATS_DESC_COUNTER(VCPU, exits)
|
||||
STATS_DESC_COUNTER(VCPU, exits),
|
||||
STATS_DESC_COUNTER(VCPU, instr_illegal_exits),
|
||||
STATS_DESC_COUNTER(VCPU, load_misaligned_exits),
|
||||
STATS_DESC_COUNTER(VCPU, store_misaligned_exits),
|
||||
STATS_DESC_COUNTER(VCPU, load_access_exits),
|
||||
STATS_DESC_COUNTER(VCPU, store_access_exits),
|
||||
};
|
||||
|
||||
const struct kvm_stats_header kvm_vcpu_stats_header = {
|
||||
|
|
|
@ -195,22 +195,27 @@ int kvm_riscv_vcpu_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
|
|||
switch (trap->scause) {
|
||||
case EXC_INST_ILLEGAL:
|
||||
kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_ILLEGAL_INSN);
|
||||
vcpu->stat.instr_illegal_exits++;
|
||||
ret = vcpu_redirect(vcpu, trap);
|
||||
break;
|
||||
case EXC_LOAD_MISALIGNED:
|
||||
kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_MISALIGNED_LOAD);
|
||||
vcpu->stat.load_misaligned_exits++;
|
||||
ret = vcpu_redirect(vcpu, trap);
|
||||
break;
|
||||
case EXC_STORE_MISALIGNED:
|
||||
kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_MISALIGNED_STORE);
|
||||
vcpu->stat.store_misaligned_exits++;
|
||||
ret = vcpu_redirect(vcpu, trap);
|
||||
break;
|
||||
case EXC_LOAD_ACCESS:
|
||||
kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_ACCESS_LOAD);
|
||||
vcpu->stat.load_access_exits++;
|
||||
ret = vcpu_redirect(vcpu, trap);
|
||||
break;
|
||||
case EXC_STORE_ACCESS:
|
||||
kvm_riscv_vcpu_pmu_incr_fw(vcpu, SBI_PMU_FW_ACCESS_STORE);
|
||||
vcpu->stat.store_access_exits++;
|
||||
ret = vcpu_redirect(vcpu, trap);
|
||||
break;
|
||||
case EXC_INST_ACCESS:
|
||||
|
|
Loading…
Reference in New Issue
Block a user