From patchwork Wed May 1 17:06:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King (Oracle)" X-Patchwork-Id: 13651036 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 8BF3DC4345F for ; Wed, 1 May 2024 17:07:21 +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:Date:Message-Id:MIME-Version:Subject:Cc :To: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=IeOX2QqQNg7z2dVE17wxw53mIJsXNNC6bheqzk8QVf0=; b=ciGmL+HZvjYyT6 uHuPsnm1H8uU9utPnNcj5aP5kopub0tQvCuRJABZHjCoHMhqKtzetI8ah8xzGwMm0hK5wREAHBd9t VRAy+39a21+znI71nYEz9duLyzqNMp/Pmy4ZffclUyhoIApFnbDwxUBlOxG9B1XRm+ZuCkH16h2yG yBEdgImj+D7QcEPtFiTNkw9M1i1x4i7x2LovKm8Ly1vEtB1KNNT/b78J3nMXobKrBHFkRr/CO2NqT I71oI7zB3R/nCp9YSRRnm9mIEbzTF/XlsPkoP9PMyVe8RNRIztTz/6AvhuOf+2upAAc9LSQPW9/cp eClgoJxFBNXB5glYS5fQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2DQD-0000000AGTn-2cxN; Wed, 01 May 2024 17:07:09 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s2DQA-0000000AGSs-2d1Z for linux-arm-kernel@lists.infradead.org; Wed, 01 May 2024 17:07:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To: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-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=v2vVbfkVI1a5rCFnVuGB28K8O3O/kRv+ENqhurcfUik=; b=NXm4aOS0yxKRy3O5L7sKB4RabH pGhmBSLVQaOnFzn3cZx3syrQfxT8vozhvbPkAlPBC92KVix9aD0z08gi1QDhzowhOGczMBIQ+COm1 dlBb7Ng4p+Y5O+idNCaqjoMac8uaOZ4oqbg+DIZ8qBxQrLE9wjmgjJ0pQV27Tdb6RJg/vYWlx+8Rb yjWp4Foi7j6aAT3nf9Zwc+lufLSfSG2J7E5r0qH0SQRO0J3vIZE4RwuUxLBkcw7k+uvIrBMXZn9wq LXA+i0fdzS2RJsVg9YLsM3QN5xCh5TUkt8APqQvZv78H3hLPy8AiGv2XDQKkiuGBP0p2ejJDm+bWn ZPlHfZLw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:42176 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1s2DPu-0006SW-10; Wed, 01 May 2024 18:06:50 +0100 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1s2DPv-00AhaA-Ra; Wed, 01 May 2024 18:06:51 +0100 From: "Russell King (Oracle)" To: Marc Zyngier , Oliver Upton , Catalin Marinas , Will Deacon Cc: James Morse , Suzuki K Poulose , Zenghui Yu , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev Subject: [PATCH RFC] KVM: arm64: allow ID_MMFR4_EL1 to be writable MIME-Version: 1.0 Content-Disposition: inline Message-Id: Date: Wed, 01 May 2024 18:06:51 +0100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240501_100706_689806_8A57B9B4 X-CRM114-Status: GOOD ( 13.29 ) 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 Between 5.4 and 5.15, the guests view of HPDS, CnP, XNX and AC2 changed their value on the same Neoverse N1 r3p1 hardware which makes migrating between these kernels on the host problematical. We already permit changing HPDS in AA64MMFR1_EL1 and CnP in AA64MMFR2_EL1. We also allow LSM as we allow that in AA64MMFR2_EL1, so this patch includes support for that even though it isn't required. Discussing with Marc Zygnier, AC2 should also be fine to be writable, even though we don't inject an UNDEF if the guest accesses those registers. The only questionable one is XNX, execute-never control distinction, which is also in AA64MMFR1_EL1 but we don't allow to be changed there. Signed-off-by: Russell King (Oracle) Signed-off-by: Cornelia Huck --- arch/arm64/kvm/sys_regs.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 0cc289b17665..f306b38ec341 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -2116,6 +2116,16 @@ static unsigned int hidden_user_visibility(const struct kvm_vcpu *vcpu, .val = mask, \ } +/* sys_reg_desc initialiser for writable AA32 ID registers */ +#define AA32_ID_WRITABLE(name, mask) { \ + ID_DESC(name), \ + .set_user = set_id_reg, \ + .visibility = aa32_id_visibility, \ + .reset = kvm_read_sanitised_id_reg, \ + .val = mask, \ +} + + /* * sys_reg_desc initialiser for architecturally unallocated cpufeature ID * register with encoding Op0=3, Op1=0, CRn=0, CRm=crm, Op2=op2 @@ -2270,7 +2280,11 @@ static const struct sys_reg_desc sys_reg_descs[] = { AA32_ID_SANITISED(ID_ISAR3_EL1), AA32_ID_SANITISED(ID_ISAR4_EL1), AA32_ID_SANITISED(ID_ISAR5_EL1), - AA32_ID_SANITISED(ID_MMFR4_EL1), + AA32_ID_WRITABLE(ID_MMFR4_EL1, ID_MMFR4_EL1_LSM | + ID_MMFR4_EL1_HPDS | + ID_MMFR4_EL1_CnP | + ID_MMFR4_EL1_XNX | + ID_MMFR4_EL1_AC2), AA32_ID_SANITISED(ID_ISAR6_EL1), /* CRm=3 */