From patchwork Thu Aug 1 09:19:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13750081 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 A3388C3DA64 for ; Thu, 1 Aug 2024 09:26: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: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=gVJmaThtpSsro+PFxFdPzHZLzOP/SKtBjabZPrJY5fA=; b=QSpxmB77WwhNZ2Sf2D1nSYEmGi xetL8CeXzGflPdsBBD6gTUALdyDEpqqIlKLhIxWJuZHL9Bm4234FqrMdZjchc+EAcHTeLM4RhQMvo ANyDjxikNJt+ksShISnHcQ2w7jMd77SpLJ88RyesThrvHj5yhWt3fqe6YynqZSJG+7q+xHbVz6cAM aCPieYIQyROKL/oozQSDFATosyH4x17r5JQghJluhFnbVgBdn41IFz9Nw5vkMIwCP5Bw2eY60CjHo m04dsAsgMcl+mlFeD7xT4+oxGCQio7uSC/zVovtbasV7ig68Yj5KDYXuWtLCIJTghG+Z+8mVwwGdh /cNXsXTw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZS59-00000004Ycp-2S4w; Thu, 01 Aug 2024 09:26:47 +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 1sZS1F-00000004XAg-2rYB for linux-arm-kernel@bombadil.infradead.org; Thu, 01 Aug 2024 09:22:45 +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=gVJmaThtpSsro+PFxFdPzHZLzOP/SKtBjabZPrJY5fA=; b=X7F1filfi6DCOmAXHipiNZZKUD ncYwk9gJzHJGHfBTVdvVS5uDTSHoIf6JbLtqA6Sk1lFAaMxNq4e4FZRxcbPYS8Go8Foa4SlVwsvqD Pr0p5p21XchVPjIioJT5ZjPUV7tj3mWGmOmjzwrm8UdIJ1GjfdrHNMIoD2HKy/wXMgRrpu7UkjLBj uqbbZBs44KTzr9IvJp2NhGmxQUE9TKg0Bq9ME6+UxD363ihwXe8lxOZE9uAn/fVzYnpPh20t0mhJ/ z3hBXjIGTW9mqwpWa8at9oCyshvKy0IH4BiojqLLMvmBE8MPnowjHkHoejERhstzOoX0ucm18vNYN eadbU+yw==; Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sZS1B-00000005QtL-3gde for linux-arm-kernel@lists.infradead.org; Thu, 01 Aug 2024 09:22:44 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B5DC5CE189B; Thu, 1 Aug 2024 09:22:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB22FC4AF0B; Thu, 1 Aug 2024 09:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722504156; bh=grh5Q/rcvt9bAWN63AYijQmUwGmeLeQjuYTHuxc1Nk8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=diuaXWeLk4Ohsvr0yKsLwqK0W6xqTKeb8QMX6z8USlIlKOvqIgS1OMMvLo3D3XDOe 0NeEe6YHR+Yzn7vWd0Os15fMEsXKgyk97vMTzLWWXLWJkSzVNwuVP5tbnbYb7Hlky5 I3PTFT9saPpUnL9r5C+khf9pdphPQPry2HlW4sdnl18KEl5aXJKNDRC/wPqp0jeZ1W /hO2qlkM9KJCBQUnZGT5K13sqC3VSDn/5QgdfTw/bHygK9oQ/IZ41qdGK0GGnOhhzh /QiP7rpM/7iou97jd9T1A7jLElhtYR0WQQ+7i5vElNN1M6BX3c19saMFZ73PI2ot/o KG/m1Knl27mrg== 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 1sZRyZ-00HKNZ-NJ; Thu, 01 Aug 2024 10:19:59 +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 , Fuad Tabba , Joey Gouly , Mark Brown Subject: [PATCH v2 1/8] KVM: arm64: Move SVCR into the sysreg array Date: Thu, 1 Aug 2024 10:19:48 +0100 Message-Id: <20240801091955.2066364-2-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801091955.2066364-1-maz@kernel.org> References: <20240801091955.2066364-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, tabba@google.com, joey.gouly@arm.com, broonie@kernel.org 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-20240801_102242_843122_F980A288 X-CRM114-Status: GOOD ( 18.18 ) 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 SVCR is just a system register, and has no purpose being outside of the sysreg array. If anything, it only makes it more difficult to eventually support SME one day. If ever. Move it into the array with its little friends, and associate it with a visibility predicate. Although this is dead code, it at least paves the way for the next set of FP-related extensions. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_host.h | 4 +++- arch/arm64/kvm/fpsimd.c | 2 +- arch/arm64/kvm/sys_regs.c | 11 ++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index a33f5996ca9f..e244e3176b56 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -446,6 +446,9 @@ enum vcpu_sysreg { GCR_EL1, /* Tag Control Register */ TFSRE0_EL1, /* Tag Fault Status Register (EL0) */ + /* FP/SIMD/SVE */ + SVCR, + /* 32bit specific registers. */ DACR32_EL2, /* Domain Access Control Register */ IFSR32_EL2, /* Instruction Fault Status Register */ @@ -664,7 +667,6 @@ struct kvm_vcpu_arch { void *sve_state; enum fp_type fp_type; unsigned int sve_max_vl; - u64 svcr; u64 fpmr; /* Stage 2 paging state used by the hardware on next switch */ diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c index c53e5b14038d..e6425414d301 100644 --- a/arch/arm64/kvm/fpsimd.c +++ b/arch/arm64/kvm/fpsimd.c @@ -134,7 +134,7 @@ void kvm_arch_vcpu_ctxsync_fp(struct kvm_vcpu *vcpu) fp_state.sve_state = vcpu->arch.sve_state; fp_state.sve_vl = vcpu->arch.sve_max_vl; fp_state.sme_state = NULL; - fp_state.svcr = &vcpu->arch.svcr; + fp_state.svcr = &__vcpu_sys_reg(vcpu, SVCR); fp_state.fpmr = &vcpu->arch.fpmr; fp_state.fp_type = &vcpu->arch.fp_type; diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index c90324060436..2dc6cab43b2f 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1669,6 +1669,15 @@ static unsigned int sve_visibility(const struct kvm_vcpu *vcpu, return REG_HIDDEN; } +static unsigned int sme_visibility(const struct kvm_vcpu *vcpu, + const struct sys_reg_desc *rd) +{ + if (kvm_has_feat(vcpu->kvm, ID_AA64PFR1_EL1, SME, IMP)) + return 0; + + return REG_HIDDEN; +} + static u64 read_sanitised_id_aa64pfr0_el1(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd) { @@ -2535,7 +2544,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { CTR_EL0_IDC_MASK | CTR_EL0_DminLine_MASK | CTR_EL0_IminLine_MASK), - { SYS_DESC(SYS_SVCR), undef_access }, + { SYS_DESC(SYS_SVCR), undef_access, reset_val, SVCR, 0, .visibility = sme_visibility }, { PMU_SYS_REG(PMCR_EL0), .access = access_pmcr, .reset = reset_pmcr, .reg = PMCR_EL0, .get_user = get_pmcr, .set_user = set_pmcr },