Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1403475rda; Mon, 23 Oct 2023 11:25:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHg2KDMmY3LaM7fMO8ceUfxsE4SmMHF6S1FPstHReVBY58WBve4izH+SHYoWFVOeENtv0Qb X-Received: by 2002:a05:6358:c329:b0:168:e95a:58f0 with SMTP id fk41-20020a056358c32900b00168e95a58f0mr1589996rwb.25.1698085532080; Mon, 23 Oct 2023 11:25:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698085532; cv=none; d=google.com; s=arc-20160816; b=hLD4IsCk0wYJZ1fsRYvFIAZeNhsV9w3N8g7lbvGQqhvbpLCBeWhOUDa1duiaDGFt+E pL0LR0XrD72B4f3uUIieET+y6uGsVWcjH8sZiwqLoNpZsl/AO3HLjhLHqT561WyNzrWQ 9RvZ9lB+cG29rFSzVD6Yz7AUqkNSI/LvYLquR8dow1sylHv7qZHZXsG25BEbfwUKAtmt OyH8mcbab2APqky9Nu6uv4UXok10eI+shuvE95htQs9+RqK6YI2Hx6RXSVCuBICGPqHA 5KUTSQqPjgTEPtC//3GpuKF9GkODzJufV8tfNZLoCa/8vbgYBACWmV59ucH0J8b0bF0I ECKg== 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=QChXizP9EOxkwbrFQch52NiZrZiX3EIsRZVyKac4G8c=; fh=4SBs4c/DZjnCE6vAWzj1P488oW14xPRLJSyN0IoPmig=; b=k0Uybuq4go/YKObgayVa79lbAnJ5LdPJCYljALAD+OaI+hVpV8hWwnngjH60vZtlCy cR3UE9wCnjBod8XF/m96q04f1+G3s0e6eNq6zcyXNZ/Ul2bcO4iikFvGWUgDIySPxW0S B3OZvgbyDyzUjzhj64bgMMpsCFj4iP1Ui/VwaHCVmn8QDxTqkPh4UDxqXzcupWHBsb9I eKR7SxQ5v1bBjjtDy6mGNVWgRZvtmXdRZ5Hx8HiaNDe6q2mVrmdAcRHx+d+5zYzGZDB2 VFNuSbgUONdRe0DYZSG6wRj/51DkKtDscgB2lsJXoc8+PIpFrmUiHCaV2u2X+gZqx02c s3qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=iGsEJTbQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id x10-20020a634a0a000000b00585a6bdce46si6962818pga.308.2023.10.23.11.25.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 11:25:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=iGsEJTbQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 28AE180A055E; Mon, 23 Oct 2023 11:25:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233519AbjJWSZD (ORCPT + 99 others); Mon, 23 Oct 2023 14:25:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230345AbjJWSZC (ORCPT ); Mon, 23 Oct 2023 14:25:02 -0400 Received: from out-199.mta0.migadu.com (out-199.mta0.migadu.com [91.218.175.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6A2210D; Mon, 23 Oct 2023 11:24:59 -0700 (PDT) Date: Mon, 23 Oct 2023 18:24:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1698085497; 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=QChXizP9EOxkwbrFQch52NiZrZiX3EIsRZVyKac4G8c=; b=iGsEJTbQ/pmMU0i2n2T//fvlwiheDsxmxNhjnWiFSsNvn4EPsecSVhGKbgbtV895dlfywq IFjdHTrBHuojcaQo0vPWHH9hRFTHd4Lqd1F5YmaOKrheubFebH5vabBSjt7EM/OUgS6urb MG1CLX6vy1Wu+Y/7MI/oyahdTxTzOPk= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Marc Zyngier Cc: Raghavendra Rao Ananta , 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 v8 02/13] KVM: arm64: PMU: Set the default PMU for the guest before vCPU reset Message-ID: References: <20231020214053.2144305-1-rananta@google.com> <20231020214053.2144305-3-rananta@google.com> <8634y162q5.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8634y162q5.wl-maz@kernel.org> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.8 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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 23 Oct 2023 11:25:15 -0700 (PDT) On Mon, Oct 23, 2023 at 11:40:50AM +0100, Marc Zyngier wrote: [...] > > +static int kvm_setup_vcpu(struct kvm_vcpu *vcpu) > > +{ > > + struct kvm *kvm = vcpu->kvm; > > + > > + /* > > + * When the vCPU has a PMU, but no PMU is set for the guest > > + * yet, set the default one. > > + */ > > + if (kvm_vcpu_has_pmu(vcpu) && !kvm->arch.arm_pmu && > > + kvm_arm_set_default_pmu(kvm)) > > + return -EINVAL; > > nit: I'm not keen on re-interpreting the error code. If > kvm_arm_set_default_pmu() returns an error, we should return *that* > particular error, and not any other. Something like: The code took this shape because I had an issue with returning ENODEV on the KVM_ARM_VCPU_INIT ioctl, which is not a documented error code. Now that the vCPU flags are sanitised early in the ioctl, KVM has decided at this point that vPMU is a supported feature. Given that, I think ENODEV is fine now as the unexpected return value would indicate a bug in KVM. > Hmmm. Contrary to what the commit message says, the default PMU is not > picked at reset time, but at the point where the target is set (the > very first vcpu init). Which is pretty different from reset, which > happens more than once. > > I also can't say I'm over the moon with yet another function that does > a very tiny bit of initialisation outside of the rest of the code that > performs the vcpu init. Following things is an absolute maze... I'm fine with this being inlined into __kvm_vcpu_set_target() so long as we maintain the clear distinction between one-time setup and vCPU reset. -- Thanks, Oliver