From patchwork Wed Dec 6 10:04:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fuad Tabba X-Patchwork-Id: 13481339 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 97763C10DC1 for ; Wed, 6 Dec 2023 10:05:47 +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:From:Subject:Message-ID: Mime-Version:Date: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=HpOu+81lBJStqmNhmul7iNNX8UQJp/W1HEr8W12bAfQ=; b=ntH FSpr5LnhdHre1dQDxIpirj/b5a0Fa/MopAsYtdwKZKk753v3lyfgKJBcElvK6dZpXAPAC7QKsmPJe XMl+APr1UeXwNw+oOVFboNxMTYFUhhzsFD8EH/Tk/7VO5BSFT8Sk2RILJl2gs2qoZB1/l8rEajex3 nimE2Vn/PwTjI+8roS2OmQWz7TOY9bF1ji/7L1xcZsHlikgsCOhWKwOelLpA3B3Nx1ozaaZzvrma9 Hzrj1QrZLNHP4YVcZ0n3dA6YPknRCrhGmXdJQEAzcwRNtGyHGOqG5nmgFnXvzu857aMp0XzUi6LOw 2uecN2menim5MpCpBm2MD63/NLxiPzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rAomH-009d3N-2i; Wed, 06 Dec 2023 10:05:13 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rAomD-009d2c-0c for linux-arm-kernel@lists.infradead.org; Wed, 06 Dec 2023 10:05:11 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5d942a656b7so37577577b3.1 for ; Wed, 06 Dec 2023 02:05:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701857105; x=1702461905; darn=lists.infradead.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=hKt4wnxhbWMieJh8Fo1EeTPFkyfgQ6Kk+mcH0bY82so=; b=KL/tmHSye4wirILQfAqMCttnzjrzXahEGddB+J40M1DXc5J6mZe0jAo45MGauR1BBc addpkdnZHA07EGRYYf84e6RZjCK+usucEnQEBvds9J/b+J7csFmk3+r5hU+EgcesC0sG +RoLOx119GdsGQraKAfUMB4Caddh42+az0zAmKfRYXWQPunFEct8ttLbp5bPAjjk0/0+ lfaOi+gP4GbnsfvDzSboCx82/R87xdHloKxyBH+HS/a2maUv443Ji2IJe7D19icWPXaz BoyiNPt3h/C5w//6rXL0AHEPebJDRoeVjLNiWcwkh7ivDMhFdDmwPP7e4sKMTg/Mcqsc L0yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701857105; x=1702461905; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=hKt4wnxhbWMieJh8Fo1EeTPFkyfgQ6Kk+mcH0bY82so=; b=Y4gKd/PqR2P8uRhKIAO9qo2PZlMsckgU6Ry8jUSGRZkQr968XRFZ+zbmBaEs07axRp 5SW0FkIxQS9O0lUGRyXFpgccvkSgz02HaRQBRs+ztxq7OnpZYOBK07jDu0gpOZ2USvf+ 6iDrot6ZzNl2/p0dfj4latxx8eDQUQ2q1Xu8TNCEIMRUW93OyeWmX5IPbF6vlJJx/F5C tbe15PoJNODY42CGlafpBMN9KyPUc6FT3ekgTfSxHWxWB3UOX8xv3yRzBUrHc5vM83k2 2uPeIvWy2n4joSxBQW1M5c1kKiAPcqHn/pIG71RDSkcsPqEh1ya+BKKl+Ubwik1wQiv8 r1gA== X-Gm-Message-State: AOJu0YzaqSVVKM/jyGgpqvsCDKCAN1K3pQ80HKrEiei+EMpAA7ba5gaz /8r9NF4Fs4GcBxdasGaWLRGbZgYGng== X-Google-Smtp-Source: AGHT+IE0PJsBsYo7iM8Ik4Zx22L0blbH5vZfupSNvop9lHF+Jf6kBA570/+wuauYae2DfKLmqYI0SGe29w== X-Received: from fuad.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1613]) (user=tabba job=sendgmr) by 2002:a81:99d0:0:b0:5d4:3013:25d4 with SMTP id q199-20020a8199d0000000b005d4301325d4mr6275ywg.5.1701857105270; Wed, 06 Dec 2023 02:05:05 -0800 (PST) Date: Wed, 6 Dec 2023 10:04:50 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.rc2.451.g8631bc7472-goog Message-ID: <20231206100503.564090-1-tabba@google.com> Subject: [PATCH v2 00/12] KVM: arm64: Fixes to fine grain traps and pKVM traps From: Fuad Tabba To: kvmarm@lists.linux.dev Cc: maz@kernel.org, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, tabba@google.com, linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231206_020510_476156_CAE07E5D X-CRM114-Status: GOOD ( 11.89 ) 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 Changes from v1: - Handle HAFGRTR_EL2 in nested virt - Update the nested virt FGT tables with the added trap bits (Marc) - Use the generated value for RES0 (Marc) - Calculate the value of NMASK based on RES0 and MASK This patch series has fixes, updates, and code for validating fine grain trap register masks, as well as some fixes to feature trapping in pKVM. New fine grain trap (FGT) bits have been defined in the latest Arm Architecture System Registers xml specification (2023-09) [*], so the code is updated to reflect them. Moreover, some of the already-defined masks overlap with RES0, which this series fixes. It also adds FGT register masks that weren't defined earlier, handling of HAFGRTR_EL2 in nested virt, as well as build time validation that the bits of the various masks are all accounted for and without overlap. Based on 6.7-rc4. Cheers, /fuad [*] https://developer.arm.com/downloads/-/exploration-tools Fuad Tabba (12): KVM: Add missing HCRX_EL2 field definitions KVM: arm64: Add latest HFGxTR_EL2 FGT entries to nested virt KVM: arm64: Add latest HFGITR_EL2 FGT entries to nested virt KVM: arm64: Add bit masks for HAFGRTR_EL2 KVM: arm64: Handle HAFGRTR_EL2 trapping in nested virt KVM: arm64: Update and fix FGT register masks KVM: arm64: Add build validation for FGT trap mask values KVM: arm64: Use generated FGT RES0 bits instead of specifying them KVM: arm64: Generate the HFGWTR-only RES0 bits KVM: arm64: Define FGT NMASK bits relative to other fields KVM: arm64: Trap external trace for protected VMs KVM: arm64: Mark CMOW as allowed for protected VMs arch/arm64/include/asm/kvm_arm.h | 58 +++++++------ arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/include/asm/sysreg.h | 20 +++++ arch/arm64/kvm/emulate-nested.c | 63 ++++++++++++++ arch/arm64/kvm/hyp/include/hyp/switch.h | 29 +++++++ .../arm64/kvm/hyp/include/nvhe/fixed_config.h | 4 +- arch/arm64/kvm/hyp/nvhe/pkvm.c | 4 + arch/arm64/kvm/sys_regs.c | 1 + arch/arm64/tools/sysreg | 82 ++++++++++++++++++- 9 files changed, 231 insertions(+), 31 deletions(-) base-commit: 33cc938e65a98f1d29d0a18403dbbee050dcad9a