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 8CE57C25B45 for ; Mon, 23 Oct 2023 18:25:33 +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=9SXTF8gwg6l0ugTsM3CiF6QBt1OZomFiiiUtd2on5nY=; b=F6nUzBTKAyYGUw YBaS+tlImZnNUWqu28JZUOUwNeW4vSdJSQ4n0DZrJUnvUV2jOZ2fN8RuWGcy6V56oN3C2ovlSP6ad dhQ+9hAoo0ojglEWvYhP/dbLJrIdAH9L5yyZ9pF3y78k1xSJ8fKXrAMgIKH3Wbj2gfx460vLDIirq VkuLD1FxxqH6/EPeTbWUsvNdmmRXUAvt2ikKDqP+lQkcP0OGOuhkLVRU0ZyGbM8feYb8GZ7U0D447 jEdPeFlm3m2dpeqjMSUwaJFTxP3PbjSP9otE+yxOkuREd24pHph2EXRzx+m3fW+nfmxPXMV6jjySH HsIKOmn4OquAmRxirjxA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1quzbx-00850R-0i; Mon, 23 Oct 2023 18:25:09 +0000 Received: from out-202.mta0.migadu.com ([91.218.175.202]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1quzbt-0084z3-2w for linux-arm-kernel@lists.infradead.org; Mon, 23 Oct 2023 18:25:07 +0000 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-Disposition: inline In-Reply-To: <8634y162q5.wl-maz@kernel.org> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231023_112506_125973_39E1718C X-CRM114-Status: GOOD ( 20.05 ) 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 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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel