From patchwork Fri Oct 4 11:07:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13822180 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 24198CFA763 for ; Fri, 4 Oct 2024 11:08:56 +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: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:In-Reply-To:References:List-Owner; bh=JSAJzo6vUlP/DhNhzN99j3PaqT15TojsIRAINM2sf08=; b=OdrPFprv1fRJZzn5Swp0lMPdTB Imty+9/b+1YkociWXcqNJcSB7IWbyCtR10rnUx/MVoybhOlFd4D842/PB1JdmwCDLcLjVNtnNprpc VX46mpYgl85V3qEuelscEgHIl15TK4li2A98DQddmIl9V6bvC0HOoO4B+ynmjZ4++v/M81KSMUySm dwQTGeNUz7KuwAVG0l6qTmc+Gcb/qHGFKck1Hjpy2KQysBJyQeHbQCGboE58XkHy0C4xNaaz2RY8g c3U6YbsGGTyc9e1YNPfTtiFboX9AHkbR1HqSuEkiego9OPP+aRXtdTyceMUgn0JNTHsSqBtTzDZeZ Ve3w0eGg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1swgAx-0000000C1QP-06SH; Fri, 04 Oct 2024 11:08:47 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1swg9d-0000000C0yn-0upz for linux-arm-kernel@lists.infradead.org; Fri, 04 Oct 2024 11:07:26 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DE9ED339; Fri, 4 Oct 2024 04:07:51 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BB2833F640; Fri, 4 Oct 2024 04:07:20 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Cc: anshuman.khandual@arm.com, james.morse@arm.com, joey.gouly@arm.com, Marc Zyngier , Oliver Upton , Suzuki K Poulose , Zenghui Yu , Jing Zhang , Shameerali Kolothum Thodi , Catalin Marinas , Will Deacon Subject: [PATCH v4 0/7] KVM: arm64: Hide unsupported MPAM from the guest Date: Fri, 4 Oct 2024 12:07:07 +0100 Message-Id: <20241004110714.2051604-1-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241004_040725_374863_3822A46D X-CRM114-Status: GOOD ( 16.61 ) 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, I have taken over these patches from James, as he doesn't have the time to push them forward currently. James wrote: This series fixes up a long standing bug where MPAM was accidentally exposed to a guest, but the feature was not otherwise trapped or context switched. This could result in KVM warning about unexpected traps, and injecting an undef into the guest contradicting the ID registers. This would prevent an MPAM aware kernel from booting - fortunately, there aren't any of those. Ideally, we'd take the MPAM feature away from the ID registers, but that would leave existing guests unable to migrate to a newer kernel. Instead, just ignore that field when it matches the hardware. KVM wasn't going to expose MPAM anyway. The guest will not see MPAM in the id registers. This series includes the head.S and KVM changes to enable/disable traps. If MPAM is neither enabled nor emulated by EL3 firmware, these system register accesses will trap to EL3. If your kernel doesn't boot, and the problem bisects here - please update your firmware. MPAM has been supported by trusted firmware since v1.6 in 2018. (also noted on patch 3). changes since v3 [1]: - Converted to the new generated sysreg file - Added MPAM_frac support - Changed the Kconfig to hopefully make it obvious that it doesn't actually enable MPAM for users - rebased onto v6.12-rc1 Thanks, Joey [1] https://lore.kernel.org/kvmarm/20240321165728.31907-1-james.morse@arm.com/ James Morse (7): arm64: head.S: Initialise MPAM EL2 registers and disable traps arm64/sysreg: Convert existing MPAM sysregs and add the remaining entries arm64: cpufeature: discover CPU support for MPAM KVM: arm64: Fix missing traps of guest accesses to the MPAM registers KVM: arm64: Add a macro for creating filtered sys_reg_descs entries KVM: arm64: Disable MPAM visibility by default and ignore VMM writes KVM: arm64: selftests: Test ID_AA64PFR0.MPAM isn't completely ignored .../arch/arm64/cpu-feature-registers.rst | 2 + arch/arm64/Kconfig | 20 +++ arch/arm64/include/asm/cpu.h | 1 + arch/arm64/include/asm/cpucaps.h | 2 + arch/arm64/include/asm/cpufeature.h | 12 ++ arch/arm64/include/asm/el2_setup.h | 16 ++ arch/arm64/include/asm/kvm_arm.h | 1 + arch/arm64/include/asm/mpam.h | 32 ++++ arch/arm64/include/asm/sysreg.h | 12 -- arch/arm64/kernel/Makefile | 2 + arch/arm64/kernel/cpufeature.c | 97 ++++++++++ arch/arm64/kernel/cpuinfo.c | 4 + arch/arm64/kernel/image-vars.h | 5 + arch/arm64/kernel/mpam.c | 8 + arch/arm64/kvm/hyp/include/hyp/switch.h | 32 ++++ arch/arm64/kvm/sys_regs.c | 114 +++++++++--- arch/arm64/tools/cpucaps | 1 + arch/arm64/tools/sysreg | 166 ++++++++++++++++++ .../selftests/kvm/aarch64/set_id_regs.c | 100 ++++++++++- 19 files changed, 587 insertions(+), 40 deletions(-) create mode 100644 arch/arm64/include/asm/mpam.h create mode 100644 arch/arm64/kernel/mpam.c