Thread (19 messages) 19 messages, 3 authors, 2020-09-09

Re: [PATCH v3 4/5] KVM: arm64: Mask out filtered events in PCMEID{0,1}_EL1

From: Auger Eric <eric.auger@redhat.com>
Date: 2020-09-09 18:09:21
Also in: kvm, kvmarm

Hi Marc,

On 9/9/20 7:50 PM, Marc Zyngier wrote:
Hi Eric,

On 2020-09-09 18:43, Auger Eric wrote:
quoted
Hi Marc,

On 9/8/20 9:58 AM, Marc Zyngier wrote:
quoted
As we can now hide events from the guest, let's also adjust its view of
PCMEID{0,1}_EL1 so that it can figure out why some common events are not
counting as they should.
Referring to my previous comment should we filter the cycle counter out?
quoted
The astute user can still look into the TRM for their CPU and find out
they've been cheated, though. Nobody's perfect.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arch/arm64/kvm/pmu-emul.c | 29 +++++++++++++++++++++++++++++
 arch/arm64/kvm/sys_regs.c |  5 +----
 include/kvm/arm_pmu.h     |  5 +++++
 3 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c
index 67a731bafbc9..0458860bade2 100644
--- a/arch/arm64/kvm/pmu-emul.c
+++ b/arch/arm64/kvm/pmu-emul.c
@@ -765,6 +765,35 @@ static int kvm_pmu_probe_pmuver(void)
     return pmuver;
 }

+u64 kvm_pmu_get_pmceid(struct kvm_vcpu *vcpu, bool pmceid1)
+{
+    unsigned long *bmap = vcpu->kvm->arch.pmu_filter;
+    u64 val, mask = 0;
+    int base, i;
+
+    if (!pmceid1) {
+        val = read_sysreg(pmceid0_el0);
+        base = 0;
+    } else {
+        val = read_sysreg(pmceid1_el0);
+        base = 32;
+    }
+
+    if (!bmap)
+        return val;
+
+    for (i = 0; i < 32; i += 8) {
s/32/4?
I don't think so, see below.
quoted
Thanks

Eric
quoted
+        u64 byte;
+
+        byte = bitmap_get_value8(bmap, base + i);
+        mask |= byte << i;
For each iteration of the loop, we read a byte from the bitmap
(hence the += 8 above), and orr it into the mask. This makes 4
iteration of the loop.

Or am I missing your point entirely?
Hum no you're right. Sorry for the noise.

Looks good to me:

Reviewed-by: Eric Auger <eric.auger@redhat.com>

Eric

Thanks,

        M.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help