Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3291314rdg; Tue, 17 Oct 2023 09:58:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGaCfTnLEREaF0U0/G8VjEdwj2KWi4Ps/BpMUjbHm8OZ+OhHvmXOb0PFuWSROUcG+OxrA5j X-Received: by 2002:a05:6a21:32a4:b0:17b:43:9ba5 with SMTP id yt36-20020a056a2132a400b0017b00439ba5mr2106474pzb.52.1697561913752; Tue, 17 Oct 2023 09:58:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697561913; cv=none; d=google.com; s=arc-20160816; b=Sy8JAfaBSMYSkH0/oN9c70tCDpEq3MVjF2NxhuiHtHi0h6R0Z1X/GRMJo40/p+UP7I mGmV19hQT30RfeKETV79AlJYsJw0VV0iX+L7r08SabEn/onThDQ0Kyoh3zzAxsd/x/iW GD6k5R/Qg3RxMkKJATT81MQj0V+cS7snuUmQVtYSERR7P/JbT8kTFhOGRufinRnZiOEg NqQsFsIoxy3gLTJwgvVkz1BBohEVUttCzmQZO7QHk+EpJWNTtJrjgb4rE9jTbBR9NgEx bK3pyaYomtgWlcs4UkHirQZCJ4WcFtfrcvjk22chMp1NDUOMjZyluos2C+8Pboq+35cF qZhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=cmPJRnpivnS9Ld3ifHaIxKEN+4gdJjCgtDpfk6S2hXE=; fh=OvPCPWmOZlQ11X1Bd0N2T4yM6wYPPrTPc3iW1iqu53w=; b=YalLJ0BVIqn4KdXDVVdTWP4lXzn9zqjYuWsN2fASrCH44/8flkNUdWccXl0b+HhYlv 4XWlY5ywIqF3z8ROr1x7i91+BQi68G9g0cF7q1CM73Qfu5ax20QrkVlx0oPd4RS4Si3i pcNadS5vmt9B+4b9e65vkoAUZx8m9RqjtYQ14Javs6O4QXAz99aUhI8vJLfwKE14c78G gE77WLd2+nxeyccaWJ2KghK+URXNvYUEV6tW7DZJ6ebh7Iqw4qfXz2zhsv9TShv9c/S0 Lwf/dcVMvkn8C1InRiNngQCZ6S1U3ViZ1J42yQhh0gYZp91m/XDAkGb0e+YIoyQyjJJ2 2/UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=2L6mAl14; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id w16-20020a1709027b9000b001c20db2510asi2029619pll.53.2023.10.17.09.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 09:58:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=2L6mAl14; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 0E9A780C7AD8; Tue, 17 Oct 2023 09:58:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232268AbjJQQ6Y (ORCPT + 99 others); Tue, 17 Oct 2023 12:58:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231569AbjJQQ6W (ORCPT ); Tue, 17 Oct 2023 12:58:22 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C629A4 for ; Tue, 17 Oct 2023 09:58:21 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1c9d4f08d7cso7935ad.0 for ; Tue, 17 Oct 2023 09:58:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697561901; x=1698166701; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=cmPJRnpivnS9Ld3ifHaIxKEN+4gdJjCgtDpfk6S2hXE=; b=2L6mAl14VlXNgBTdAeiI02k9MwHXmJE9UQV5MZL9VCENvj6D1mevT2fEXAhjVX8EfG 45RyGf0w7m0g+uwJOjJE0rxL8jW5V56485TckBhhBi+FejNVTzvk3X82z7JbEHVZsNL4 kwC30yu3Iz8WiqNGjXBmiuxpCuJewbnNvaBTFk4aNvAxBBRPZp+IsgY+uXesxlS7C4oN RpFWfCezO25f3ZCvQ2utcTzxsi7N7gdSCluzfZJtkPcc/NXIBYruurXxHET1B9p518vD vmAOuzH/zdwitvzj1Ro4SRiktu4xHu5mkrKXWUm07XDjKR8RyJoG7KwoRs8hp00zmS4B aSMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697561901; x=1698166701; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cmPJRnpivnS9Ld3ifHaIxKEN+4gdJjCgtDpfk6S2hXE=; b=GFl5TIV6rljhKvF0zL8ipAJ/bUmtOhysLzq9vs6JDsanOhr8MW+OEB+2Z+SoGjmjx5 T/+xmkhnhT506TF0dlqHHT0oYyedb9ui3Lz1i2U3ZRS5sbuv4fqnt+RvWCzK1j2kbEQj 18UXmkeVh9Qb+b90yXaU8Z8GwPGT3Iu3pgBJHtFiRVHg41h+wyrFDalV1bHy6KplOEnv dTQOEzqSYOxzdeUuCpMGDDvaVmDxVwWOMCgmNV6ldsbY9qdyiJVhMTtd5muy4reZk7ba 3yEUUJzfyKh0HMEfIxGEZkJplRGkvKwKB8GPQR5B2246foM8MnQ8VQ/nGy8/Kl8pou1/ DdZA== X-Gm-Message-State: AOJu0YxAsrosd5WjAJaV4nWgU12fGP4c9JwTfpixRr0af9akVmY5tH9y TVcawdvGJUIWv492347Bm/j+UjlkNDt19OyKmR+FYw== X-Received: by 2002:a17:903:290:b0:1ca:16b8:b541 with SMTP id j16-20020a170903029000b001ca16b8b541mr6265plr.24.1697561900478; Tue, 17 Oct 2023 09:58:20 -0700 (PDT) MIME-Version: 1.0 References: <20231009230858.3444834-1-rananta@google.com> <20231009230858.3444834-8-rananta@google.com> In-Reply-To: From: Raghavendra Rao Ananta Date: Tue, 17 Oct 2023 09:58:08 -0700 Message-ID: Subject: Re: [PATCH v7 07/12] KVM: arm64: PMU: Set PMCR_EL0.N for vCPU based on the associated PMU To: Oliver Upton 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Tue, 17 Oct 2023 09:58:31 -0700 (PDT) On Mon, Oct 16, 2023 at 10:52=E2=80=AFPM Oliver Upton wrote: > > 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 val= ue. > > > > > 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. > I didn't get this comment. We still do initialize pmcr, but using the pmcr.n read via kvm_vcpu_read_pmcr() instead of the actual system register. Thank you. Raghavendra > > @@ -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 tracke= d > > + * 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 =3D __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_SH= IFT); > > } > > > -- > Thanks, > Oliver