From patchwork Wed Feb 22 11:47:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 9586693 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7EC9D6020B for ; Wed, 22 Feb 2017 11:47:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BFA8288BC for ; Wed, 22 Feb 2017 11:47:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5115C288E6; Wed, 22 Feb 2017 11:47:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E78E2288BC for ; Wed, 22 Feb 2017 11:47:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932589AbdBVLrw (ORCPT ); Wed, 22 Feb 2017 06:47:52 -0500 Received: from foss.arm.com ([217.140.101.70]:43310 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932563AbdBVLrn (ORCPT ); Wed, 22 Feb 2017 06:47:43 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F11A91424; Wed, 22 Feb 2017 03:47:42 -0800 (PST) Received: from approximate.cambridge.arm.com (approximate.cambridge.arm.com [10.1.207.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1A5F13F220; Wed, 22 Feb 2017 03:47:41 -0800 (PST) From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu Cc: Christoffer Dall , Shannon Zhao Subject: [PATCH 7/8] arm64: KVM: pmu: Make illegal accesses seen as successfully emulated Date: Wed, 22 Feb 2017 11:47:27 +0000 Message-Id: <20170222114728.2472-8-marc.zyngier@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170222114728.2472-1-marc.zyngier@arm.com> References: <20170222114728.2472-1-marc.zyngier@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that we can deliver an exception on an illegal PMU access, we can stop pretending that they have failed to be emulated. We can thus return "true" in all these cases. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/sys_regs.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 01c8d841851e..44b7a7325229 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -506,7 +506,7 @@ static bool access_pmcr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, return trap_raz_wi(vcpu, p, r); if (pmu_access_el0_disabled(vcpu)) - return false; + return true; if (p->is_write) { /* Only update writeable bits of PMCR */ @@ -532,7 +532,7 @@ static bool access_pmselr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, return trap_raz_wi(vcpu, p, r); if (pmu_access_event_counter_el0_disabled(vcpu)) - return false; + return true; if (p->is_write) vcpu_sys_reg(vcpu, PMSELR_EL0) = p->regval; @@ -555,7 +555,7 @@ static bool access_pmceid(struct kvm_vcpu *vcpu, struct sys_reg_params *p, BUG_ON(p->is_write); if (pmu_access_el0_disabled(vcpu)) - return false; + return true; if (!(p->Op2 & 1)) pmceid = read_sysreg(pmceid0_el0); @@ -594,14 +594,14 @@ static bool access_pmu_evcntr(struct kvm_vcpu *vcpu, if (r->Op2 == 2) { /* PMXEVCNTR_EL0 */ if (pmu_access_event_counter_el0_disabled(vcpu)) - return false; + return true; idx = vcpu_sys_reg(vcpu, PMSELR_EL0) & ARMV8_PMU_COUNTER_MASK; } else if (r->Op2 == 0) { /* PMCCNTR_EL0 */ if (pmu_access_cycle_counter_el0_disabled(vcpu)) - return false; + return true; idx = ARMV8_PMU_CYCLE_IDX; } else { @@ -610,13 +610,13 @@ static bool access_pmu_evcntr(struct kvm_vcpu *vcpu, } else if (r->CRn == 0 && r->CRm == 9) { /* PMCCNTR */ if (pmu_access_event_counter_el0_disabled(vcpu)) - return false; + return true; idx = ARMV8_PMU_CYCLE_IDX; } else if (r->CRn == 14 && (r->CRm & 12) == 8) { /* PMEVCNTRn_EL0 */ if (pmu_access_event_counter_el0_disabled(vcpu)) - return false; + return true; idx = ((r->CRm & 3) << 3) | (r->Op2 & 7); } else { @@ -624,11 +624,11 @@ static bool access_pmu_evcntr(struct kvm_vcpu *vcpu, } if (!pmu_counter_idx_valid(vcpu, idx)) - return false; + return true; if (p->is_write) { if (pmu_access_el0_disabled(vcpu)) - return false; + return true; kvm_pmu_set_counter_value(vcpu, idx, p->regval); } else { @@ -647,7 +647,7 @@ static bool access_pmu_evtyper(struct kvm_vcpu *vcpu, struct sys_reg_params *p, return trap_raz_wi(vcpu, p, r); if (pmu_access_el0_disabled(vcpu)) - return false; + return true; if (r->CRn == 9 && r->CRm == 13 && r->Op2 == 1) { /* PMXEVTYPER_EL0 */ @@ -665,7 +665,7 @@ static bool access_pmu_evtyper(struct kvm_vcpu *vcpu, struct sys_reg_params *p, } if (!pmu_counter_idx_valid(vcpu, idx)) - return false; + return true; if (p->is_write) { kvm_pmu_set_counter_event_type(vcpu, p->regval, idx); @@ -686,7 +686,7 @@ static bool access_pmcnten(struct kvm_vcpu *vcpu, struct sys_reg_params *p, return trap_raz_wi(vcpu, p, r); if (pmu_access_el0_disabled(vcpu)) - return false; + return true; mask = kvm_pmu_valid_counter_mask(vcpu); if (p->is_write) { @@ -745,7 +745,7 @@ static bool access_pmovs(struct kvm_vcpu *vcpu, struct sys_reg_params *p, return trap_raz_wi(vcpu, p, r); if (pmu_access_el0_disabled(vcpu)) - return false; + return true; if (p->is_write) { if (r->CRm & 0x2) @@ -770,7 +770,7 @@ static bool access_pmswinc(struct kvm_vcpu *vcpu, struct sys_reg_params *p, return trap_raz_wi(vcpu, p, r); if (pmu_write_swinc_el0_disabled(vcpu)) - return false; + return true; if (p->is_write) { mask = kvm_pmu_valid_counter_mask(vcpu); @@ -779,7 +779,7 @@ static bool access_pmswinc(struct kvm_vcpu *vcpu, struct sys_reg_params *p, } pend_undef(vcpu); - return false; + return true; } static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p,