Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3016452rwb; Fri, 9 Dec 2022 08:59:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf6ANwVmZgID9liM7VfAmP9116D81QGu2/XceaAj4qsuXLyWCEfTdMBWCJIkER6t/KqGADJR X-Received: by 2002:a05:6402:e9f:b0:45c:835b:8f9a with SMTP id h31-20020a0564020e9f00b0045c835b8f9amr5185203eda.5.1670605157076; Fri, 09 Dec 2022 08:59:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670605157; cv=none; d=google.com; s=arc-20160816; b=hlVegVxlKkK9eTigss0/qekmP5VCVBgaklaT/8eZ3D7sao/l5LUGsz5fyNNWZceEjy NLMGdrpZrijJZcKFBr7T+XtDqZJQzB6iyCkohvbMLofS2ISgNlYUmq1D6TYFauHWTXvG P3CqowdD9eBSJ2SAHtm1He1phwgAcwV+9wPWEeUDxcVdB8cZaD/d48osGI8NN++LHwez liogYwBJ2tVwqgCSexGN0HS3LrcT5cJrE6UbX2CwVRO4RrvibEOHLQdDMZJRHHJ4NLn/ RzOkno55Puw3qYmLKapN8mwA5mfBWbcUwQSSYqe2VVxIEEJhIEtE7CKrknceBWw6tk3/ YZuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=oynctOzENr0XjdFbsuLte8H+uJMqZq4Idj0g0UQwvQk=; b=A/p6F/9KAmMP4IXudi7cImwbQAMyVXcxChaP8AYekup/HfsUNqwxgDJlI6rFNDSFa7 brn4CyQ+26AC9oxKBkzvkDdDamRmABLLTPLYNdh74HzlMFwcgYJTCYfAOeU17Yb7EJFi vR4V8ZKyek1dzciirdpERmJ9NLlKjubzy5nikYmpOvQsaZirJ5errag0laL08xhzc1DJ M90zFottysLQkoreVfFxgc9HdH/237QUCztYSTe7C4ORoTkwVxO4WLm8Xc+vtLFABI1z vRJQTkccrtlU78n93vVEMYpR8JKX29MAtphV3EoxVWj2X/Ah3eMqc7IFo1McqLeKCC4n nX8Q== 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 j17-20020a05640211d100b00462848f0cdbsi2444506edw.299.2022.12.09.08.58.59; Fri, 09 Dec 2022 08:59:17 -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 S229714AbiLIQpS (ORCPT + 75 others); Fri, 9 Dec 2022 11:45:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229631AbiLIQpO (ORCPT ); Fri, 9 Dec 2022 11:45:14 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D47102EF22 for ; Fri, 9 Dec 2022 08:45:13 -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 68027D6E; Fri, 9 Dec 2022 08:45:20 -0800 (PST) Received: from e126815.warwick.arm.com (e126815.arm.com [10.32.32.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E3C1A3F73D; Fri, 9 Dec 2022 08:45:11 -0800 (PST) From: James Clark To: kvmarm@lists.linux.dev Cc: James Clark , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Oliver Upton , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Subject: [PATCH 1/1] KVM: arm64: PMU: Fix PMCR_EL0 reset value Date: Fri, 9 Dec 2022 16:44:46 +0000 Message-Id: <20221209164446.1972014-2-james.clark@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221209164446.1972014-1-james.clark@arm.com> References: <20221209164446.1972014-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,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 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. 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 --- 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