From patchwork Sat Mar 2 11:19:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13579513 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 40F82C54E4A for ; Sat, 2 Mar 2024 11:20:17 +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=e3J2xd5a3udn8AnN/pMonMRTq2FvAvg7NHHzQYhvjYc=; b=22dHc5hkcO9oVB umpxYxwr0mmTy959MDsx7SZtRrLfqlfX6G7jO9dhfGrt5VGfI8hG4BNQkAV5MyIuImfhbJcasYNeX KDipUq1ShQYaQMnCU4/Jn12jEEkIlBOkF5DKGfnJDRapR69GUNPBMeCPHWpEiHlS8UqpUkHrQj1GM jqFArZo1WHjLiLzYL1y6JoztMlF8NJ5eePWyaoY/1tRk7cJ0MGTwYke7K6pLatUzYJlqTpTOBgRRQ Fv+9Cj8aUJQRtWLKs6KD7p0/OHJ666TSVaFMJkMmSBynPKSzYX9iTyvf1g4gBtr14D2W0zh59zBWk rhJDulNxK3yaIuu8l/Qw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgNPP-00000003OcM-3X9S; Sat, 02 Mar 2024 11:20:03 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgNPL-00000003OZg-2UFZ for linux-arm-kernel@lists.infradead.org; Sat, 02 Mar 2024 11:20:01 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id EA7D361468; Sat, 2 Mar 2024 11:19:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DB7DC433A6; Sat, 2 Mar 2024 11:19:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709378398; bh=HS/j+OQhYdAZh6fG4YkqbtHPpdB6xcRRNkEe+IveeC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oSRFECNaK6As5fvWwyYr7u/3BrMN+qSHneRYkWkXUHZfzV0Wv4xZ0SRxLua2/kqbg tEETbKr6CxGY+wle3aMypN4WJ4zm4YL4HwpmjKKsk8ffdodcJZF7kfcucqppUHyj1a GsGm9MB82V/aTKn+HSlaXDvVanMk5dk/yRkif3w5TH25gkJ78HG0MqnYM+XKjWFuzo HaEfGp6VvnvOcRAScPHlZ+d/q3C6D0KQVIjCU49AsYL7An8AhJL9rB9QEagJuEeMmI WZgo1budNv9NTapjehmkJoUvcmPclTIibVNQtHIj81OlDhZed7Ip5eq/xcPZZIWjz3 k+dsAjPO90fGw== 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 1rgNPI-008lLw-Ha; Sat, 02 Mar 2024 11:19:56 +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 Subject: [PATCH 3/5] KVM: arm64: Exclude mdcr_el2_host from kvm_vcpu_arch Date: Sat, 2 Mar 2024 11:19:33 +0000 Message-Id: <20240302111935.129994-4-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240302111935.129994-1-maz@kernel.org> References: <20240302111935.129994-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 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-20240302_031959_785351_2A16C9ED X-CRM114-Status: GOOD ( 12.68 ) 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 90ea5524c545..a3718f441e12 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -517,6 +517,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; }; @@ -576,9 +578,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 9405a0c9b4c3..8ae81301083f 100644 --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -225,7 +225,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)) { @@ -247,7 +247,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()) {