From patchwork Fri Mar 22 17:09:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13600336 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 E54CAC47DD9 for ; Fri, 22 Mar 2024 17:10: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kUxUz7NHu1fcdUeHoavs4uJ2kO6IIj9Nr0fI8UGp17I=; b=naVOD8Xs1d5LW3 Xp9SP5LoooUBTglV3cVmdllFlm9sanqNonIXABYWplWco//LU6j+YcU5Gevu+Th/+WUQjSIMIDkgw iH0cxeVxvl4l7+bhjw68HHyNJRDezoJUZnnyW3sRssp3469sre7vVuGcLZfmGpHGea3eS73e8mH2z c88MLh/7kl91z6IPbdYf8c4hxQH/fNMLClViO5hphRrqGlEN8Umpd7L1PT/KAOpEfvRpd0vSfLUTJ PJVk160J/CuiQAaHSTj2jHuBG2pGsTk1+BjJ2p2Qy0vsX4akP+9dFrUUIuVmZhiHSfQvRaubZK4jR klpkzMMFh+HiV5JRBk3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rniPk-000000086zB-3uGc; Fri, 22 Mar 2024 17:10:44 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rniPE-000000086dg-2ZKP for linux-arm-kernel@lists.infradead.org; Fri, 22 Mar 2024 17:10:14 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 41395CE1849; Fri, 22 Mar 2024 17:10:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 582E8C433A6; Fri, 22 Mar 2024 17:10:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711127409; bh=f7zVa7Vb35emtaj3yee+ueV8CX7+6/2j7VjOZT6XV3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dnzT4Lpe1JiyN2deKxmgb2UZ9xsGpuoomAUFdtyIk7yGTXCFt7Zp/h987rdRV/knn 4YefQy/Xm2XWppM636tP1mrYP7aC7SjhRv5FgP2p96CFhSqXsAYKydOflhehQI9U7H 0Z3Q8moUxuBE3ia5qu1TiJC/TI27DJhbRoPmN6vPAI+7miAc7dZ/R+/o8RdPa/Wxic oJ2rVXnsODWtHK0AO+aMl38p0f5KLU6CQ1+MXqBjv+uO/oxjUWxEyr8OhUHM+9EZ7J aJeyZVu3ckIMQvJb2f6hRxV69nmpzv7vtqUxEWAwx2NfzaT8RHHITONK76/8hBSFRi 9lCLzC4F+0qAQ== 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 1rniP9-00EZPz-Ip; Fri, 22 Mar 2024 17:10:07 +0000 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 , James Clark , Anshuman Khandual , Mark Brown , Dongli Zhang Subject: [PATCH v2 3/5] KVM: arm64: Exclude mdcr_el2_host from kvm_vcpu_arch Date: Fri, 22 Mar 2024 17:09:43 +0000 Message-Id: <20240322170945.3292593-4-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240322170945.3292593-1-maz@kernel.org> References: <20240322170945.3292593-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, james.clark@arm.com, anshuman.khandual@arm.com, broonie@kernel.org, dongli.zhang@oracle.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-20240322_101013_063749_3BE2D8D4 X-CRM114-Status: GOOD ( 13.22 ) 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 As for the rest of the host debug state, the host copy of mdcr_el2 has little to do in the vcpu, and is better placed in the host_data structure. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_host.h | 5 ++--- arch/arm64/kvm/hyp/include/hyp/switch.h | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 8c149e4ae99d..590e8767b720 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -555,6 +555,8 @@ struct kvm_host_data { u64 pmscr_el1; /* Self-hosted trace */ u64 trfcr_el1; + /* Values of trap registers for the host before guest entry. */ + u64 mdcr_el2; } host_debug_state; }; @@ -615,9 +617,6 @@ struct kvm_vcpu_arch { u64 mdcr_el2; u64 cptr_el2; - /* Values of trap registers for the host before guest entry. */ - u64 mdcr_el2_host; - /* Exception Information */ struct kvm_vcpu_fault_info fault; diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h index ae198b84ca01..7d7de0245ed0 100644 --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -232,7 +232,7 @@ static inline void __activate_traps_common(struct kvm_vcpu *vcpu) vcpu_set_flag(vcpu, PMUSERENR_ON_CPU); } - vcpu->arch.mdcr_el2_host = read_sysreg(mdcr_el2); + *host_data_ptr(host_debug_state.mdcr_el2) = read_sysreg(mdcr_el2); write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2); if (cpus_have_final_cap(ARM64_HAS_HCX)) { @@ -254,7 +254,7 @@ static inline void __activate_traps_common(struct kvm_vcpu *vcpu) static inline void __deactivate_traps_common(struct kvm_vcpu *vcpu) { - write_sysreg(vcpu->arch.mdcr_el2_host, mdcr_el2); + write_sysreg(*host_data_ptr(host_debug_state.mdcr_el2), mdcr_el2); write_sysreg(0, hstr_el2); if (kvm_arm_support_pmu_v3()) {