Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3146032rwb; Fri, 9 Dec 2022 10:30:10 -0800 (PST) X-Google-Smtp-Source: AA0mqf454cBuf/FNfS5XOCEfQuFokZBF1ZD03+N9A+pGLYusKhT54u+0JhoyeviW91mER5G08KLj X-Received: by 2002:a05:6a00:1786:b0:566:901d:cbef with SMTP id s6-20020a056a00178600b00566901dcbefmr9134261pfg.1.1670610610234; Fri, 09 Dec 2022 10:30:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670610610; cv=none; d=google.com; s=arc-20160816; b=WJt600iyWBppQb514+f4Wp6HN4kZO9EDGzMxOhUVKfFfFF7iKeayb5ZUzKby9gb1tr wUuw3aTWrwilnZvV3X0dx40ug/Z3LaD7fDli9qkJvEaUxAkunGudW1QCDsHccogPt/D1 FLv7tQjtcfd99qDUcX2DLLPVHKyojzHRZsHwbdMOrdU17r1iYhjFxiO0ISg1rzvIRnxR dqE9Om4atWue++M6TcGYqRHI8VnhAqHVN+f6etuENVe4pi3HzUpqL5Fk9MAyTrRoI0oi yRG7/CLmbWx7sM75Pl0wLQPL57DXsibrPgj9TmUXKhNkhRWoUbb3eGWUrKcRjbew6EDP iERQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=IR+jrVVuE0jVnD3pXeex+chn1g7QgKrTqJIzEs1h2fU=; b=Qq18RycR4wAKS82oTDrKb6XxpH9buRK0mn1HQnUZoCRCUyXbmEDdL5P1EgafRzN1jI 4DQ9FrAzIayHjMhauVRkcYpCHkCdKK44jAOcPsS/RXX1z0wRqNINDcwtjhYEm5jWK8kg 0helNqQBuEfsG1aFipVZ7Ysw3Bf90kCSJs9qMMT6hCnO8HK4EWkHDPhwMzqmNU2fUvSd Si88FC3sUla4j5l91mKY2TmruBlaJy1w1rJaKh1j1FuMqpiyBOMLBIZOybmUlHxypirg i6tizSsW8bkIzwt6NiQhAlLhsQWRQgTv4n2eNMxHRUhmDfeYaGKtzTZngZqTgKVexKtd QiqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=XgcgOcm1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i23-20020a633c57000000b00478ba6bfcf0si2030164pgn.703.2022.12.09.10.30.00; Fri, 09 Dec 2022 10:30:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=XgcgOcm1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229896AbiLIR6j (ORCPT + 74 others); Fri, 9 Dec 2022 12:58:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229696AbiLIR6i (ORCPT ); Fri, 9 Dec 2022 12:58:38 -0500 Received: from out-123.mta0.migadu.com (out-123.mta0.migadu.com [IPv6:2001:41d0:1004:224b::7b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A9C27DA69 for ; Fri, 9 Dec 2022 09:58:37 -0800 (PST) Date: Fri, 9 Dec 2022 17:58:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1670608715; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IR+jrVVuE0jVnD3pXeex+chn1g7QgKrTqJIzEs1h2fU=; b=XgcgOcm1DkOKZUjSCrn+qe9RWw0h2gVpf94YOFQK3dKy2YVyyw5mpkzzmrBhWvop6GONrw DU3fcIitfN0dyWC+lATNByCy5EUv/Eud1jWUJOS6SI3hhsXCdsXazyAc7HNBjPmcqpWa4T PYcbxNZR+B79FzdVQPOB5jYyuAqIYQU= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: James Clark Cc: kvmarm@lists.linux.dev, Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] KVM: arm64: PMU: Fix PMCR_EL0 reset value Message-ID: References: <20221209164446.1972014-1-james.clark@arm.com> <20221209164446.1972014-2-james.clark@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221209164446.1972014-2-james.clark@arm.com> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 09, 2022 at 04:44:46PM +0000, James Clark wrote: > ARMV8_PMU_PMCR_N_MASK is an unshifted value which results in the wrong > reset value for PMCR_EL0, so shift it to fix it. That's just mean. *_MASK tends to be a shifted mask, although it would appear that asm/perf_event.h does not follow this convention. Fixing that would be nice (as I'm sure somebody else will get burned by this), but for the sake of an immediate fix: > This fixes the following error when running qemu: > > $ qemu-system-aarch64 -cpu host -machine type=virt,accel=kvm -kernel ... > > target/arm/helper.c:1813: pmevcntr_rawwrite: Assertion `counter < pmu_num_counters(env)' failed. > > Fixes: 292e8f149476 ("KVM: arm64: PMU: Simplify PMCR_EL0 reset handling") > Signed-off-by: James Clark Reviewed-by: Oliver Upton -- Thanks, Oliver > --- > arch/arm64/kvm/sys_regs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index d5ee52d6bf73..c6cbfe6b854b 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -646,7 +646,7 @@ static void reset_pmcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *r) > return; > > /* Only preserve PMCR_EL0.N, and reset the rest to 0 */ > - pmcr = read_sysreg(pmcr_el0) & ARMV8_PMU_PMCR_N_MASK; > + pmcr = read_sysreg(pmcr_el0) & (ARMV8_PMU_PMCR_N_MASK << ARMV8_PMU_PMCR_N_SHIFT); > if (!kvm_supports_32bit_el0()) > pmcr |= ARMV8_PMU_PMCR_LC; > > -- > 2.25.1 >