From patchwork Fri Dec 9 16:44:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 31872 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp881475wrr; Fri, 9 Dec 2022 08:49:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf7kqASx8dTDM6EDaktFAPl1V9jqFXx1GvK3mS8Ntj365fVbWQZzHOb0ecm4ZXXNNch/jl1L X-Received: by 2002:a17:902:7407:b0:189:5b2b:3df4 with SMTP id g7-20020a170902740700b001895b2b3df4mr6186003pll.24.1670604566105; Fri, 09 Dec 2022 08:49:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670604566; cv=none; d=google.com; s=arc-20160816; b=mWccfwCNd7UATA9HAU0ngND2HFm/EF8IhC3/ZaVcnHCx2o+D9JwOpVMCDnEGQ+gH6L jMTBXiaeYwWj/zRoB1GKwAwTnNgu3MSLo1fsp93xqSTDbkY2EjgNa3pjXXDvfhZ9s4X2 y2KSO++H1uftP6D3H/huQT2hlqrI1qXS4DzhOIxLQtTmF0wevlvH57/swXnrA+rc/FjS qB2sLPgdo79qv+6f1wIzfTKEUq642cE3pMOaSCk73TG/JvAVHkHU3kDxBKaZ4Fk4lwK6 Iz1dhslycMt0e5D1ehdTgQ1mo0Mw3+VW8PVq2E/l1hKjesJo48hA04ziAXgcCmvBUztq jJsA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x15-20020a170902ec8f00b001870dc9ef5asi2061659plg.285.2022.12.09.08.49.10; Fri, 09 Dec 2022 08:49:26 -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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751755665366385403?= X-GMAIL-MSGID: =?utf-8?q?1751755853933255623?= 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 Reviewed-by: Oliver Upton --- 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;