From: Oliver Upton oupton@google.com
mainline inclusion from mainline-v5.14 commit fe5161d2c39b8c2801f0e786631460c6e8a1cae4 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4VZJT CVE: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
--------------------------------
Most other architectures that implement KVM record a statistic indicating the number of times a vCPU has exited due to a pending signal. Add support for that stat to arm64.
Reviewed-by: Jing Zhang jingzhangos@google.com Signed-off-by: Oliver Upton oupton@google.com Signed-off-by: Marc Zyngier maz@kernel.org Link: https://lore.kernel.org/r/20210802192809.1851010-2-oupton@google.com
Signed-off-by: Zhang Qiao zhangqiao22@huawei.com Reviewed-by: Keqian Zhu zhukeqian1@huawei.com Signed-off-by: Zheng Zengkai zhengzengkai@huawei.com --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/arm.c | 1 + arch/arm64/kvm/guest.c | 2 ++ 3 files changed, 4 insertions(+)
diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index d44d91e020a4..1723956949f8 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -483,6 +483,7 @@ struct kvm_vcpu_stat { u64 wfi_exit_stat; u64 mmio_exit_user; u64 mmio_exit_kernel; + u64 signal_exits; u64 exits; u64 fp_asimd_exit_stat; u64 irq_exit_stat; diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index d7745ff2eb59..b50d9daf3685 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -794,6 +794,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu) if (signal_pending(current)) { ret = -EINTR; run->exit_reason = KVM_EXIT_INTR; + ++vcpu->stat.signal_exits; }
/* diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index 9e83560bc152..f9c3dbc999e5 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -39,6 +39,7 @@ struct kvm_stats_debugfs_item debugfs_entries[] = { VCPU_STAT("wfi_exit_stat", wfi_exit_stat), VCPU_STAT("mmio_exit_user", mmio_exit_user), VCPU_STAT("mmio_exit_kernel", mmio_exit_kernel), + VCPU_STAT("signal_exits", signal_exits), VCPU_STAT("exits", exits), VCPU_STAT("halt_poll_success_ns", halt_poll_success_ns), VCPU_STAT("halt_poll_fail_ns", halt_poll_fail_ns), @@ -54,6 +55,7 @@ struct dfx_kvm_stats_debugfs_item dfx_debugfs_entries[] = { DFX_STAT("wfi_exit_stat", wfi_exit_stat), DFX_STAT("mmio_exit_user", mmio_exit_user), DFX_STAT("mmio_exit_kernel", mmio_exit_kernel), + DFX_STAT("signal_exits", signal_exits), DFX_STAT("exits", exits), DFX_STAT("fp_asimd_exit_stat", fp_asimd_exit_stat), DFX_STAT("irq_exit_stat", irq_exit_stat),