Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2560697rdh; Wed, 27 Sep 2023 06:26:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGf1lQvxKmZNaG4qNUluuEWf4h0uTRxXw3L0j4CDyDu6TKZ1u8MOw8UaQwT03d57EwMFRS X-Received: by 2002:a05:6870:d1c3:b0:1b0:3637:2bbe with SMTP id b3-20020a056870d1c300b001b036372bbemr2506608oac.54.1695821185161; Wed, 27 Sep 2023 06:26:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695821185; cv=none; d=google.com; s=arc-20160816; b=WIBDEuI1vfhR8y/KkDururNYynxwe9JA7OMHeN+asPUSZ86Jz6PYVQ/9PRf8P3vO7R Ezq0Kt2rbUJtze0sKiZXccVUVAObW+9wIbwuytMSAuId7J5bel46Z++FjeBtT+/FM7f7 jQITBicJDpU0W5jrYVx6yrPGlC5nDnWIh4a/0gVZWGuvnVM11X4hLKUVvh7UZ9Hw35dl AxyuPeGFPqe96wEaeLsIk62Eo1+xR1ki/rbbrFztXFFg2yO4TSWPalG+g7/RN7EQ1oQ5 ZXW6jxPWc2/IyxH1a6OUbzG2ttanH2or02fQ8AOLMjAH2irvLLEB2Kou5Cxl1KJGhLtn hrYw== 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=P1b5Vu+07ETgZbRINBDyHraEk19f7O0PJbIxNMiL+uw=; fh=4I6BNv7iobpZrRcbueKA7r9RD02xPQmynyU/PeDFguM=; b=VUT9TOMTqrdLaIGd2qqIRlqRRA7nUQfisP64N+WcQLt2C1PRuKuBx877hBe0nTPVPz sNaO48ZtC5eXRdA7FDjE94+PPM4Iwoq73Kd+n9S/a2giwx86V59mTeNgz5VZ7OYephwl yVYGMETFLwHkGqreyZbCmBHSw08PQoj/KDmGpd5oJPtn/FdZl76+/8hVqdFRitueAgWh P08Y3h4DpLJFVV8Np+F/REKfKCZ0MRKhjtQPrcCP1OxqDb75fE25JowgVJyWYIRoxKMr hWd8gF3CLdvGvmlzOqd9EIc7QJ78s62KXrP0d98dv20FhHAvD2EYh0UzwLbcEaXOE9qK fIBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=MvKjYHrY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id 126-20020a630284000000b00565f611a1f8si15098899pgc.263.2023.09.27.06.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 06:26:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=MvKjYHrY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id B7ECD80DCC9B; Wed, 27 Sep 2023 01:03:05 -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 S230093AbjI0ICu (ORCPT + 99 others); Wed, 27 Sep 2023 04:02:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229981AbjI0ICt (ORCPT ); Wed, 27 Sep 2023 04:02:49 -0400 Received: from out-190.mta1.migadu.com (out-190.mta1.migadu.com [IPv6:2001:41d0:203:375::be]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBD0411D for ; Wed, 27 Sep 2023 01:02:47 -0700 (PDT) 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230926234008.2348607-3-rananta@google.com> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 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 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 01:03:06 -0700 (PDT) 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