Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2842686rdh; Wed, 27 Sep 2023 14:43:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNAcA2NUWUz0YfAeJsSexueDdBwNUPSp4YeWq0ESh4F984W0bhaywyibESCwOK4pUfviqj X-Received: by 2002:a05:6358:91c:b0:143:8c3d:58ff with SMTP id r28-20020a056358091c00b001438c3d58ffmr3225288rwi.5.1695851035597; Wed, 27 Sep 2023 14:43:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695851035; cv=none; d=google.com; s=arc-20160816; b=vzVcUMT5pYBPZtTWqMbn+X5eUHOIYfA+UpbKt8W6wQxvtoAnwe+T1AUH0DK2E9CVOQ qmGbfy3qL1CrllJ/JilYD5nfjmzbsJBA1uLapM3IEzi0cVScOzdeYPV8s5/kcX1OOFnA lAh70AHTjqUCyOpnlRcgQHOlfaELK1PBpVDBy7nQtgnV8g8QJNobq9qIWzXzgmxxAvEO N0k4y8omjltmnAW2uAxBR1SsXp4u0zFAtloKdxuHw2vs284rYIgxzPAToJvQ2LA2xPRp 7p/GLHt1es9alS2fF8i2dTV1aIBAcbz0DXpts8/lgGjSoGgxRpQsFEcdssdB7VCsoqN0 dJcg== 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=qCVNsJJaiR6CMnhGVjseVngepymRi6tNcmHrCszc8zo=; fh=dMrWgnXzzePbjJ5Lnz3JQ1FNdAF92uv7SkGdCptz9bs=; b=JD0Q4q0Z4ZMQVv/VBWcHLfaigYlns8KkAHvRcqO2CzzUKeLOYlgGVGfroaOY7epbW7 MCUxvZYasQactWsm/7bXcaVqLJWwIqEQbsJ6nZ+2ESy/bm1wNK/EmrbBWu1ysOl6j4aq 7KIBwucRrC11lZnJPjzfPOHYTCSlakUoO+uJpZXLlg6uxwml6ZSILZcoctAZ7fdnsZPy gRjKnSiBWhlLWHIA8xrD/VzwkwodPRLRCR3wI4HZIWr90tpCVjlumNay4un3qZ7OGRy4 ARKbPrQjdnhyiGdxXDB+azc1Cuy6sqEKg7iFpI2MBRr0DLPn3+k4pG+MMtIzMBmSdOKm oraw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=1XJ1zIQe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id j191-20020a638bc8000000b0056357813fc2si16135524pge.183.2023.09.27.14.43.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 14:43:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=1XJ1zIQe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 2536C809C38F; Wed, 27 Sep 2023 10:37:01 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229473AbjI0Rgo (ORCPT + 99 others); Wed, 27 Sep 2023 13:36:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjI0Rgn (ORCPT ); Wed, 27 Sep 2023 13:36:43 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65399B4 for ; Wed, 27 Sep 2023 10:36:42 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1c6193d6bb4so17225ad.0 for ; Wed, 27 Sep 2023 10:36:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695836202; x=1696441002; 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=qCVNsJJaiR6CMnhGVjseVngepymRi6tNcmHrCszc8zo=; b=1XJ1zIQeinDaZJV2XOS+9NXgpofXhIExDxbIFglZsotc8+0im3Nk9o2rDzpcCMO0h0 rP8Vg6kU4ARl2gOUor47tpObJXZG4uzLfnwDepNqq3LyTZ7sEDypGS2hw985CBWjc0ot KNOJfjiUwqqHSMXLO7hj4DVCfMuein6N3eAgo0+kxvWvQ7FvHm9278D/WtIqXzPNfkr+ FXMHgaDZzrPjfZBYWeiK/iYUOQjTq9yJQNTKUqcccb6ZsqS+mWGW/Mjq0rARbOl26Ja0 68/G0aXl5TDoktIBASFEz9oz/rHe4RcqXdCXc+/kxkqeO4Z7apiMBAxexMzdSkvEcQAG /5xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695836202; x=1696441002; 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=qCVNsJJaiR6CMnhGVjseVngepymRi6tNcmHrCszc8zo=; b=N179a7vNvVzFr3O9I8ev01mAc0G/mhf4DlSyuK3m++IPPxDTmlRZNs3P+UOC4+8Rfb YDouOL+Yc3LKNXCslAdDxdAumw/gFaT1kPDxwPbqKdRc+As+UW6gm7m76uiqZRsUwIT0 N+iX6Ihz6+ndz4u+Ji3VqZomldngInOYBmi/LtUICW8PoF1VoCml/N9quNUJy/LSEb9C YCX0qGwYieBMM2cqHfDbfrlrje9zOzNaqDKzUe1Wb5LIbmTW74p8XQCzTRSliVq5gPW+ owGpEVMntB4aqbTZOjajK21CAdM47P4bVfOXpv//J8S49Jk3YWMMZRXcn1KLfIXtLbPm BhQQ== X-Gm-Message-State: AOJu0YyEkcG6BMPdqHSqR50UiU0WIEQ6H+DNDqy7B66EX7kw45qej+2S 6tM34DTIjNDKY2jUYkRtPISJNRHdXq5HbghSoLD4qA== X-Received: by 2002:a17:903:2447:b0:1bc:66f2:4bb with SMTP id l7-20020a170903244700b001bc66f204bbmr542482pls.8.1695836201617; Wed, 27 Sep 2023 10:36:41 -0700 (PDT) MIME-Version: 1.0 References: <20230926234008.2348607-1-rananta@google.com> <20230926234008.2348607-3-rananta@google.com> In-Reply-To: From: Raghavendra Rao Ananta Date: Wed, 27 Sep 2023 10:36:29 -0700 Message-ID: Subject: Re: [PATCH v6 02/11] KVM: arm64: PMU: Set the default PMU for the guest on vCPU reset To: Oliver Upton Cc: 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 morse.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 (morse.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:37:01 -0700 (PDT) Hi Oliver, On Wed, Sep 27, 2023 at 1:02=E2=80=AFAM Oliver Upton wrote: > > Hi Raghu, > > On Tue, Sep 26, 2023 at 11:39:59PM +0000, Raghavendra Rao Ananta wrote: > > From: Reiji Watanabe > > > > The following patches will use the number of counters information > > from the arm_pmu and use this to set the PMCR.N for the guest > > during vCPU reset. However, since the guest is not associated > > with any arm_pmu until userspace configures the vPMU device > > attributes, and a reset can happen before this event, call > > kvm_arm_support_pmu_v3() just before doing the reset. > > > > No functional change intended. > > I would argue there still is a functional change here, as PMU > initialization failure now shows up on a completely different ioctl for > userspace. > > > @@ -216,6 +217,18 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu) > > vcpu->arch.reset_state.reset =3D false; > > spin_unlock(&vcpu->arch.mp_state_lock); > > > > + if (kvm_vcpu_has_pmu(vcpu)) { > > + if (!kvm_arm_support_pmu_v3()) > > + return -EINVAL; > > + > > + /* > > + * When the vCPU has a PMU, but no PMU is set for the gue= st > > + * yet, set the default one. > > + */ > > + if (unlikely(!kvm->arch.arm_pmu) && kvm_arm_set_default_p= mu(kvm)) > > + return -EINVAL; > > + } > > + > > Ah, this probably will not mix well with my recent change to get rid of > the return value altogether from kvm_reset_vcpu() [*]. I see two ways to > handle this: > > - Add a separate helper responsible for one-time setup of the vCPU > called from KVM_ARM_VCPU_INIT which may fail. > > - Add a check for !kvm->arch.arm_pmu to kvm_arm_pmu_v3_init(). > > No strong preference, though. > Thanks for the pointer. I think adding it in kvm_arm_pmu_v3_init() may not be feasible as the reset (reset_pmcr()) may happen before this init and we may end up setting 0 as PMCR.N for the guest. I'll explore the other option though. Thank you. Raghavendra > [*]: https://lore.kernel.org/r/20230920195036.1169791-8-oliver.upton@linu= x.dev > > -- > Thanks, > Oliver