All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Alexandru Elisei <alexandru.elisei@arm.com>,
	Andrew Jones <drjones@redhat.com>,
	Andrew Murray <andrew.murray@arm.com>,
	Beata Michalska <beata.michalska@linaro.org>,
	Christoffer Dall <christoffer.dall@arm.com>,
	Eric Auger <eric.auger@redhat.com>, Gavin Shan <gshan@redhat.com>,
	Haibin Wang <wanghaibin.wang@huawei.com>,
	James Morse <james.morse@arm.com>,
	Mark Brown <broonie@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Russell King <rmk+kernel@armlinux.org.uk>,
	Shannon Zhao <shannon.zhao@linux.alibaba.com>,
	Steven Price <steven.price@arm.com>,
	Will Deacon <will@kernel.org>, YueHaibing <yuehaibing@huawei.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Julien Thierry <julien.thierry.kdev@gmail.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org
Subject: [PATCH 22/23] KVM: arm64: pmu: Only handle supported event counters
Date: Thu, 30 Jan 2020 13:25:57 +0000	[thread overview]
Message-ID: <20200130132558.10201-23-maz@kernel.org> (raw)
In-Reply-To: <20200130132558.10201-1-maz@kernel.org>

From: Eric Auger <eric.auger@redhat.com>

Let the code never use unsupported event counters. Change
kvm_pmu_handle_pmcr() to only reset supported counters and
kvm_pmu_vcpu_reset() to only stop supported counters.

Other actions are filtered on the supported counters in
kvm/sysregs.c

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20200124142535.29386-5-eric.auger@redhat.com
---
 virt/kvm/arm/pmu.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/virt/kvm/arm/pmu.c b/virt/kvm/arm/pmu.c
index 560db6282137..f0d0312c0a55 100644
--- a/virt/kvm/arm/pmu.c
+++ b/virt/kvm/arm/pmu.c
@@ -247,10 +247,11 @@ void kvm_pmu_vcpu_init(struct kvm_vcpu *vcpu)
  */
 void kvm_pmu_vcpu_reset(struct kvm_vcpu *vcpu)
 {
-	int i;
+	unsigned long mask = kvm_pmu_valid_counter_mask(vcpu);
 	struct kvm_pmu *pmu = &vcpu->arch.pmu;
+	int i;
 
-	for (i = 0; i < ARMV8_PMU_MAX_COUNTERS; i++)
+	for_each_set_bit(i, &mask, 32)
 		kvm_pmu_stop_counter(vcpu, &pmu->pmc[i]);
 
 	bitmap_zero(vcpu->arch.pmu.chained, ARMV8_PMU_MAX_COUNTER_PAIRS);
@@ -527,10 +528,9 @@ void kvm_pmu_software_increment(struct kvm_vcpu *vcpu, u64 val)
  */
 void kvm_pmu_handle_pmcr(struct kvm_vcpu *vcpu, u64 val)
 {
-	u64 mask;
+	unsigned long mask = kvm_pmu_valid_counter_mask(vcpu);
 	int i;
 
-	mask = kvm_pmu_valid_counter_mask(vcpu);
 	if (val & ARMV8_PMU_PMCR_E) {
 		kvm_pmu_enable_counter_mask(vcpu,
 		       __vcpu_sys_reg(vcpu, PMCNTENSET_EL0) & mask);
@@ -542,7 +542,7 @@ void kvm_pmu_handle_pmcr(struct kvm_vcpu *vcpu, u64 val)
 		kvm_pmu_set_counter_value(vcpu, ARMV8_PMU_CYCLE_IDX, 0);
 
 	if (val & ARMV8_PMU_PMCR_P) {
-		for (i = 0; i < ARMV8_PMU_CYCLE_IDX; i++)
+		for_each_set_bit(i, &mask, 32)
 			kvm_pmu_set_counter_value(vcpu, i, 0);
 	}
 }
-- 
2.20.1


WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Gavin Shan <gshan@redhat.com>,
	kvm@vger.kernel.org, Will Deacon <will@kernel.org>,
	kvmarm@lists.cs.columbia.edu, YueHaibing <yuehaibing@huawei.com>,
	Steven Price <steven.price@arm.com>,
	Shannon Zhao <shannon.zhao@linux.alibaba.com>,
	Russell King <rmk+kernel@armlinux.org.uk>,
	Mark Brown <broonie@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	Andrew Murray <andrew.murray@arm.com>
Subject: [PATCH 22/23] KVM: arm64: pmu: Only handle supported event counters
Date: Thu, 30 Jan 2020 13:25:57 +0000	[thread overview]
Message-ID: <20200130132558.10201-23-maz@kernel.org> (raw)
In-Reply-To: <20200130132558.10201-1-maz@kernel.org>

From: Eric Auger <eric.auger@redhat.com>

Let the code never use unsupported event counters. Change
kvm_pmu_handle_pmcr() to only reset supported counters and
kvm_pmu_vcpu_reset() to only stop supported counters.

Other actions are filtered on the supported counters in
kvm/sysregs.c

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20200124142535.29386-5-eric.auger@redhat.com
---
 virt/kvm/arm/pmu.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/virt/kvm/arm/pmu.c b/virt/kvm/arm/pmu.c
index 560db6282137..f0d0312c0a55 100644
--- a/virt/kvm/arm/pmu.c
+++ b/virt/kvm/arm/pmu.c
@@ -247,10 +247,11 @@ void kvm_pmu_vcpu_init(struct kvm_vcpu *vcpu)
  */
 void kvm_pmu_vcpu_reset(struct kvm_vcpu *vcpu)
 {
-	int i;
+	unsigned long mask = kvm_pmu_valid_counter_mask(vcpu);
 	struct kvm_pmu *pmu = &vcpu->arch.pmu;
+	int i;
 
-	for (i = 0; i < ARMV8_PMU_MAX_COUNTERS; i++)
+	for_each_set_bit(i, &mask, 32)
 		kvm_pmu_stop_counter(vcpu, &pmu->pmc[i]);
 
 	bitmap_zero(vcpu->arch.pmu.chained, ARMV8_PMU_MAX_COUNTER_PAIRS);
@@ -527,10 +528,9 @@ void kvm_pmu_software_increment(struct kvm_vcpu *vcpu, u64 val)
  */
 void kvm_pmu_handle_pmcr(struct kvm_vcpu *vcpu, u64 val)
 {
-	u64 mask;
+	unsigned long mask = kvm_pmu_valid_counter_mask(vcpu);
 	int i;
 
-	mask = kvm_pmu_valid_counter_mask(vcpu);
 	if (val & ARMV8_PMU_PMCR_E) {
 		kvm_pmu_enable_counter_mask(vcpu,
 		       __vcpu_sys_reg(vcpu, PMCNTENSET_EL0) & mask);
@@ -542,7 +542,7 @@ void kvm_pmu_handle_pmcr(struct kvm_vcpu *vcpu, u64 val)
 		kvm_pmu_set_counter_value(vcpu, ARMV8_PMU_CYCLE_IDX, 0);
 
 	if (val & ARMV8_PMU_PMCR_P) {
-		for (i = 0; i < ARMV8_PMU_CYCLE_IDX; i++)
+		for_each_set_bit(i, &mask, 32)
 			kvm_pmu_set_counter_value(vcpu, i, 0);
 	}
 }
-- 
2.20.1

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Gavin Shan <gshan@redhat.com>,
	Beata Michalska <beata.michalska@linaro.org>,
	kvm@vger.kernel.org, Will Deacon <will@kernel.org>,
	kvmarm@lists.cs.columbia.edu, YueHaibing <yuehaibing@huawei.com>,
	Steven Price <steven.price@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Haibin Wang <wanghaibin.wang@huawei.com>,
	Julien Thierry <julien.thierry.kdev@gmail.com>,
	Andrew Jones <drjones@redhat.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Shannon Zhao <shannon.zhao@linux.alibaba.com>,
	Eric Auger <eric.auger@redhat.com>,
	Russell King <rmk+kernel@armlinux.org.uk>,
	Mark Brown <broonie@kernel.org>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	Christoffer Dall <christoffer.dall@arm.com>,
	James Morse <james.morse@arm.com>,
	Andrew Murray <andrew.murray@arm.com>
Subject: [PATCH 22/23] KVM: arm64: pmu: Only handle supported event counters
Date: Thu, 30 Jan 2020 13:25:57 +0000	[thread overview]
Message-ID: <20200130132558.10201-23-maz@kernel.org> (raw)
In-Reply-To: <20200130132558.10201-1-maz@kernel.org>

From: Eric Auger <eric.auger@redhat.com>

Let the code never use unsupported event counters. Change
kvm_pmu_handle_pmcr() to only reset supported counters and
kvm_pmu_vcpu_reset() to only stop supported counters.

Other actions are filtered on the supported counters in
kvm/sysregs.c

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20200124142535.29386-5-eric.auger@redhat.com
---
 virt/kvm/arm/pmu.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/virt/kvm/arm/pmu.c b/virt/kvm/arm/pmu.c
index 560db6282137..f0d0312c0a55 100644
--- a/virt/kvm/arm/pmu.c
+++ b/virt/kvm/arm/pmu.c
@@ -247,10 +247,11 @@ void kvm_pmu_vcpu_init(struct kvm_vcpu *vcpu)
  */
 void kvm_pmu_vcpu_reset(struct kvm_vcpu *vcpu)
 {
-	int i;
+	unsigned long mask = kvm_pmu_valid_counter_mask(vcpu);
 	struct kvm_pmu *pmu = &vcpu->arch.pmu;
+	int i;
 
-	for (i = 0; i < ARMV8_PMU_MAX_COUNTERS; i++)
+	for_each_set_bit(i, &mask, 32)
 		kvm_pmu_stop_counter(vcpu, &pmu->pmc[i]);
 
 	bitmap_zero(vcpu->arch.pmu.chained, ARMV8_PMU_MAX_COUNTER_PAIRS);
@@ -527,10 +528,9 @@ void kvm_pmu_software_increment(struct kvm_vcpu *vcpu, u64 val)
  */
 void kvm_pmu_handle_pmcr(struct kvm_vcpu *vcpu, u64 val)
 {
-	u64 mask;
+	unsigned long mask = kvm_pmu_valid_counter_mask(vcpu);
 	int i;
 
-	mask = kvm_pmu_valid_counter_mask(vcpu);
 	if (val & ARMV8_PMU_PMCR_E) {
 		kvm_pmu_enable_counter_mask(vcpu,
 		       __vcpu_sys_reg(vcpu, PMCNTENSET_EL0) & mask);
@@ -542,7 +542,7 @@ void kvm_pmu_handle_pmcr(struct kvm_vcpu *vcpu, u64 val)
 		kvm_pmu_set_counter_value(vcpu, ARMV8_PMU_CYCLE_IDX, 0);
 
 	if (val & ARMV8_PMU_PMCR_P) {
-		for (i = 0; i < ARMV8_PMU_CYCLE_IDX; i++)
+		for_each_set_bit(i, &mask, 32)
 			kvm_pmu_set_counter_value(vcpu, i, 0);
 	}
 }
-- 
2.20.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2020-01-30 13:29 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-30 13:25 [GIT PULL 00/23] KVM/arm updates for 5.6 Marc Zyngier
2020-01-30 13:25 ` Marc Zyngier
2020-01-30 13:25 ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 01/23] KVM: arm64: Only sign-extend MMIO up to register width Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 02/23] KVM: arm/arm64: vgic-its: Fix restoration of unmapped collections Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 03/23] KVM: arm/arm64: vgic: Handle GICR_PENDBASER.PTZ filed as RAZ Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 04/23] arm64: kvm: Fix IDMAP overlap with HYP VA Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 05/23] KVM: ARM: Call hyp_cpu_pm_exit at the right place Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 06/23] KVM: arm: Remove duplicate include Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 07/23] KVM: arm/arm64: Re-check VMA on detecting a poisoned page Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 08/23] KVM: arm64: Correct PSTATE on exception entry Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 09/23] KVM: arm/arm64: Correct CPSR " Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 10/23] KVM: arm/arm64: Correct AArch32 SPSR " Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 11/23] KVM: arm/arm64: vgic-its: Properly check the unmapped coll in DISCARD handler Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 12/23] KVM: arm/arm64: vgic: Drop the kvm_vgic_register_mmio_region() Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 13/23] KVM: arm/arm64: Cleanup MMIO handling Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 14/23] arm64: KVM: Add UAPI notes for swapped registers Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 15/23] arm64: KVM: Annotate guest entry/exit as a single function Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 16/23] KVM: arm/arm64: Fix young bit from mmu notifier Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 17/23] KVM: arm: Fix DFSR setting for non-LPAE aarch32 guests Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 18/23] KVM: arm: Make inject_abt32() inject an external abort instead Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 19/23] KVM: arm64: pmu: Don't increment SW_INCR if PMCR.E is unset Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 20/23] KVM: arm64: pmu: Don't mark a counter as chained if the odd one is disabled Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 21/23] KVM: arm64: pmu: Fix chained SW_INCR counters Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` Marc Zyngier [this message]
2020-01-30 13:25   ` [PATCH 22/23] KVM: arm64: pmu: Only handle supported event counters Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25 ` [PATCH 23/23] KVM: arm64: Treat emulated TVAL TimerValue as a signed 32-bit integer Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 13:25   ` Marc Zyngier
2020-01-30 14:11   ` Alexandru Elisei
2020-01-30 14:11     ` Alexandru Elisei
2020-01-30 14:11     ` Alexandru Elisei
2020-01-30 14:15     ` Marc Zyngier
2020-01-30 14:15       ` Marc Zyngier
2020-01-30 14:15       ` Marc Zyngier
2020-01-30 17:13 ` [GIT PULL 00/23] KVM/arm updates for 5.6 Paolo Bonzini
2020-01-30 17:13   ` Paolo Bonzini
2020-01-30 17:13   ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200130132558.10201-23-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=alexandru.elisei@arm.com \
    --cc=andrew.murray@arm.com \
    --cc=beata.michalska@linaro.org \
    --cc=broonie@kernel.org \
    --cc=christoffer.dall@arm.com \
    --cc=drjones@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=gshan@redhat.com \
    --cc=james.morse@arm.com \
    --cc=julien.thierry.kdev@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=pbonzini@redhat.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=shannon.zhao@linux.alibaba.com \
    --cc=steven.price@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=wanghaibin.wang@huawei.com \
    --cc=will@kernel.org \
    --cc=yuehaibing@huawei.com \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.