From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B96E0E810A3 for ; Wed, 27 Sep 2023 08:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=C/szB8CSIerNYgj+o5YxwVQvX+ibeE2h6n8DZBYlxhI=; b=T5lJ2wH8wBdUDu wxZJ9N8OnUwRwwqmmFMHeyjOqDWyOV+aY0ad006l9D7zC7fw4FTXVbmbYkz5v+y6+jw02C9/UQZPW Mo2rJuLPUYeceqPe1tAiE6T/BNWj6vq598wkwZx+bamqWbmuiWEKDFYfH4h09Ctm/WpNNpLaPlKBZ DZEt1XjIJI2AxOayrVPDgqgYjw4nG3LNMgmpaWqWjRvoqEWT881q77GJMrElcC8ML3iBRT7xZXqDI jb0ZmH++lcpmJB32C4BnvaFf3YH2qWWCOTzlUladB1WLPwposuKt1qmLkd6H5f6Blg7GA8jo+TaL1 6frN5IUo3+2HQ3AmvYPw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qlPVV-000ILU-0i; Wed, 27 Sep 2023 08:02:53 +0000 Received: from out-194.mta1.migadu.com ([2001:41d0:203:375::c2]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qlPVR-000IKd-2r for linux-arm-kernel@lists.infradead.org; Wed, 27 Sep 2023 08:02:51 +0000 Date: Wed, 27 Sep 2023 08:02:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1695801765; 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=P1b5Vu+07ETgZbRINBDyHraEk19f7O0PJbIxNMiL+uw=; b=MvKjYHrYCAKE6MJeHVIPDbLVB7UDJsGnTRk6BcBQ/nKGRmhszabL6whjC3rmPsLpupHTxQ Iu2mElUNoePLQxX85XCn2Sd46cCd7Ip7oaD/P/Z+rqQh4eAXeBV7xIb9+fPXiOhBOvfRqk dy5Pn0ozwmok3Xl0WTydQ4tiIOMIKQ8= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Raghavendra Rao Ananta 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 Subject: Re: [PATCH v6 02/11] KVM: arm64: PMU: Set the default PMU for the guest on vCPU reset Message-ID: References: <20230926234008.2348607-1-rananta@google.com> <20230926234008.2348607-3-rananta@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230926234008.2348607-3-rananta@google.com> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230927_010250_374271_E8A30ABD X-CRM114-Status: GOOD ( 18.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 = 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 guest > + * yet, set the default one. > + */ > + if (unlikely(!kvm->arch.arm_pmu) && kvm_arm_set_default_pmu(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. [*]: https://lore.kernel.org/r/20230920195036.1169791-8-oliver.upton@linux.dev -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel