lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue,  7 Sep 2021 17:08:24 -0700
From:   Dongli Zhang <dongli.zhang@...cle.com>
To:     kvm@...r.kernel.org
Cc:     pbonzini@...hat.com, seanjc@...gle.com, vkuznets@...hat.com,
        wanpengli@...cent.com, jmattson@...gle.com, joro@...tes.org,
        tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, x86@...nel.org,
        hpa@...or.com, linux-kernel@...r.kernel.org, joe.jin@...cle.com
Subject: [PATCH RFC 1/1] kvm: export per-vcpu exits to userspace

People sometimes may blame KVM scheduling if there is softlockup/rcu_stall
in VM kernel. The KVM developers are required to prove that a specific VCPU
is being regularly scheduled by KVM hypervisor.

So far we use "pidstat -p <qemu-pid> -t 1" or
"cat /proc/<pid>/task/<tid>/stat", but 'exits' is more fine-grained.

Therefore, the 'exits' is exported to userspace to verify if a VCPU is
being scheduled regularly.

I was going to export 'exits', until there was binary stats available.
Unfortunately, QEMU does not support binary stats and we will need to
read via debugfs temporarily. This patch can also be backported to prior
versions that do not support binary stats.

Signed-off-by: Dongli Zhang <dongli.zhang@...cle.com>
---
 arch/x86/kvm/debugfs.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/x86/kvm/debugfs.c b/arch/x86/kvm/debugfs.c
index 95a98413dc32..69ecc06e45a0 100644
--- a/arch/x86/kvm/debugfs.c
+++ b/arch/x86/kvm/debugfs.c
@@ -17,6 +17,15 @@ static int vcpu_get_timer_advance_ns(void *data, u64 *val)
 
 DEFINE_SIMPLE_ATTRIBUTE(vcpu_timer_advance_ns_fops, vcpu_get_timer_advance_ns, NULL, "%llu\n");
 
+static int vcpu_get_exits(void *data, u64 *val)
+{
+	struct kvm_vcpu *vcpu = (struct kvm_vcpu *) data;
+	*val = vcpu->stat.exits;
+	return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(vcpu_exits_fops, vcpu_get_exits, NULL, "%llu\n");
+
 static int vcpu_get_guest_mode(void *data, u64 *val)
 {
 	struct kvm_vcpu *vcpu = (struct kvm_vcpu *) data;
@@ -54,6 +63,8 @@ DEFINE_SIMPLE_ATTRIBUTE(vcpu_tsc_scaling_frac_fops, vcpu_get_tsc_scaling_frac_bi
 
 void kvm_arch_create_vcpu_debugfs(struct kvm_vcpu *vcpu, struct dentry *debugfs_dentry)
 {
+	debugfs_create_file("exits", 0444, debugfs_dentry, vcpu,
+			    &vcpu_exits_fops);
 	debugfs_create_file("guest_mode", 0444, debugfs_dentry, vcpu,
 			    &vcpu_guest_mode_fops);
 	debugfs_create_file("tsc-offset", 0444, debugfs_dentry, vcpu,
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ