From patchwork Sat Mar 2 11:19:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 13579512 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 D0D04C54E55 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: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:In-Reply-To:References: List-Owner; bh=vDR2L+LlCyBpxVeHrngOCa4D5bnApk20sKPxOWDFAv4=; b=b/bn5guQ7FLWjm BgXghCrMHJTPyWQ1RcVAbuZLZFhNIjqSbQyPXtG46laDCTPpkBoUNKMZzK1sLw8eOPYCWrJcHE45R EERCOkRx8hu/sTRivPgQNeAKttwzMELK8vBtXf0PdgUMJ1I1mX+K5ydeHgcFujTRTly+F5kVm0Zki 5Ek+D+rngX1s73k+SU4cxogRxzKFKgLdvybP4NtAiv1OvkzfdIip7k/98z2WQG6GNLh9RCFZcGrle Q2HgN3x99z+/fRXfcK4+2h6Rw2Qh5/WTmsUpIwA5cTXKRVd8hqRNdJN9lpVTF6KoGZBCESKf97Jbd iFJz5FMT3luORLDwVt7w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgNPR-00000003Odg-457B; Sat, 02 Mar 2024 11:20:05 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rgNPN-00000003Oa6-0dLA for linux-arm-kernel@lists.infradead.org; Sat, 02 Mar 2024 11:20:02 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 27200CE0946; Sat, 2 Mar 2024 11:19:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6120CC433C7; 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=3J0k5g/fnp9TIqJEjL4u2lVp2pibB+1Yu7BCqEtpkcc=; h=From:To:Cc:Subject:Date:From; b=pm9ufTbxxjZsBrr/XVm2dvtNYlj7rw2LvlPI3aQ64itVz0HOGeHwPQ5G07Gl4extj a27Wmu8v1cmYXnh4h56M9NPw4kgqpUsmD8ljh5VuzwVCxD8TnKtWJUW2mrlJQpQUYf 2cOllCxzRpu6L1gFCQNu1kXsyb1eeT2WMTwXi32CiXVc3W4LloPmHtRVlIV4Sw7PHZ uPJZO2oDDX+ZPojNvuWBD7MZuvy7p7IKpZdRPQpPVVggfK9p+vNepJsixdGICmz+65 hyC+6e/oS83P4J9yqTsVC7spYQoaUoNRIK4PmDdRfD3D+a77zyB0jz5OeNJalqINJ2 AMMTxGiNpvRAw== 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 1rgNPH-008lLw-RB; 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 0/5] KVM: arm64: Move host-specific data out of kvm_vcpu_arch Date: Sat, 2 Mar 2024 11:19:30 +0000 Message-Id: <20240302111935.129994-1-maz@kernel.org> X-Mailer: git-send-email 2.39.2 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_032001_604869_FE5F6FC5 X-CRM114-Status: GOOD ( 13.62 ) 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 It appears that over the years, we have accumulated a lot of cruft in the kvm_vcpu_arch structure. Part of the gunk is data that is strictly host CPU specific, and this result in two main problems: - the structure itself is stupidly large, over 8kB. With the arch-agnostic kvm_vcpu, we're above 10kB, which is insane. This has some ripple effects, as we need physically contiguous allocation to be able to map it at EL2 for !VHE. There is more to it though, as some data structures, although per-vcpu, could be allocated separately. - We lose track of the life-cycle of this data, because we're guaranteed that it will be around forever and we start relying on wrong assumptions. This is becoming a maintenance burden. This series rectifies some of these things, starting with the two main offenders: debug and FP, a lot of which gets pushed out to the per-CPU host structure. Indeed, their lifetime really isn't that of the vcpu, but tied to the physical CPU the vpcu runs on. This results in a small reduction of the vcpu size, but mainly a much clearer understanding of the life-cycle of these structures. Patches against v6.8-rc6. Marc Zyngier (5): KVM: arm64: Add accessor for per-CPU state KVM: arm64: Exclude host_debug_data from vcpu_arch KVM: arm64: Exclude mdcr_el2_host from kvm_vcpu_arch KVM: arm64: Exclude host_fpsimd_state pointer from kvm_vcpu_arch KVM: arm64: Exclude FP ownership from kvm_vcpu_arch arch/arm64/include/asm/kvm_emulate.h | 4 +- arch/arm64/include/asm/kvm_host.h | 65 ++++++++++++++--------- arch/arm64/kvm/arm.c | 8 +-- arch/arm64/kvm/fpsimd.c | 13 +++-- arch/arm64/kvm/hyp/include/hyp/debug-sr.h | 8 +-- arch/arm64/kvm/hyp/include/hyp/switch.h | 23 ++++---- arch/arm64/kvm/hyp/nvhe/debug-sr.c | 8 +-- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 3 -- arch/arm64/kvm/hyp/nvhe/psci-relay.c | 2 +- arch/arm64/kvm/hyp/nvhe/setup.c | 3 +- arch/arm64/kvm/hyp/nvhe/switch.c | 6 +-- arch/arm64/kvm/hyp/vhe/switch.c | 6 +-- arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 4 +- arch/arm64/kvm/pmu.c | 2 +- 14 files changed, 79 insertions(+), 76 deletions(-)