From patchwork Mon Mar 10 12:24:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 14009970 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 15D4FC282DE for ; Mon, 10 Mar 2025 13:03:40 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yP6r3UJtoGCclHljYp5u8/qkuJ+EScxz0286YJyWmFo=; b=KMPsjL/EcQV0acDB8HI9PhcEaQ MF0s/AZc8GSJrSU95x0OajwtHPN10xKBYA4K+oaVONGKFujt6TO7cD53MOgdl2/kKdCXG38/izf2S vTRAWFEEwvtHSetNB22q7CYyditk0EkSkbNT6Cmymn1Ph6JJTst2nXrxE+w5p7dWMXrJHT0bwzB7G iwZ1GjXN+5yLk98qvY80sF8OH22tzvI4QRsJSX9LMKgRcYS2/3Be95C7yie3FVdwsvT4VMvTeOTTD 6qNlG93tzSqdvgg1wDRUrBJsdQuPa0ujIyACldT1q05c0OIMbFYr0pP8LmEsviceEUS1XReKzRybM 40PKOekg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1trcn2-00000002its-1I5u; Mon, 10 Mar 2025 13:03:28 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1trcC3-00000002bTz-2z4G for linux-arm-kernel@lists.infradead.org; Mon, 10 Mar 2025 12:25:16 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id B83525C62FC; Mon, 10 Mar 2025 12:22:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5291EC4CEE5; Mon, 10 Mar 2025 12:25:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1741609514; bh=JoVlWRgVnY+j9LNB7Hewwr7ScankrSkCZVdzMJAowdw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q6SRu8AQ59hhcwnFWRgYVwQ6Re2+QgSG95nIDpmF1RfjmOD6woAiJYWrnoDPCs6+B DDdv9CWbXnVXV5HYNuxlSUjfzrc0U3jEixB7r0fUYYK5yLmFhs/7aqehS3Q0lEwQ1P m5olg+SgeCa0flCKENego47//y/2nVH08h6JKdr07oTlL7dSIFhlUu6A5Uhou0h01O 74zxXnHeSrxsTWVmorXTqCxlOylF+EOpAIu67Ln7UA0eKmO+0VAAfeRh9poZqBbdZN YhjwX2mrug1zFOOUgPHZ6gN0NiNGLfobVXb22N4n+O+whTYjqK17AMYVYA2Ti15yt0 nGvSdMg2Z8OUg== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1trcC0-00CAea-G3; Mon, 10 Mar 2025 12:25:12 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Joey Gouly , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Mark Rutland , Fuad Tabba Subject: [PATCH v2 10/23] KVM: arm64: Add description of FGT bits leading to EC!=0x18 Date: Mon, 10 Mar 2025 12:24:52 +0000 Message-Id: <20250310122505.2857610-11-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20250310122505.2857610-1-maz@kernel.org> References: <20250310122505.2857610-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, joey.gouly@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, mark.rutland@arm.com, tabba@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250310_052515_852445_5132C40B X-CRM114-Status: GOOD ( 14.08 ) 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 The current FTP tables are only concerned with the bits generating ESR_ELx.EC==0x18. However, we want an exhaustive view of what KVM really knows about. So let's add another small table that provides that extra information. Signed-off-by: Marc Zyngier --- arch/arm64/kvm/emulate-nested.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kvm/emulate-nested.c b/arch/arm64/kvm/emulate-nested.c index bbfe89c37a86e..4f468759268c0 100644 --- a/arch/arm64/kvm/emulate-nested.c +++ b/arch/arm64/kvm/emulate-nested.c @@ -1279,16 +1279,21 @@ enum fg_filter_id { __NR_FG_FILTER_IDS__ }; -#define SR_FGF(sr, g, b, p, f) \ - { \ - .encoding = sr, \ - .end = sr, \ - .tc = { \ +#define __FGT(g, b, p, f) \ + { \ .fgt = g ## _GROUP, \ .bit = g ## _EL2_ ## b ## _SHIFT, \ .pol = p, \ .fgf = f, \ - }, \ + } + +#define FGT(g, b, p) __FGT(g, b, p, __NO_FGF__) + +#define SR_FGF(sr, g, b, p, f) \ + { \ + .encoding = sr, \ + .end = sr, \ + .tc = __FGT(g, b, p, f), \ .line = __LINE__, \ } @@ -1989,6 +1994,14 @@ static const struct encoding_to_trap_config encoding_to_fgt[] __initconst = { SR_FGT(SYS_AMEVCNTR0_EL0(0), HAFGRTR, AMEVCNTR00_EL0, 1), }; +/* Additional FGTs that do not fire with ESR_EL2.EC==0x18 */ +static const union trap_config non_0x18_fgt[] __initconst = { + FGT(HFGITR, nGCSSTR_EL1, 0), + FGT(HFGITR, SVC_EL1, 1), + FGT(HFGITR, SVC_EL0, 1), + FGT(HFGITR, ERET, 1), +}; + static union trap_config get_trap_config(u32 sysreg) { return (union trap_config) { @@ -2199,6 +2212,13 @@ int __init populate_nv_trap_config(void) } } + for (int i = 0; i < ARRAY_SIZE(non_0x18_fgt); i++) { + if (!aggregate_fgt(non_0x18_fgt[i])) { + ret = -EINVAL; + kvm_err("non_0x18_fgt[%d] is reserved\n", i); + } + } + ret = check_all_fgt_masks(ret); kvm_info("nv: %ld fine grained trap handlers\n",