From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4B4840C0F for ; Mon, 22 Jan 2024 20:19:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705954740; cv=none; b=qXOM2Gc9MoCcJeybL3mnjKtrQJuHwlA5ejvGrEwF9zXn8NdDuA/6RGAgS2zw190EyXEXr4qh1qinK8Y2TI5BsyY+KyfvktRrcF1tB4e1TdTsNENLOgHAThQZeX/qrIy4PNqmwezdm/JAGDyqT2PEoMZAiovAWBcAOcnbPC6YeDo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705954740; c=relaxed/simple; bh=ATf0ih7gkfEuE/hvRMYfwvXo1cLdsttokMnyWpUrPKo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EdJPHSRnC5CfkD+dOJKwGvAm42qFOwoOFmGfXHM4469+ptS5hiLluD5H1XcYjn6+WzwdrF5k4cB4MrAP2SMmfVvI+burPDUM1p+fzGxz51fj5UMpK4eMdthTmNrAaZDxYEB6mBoWf0qQv4n0JGLJqbpIomusQXkSXQ6Yj/rBsb8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HLMbFUVC; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HLMbFUVC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABAB5C43609; Mon, 22 Jan 2024 20:19:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705954740; bh=ATf0ih7gkfEuE/hvRMYfwvXo1cLdsttokMnyWpUrPKo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HLMbFUVCGyhhvj9YshkPJ/bwgKy3JJYNtTxhlYizkqL0M0ZrfKh7cvis3A5J5OSMA oVgW5RKeG+Bqs6yY2OKMPDsrft3ef7E5qyTrcHK/F2GA4TPUerJaEEFWvb9i6mtpK+ zjy4yr72Nsv3iX5yxSJZQj2T4IOaDjKeeTxFmHgqhusuOvGU25yZlRtz+myaH/lBvi DleqS7aEv0Mm2gxxxon00VS2crSpFlwwr5hQEJl/tRAm7o/5uQpxmy31/LcqD9iZgN d46GQNOmmIMnsB5sgW/S5rTmsxVddDjKUWOs9lQNxuJ0m5sZzjGjR04vGEJvaQ8giK rnJSCEhxYuvzg== 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 1rS0l0-00DjkQ-RU; Mon, 22 Jan 2024 20:18:58 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Catalin Marinas , Will Deacon , Joey Gouly , Mark Brown Subject: [PATCH 17/25] KVM: arm64: Add Fine-Grained UNDEF tracking information Date: Mon, 22 Jan 2024 20:18:44 +0000 Message-Id: <20240122201852.262057-18-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240122201852.262057-1-maz@kernel.org> References: <20240122201852.262057-1-maz@kernel.org> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, joey.gouly@arm.com, broonie@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false In order to efficiently handle system register access being disabled, and this resulting in an UNDEF exception being injected, we introduce the (slightly dubious) concept of Fine-Grained UNDEF, modeled after the architectural Fine-Grained Traps. For each FGT group, we keep a 64 bit word that has the exact same bit assignment as the corresponding FGT register, where a 1 indicates that trapping this register should result in an UNDEF exception being reinjected. So far, nothing populates this information, nor sets the corresponding trap bits. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_host.h | 21 +++++++++++++++++++++ arch/arm64/kvm/emulate-nested.c | 12 ------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index e7a6219f2929..4e0ac507ca01 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -240,9 +240,30 @@ static inline u16 kvm_mpidr_index(struct kvm_mpidr_data *data, u64 mpidr) struct kvm_sysreg_masks; +enum fgt_group_id { + __NO_FGT_GROUP__, + HFGxTR_GROUP, + HDFGRTR_GROUP, + HDFGWTR_GROUP = HDFGRTR_GROUP, + HFGITR_GROUP, + HAFGRTR_GROUP, + + /* Must be last */ + __NR_FGT_GROUP_IDS__ +}; + struct kvm_arch { struct kvm_s2_mmu mmu; + /* + * Fine-Grained UNDEF, mimicking the FGT layout defined by the + * architecture. We track them globally, as we present the + * same feature-set to all vcpus. + * + * Index 0 is currently spare. + */ + u64 fgu[__NR_FGT_GROUP_IDS__]; + /* Interrupt controller */ struct vgic_dist vgic; diff --git a/arch/arm64/kvm/emulate-nested.c b/arch/arm64/kvm/emulate-nested.c index b39ced4ea331..539b3913628d 100644 --- a/arch/arm64/kvm/emulate-nested.c +++ b/arch/arm64/kvm/emulate-nested.c @@ -1009,18 +1009,6 @@ static const struct encoding_to_trap_config encoding_to_cgt[] __initconst = { static DEFINE_XARRAY(sr_forward_xa); -enum fgt_group_id { - __NO_FGT_GROUP__, - HFGxTR_GROUP, - HDFGRTR_GROUP, - HDFGWTR_GROUP = HDFGRTR_GROUP, - HFGITR_GROUP, - HAFGRTR_GROUP, - - /* Must be last */ - __NR_FGT_GROUP_IDS__ -}; - enum fg_filter_id { __NO_FGF__, HCRX_FGTnXS, -- 2.39.2 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 85EA0C47DDC for ; Mon, 22 Jan 2024 20:19:48 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TEYOHiDWbjctNSQ8w94YN/q8/r0BRyJyAKTvwf4t9Zs=; b=ZUen0bSfXVKt8S oLuf0Ccbq+ZvcNobST1WnAb/PX3iQ/mjzPrTrIoqeWsEd/Esxwt5qMkiBPwWxPSaH09CikT1CL8xw mP6bghKPdlyUOEFHFwALkGAG0h63JBNarhK1E3sQF/c3iP9/GF37o++UX6KZdIs+TEPY53J4g0C2r RB3kFw/hgZc8EW84KTR40TJkmMNVg3rFu2dVcuUhaNcV27liFenVYIFjRWH4LsR3Wrb6QWBuqNQGj cUaO9e15WapDMADMRrRu3be7cVPOVm86p0dlEuoPJDcNI1KRYLiDSxQZb4ZSpnBHn0EbjgcptzTUg wY8HjIpyy7qJZYNnSdQw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rS0lH-00Ds2u-2E; Mon, 22 Jan 2024 20:19:15 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rS0l4-00Dru3-2M for linux-arm-kernel@lists.infradead.org; Mon, 22 Jan 2024 20:19:05 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 04DEB61A44; Mon, 22 Jan 2024 20:19:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABAB5C43609; Mon, 22 Jan 2024 20:19:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705954740; bh=ATf0ih7gkfEuE/hvRMYfwvXo1cLdsttokMnyWpUrPKo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HLMbFUVCGyhhvj9YshkPJ/bwgKy3JJYNtTxhlYizkqL0M0ZrfKh7cvis3A5J5OSMA oVgW5RKeG+Bqs6yY2OKMPDsrft3ef7E5qyTrcHK/F2GA4TPUerJaEEFWvb9i6mtpK+ zjy4yr72Nsv3iX5yxSJZQj2T4IOaDjKeeTxFmHgqhusuOvGU25yZlRtz+myaH/lBvi DleqS7aEv0Mm2gxxxon00VS2crSpFlwwr5hQEJl/tRAm7o/5uQpxmy31/LcqD9iZgN d46GQNOmmIMnsB5sgW/S5rTmsxVddDjKUWOs9lQNxuJ0m5sZzjGjR04vGEJvaQ8giK rnJSCEhxYuvzg== 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 1rS0l0-00DjkQ-RU; Mon, 22 Jan 2024 20:18:58 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Catalin Marinas , Will Deacon , Joey Gouly , Mark Brown Subject: [PATCH 17/25] KVM: arm64: Add Fine-Grained UNDEF tracking information Date: Mon, 22 Jan 2024 20:18:44 +0000 Message-Id: <20240122201852.262057-18-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240122201852.262057-1-maz@kernel.org> References: <20240122201852.262057-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, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, joey.gouly@arm.com, broonie@kernel.org 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-20240122_121902_914093_601AE112 X-CRM114-Status: GOOD ( 14.07 ) 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 In order to efficiently handle system register access being disabled, and this resulting in an UNDEF exception being injected, we introduce the (slightly dubious) concept of Fine-Grained UNDEF, modeled after the architectural Fine-Grained Traps. For each FGT group, we keep a 64 bit word that has the exact same bit assignment as the corresponding FGT register, where a 1 indicates that trapping this register should result in an UNDEF exception being reinjected. So far, nothing populates this information, nor sets the corresponding trap bits. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_host.h | 21 +++++++++++++++++++++ arch/arm64/kvm/emulate-nested.c | 12 ------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index e7a6219f2929..4e0ac507ca01 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -240,9 +240,30 @@ static inline u16 kvm_mpidr_index(struct kvm_mpidr_data *data, u64 mpidr) struct kvm_sysreg_masks; +enum fgt_group_id { + __NO_FGT_GROUP__, + HFGxTR_GROUP, + HDFGRTR_GROUP, + HDFGWTR_GROUP = HDFGRTR_GROUP, + HFGITR_GROUP, + HAFGRTR_GROUP, + + /* Must be last */ + __NR_FGT_GROUP_IDS__ +}; + struct kvm_arch { struct kvm_s2_mmu mmu; + /* + * Fine-Grained UNDEF, mimicking the FGT layout defined by the + * architecture. We track them globally, as we present the + * same feature-set to all vcpus. + * + * Index 0 is currently spare. + */ + u64 fgu[__NR_FGT_GROUP_IDS__]; + /* Interrupt controller */ struct vgic_dist vgic; diff --git a/arch/arm64/kvm/emulate-nested.c b/arch/arm64/kvm/emulate-nested.c index b39ced4ea331..539b3913628d 100644 --- a/arch/arm64/kvm/emulate-nested.c +++ b/arch/arm64/kvm/emulate-nested.c @@ -1009,18 +1009,6 @@ static const struct encoding_to_trap_config encoding_to_cgt[] __initconst = { static DEFINE_XARRAY(sr_forward_xa); -enum fgt_group_id { - __NO_FGT_GROUP__, - HFGxTR_GROUP, - HDFGRTR_GROUP, - HDFGWTR_GROUP = HDFGRTR_GROUP, - HFGITR_GROUP, - HAFGRTR_GROUP, - - /* Must be last */ - __NR_FGT_GROUP_IDS__ -}; - enum fg_filter_id { __NO_FGF__, HCRX_FGTnXS, -- 2.39.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel