From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f73.google.com (mail-wm1-f73.google.com [209.85.128.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F92037F745 for ; Fri, 12 Jun 2026 06:59:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781247569; cv=none; b=S5mVopv0fevvTyLxX+NhZUlXXT0g2/MfzKSwagtrma+yGSLoTp+V2ARBwNQ3dZs+4okJ/avxJlG0S3GTCam0bTnDohbc9TqpX2kJviB3UZcy5ZCmW4SSb/FI4J5cwsy92bxFAAyH2354/rtdkDUX99VLC0v1SHeyIkz7wljZruA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781247569; c=relaxed/simple; bh=2NWQv9gpSA5WmDYPM1gJ/c2gsARVXvjNHnCAwfJpAhY=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=PtwLZ4E/diCjDG4gcNp82YGulAO/nY731pzIcqwwqgbD10ei8J5YvR5juIKjtDIFGd6jloVEF2gnWrQXV+wzWsfpqUwg1Ne7Fo3vnLr5dh9r6kMpw0mcrJLjXFdgquVHV5pqrobkyiG1dbo2cfuqxI4/DTkiRuSzjn6s7jWDmIk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--tabba.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=mUPbLarA; arc=none smtp.client-ip=209.85.128.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--tabba.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="mUPbLarA" Received: by mail-wm1-f73.google.com with SMTP id 5b1f17b1804b1-490b79e6b94so4624435e9.2 for ; Thu, 11 Jun 2026 23:59:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781247566; x=1781852366; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=3/A8TfYJZJXuz9sD68tmOmSoDXJZKG01yZuG4gQpAiw=; b=mUPbLarAfh5+9B5AIV9vC6LKa7oZ0x9KU0fTHbt+X6d8fvnADxVNG3IiiebOBQnCyQ Bcz+dX7J0+kUy8fYLj7/zxHL7UTvhcJI9oxNn34ZUQH/mHhrFlC5ALTW8KD0l2y5q/AY v+csuWtAX2OVMpYPufJ067VCHRcA3RDRXSMMS4ZkJtxvBQXhxj1yXIdx1wxtid5H5ptd Kjnl4K5LgoF+KfS5lbM4yUoMbHT0RhoM12AgJdDkO8bIC+jq90Jxtd0+khBPmTSO0clw UaHqvdKcW84JBA2ZxzyaSqh0fXC1zI76SqLMhsmMBHM/j51f0ec4drTRtlYxvzYLZ+/k BFZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781247566; x=1781852366; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=3/A8TfYJZJXuz9sD68tmOmSoDXJZKG01yZuG4gQpAiw=; b=Bknvk65FBUdrYWemLelgAujqonwea48wKFTjSciwqH6M4HUcDSTVM1U6KT/txWD8Af 7QqdmBQL7IY3MlOBs+r5pSfTWQP3TnHjAias7moV4n/eFHbetXww3ssgXZ6vmAY0LHRr s12navlISgkAEdVWyIRn4H13wvbsZMYmnQEIiQr36NKyoEXRFRoSevDw36+5oygw8dsf i7Qv+GcMUm8d/xY7fUfSgGokrNuOZ+7yzrL5jp5HB+KM1JW9LytyKb+k22Ytxb8R7DNV RK4CVDz9RV4CUeE9ZnkIB8a6MwZeSiqm9HjkcAogXHiBSvj2PWG8krlCwCnKLKtrp2Sj 3rnA== X-Forwarded-Encrypted: i=1; AFNElJ9RQseA4m5lHYvNxjeJKMlhlA8jHvaPC8IpbRoVOBUSth2StiAKJV0IDOdrD3KWyFk3il+pP0M7aOfpaVA=@vger.kernel.org X-Gm-Message-State: AOJu0YxzzXXx7sfeSKCmtiWv2Q+GCWl3ubyhuPXF3YF/MMgksezWpiBI 9bae98uqb9owQ1EIYw/nuKqf1enmb5ykpbibbiglPoE0Cr26GbyfSIPYphYEVvx7I+/Faly2J4E BrQ== X-Received: from wmbg25.prod.google.com ([2002:a05:600c:a419:b0:490:b2b0:c4aa]) (user=tabba job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600d:6447:10b0:490:e18f:d108 with SMTP id 5b1f17b1804b1-490ec501b2cmr10440745e9.19.1781247566496; Thu, 11 Jun 2026 23:59:26 -0700 (PDT) Date: Fri, 12 Jun 2026 07:59:14 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.54.0.1136.gdb2ca164c4-goog Message-ID: <20260612065925.755562-1-tabba@google.com> Subject: [PATCH v1 00/11] KVM: arm64: Rework pKVM vCPU state synchronisation From: tabba@google.com To: Marc Zyngier , Oliver Upton Cc: Fuad Tabba , Will Deacon , Catalin Marinas , Quentin Perret , Vincent Donnefort , Sebastian Ene , Per Larsen , Suzuki K Poulose , Zenghui Yu , Joey Gouly , Steffen Eiden , Mark Rutland , Jonathan Cameron , Hyunwoo Kim , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Hi folks, Building on Will's pKVM infrastructure series [1], this series reworks how pKVM moves vCPU state between the host and EL2, and stops copying a non-protected guest's state on every world switch. EL2 gains proper primitives for the state it transfers: vCPU lookup helpers, and VGIC flush/sync that reduces how much host state EL2 dereferences. The series also moves some preparatory code (such as sys reg access and PSCI helpers) to shared headers and HYP, and implements lazy copying of a non-protected guest's register state back to the host until the host actually needs it, instead of on every exit. This is the first of two series moving pKVM vCPU state management to EL2. The follow-up completes the job for protected VMs: state isolation, PSCI handling at EL2, and the resulting API behaviour. The series is structured as follows: 01-03: Guard/scoped-resource support for hyp_spinlock and KVM locking (Marc asked for this to land as a prequel to a series that uses it). 04-07: Preparatory refactoring (MPIDR, sys reg access, vCPU reset, PSCI helpers) to shared headers and HYP. 08: Host and hypervisor vCPU lookup primitives. 09-10: VGIC: reduce EL2's exposure to host state, add flush/sync primitives. 11: Lazy state sync for non-protected guests. Based on v7.1-rc7. [1] https://lore.kernel.org/all/20260105154939.11041-1-will@kernel.org/ Cheers, /fuad Fuad Tabba (8): KVM: arm64: Add scoped resource management (guard) for hyp_spinlock KVM: arm64: Use guard(hyp_spinlock) in pKVM hypervisor code KVM: arm64: Use guard()/scoped_guard() in arm64 KVM EL1 code KVM: arm64: Extract MPIDR computation into a shared header KVM: arm64: Make vcpu_{read,write}_sys_reg available to HYP code KVM: arm64: Factor out reusable vCPU reset helpers KVM: arm64: Move PSCI helper functions to a shared header KVM: arm64: Implement lazy vCPU state sync for non-protected guests Marc Zyngier (3): KVM: arm64: Add host and hypervisor vCPU lookup primitives KVM: arm64: Minimise EL2's exposure of host VGIC state during world switch KVM: arm64: Add primitives to flush/sync the VGIC state at EL2 arch/arm64/include/asm/kvm_arm.h | 12 + arch/arm64/include/asm/kvm_asm.h | 1 + arch/arm64/include/asm/kvm_emulate.h | 80 ++++++- arch/arm64/include/asm/kvm_host.h | 2 + arch/arm64/kvm/arm.c | 21 +- arch/arm64/kvm/handle_exit.c | 22 ++ arch/arm64/kvm/hyp/include/nvhe/spinlock.h | 6 + arch/arm64/kvm/hyp/nvhe/ffa.c | 154 +++++-------- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 255 ++++++++++++++++++--- arch/arm64/kvm/hyp/nvhe/mm.c | 37 +-- arch/arm64/kvm/hyp/nvhe/page_alloc.c | 13 +- arch/arm64/kvm/hyp/nvhe/pkvm.c | 86 +++---- arch/arm64/kvm/mmu.c | 80 +++---- arch/arm64/kvm/pkvm.c | 26 +-- arch/arm64/kvm/psci.c | 47 +--- arch/arm64/kvm/reset.c | 68 +----- arch/arm64/kvm/sys_regs.c | 14 +- arch/arm64/kvm/sys_regs.h | 19 ++ include/kvm/arm_psci.h | 28 +++ 19 files changed, 562 insertions(+), 409 deletions(-) base-commit: 4549871118cf616eecdd2d939f78e3b9e1dddc48 -- 2.54.0.1136.gdb2ca164c4-goog