From patchwork Wed May 24 16:08:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 9746349 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 6965D6032B for ; Wed, 24 May 2017 16:08:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5926A289B4 for ; Wed, 24 May 2017 16:08:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C568289B6; Wed, 24 May 2017 16:08:55 +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 E9D21289B4 for ; Wed, 24 May 2017 16:08:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030619AbdEXQIx (ORCPT ); Wed, 24 May 2017 12:08:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48910 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030500AbdEXQIn (ORCPT ); Wed, 24 May 2017 12:08:43 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7AC75C04B95B for ; Wed, 24 May 2017 16:08:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7AC75C04B95B Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=drjones@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7AC75C04B95B Received: from kamzik.brq.redhat.com (kamzik.brq.redhat.com [10.34.1.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA42A91722; Wed, 24 May 2017 16:08:41 +0000 (UTC) From: Andrew Jones To: kvm@vger.kernel.org Cc: pbonzini@redhat.com, rkrcmar@redhat.com, lvivier@redhat.com, thuth@redhat.com Subject: [PATCH kvm-unit-tests 7/8] AArch32: apply errata framework to unsafe pmccntr64 test Date: Wed, 24 May 2017 18:08:17 +0200 Message-Id: <20170524160818.4326-8-drjones@redhat.com> In-Reply-To: <20170524160818.4326-1-drjones@redhat.com> References: <20170524160818.4326-1-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 24 May 2017 16:08:43 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Andrew Jones --- arm/pmu.c | 26 ++++++++++++++++++-------- errata.txt | 1 + 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/arm/pmu.c b/arm/pmu.c index 74848988a678..ae399255f701 100644 --- a/arm/pmu.c +++ b/arm/pmu.c @@ -14,6 +14,7 @@ * for more details. */ #include "libcflat.h" +#include "errata.h" #include "asm/barrier.h" #include "asm/sysreg.h" #include "asm/processor.h" @@ -57,18 +58,12 @@ static inline uint8_t get_pmu_version(void) static inline uint64_t get_pmccntr(void) { - if (pmu_version == 0x3) - return read_sysreg(PMCCNTR64); - else - return read_sysreg(PMCCNTR32); + return read_sysreg(PMCCNTR32); } static inline void set_pmccntr(uint64_t value) { - if (pmu_version == 0x3) - write_sysreg(value, PMCCNTR64); - else - write_sysreg(value & 0xffffffff, PMCCNTR32); + write_sysreg(value & 0xffffffff, PMCCNTR32); } /* PMCCFILTR is an obsolete name for PMXEVTYPER31 in ARMv7 */ @@ -267,6 +262,19 @@ static bool check_cpi(int cpi) return true; } +static void pmccntr64_test(void) +{ +#ifdef __arm__ + if (pmu_version == 0x3) { + if (ERRATA(9e3f7a296940)) { + write_sysreg(0xdead, PMCCNTR64); + report("pmccntr64", true); + } else + report_skip("Skipping unsafe pmccntr64 test. Set ERRATA_9e3f7a296940=y to enable."); + } +#endif +} + /* Return FALSE if no PMU found, otherwise return TRUE */ bool pmu_probe(void) { @@ -293,5 +301,7 @@ int main(int argc, char *argv[]) report("Monotonically increasing cycle count", check_cycles_increase()); report("Cycle/instruction ratio", check_cpi(cpi)); + pmccntr64_test(); + return report_summary(); } diff --git a/errata.txt b/errata.txt index 95b66c837c63..682d7aa067b9 100644 --- a/errata.txt +++ b/errata.txt @@ -2,4 +2,5 @@ # commit : minimum kernel : summary # 12 hex digits : version : #---------------:-----------------------:-------------------------------------- +9e3f7a296940 : 4.9 : arm64: KVM: pmu: Fix AArch32 cycle counter access #---------------:-----------------------:--------------------------------------