Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6306270rwb; Sun, 11 Dec 2022 23:19:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf48ArRxxs9tAq1Fz2Vo8Yg7UHB23c/iLf5PJneHhPIt6K79u0BPuO4/pRwlwZTWR7IVohLx X-Received: by 2002:aa7:8554:0:b0:578:5b4:49a6 with SMTP id y20-20020aa78554000000b0057805b449a6mr10822223pfn.12.1670829551236; Sun, 11 Dec 2022 23:19:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670829551; cv=none; d=google.com; s=arc-20160816; b=cnydVyRqpINB4EosJ2hNuv/wbzh7QCcukbEuOe50G51nnslzXVoXJbiHklGfhtwRBw vXTWcOOHBjuWDFStND8jqvAeGfNR4m2x2rjuRrKNrpRWVU77LE6KGFw9Jsxl4L3XRAhn EclJMyTIor6Ex7EAlOID+Ot+7NeuflcBmHvtubwCcRBLcyQAxqsuoTOxs22lQCXvL74k HhA9GCs17sl0+afNV1c1QdpKSxLjQcktTazSCO5MgfruqFWzsio71xtaemgd9lqASwfB +kNOlxhdLpUoBklTo2AGFQjhY6boZSWW5yJXn/qs/3nxCI9DAnUatv09R/0/1JTTIwHN SceA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=GehQUCCY8oAYp4WEBcxb+xrvRkb1Ny9j+8/g6mV4SR8=; b=oVRky950AqBaZi6YLr0rsO+vgSHHnI7FOFExm1Qhk/CYONDi7LOBOYOdnEF/N62ika bJnw4QmIZ7pqkAxb9a6VHBflkoAzq8uUyVrSap7Q5OCaB73bVSIyb1txxWX+IJ7G8CRw /Y9eR+pGjlVLdRaAFkGh+MfTolbCp/CxSqlaEdy3UjqZJFyW/znO5LjoW5it+ckLBpSs trddhwY7XR9Amm3FOnycBLNlNML4aVMh51FVTjgnWarc3saRerQGNbW3TWmh0KrjTfiw oZrZY1e3VnnObK7QtQTGFLXtbukg1Jx8W30/M4m5Lp9K3cYxEeCX+4508WsNX5grvv8S rAJQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v17-20020aa78511000000b00576d944dd65si8547713pfn.54.2022.12.11.23.19.01; Sun, 11 Dec 2022 23:19:11 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231262AbiLLGIb (ORCPT + 75 others); Mon, 12 Dec 2022 01:08:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231248AbiLLGI1 (ORCPT ); Mon, 12 Dec 2022 01:08:27 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 205A1DECE for ; Sun, 11 Dec 2022 22:08:24 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2C6031FB; Sun, 11 Dec 2022 22:09:04 -0800 (PST) Received: from [10.162.43.6] (unknown [10.162.43.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A1A4A3F71E; Sun, 11 Dec 2022 22:08:19 -0800 (PST) Message-ID: Date: Mon, 12 Dec 2022 11:38:16 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH 1/1] KVM: arm64: PMU: Fix PMCR_EL0 reset value Content-Language: en-US To: Oliver Upton , 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 References: <20221209164446.1972014-1-james.clark@arm.com> <20221209164446.1972014-2-james.clark@arm.com> From: Anshuman Khandual In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE 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 12/9/22 23:28, Oliver Upton wrote: > 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: New arch/arm64/tools/sysreg generates shifted i.e in place masks for register fields. Once all these PMU registers move into arch/arm64/tools/sysreg, this problem will be solved. > >> 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 >> > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel