From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (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 F2D923ECBD8 for ; Tue, 28 Apr 2026 10:30:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777372214; cv=none; b=b0+67ypzIyCtDBEnvf+V5BQ0uq9BSoP5GS5zrakkmHdib900TwZ6xV/IxovrpcNL4hNAfWrlH5gScp4ZUoW2XDrPhLFtcczCz/OPBHh8fFCOP758jaLo320say/vFDqh6ElWG3avkx2uy3Daq5CJ8scqvPzaZ96fe9dwu8VeKKs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777372214; c=relaxed/simple; bh=Q1SQtMHy3aqsHkz2pqwBb00QPVJHhdgc6QUsbv3XMuk=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=F6d9rxdS6/7s9E8yDJFBEA+kCwLrMIz3/M99cBrJ4/MrU/IO7FwoKDa65AwDI+IUaC0i65BtSbfzopFejf+jiZR3kBVEhUlY5Sv1GM3v7Wzv4kgX71umSDNidMuJv9naOO63vtB4Rrm9CFnOQQePO+sT7vLLYvf7Yukc1CAbcbU= 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=oQHe34oP; arc=none smtp.client-ip=209.85.128.74 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="oQHe34oP" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-4837bfcfe0dso125256075e9.1 for ; Tue, 28 Apr 2026 03:30:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1777372209; x=1777977009; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=ybPE6uBPAKDLSIVRQh3Dd/khXkWqQgT9nsbAgFbes8s=; b=oQHe34oPA9XmpeNDCzIzkkzcuI29Q0ml2z+Uh09iSXZuI6MySlMDJloZb0cv7bFkMd qp5BZ/I7RFm97SuKvEa1pFmKfUY38yR5BtLj9joCQiKyxjSovN5HoLkuZOF4eC4SpgCj akyHoGpRBw/ScvoHSZs85WDbm8Lq9wHetzhDpgWRZkYHjiXoCj0ui6tAonKaaXL+OrOw i3zFW/LYptl7UTDy1YSCbgIB+RK8wTBR/38Sy+C2ET3hQr5IMIXhWhcpCzwCgay4PZ5Z aEQ+dNEEQxGC9G82ig63UxWBqnUvDCpUaHq6CjnbYYEqds3Npuli1BjzAUWiww22Exzi ZdcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777372209; x=1777977009; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ybPE6uBPAKDLSIVRQh3Dd/khXkWqQgT9nsbAgFbes8s=; b=UsZPv/wdP2dqQ1c+1ard8mzAyy+Ii8p8airxUmQwTA1gWXf4aK8GtSwV+MZxKShcKw cQHges9xQXpSSu4Xn7gs54wJ1w70AnATrvUU16TEpXT2uWj1SJXYF1Us4kdZFZ3m78u7 q2lQ9IVKs9p/LmsS69UA5IUJ4HT3Dxnk2qHn93mUKBKRsMASKRZ/NAvdr5eOk+mbkkgx vuLdiPso/6CJLqTzKEHCQFCtPFOMIC4MEDB2Zavk7XoJIxBzAh3+NYgGE40ZsChhbeam Fz9UMC137ckRa27Fp4XIGptlIEDrgEIsDib5TJ6/i/lh6b/qZe3Jluq3URK3jv4wHLac kzIw== X-Forwarded-Encrypted: i=1; AFNElJ839gUNYZ+WL3KLpkcavT7TYTXlnenK8q/eobBTRf2r1w3S575sriiVM3BHv670INwZ+xR5syhnPsoi+4M=@vger.kernel.org X-Gm-Message-State: AOJu0YxXXc+H0XvcwG8fRmG84FPEUB7682vWO+Cm1CSutjzQFYqEUxeX Cpb/PIF6tAcXUUpDi6is2i3QWyjF1lO12w3uZ2PMXvSM8BJrZTUf1Rbi5SjZdvZT7eA5T9H+CaB 48Q== X-Received: from wmby10.prod.google.com ([2002:a05:600c:c04a:b0:486:fca5:7a8d]) (user=tabba job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:a013:b0:48a:563c:c8e0 with SMTP id 5b1f17b1804b1-48a77ad5a89mr41979925e9.1.1777372209349; Tue, 28 Apr 2026 03:30:09 -0700 (PDT) Date: Tue, 28 Apr 2026 11:30:00 +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.545.g6539524ca2-goog Message-ID: <20260428103008.696141-1-tabba@google.com> Subject: [PATCH 0/8] KVM: arm64: EL2 synchronisation and pKVM stage-2 error propagation fixes From: Fuad Tabba To: maz@kernel.org, oliver.upton@linux.dev Cc: james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, qperret@google.com, vdonnefort@google.com, tabba@google.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Hi folks, This is yet another series of fixes I'd like to land before posting a follow-up to Will's pKVM infrastructure series [1]. I found these while developing KVM and arm64 system guides for review-prompts [2], an open-source set of AI-assisted review prompts used by sashiko [3]. While writing the guides I tried to find cases that would be easy to miss or trip up an LLM, and stumbled on these bugs. A local run with the updated guides flagged all of them correctly (some of the commit messages incorporate feedback from that run, e.g., the impact of WARN_ON() in hyp). I plan to upstream the guides once they are complete. The patches fall into three groups: EL2 context-synchronisation (patches 1-2): Patch 1 sets SCTLR_EL2.EIS and SCTLR_EL2.EOS in INIT_SCTLR_EL2_MMU_ON. On FEAT_ExS hardware these bits are UNKNOWN at reset; without them EL2 exception entry and exit are not architecturally guaranteed to be Context Synchronisation Events. KVM/arm64 hot paths rely on that guarantee implicitly to elide explicit ISBs after MSRs to context-switching sysregs. Patch 2 adds an explicit ISB after write_sysreg_hcr() on the __deactivate_traps() path. The activate path is covered by the ERET that follows (a CSE, guaranteed by patch 1); on the deactivate path, subsequent EL2 sysreg accesses run before any natural CSE. Minor fixes (patches 3-4): Patch 3 fixes a parameter-name typo in __deactivate_fgt() that causes it to silently capture a variable from the enclosing scope rather than use its declared parameter. Patch 4 guards the VHE hyp panic path against a NULL vcpu pointer; the nVHE counterpart already has this guard. pKVM stage-2 error propagation (patches 5-8): At EL2 in nVHE/pKVM, WARN_ON() is not warn-and-continue: it expands to a BRK that enters the invalid-host-el2 vector and branches to hyp_panic(), which is __noreturn. Four pKVM memory-transition functions wrapped the return value of kvm_pgtable_stage2_map() in WARN_ON() and discarded it. For the share and donation paths the map can fail via -ENOMEM when the vcpu memcache is exhausted, converting a recoverable hypercall error into a fatal hyp panic. The four patches capture and propagate the return value, with appropriate stage-2 unmap and host-side rollback for the reachable failure cases. Cheers, /fuad [1] https://lore.kernel.org/all/20260105154939.11041-1-will@kernel.org/ [2] https://github.com/masoncl/review-prompts [3] https://sashiko.dev/ Fuad Tabba (8): KVM: arm64: Make EL2 exception entry and exit context-synchronization events KVM: arm64: Synchronise HCR_EL2 writes on the guest exit path KVM: arm64: Guard against NULL vcpu on VHE hyp panic path KVM: arm64: Fix __deactivate_fgt macro parameter typo KVM: arm64: Propagate stage-2 map failure on host->guest share KVM: arm64: Propagate stage-2 map failure on host->guest donation KVM: arm64: Propagate stage-2 map failure on guest->host share KVM: arm64: Propagate stage-2 map failure on guest->host unshare arch/arm64/include/asm/sysreg.h | 2 +- arch/arm64/kvm/hyp/include/hyp/switch.h | 2 +- arch/arm64/kvm/hyp/nvhe/mem_protect.c | 99 +++++++++++++++++++++---- arch/arm64/kvm/hyp/nvhe/switch.c | 11 +++ arch/arm64/kvm/hyp/vhe/switch.c | 14 +++- 5 files changed, 111 insertions(+), 17 deletions(-) -- 2.54.0.545.g6539524ca2-goog