From nobody Tue May 21 04:03:30 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15532723589611009.0967009313889; Fri, 22 Mar 2019 09:32:38 -0700 (PDT) Received: from localhost ([127.0.0.1]:59885 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7N5s-00029B-Ez for importer@patchew.org; Fri, 22 Mar 2019 12:32:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7N3T-0000DV-7p for qemu-devel@nongnu.org; Fri, 22 Mar 2019 12:30:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h7N3C-00047W-IF for qemu-devel@nongnu.org; Fri, 22 Mar 2019 12:29:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34687) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h7N3B-0003yI-8y; Fri, 22 Mar 2019 12:29:45 -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 905A4C049E23; Fri, 22 Mar 2019 16:23:37 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.43.2.160]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BFFA5D9CC; Fri, 22 Mar 2019 16:23:36 +0000 (UTC) From: Andrew Jones To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Date: Fri, 22 Mar 2019 17:23:31 +0100 Message-Id: <20190322162333.17159-2-drjones@redhat.com> In-Reply-To: <20190322162333.17159-1-drjones@redhat.com> References: <20190322162333.17159-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]); Fri, 22 Mar 2019 16:23:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/3] target/arm: fix crash on pmu register access X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, aaron@os.amperecomputing.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Fix a QEMU NULL derefence that occurs when the guest attempts to enable PMU counters with a non-v8 cpu model or a v8 cpu model which has not configured a PMU. Fixes: 4e7beb0cc0f3 ("target/arm: Add a timer to predict PMU counter overfl= ow") Signed-off-by: Andrew Jones Reviewed-by: Aaron Lindsay Reviewed-by: Richard Henderson --- target/arm/helper.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index c8d3c213b6b7..fc73488f6cc0 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -1259,6 +1259,10 @@ static bool pmu_counter_enabled(CPUARMState *env, ui= nt8_t counter) int el =3D arm_current_el(env); uint8_t hpmn =3D env->cp15.mdcr_el2 & MDCR_HPMN; =20 + if (!arm_feature(env, ARM_FEATURE_PMU)) { + return false; + } + if (!arm_feature(env, ARM_FEATURE_EL2) || (counter < hpmn || counter =3D=3D 31)) { e =3D env->cp15.c9_pmcr & PMCRE; --=20 2.17.2 From nobody Tue May 21 04:03:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553272457132142.40813160555467; Fri, 22 Mar 2019 09:34:17 -0700 (PDT) Received: from localhost ([127.0.0.1]:59895 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7N7Y-0003YA-3c for importer@patchew.org; Fri, 22 Mar 2019 12:34:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42905) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7N4b-0001NB-8w for qemu-devel@nongnu.org; Fri, 22 Mar 2019 12:31:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h7N4Z-0006zu-Hd for qemu-devel@nongnu.org; Fri, 22 Mar 2019 12:31:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38573) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h7N4W-0006su-Gu; Fri, 22 Mar 2019 12:31:08 -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 08FA33086223; Fri, 22 Mar 2019 16:23:39 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.43.2.160]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7F1E5D9CC; Fri, 22 Mar 2019 16:23:37 +0000 (UTC) From: Andrew Jones To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Date: Fri, 22 Mar 2019 17:23:32 +0100 Message-Id: <20190322162333.17159-3-drjones@redhat.com> In-Reply-To: <20190322162333.17159-1-drjones@redhat.com> References: <20190322162333.17159-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.42]); Fri, 22 Mar 2019 16:23:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/3] target/arm: cortex-a7 and cortex-a15 have pmus X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, aaron@os.amperecomputing.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" cortex-a7 and cortex-a15 have pmus (PMUv2) and they advertise them in ID_DFR0. Let's allow them to function. This also enables the pmu cpu property to work with these cpu types, i.e. we can now do '-cpu cortex-a15,pmu=3Doff' to remove the pmu. Signed-off-by: Andrew Jones Reviewed-by: Richard Henderson --- target/arm/cpu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 96f0ff0ec727..504a4771fbd3 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1109,6 +1109,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error= **errp) #endif } else { cpu->id_aa64dfr0 &=3D ~0xf00; + cpu->id_dfr0 &=3D ~(0xf << 24); cpu->pmceid0 =3D 0; cpu->pmceid1 =3D 0; } @@ -1744,6 +1745,7 @@ static void cortex_a7_initfn(Object *obj) set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); set_feature(&cpu->env, ARM_FEATURE_EL2); set_feature(&cpu->env, ARM_FEATURE_EL3); + set_feature(&cpu->env, ARM_FEATURE_PMU); cpu->kvm_target =3D QEMU_KVM_ARM_TARGET_CORTEX_A7; cpu->midr =3D 0x410fc075; cpu->reset_fpsid =3D 0x41023075; @@ -1789,6 +1791,7 @@ static void cortex_a15_initfn(Object *obj) set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); set_feature(&cpu->env, ARM_FEATURE_EL2); set_feature(&cpu->env, ARM_FEATURE_EL3); + set_feature(&cpu->env, ARM_FEATURE_PMU); cpu->kvm_target =3D QEMU_KVM_ARM_TARGET_CORTEX_A15; cpu->midr =3D 0x412fc0f1; cpu->reset_fpsid =3D 0x410430f0; --=20 2.17.2 From nobody Tue May 21 04:03:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553275032610752.2833235777687; Fri, 22 Mar 2019 10:17:12 -0700 (PDT) Received: from localhost ([127.0.0.1]:60499 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7Nn0-0003n7-Am for importer@patchew.org; Fri, 22 Mar 2019 13:17:06 -0400 Received: from eggs.gnu.org ([209.51.188.92]:47856) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7NT0-0002tQ-EJ for qemu-devel@nongnu.org; Fri, 22 Mar 2019 12:56:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h7N94-0006t8-Nv for qemu-devel@nongnu.org; Fri, 22 Mar 2019 12:35:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36024) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h7N3k-00057f-FP; Fri, 22 Mar 2019 12:30:20 -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 7802688302; Fri, 22 Mar 2019 16:23:40 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.43.2.160]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50AC25D9CC; Fri, 22 Mar 2019 16:23:39 +0000 (UTC) From: Andrew Jones To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Date: Fri, 22 Mar 2019 17:23:33 +0100 Message-Id: <20190322162333.17159-4-drjones@redhat.com> In-Reply-To: <20190322162333.17159-1-drjones@redhat.com> References: <20190322162333.17159-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.28]); Fri, 22 Mar 2019 16:23:40 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/3] target/arm: make pmccntr_op_start/finish static X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, aaron@os.amperecomputing.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" These functions are not used outside helper.c Signed-off-by: Andrew Jones Reviewed-by: Aaron Lindsay Reviewed-by: Richard Henderson --- target/arm/cpu.h | 11 ----------- target/arm/helper.c | 4 ++-- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 5f23c621325c..d4d2836923df 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -992,17 +992,6 @@ static inline bool is_a64(CPUARMState *env) int cpu_arm_signal_handler(int host_signum, void *pinfo, void *puc); =20 -/** - * pmccntr_op_start/finish - * @env: CPUARMState - * - * Convert the counter in the PMCCNTR between its delta form (the typical = mode - * when it's enabled) and the guest-visible value. These two calls must al= ways - * surround any action which might affect the counter. - */ -void pmccntr_op_start(CPUARMState *env); -void pmccntr_op_finish(CPUARMState *env); - /** * pmu_op_start/finish * @env: CPUARMState diff --git a/target/arm/helper.c b/target/arm/helper.c index fc73488f6cc0..a36f4b3d6997 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -1337,7 +1337,7 @@ static void pmu_update_irq(CPUARMState *env) * etc. can be done logically. This is essentially a no-op if the counter = is * not enabled at the time of the call. */ -void pmccntr_op_start(CPUARMState *env) +static void pmccntr_op_start(CPUARMState *env) { uint64_t cycles =3D cycles_get_count(env); =20 @@ -1367,7 +1367,7 @@ void pmccntr_op_start(CPUARMState *env) * guest-visible count. A call to pmccntr_op_finish should follow every ca= ll to * pmccntr_op_start. */ -void pmccntr_op_finish(CPUARMState *env) +static void pmccntr_op_finish(CPUARMState *env) { if (pmu_counter_enabled(env, 31)) { #ifndef CONFIG_USER_ONLY --=20 2.17.2