From patchwork Tue Aug 13 14:47:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13762178 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 D63A6C52D7C for ; Tue, 13 Aug 2024 14:53:28 +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:References:In-Reply-To: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:List-Owner; bh=lLm5x6t/WN60rydb7UJl/7PabA87yZNYNcWzj+JnMk4=; b=BbwBPBuDonl8V9qkQtc/cz8ytl +8dvPxlbed3Li0aDdfFvjR7nQSxfSkvwft5sGEQD+1QtKCg/XwdBmu4daj2lrqYraGwC4T6CEBMRg 0vK9+w0i4gVFawqVwoAEYmBiyG0ew71InkoM8yg0kW9pfKeQ/TNLaBBS8A3tk5Hmf3erbGgbSpdvB q0cP5s9+NZ4bLKVwxgcOEawcOTLDgfWEkQG5TE6lnNzauLMgX237M72nsDIF8BJL0eTWMW0AcZSHb KUMb7s1J8ejhz4vpxJ8EjAQZo1/G0qGA8r6lMCDoixUejObdTgx2vT3IOgVTPAgNplXg3ra4icH79 YGG8sXbw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdstg-000000045r7-3Gwa; Tue, 13 Aug 2024 14:53:16 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdsoh-000000044eq-26Av for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Aug 2024 14:48:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=lLm5x6t/WN60rydb7UJl/7PabA87yZNYNcWzj+JnMk4=; b=SOJ5mLSnomOkz9bw8RcZ+Czvpf 5xJM0qtT9lHqrKp6KMFiQqMz5T56kBEtplWyfOqs8M0pGdLj1eICuBoq/VhZZqd7f+6cOjiXseySO 9hvw1WC0AP/scrg0/l22+xWKYzwt0vMNaoIyYDtXPm4q5yXgB0LZEGTn02s0UFCIWS22AqLmEWkGu Xf/OTk9kyT9xPIhvt1/D5CrE424xVF4KCc6y7X89OLiD+bek50BgOssf/OU5TP/Yh0kMO8GWwmFbx LeSJu3sMC8lOFMkz8ph+11jPqqWzYL7D7Z9v0bA3DM0mR6rwHdtrli6XS4SVHBJ6jE/27SszGRSKi FXrHLakw==; Received: from dfw.source.kernel.org ([139.178.84.217]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdsoc-00000007oUf-1jG3 for linux-arm-kernel@lists.infradead.org; Tue, 13 Aug 2024 14:48:06 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id F3D6C61759; Tue, 13 Aug 2024 14:47:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A890EC4AF0F; Tue, 13 Aug 2024 14:47:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723560478; bh=/44hNubfAJPoo02XSxaPr9+x1CFGhuefxVXsc2EW9QQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lm42YvMY/V/0fQfMmYVV8Edn24AkcsvAv93AsDpQCZc5R2j9H0gcw5BxxJqODy1Rb nQRvbz86dE2sOTZnhbLtUyUNp437A++RSXsgaNMaq1sW67fOGaeMVQUBPDH/3wFEsP cMFQc4ZP0OhuzPyBBv7h/MBmv0CKrI/2FQAwzP078qO9kmiE7kqUNgjLtqG4dkNhEL +u3MaEg9RVNfOPxJegv3H2mpZ0mAQnb9MqYucc4EHIMAsOmBLw30VRTKw2JtuT87Nv FRDFJzFiJs73PS/+0Nwc0ZW0/KOnU0Y05pQpTcfUKs6tkyKdmpH/rLzQecuQCR2d7Q v6ikXH9ku7HTw== 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 1sdsoW-003O27-P4; Tue, 13 Aug 2024 15:47:56 +0100 From: Marc Zyngier To: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Joey Gouly , Alexandru Elisei Subject: [PATCH 03/10] KVM: arm64: Add TCR2_EL2 to the sysreg arrays Date: Tue, 13 Aug 2024 15:47:31 +0100 Message-Id: <20240813144738.2048302-4-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240813144738.2048302-1-maz@kernel.org> References: <20240813144738.2048302-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, kvm@vger.kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, joey.gouly@arm.com, alexandru.elisei@arm.com 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-20240813_154803_028108_2735E417 X-CRM114-Status: GOOD ( 11.97 ) 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 Add the TCR2_EL2 register to the per-vcpu sysreg register array, as well as the sysreg descriptor array. Access to this register is conditionned on ID_AA64MMFR3_EL1.TCRX being advertised. Signed-off-by: Marc Zyngier Reviewed-by: Joey Gouly --- arch/arm64/include/asm/kvm_host.h | 1 + arch/arm64/kvm/sys_regs.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index a33f5996ca9f..5a9e0ad35580 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -462,6 +462,7 @@ enum vcpu_sysreg { TTBR0_EL2, /* Translation Table Base Register 0 (EL2) */ TTBR1_EL2, /* Translation Table Base Register 1 (EL2) */ TCR_EL2, /* Translation Control Register (EL2) */ + TCR2_EL2, /* Extended Translation Control Register (EL2) */ SPSR_EL2, /* EL2 saved program status register */ ELR_EL2, /* EL2 exception link register */ AFSR0_EL2, /* Auxiliary Fault Status Register 0 (EL2) */ diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index 95832881fd66..52250db3c122 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -436,6 +436,18 @@ static bool access_vm_reg(struct kvm_vcpu *vcpu, return true; } +static bool access_tcr2_el2(struct kvm_vcpu *vcpu, + struct sys_reg_params *p, + const struct sys_reg_desc *r) +{ + if (!kvm_has_feat(vcpu->kvm, ID_AA64MMFR3_EL1, TCRX, IMP)) { + kvm_inject_undefined(vcpu); + return false; + } + + return access_rw(vcpu, p, r); +} + static bool access_actlr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, const struct sys_reg_desc *r) @@ -2783,6 +2795,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { EL2_REG(TTBR0_EL2, access_rw, reset_val, 0), EL2_REG(TTBR1_EL2, access_rw, reset_val, 0), EL2_REG(TCR_EL2, access_rw, reset_val, TCR_EL2_RES1), + EL2_REG(TCR2_EL2, access_tcr2_el2, reset_val, TCR2_EL2_RES1), EL2_REG_VNCR(VTTBR_EL2, reset_val, 0), EL2_REG_VNCR(VTCR_EL2, reset_val, 0),