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-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230310105346.12302-4-likexu@tencent.com>
Date:   Fri, 10 Mar 2023 18:53:44 +0800
From:   Like Xu <like.xu.linux@...il.com>
To:     Sean Christopherson <seanjc@...gle.com>
Cc:     Paolo Bonzini <pbonzini@...hat.com>,
        Ravi Bangoria <ravi.bangoria@....com>, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH 3/5] KVM: x86/pmu: Move the overflow of a normal counter out of PMI context

From: Like Xu <likexu@...cent.com>

>From the guest's point of view, vPMU's global_status bit update following
a counter overflow is completely independent of whether it is emulated
in the host PMI context. The guest counter overflow emulation only depends
on whether pmc->counter has an overflow or not. Plus the counter overflow
generated by the emulation instruction has been delayed and not been
handled in the PMI context. This part of the logic can be unified by
reusing pmc->prev_counter for a normal counter. However for a PEBS
counter, its buffer overflow irq still requires hardware to trigger PMI.

Signed-off-by: Like Xu <likexu@...cent.com>
---
 arch/x86/kvm/pmu.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
index 01a6b7ffa9b1..81c7cc4ceadf 100644
--- a/arch/x86/kvm/pmu.c
+++ b/arch/x86/kvm/pmu.c
@@ -160,7 +160,10 @@ static void kvm_perf_overflow(struct perf_event *perf_event,
 	if (test_and_set_bit(pmc->idx, pmc_to_pmu(pmc)->reprogram_pmi))
 		return;
 
-	__kvm_perf_overflow(pmc, true);
+	if (pebs_is_enabled(pmc))
+		__kvm_perf_overflow(pmc, true);
+	else
+		pmc->prev_counter = pmc->counter;
 
 	kvm_make_request(KVM_REQ_PMU, pmc->vcpu);
 }
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ