From patchwork Mon May 22 16:23:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13250810 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 5B776C77B75 for ; Mon, 22 May 2023 16:25:05 +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:Cc:To:MIME-Version:Message-Id:Date: Subject:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=CFcU8TQ2hknGgKQwDZTQFSjnYFN3jQlT+B2fKXWKi2g=; b=Z0JGbuemSR1cdk OIL7w3tTRY0ZgdVvGRpCe0u53yPqXGJSwdB6qmsEfRT7KVnVWzuxhhLxBnsi2x0JJEJhJyCnYT76I RfRyK7ijLtk7zuE8Gn14kkMVOuVmYC48sQgPTRQ5biERc7amOCmCcHpdsLJcbxQQPeJgrIknZf/nA J5VJozSb1154/7dxxn/fBOtZhOFZdLt1G7MwwChpfLLmE7xDPPIlKHf7nNXKBHZwgcCItzCD5aiPw ixOvFOOMqmUQfavg8kYdCyGs7EdsWX4PhrHhDXBI2fbCfRsw8EyxVXlCzA5h2V9hoSxXyBsbbk0x6 lkgL7/dnve/giNRhP+cw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q18L6-007CRr-2t; Mon, 22 May 2023 16:24:52 +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 1q18KR-007C6p-0r for linux-arm-kernel@lists.infradead.org; Mon, 22 May 2023 16:24:12 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7BD6760C67; Mon, 22 May 2023 16:24:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C6A9C433EF; Mon, 22 May 2023 16:24:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684772649; bh=I3YlnBhxCD0gEcml/CcInHo3e5hMQBL8zuDgV1zgfTk=; h=From:Subject:Date:To:Cc:From; b=VANP4UsdACd9ZuXA/xC5fsgPQ6Ld6r03FBaG2cuVsZA8PZyqMbuZna9hPI6IqqZF9 yz+c2EwSVLKGa7c8BfADkPxZCeJ0J8gzQwLdGMgs0PASO9GXgjLyOlmUmT2MfhM0XR m5W7uaalNEcL0RZqg79Q1x8hvjRmrl9mkg5xvQkv2MXDg6XMeIibWIvlCaufqeLH0n TKByW6b1Yuj/BJBqbkDw8RMd1YJxKXvJPPFo7HvQ22LtaPJVBU9w8TAAqvwrlocqOC M+Tj7aJAHjGpc1xWfVPE2Ln5OfnC7XYpCOdpDgMj8nxvyU3zug6g4+l4oYQY1S+jxZ hdSib2Mz88V3A== From: Mark Brown Subject: [PATCH v4 0/2] KVM: arm64: Support for per-guest fine grained traps configuration Date: Mon, 22 May 2023 17:23:55 +0100 Message-Id: <20230301-kvm-arm64-fgt-v4-0-1bf8d235ac1f@kernel.org> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIABuXa2QC/33NSw6DIBgE4KsY1qXhoWi76j2aLhB+lFjRgCFtj HcvuGuaupxJvpkVBfAWAroWK/IQbbCTS6E8FUj10nWArU4ZMcI44YTiIY5Y+lGU2HQLhkpryup SGFGjZFoZALdeOtVntYxzbmcPxr72l/sj5d6GZfLv/TTS3P7bjxQTrIw2NZVK1FrdBvAOnufJd yhPRXbIWeaUKqKVaSiRP5wfcp54Y6pLVfK2FQ3/4tu2fQC8oETYPwEAAA== To: Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon Cc: Joey Gouly , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, Mark Brown X-Mailer: b4 0.13-dev-bfdf5 X-Developer-Signature: v=1; a=openpgp-sha256; l=2217; i=broonie@kernel.org; h=from:subject:message-id; bh=I3YlnBhxCD0gEcml/CcInHo3e5hMQBL8zuDgV1zgfTk=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBka5ck/fW5JvaA+zWZGNCCdlvr+FuHCtCowNiW21s9 pyQQZKuJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZGuXJAAKCRAk1otyXVSH0AM4B/ 4miRA+qjaR6pqwAZxr9VhEbZZNmLChAzg/WSdQA22cTU8UxrAOht9U06s2IMMF0/SUjwKMghssDSVi Nrlc6S/XolJMsb0hoGELYK8srGd/CVKX/IBg/hzxgmxV53x37thxP7yGm8wdK9B9Hf7tx2hjoKk4WM aIPrO7xazdNh/A3BkBYHICDXLOacDY+N7S1mjiJ9kYn+d25InhVYS+6qscylNM5LE0tKMgCHNPnRNV lWK2tY7Tkbw/Lmb/2D0UoluvU7Kdn11dgOCYqT8udChkpJsAkL5A3i4tJNN+zg7Bygl+wWvDPesddL hSiDAF2yPPHXUMI+H8I1GrHOlu7Z0B X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230522_092411_399991_DFDCCB43 X-CRM114-Status: GOOD ( 14.93 ) 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 A number of upcoming features will require per guest configuration of the fine grained traps enabled in the guest. At present the only management we do is for SME where we don't yet have guest support so we unconditionally enable the traps while guests are running but this will change going forward and at present the code isn't particularly scalable. This series aims to make it easier to configure which traps are enabled for the guest by making the value set for the guest into configuration in the vCPU data which we can set up based on the chosen features rather than requiring conditional code in the trap enable and disable paths. This will have no benefit until one of the features that requires configuration of these traps is merged but since there's a number of such features it seems useful to decide on an approach to handling traps for them which can be shared. Changes in v4: - Reboase onto v6.4-rc3. - Link to v3: https://lore.kernel.org/r/20230301-kvm-arm64-fgt-v3-0-8f59543bb683@kernel.org Changes in v3: - Move the HFGxTR_EL2 storage from the sys_regs array to a member variable directly in struct kvm_vcpu_context. - Link to v2: https://lore.kernel.org/r/20230301-kvm-arm64-fgt-v2-0-c11c0dcf810a@kernel.org Changes in v2: - List all the traps enabled by setting the registers to 0 by default. - Save the HWFGxTR_EL2 valus in the vCPU/host sysreg structures. - Link to v1: https://lore.kernel.org/r/20230301-kvm-arm64-fgt-v1-0-cfdf71ac67dc@kernel.org --- Mark Brown (2): arm64: Add feature detection for fine grained traps KVM: arm64: Move FGT value configuration to vCPU state arch/arm64/include/asm/kvm_emulate.h | 16 ++++++++++++++ arch/arm64/include/asm/kvm_host.h | 3 +++ arch/arm64/kernel/cpufeature.c | 11 ++++++++++ arch/arm64/kvm/arm.c | 1 + arch/arm64/kvm/hyp/include/hyp/switch.h | 37 +++++++++++++++++++-------------- arch/arm64/tools/cpucaps | 1 + 6 files changed, 53 insertions(+), 16 deletions(-) --- base-commit: 44c026a73be8038f03dbdeef028b642880cf1511 change-id: 20230301-kvm-arm64-fgt-e5dd12746f67 Best regards,