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 88394CEACDD for ; Tue, 1 Oct 2024 16:01:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=krvBzYJaeORgAvAaVCh9MhGFYTCNGpbFuoS8Ici3REA=; b=i6okyLn6/HkMWvJ/XZumnkAJ4S k6EqlVPPZa+EVBg4jYj2ijcAXQIInW55anIkMBl/z0gxpAOw+OoI6d9CF6+Os/+4TrTSsjLSdm/Js KEGBiLaRsfwNtbxAQnUZIucGDsX7/HIvj/r8b9SqrR8EvcjNa49/W4v6AJti+tBuFZcVAHFR+wawy Ec7vM/EO20KX+2KlEyhM0++1jgs4WI5pBRzQ3vedrcB5P6bGczZtRfPEwEPN6srl2heQeFFlu3Hcd dU9HxwO0OPK/Toew6kQ7vD/TC0rip1M/CcummBOx2gSN+r0SWchBtAqOM62TfiUkkQRUNxxb3c3Kj q3N8r9vQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1svfJY-00000003PWi-2Os2; Tue, 01 Oct 2024 16:01:28 +0000 Received: from out-182.mta0.migadu.com ([91.218.175.182]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sve99-00000003C7D-1Roy for linux-arm-kernel@lists.infradead.org; Tue, 01 Oct 2024 14:46:41 +0000 Date: Tue, 1 Oct 2024 07:46:29 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1727793995; 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=krvBzYJaeORgAvAaVCh9MhGFYTCNGpbFuoS8Ici3REA=; b=r9n/OPXUXQDaYRcdsKMAxEjrhN2HRpXTM4f3VfmqpaE9JCjSguvWXFRC14STLSBRgZqagK WrP+n5L2FXvKwFyltYswmJeEsd9z2nUDt/LDKCzTKndbyRalmnBMaCk9yg6MlAL8c/jUjG sTe7e4hhzSekuaTJ5BEdma5v+ubcQZc= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Anshuman Khandual Cc: linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, maz@kernel.org, James Morse , Suzuki K Poulose , Catalin Marinas , Will Deacon , Mark Brown Subject: Re: [PATCH 47/47] KVM: arm64: nv: Add trap forwarding for FEAT_FGT2 described registers Message-ID: References: <20241001024356.1096072-1-anshuman.khandual@arm.com> <20241001024356.1096072-48-anshuman.khandual@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241001024356.1096072-48-anshuman.khandual@arm.com> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241001_074640_197174_3B2B8678 X-CRM114-Status: GOOD ( 12.12 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Anshuman, On Tue, Oct 01, 2024 at 08:13:56AM +0530, Anshuman Khandual wrote: > +#define check_cntr_accessible(num) \ > +static enum trap_behaviour check_cntr_accessible_##num(struct kvm_vcpu *vcpu) \ > +{ \ > + u64 mdcr_el2 = __vcpu_sys_reg(vcpu, MDCR_EL2); \ > + int cntr = FIELD_GET(MDCR_EL2_HPMN_MASK, mdcr_el2); \ > + \ > + if (num >= cntr) \ > + return BEHAVE_FORWARD_ANY; \ > + return BEHAVE_HANDLE_LOCALLY; \ > +} \ > + > +check_cntr_accessible(0) > +check_cntr_accessible(1) > +check_cntr_accessible(2) > +check_cntr_accessible(3) > +check_cntr_accessible(4) > +check_cntr_accessible(5) > +check_cntr_accessible(6) > +check_cntr_accessible(7) > +check_cntr_accessible(8) > +check_cntr_accessible(9) > +check_cntr_accessible(10) > +check_cntr_accessible(11) > +check_cntr_accessible(12) > +check_cntr_accessible(13) > +check_cntr_accessible(14) > +check_cntr_accessible(15) > +check_cntr_accessible(16) > +check_cntr_accessible(17) > +check_cntr_accessible(18) > +check_cntr_accessible(19) > +check_cntr_accessible(20) > +check_cntr_accessible(21) > +check_cntr_accessible(22) > +check_cntr_accessible(23) > +check_cntr_accessible(24) > +check_cntr_accessible(25) > +check_cntr_accessible(26) > +check_cntr_accessible(27) > +check_cntr_accessible(28) > +check_cntr_accessible(29) > +check_cntr_accessible(30) I'd rather we not use templates for this problem. It bloats the kernel text as well as the trap encoding space. I have a patch in the nested PMU series that uses a single complex trap ID to evaluate HPMN, and derives the index from ESR_EL2. I think it could also be extended to the PMEVCNTSVR range as well. Also, keep in mind that the HPMN trap is annoying since it affects Host EL0 in addition to 'guest' ELs. [*]: https://lore.kernel.org/kvmarm/20240827002235.1753237-9-oliver.upton@linux.dev/ -- Thanks, Oliver