Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8795105rwb; Tue, 13 Dec 2022 10:29:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Ue8xGMduH1C52EmpAgYiH5IpcCLfhMWfDt+6ZWltRC0F0Axv/wzgEoFxaKAQ7TlLZM/Cy X-Received: by 2002:a17:903:2655:b0:189:d072:18f0 with SMTP id je21-20020a170903265500b00189d07218f0mr20190564plb.25.1670956154234; Tue, 13 Dec 2022 10:29:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670956154; cv=none; d=google.com; s=arc-20160816; b=Z/0Hofwg75/t2o1dnuHmAvR9TdFkBaqBQbuumhoE0W6oi8tAJjD+HS8bT6qlHTy2R6 1zjR0DWtzrzc6pi6vszA2kiZtAzA5xZH7W3XvGzbaBjk0pQAHAqZ9eBe82GmjRcbR6WK dLVyFcn/99T2Tfj5jlk0xG3yXkqjg4B7fuK4QZS2Vv/hmUR39aMN30S5EXpKFl0c1BCK ljM0NJ0elIKDV+G9sNGeghB2mzdvzTGGEZg+DdAJy/vtTzyADb4DpsE954FdgbDXA6QD JrAwRT88WV/baMH4DwpFi8DJwA5X7obFrUwiWAX0u5e9krExGY8B+mTWNHDUbGIjJkct Okxw== 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:date:dkim-signature; bh=vbt0meIgNn6WBG4YKbNfGi1T3PYNH2tI0RABGm6MAIY=; b=nfxq4Yo7TYTyrIPoP/IxyZ0Hh4MB+EjBmj3Qs1bs2REFwPtbMOzUzFc92NETYNZbbA qJ7RkTb9oFrD9tHx4beJNClgo/OX2cygFxSCLj9hVZ023bXCD3XonF8Ge8BiBcMNtWus rFTDX2PfOW96+8OFsn1GKjkgaNX75PSN0cITOdE8Woz2cVRS64f+Ad/C+wTOJrvtTb5e OX8YPzLsL8Ui+rolw84OHhxedCyc8Q6dFTWfAy/PNwIpxte+QGdcREj7dKrdrdCjB8pY 6dCXSFZrBHnF5OLFNzwiqpZ0maBxsrHOg1bSu8Lf2p3LdgYQLk6EUUUuJ2Povz5KNIHB vZcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=clVFCd5N; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020a170903024800b001846e0e0511si427190plh.226.2022.12.13.10.29.05; Tue, 13 Dec 2022 10:29:14 -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=@google.com header.s=20210112 header.b=clVFCd5N; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236425AbiLMSW4 (ORCPT + 72 others); Tue, 13 Dec 2022 13:22:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236271AbiLMSWy (ORCPT ); Tue, 13 Dec 2022 13:22:54 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B482248 for ; Tue, 13 Dec 2022 10:22:50 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id r18so388759pgr.12 for ; Tue, 13 Dec 2022 10:22:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=vbt0meIgNn6WBG4YKbNfGi1T3PYNH2tI0RABGm6MAIY=; b=clVFCd5NAswd0cV5yiJ07YbrMqm/CoMDjz7XOZ2ww7a9GYyW5vk4yywNHRG5Ad+WXB hbq44pfn7aYqEIVVmUQsFM6Y8CxcJlw3QXr/qCvnKCNZBr8PzznZVoNkfZNbn1xITgwW +nBS4O9SzJ/7RuXokUHopQoBRfoB75i29p7cO2lqearialjc2gIWpVxIy1tX/nmDQgwc W58XTPAQZgCLDbxqZzXtl1PCpopHaxD1OtIsbXSLCYd76Ow533MgDCL5mG6/XVENGbWF ZfNmBf8gS0lPgVdqVkKxH6lghccfPJyKH2BL2/y9fbgiRx549qyPOE9NiT9AsmrxddrV KhUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=vbt0meIgNn6WBG4YKbNfGi1T3PYNH2tI0RABGm6MAIY=; b=FvH8gYnPIeH63ZFQjVe0hKr1tfEWLjAsqujuPG9+bvjrtVKn2CJqZ0qk3y3wCwdwKA Vg8/lD6dqnOj/rEZIo9OhrpLZQTZXsZA+DKRD8Zrzu/kGWFlRzoANFAUk5ccMH8RcmJF ORZZoTWri8E+LmQzKYb5zgpDjIr/9hMZxmk+xx12sJWJ6IzbmiZ29i0Kg0O3IL7xWJTk MR91yOWPzn1H6uCiNWRJBa5W07sO17Ukl5WOQ9gpJcm5zqghIdbGJMble6jMz1paUBXh mRwOma0N5lttQpvEly3fiGDRDVVY/xDcmZFEjhedu6fJju5BH5gC1Hiy1lfEHFiWBHyQ aZEA== X-Gm-Message-State: ANoB5plCgsIwHPht4m1AajnZwEFIV7bKGj8AoYkmQstvb+zwZ0ciLYzb DXSpGb5R+34Dy/neZ5tvm1DcrpAjjW2+bH1+ X-Received: by 2002:aa7:9697:0:b0:576:9252:d06 with SMTP id f23-20020aa79697000000b0057692520d06mr371181pfk.0.1670955769814; Tue, 13 Dec 2022 10:22:49 -0800 (PST) Received: from google.com (220.181.82.34.bc.googleusercontent.com. [34.82.181.220]) by smtp.gmail.com with ESMTPSA id g74-20020a62524d000000b0056bb4bbfb9bsm8195038pfb.95.2022.12.13.10.22.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Dec 2022 10:22:49 -0800 (PST) Date: Tue, 13 Dec 2022 10:22:45 -0800 From: Ricardo Koller To: Oliver Upton Cc: James Clark , Will Deacon , Marc Zyngier , linux-kernel@vger.kernel.org, Catalin Marinas , kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.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: X-Spam-Status: No, score=-16.4 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, URI_DOTEDU,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=no 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 05:58:31PM +0000, 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: > Even kvm-unit-tests does this: arm/pmu.c: #define PMU_PMCR_N_SHIFT 11 #define PMU_PMCR_N_MASK 0x1f > > 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 > > > _______________________________________________ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm