Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2949250rdg; Mon, 16 Oct 2023 22:52:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGbAX2Zbe081bPj6nYPpbJUzAbqVL8kIHlGtD1kTmcOzSNfxQfksu9pB4w1Lp0fxiAd7l31 X-Received: by 2002:a17:902:e5c8:b0:1ca:35cb:dbb with SMTP id u8-20020a170902e5c800b001ca35cb0dbbmr1605716plf.46.1697521973424; Mon, 16 Oct 2023 22:52:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697521973; cv=none; d=google.com; s=arc-20160816; b=Ey7YbYqkeCtVw9pifa8BDlC0njtNQ03SvvLzNtL+RCP9JV65sqUIL9cGvlFNIHvtT9 m7aoNgCX2Ba5BUv7HGHejn9OMDBeAbVzWzmTP/PwhtjNOpaFsehw2OlDyFSvWG/eZjp9 fPMmvQFUtiNA2rT31pR8IwKYXpAB+piX1pvp05GDfW2jQu0yJ4Bd0lwZU259ecVJn3yJ KYW5RcdV9gqD1ZmnY2pbQ4nImWpnrYFNVEo3WkzkuLu3PVZLQZIJyXqbakRyL+1+2Psw 7BTI4PF+k8DcS1m7M8kIffhTJkTB9byYdbDVyfro7kBeygRgccuUzvCjtcKi8b1mS3rX dmlA== 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=fVj3QOXnTr/Xh7eUU3olV979cXmOJTmj7/jYZIF4yF4=; fh=w0flhQl7mctFcbI2b5EuDMWx0RWmm/SggScYTmVZk3E=; b=wu+cYmV873oqgEzPO4TQgkdefrZdVoM47kGOr+P6hIjOC0f1d1dcPKB5EEM0mLV2F2 qvleYXs24OVKSecr7vB+Vnk0g2SljD5/oiXDj+5WUaV3h0DZ8y7U5o/SeNxMUd1nNiTc +oFAkWCz0HLOre/pkpSPR9cz7Vg56y+NybIBq2q6Do6nJVh17WjXMlgmDMOC+JAm0Qgy hOQxkALZ9siAz6e5q6L0Qtu6Tezt5xCM01seTqUQonHp4Nov3SkQNeC8AY/lFeALYERI gyghuXDvIsHouHi6E8kUhB+YqH/9piP7hmhfiWfJnaPju67/Tv02WaciicJO+hc8+Z0G elyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=OdmnPA8A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id s13-20020a170902ea0d00b001c62161b18esi1080851plg.580.2023.10.16.22.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 22:52:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=OdmnPA8A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 2CAFA80AC591; Mon, 16 Oct 2023 22:52:51 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234454AbjJQFwg (ORCPT + 99 others); Tue, 17 Oct 2023 01:52:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230343AbjJQFwe (ORCPT ); Tue, 17 Oct 2023 01:52:34 -0400 Received: from out-209.mta0.migadu.com (out-209.mta0.migadu.com [IPv6:2001:41d0:1004:224b::d1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A332F9E; Mon, 16 Oct 2023 22:52:32 -0700 (PDT) Date: Tue, 17 Oct 2023 05:52:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1697521950; 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=fVj3QOXnTr/Xh7eUU3olV979cXmOJTmj7/jYZIF4yF4=; b=OdmnPA8A+91moypBiaGZn8ibVGmZmN0HlfkfnzmzJQJBXglPtzHGRWJlvkfP5NADESecPn LfHytZzAvYtJ/AuWS3MjDUzpoPd1KHYxGwXalx8C92EpY8eHM4WMityUHrBuqJvQO9N3Y6 ePHgtv1NQGXK0zyXqDl1SenjwijfMhQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Raghavendra Rao Ananta Cc: Sebastian Ott , Marc Zyngier , Alexandru Elisei , James Morse , Suzuki K Poulose , Paolo Bonzini , Zenghui Yu , Shaoqin Huang , Jing Zhang , Reiji Watanabe , Colton Lewis , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH v7 07/12] KVM: arm64: PMU: Set PMCR_EL0.N for vCPU based on the associated PMU Message-ID: References: <20231009230858.3444834-1-rananta@google.com> <20231009230858.3444834-8-rananta@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 16 Oct 2023 22:52:51 -0700 (PDT) On Mon, Oct 16, 2023 at 02:35:52PM -0700, Raghavendra Rao Ananta wrote: [...] > > What's the point of doing this in the first place? The implementation of > > kvm_vcpu_read_pmcr() is populating PMCR_EL0.N using the VM-scoped value. > > > I guess originally the change replaced read_sysreg(pmcr_el0) with > kvm_vcpu_read_pmcr(vcpu) to maintain consistency with others. > But if you and Sebastian feel that it's an overkill and directly > getting the value via vcpu->kvm->arch.pmcr_n is more readable, I'm > happy to make the change. No, I'd rather you delete the line where PMCR_EL0.N altogether. reset_pmcr() tries to initialize the field, but your kvm_vcpu_read_pmcr() winds up replacing it with pmcr_n. > @@ -1105,8 +1109,16 @@ u8 kvm_arm_pmu_get_pmuver_limit(void) > /** > * kvm_vcpu_read_pmcr - Read PMCR_EL0 register for the vCPU > * @vcpu: The vcpu pointer > + * > + * The function returns the value of PMCR.N based on the per-VM tracked > + * value (kvm->arch.pmcr_n). This is to ensure that the register field > + * remains consistent for the VM, even on heterogeneous systems where > + * the value may vary when read from different CPUs (during vCPU reset). Since I'm looking at this again, I don't believe the comment is adding much. KVM doesn't read pmcr_el0 directly anymore, and kvm_arch is clearly VM-scoped context. > */ > u64 kvm_vcpu_read_pmcr(struct kvm_vcpu *vcpu) > { > - return __vcpu_sys_reg(vcpu, PMCR_EL0); > + u64 pmcr = __vcpu_sys_reg(vcpu, PMCR_EL0) & > + ~(ARMV8_PMU_PMCR_N_MASK << ARMV8_PMU_PMCR_N_SHIFT); > + > + return pmcr | ((u64)vcpu->kvm->arch.pmcr_n << ARMV8_PMU_PMCR_N_SHIFT); > } -- Thanks, Oliver