Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2700546rdg; Mon, 16 Oct 2023 12:03:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFjnvLN3xkUsf1Hh0q/P/4td6l3NLddlUfuPNoZMP0a1qXgKDhbmGsh8NQj4XRQDUAm77uj X-Received: by 2002:a05:6a20:918e:b0:140:6979:295d with SMTP id v14-20020a056a20918e00b001406979295dmr35011348pzd.2.1697482983980; Mon, 16 Oct 2023 12:03:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697482983; cv=none; d=google.com; s=arc-20160816; b=jG+P6cxO2ZEAIgM01X6EYo6AY92mBR0THpQKEWZ3Phi8aQ0k1rZuRN5oEdhxshjenj iH+74rrMRd+UTESbU9NGHWQzFO4xjmN0Pq5kI8id3nuqbvfIzfSCZXTTCnAG+8HI7QIg EyKEKdQbsnewciKUug2Jat27xV81plz8LkPuccOIZFmMGlkm1u5G3l+PCy5obg+1CDvB ujR+wWzcD4XXiF8fJXiSl8MPH22jnlvEwb0j8wDzkMpzJbe56i69RoY+bQ110W4d41zS 4mIAqW3E+ZE8brO5GAHab0emEa5pFoGkifP6WQEUYXIuNwoOHGp84K+ySNST4mS51rn/ 5uVA== 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=eOzjlLla6gf/R2odr013SLR7czPeJxtYfJ4GpduX1qQ=; fh=Ydzx9+q2LPKW+62Dx8Wwj8Mofu196V11LHOTZ5Nf2xk=; b=Cv+LJ24BUYt5Q7U1y5GsLQJtlDCT8OTtASKhjFiXSHbhkasYygjDMMViuuctevxpyr yW65zWemZhi22XdiwTwe/b3g3wsLC+EWNYBL2NKwTIZ0Avbft0tp0EHtwHd94kPd7+r3 qrieJR0T2g+A/ASGfL6M79fxTwCRJOrsKiEKMhYyrhZgMbQ1O0Q9YSKHUN/cgb3/9cd5 Ub2ZUsyfiGKDlrTQYLkUNKpSF22YkWZPP3CIjgS88FrES7jcKAfhLePkKMmz2DeHaCpc XeMhMeHmYp4nrOgQ98adl43xdZzgbRC61zrBES3olyU+etTumT3ZKt5921NM05I/kFYZ YFjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=aZlCyDRk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id x25-20020a631719000000b0054fd947f66dsi11193764pgl.210.2023.10.16.12.02.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 12:03:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=aZlCyDRk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id F1C778039FF0; Mon, 16 Oct 2023 12:02:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232228AbjJPTCq (ORCPT + 99 others); Mon, 16 Oct 2023 15:02:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229943AbjJPTCp (ORCPT ); Mon, 16 Oct 2023 15:02:45 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E75A95 for ; Mon, 16 Oct 2023 12:02:40 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1c9b70b9671so31855ad.1 for ; Mon, 16 Oct 2023 12:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697482959; x=1698087759; 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=eOzjlLla6gf/R2odr013SLR7czPeJxtYfJ4GpduX1qQ=; b=aZlCyDRkQfvcKflCuPbSRvOdYXTqJCiW7XzJv5bkLwiCbMLbEn2H+w+kuEQuAZXAvW VFmdc6CMnUYxcIJQVxyJh9hZqqKgUAOC3Je/hJwCxsa2QdM4gxCymyBadG2VuIQgJylt Sd4ZRs9pvbKiuAMXd8SzDQvwZgpTNVeKqH8ftsfe8R1hW+ryzQ68UQTl2AKQB9+Wxqth bv6QWaaX2ppG1kL9gtN+8O8gmIUch/SNRCrj3FhLJFHIk6bSaorRE6b7xxNXd/pqWiaq zfCNO3eC7vjyCtPr3ZuRs+FoeBWta2GkWC3G8rFkGJu2WR8VjptzBFPQynIZhLj3Z3Ad JblA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697482959; x=1698087759; 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=eOzjlLla6gf/R2odr013SLR7czPeJxtYfJ4GpduX1qQ=; b=Z1JQZ20bUC1EaExT4ayZ7QrXqaQLRHUrBxC6W8fX/frjsrh4mDAS5DzPqh0yb8bPnQ pzvk1YK7E1myn/NU6cLkuW/NeTeg/jwgB+nJbtVodxW4UkqftWwcquGzsviHPXb0ACF0 0cjnfTvTOfPsWqoUGVYsVe5oCCN5mzhkKTek5MC7D6MfHaNy5eJ6itvhM7o3Kxkl5vwm hd4qwtTwvO44kaf+HfSvipRezlIaya34S8RG8ZKIcc0kNNKt2xwqWD/oIafrjBsy38aj ABBQw1k6U3rG3biihpUfnET9Y8ShduHDMhP1WYcLCAo1uFNwTk3ZPegbKTgyF+fnvDBv AA2g== X-Gm-Message-State: AOJu0Yy+A8t6Ki80L5Jn8hi1DTdfE+MgdJZ8LfVfsnpCLTFjfinlwgJu d+ojHYLf7+VppV3UT3Vh0zWcPtOmz7qnGkX+4vNBfg== X-Received: by 2002:a17:903:1c1:b0:1c9:af6a:6d0d with SMTP id e1-20020a17090301c100b001c9af6a6d0dmr25087plh.9.1697482959233; Mon, 16 Oct 2023 12:02:39 -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: Mon, 16 Oct 2023 12:02:27 -0700 Message-ID: Subject: Re: [PATCH v7 07/12] KVM: arm64: PMU: Set PMCR_EL0.N for vCPU based on the associated PMU To: Sebastian Ott Cc: Oliver Upton , 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 16 Oct 2023 12:02:58 -0700 (PDT) On Mon, Oct 16, 2023 at 6:35=E2=80=AFAM Sebastian Ott w= rote: > > On Mon, 9 Oct 2023, Raghavendra Rao Ananta wrote: > > 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); > > } > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > > index ff0f7095eaca..c750722fbe4a 100644 > > --- a/arch/arm64/kvm/sys_regs.c > > +++ b/arch/arm64/kvm/sys_regs.c > > @@ -745,12 +745,8 @@ static u64 reset_pmcr(struct kvm_vcpu *vcpu, const= struct sys_reg_desc *r) > > { > > u64 pmcr; > > > > - /* No PMU available, PMCR_EL0 may UNDEF... */ > > - if (!kvm_arm_support_pmu_v3()) > > - return 0; > > - > > /* Only preserve PMCR_EL0.N, and reset the rest to 0 */ > > - pmcr =3D read_sysreg(pmcr_el0) & (ARMV8_PMU_PMCR_N_MASK << ARMV8_= PMU_PMCR_N_SHIFT); > > + pmcr =3D kvm_vcpu_read_pmcr(vcpu) & (ARMV8_PMU_PMCR_N_MASK << ARM= V8_PMU_PMCR_N_SHIFT); > > pmcr =3D ((u64)vcpu->kvm->arch.pmcr_n << ARMV8_PMU_PMCR_N_SHIFT); > Would that maybe make it more clear what is done here? > Since we require the entire PMCR register, and not just the PMCR.N field, I think using kvm_vcpu_read_pmcr() would be technically correct, don't you think? Thank you. Raghavendra