From nobody Mon Jun 8 07:22:49 2026 Received: from mail-ej1-f74.google.com (mail-ej1-f74.google.com [209.85.218.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 BED3C3914FE for ; Sun, 31 May 2026 15:45:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780242353; cv=none; b=VuS7aA4iOLXm0F/JnYhEVOIjVkaySIgpYNkuEMJXrRMTYjBtwJAaHGCWMTW0/XWAo3X/AXd4k1u2hzRenwspSNDspQqyVkncAW83xKwW1+nZ8FIZvy8eKudpq8RZrYSiVi5VT7BrXC6Es81Cw79kyoq6uFyF8YnudXQdK3txbFE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780242353; c=relaxed/simple; bh=4W1NFT8egfIsuOpwHtsrvwG4F7ILQ3DCUTBazhiSZQ8=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=Q/+FWC8a1OVP2QcTmHKNt2eyOj8ZHOvdwYWHq/ODhj9aptxyagLozOZK9Rxqkhqc4g7GaRIhph3bNCAiWPBW4LqNSKPRQ03nTn6GxzmaRsmPqtWOAJA9n3HMi0jIPppcG2YtJTTVbD8z1k5upOjoFLq2SAjYUgldRjWN3Frk6/4= 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=hR0vg1Dp; arc=none smtp.client-ip=209.85.218.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="hR0vg1Dp" Received: by mail-ej1-f74.google.com with SMTP id a640c23a62f3a-beb7c5c1f52so78364866b.2 for ; Sun, 31 May 2026 08:45:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780242349; x=1780847149; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=4HGHSV+ymwGZVts9xs57iGtb0PHiB6C1QG35wARFiWM=; b=hR0vg1Dp/vjZElzzXGxGbWvQZwsLGh1bjfjwZaFqdBzGXwsK9poDFNM9aGYiFFj0Wt hkwm6lgKkGNcoxBc6gg7+UDLf+lpy8yCs4PZBhAlSy8xwYx/rHEtNPEApqd+VM9r0R9w PEMmUa58xxaK4PseHs5SRSCZK1cg56aWK8k08EG5SZ3YeoDrUUxF1RRsJnHJmVWEGSYF mUIER9vcuYIy4QsKJTUFZbqDrefyul9pb+wQ215isRnLNTvbeuRX05yoZgVScgwKWfer kDZQKG8z4v6gQmW37tjww1075eQari/IUPI4fRMSTyFREuR6Wvjdy7mkDiolwWY0hKHW 2esg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780242349; x=1780847149; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=4HGHSV+ymwGZVts9xs57iGtb0PHiB6C1QG35wARFiWM=; b=H/aNfrCh9dpj2QNxZdiVOgIGHCb7E9Er6IBsoA+pcgVu+TpVcwF37iCoolrDqbrVqr Trjss/haFojjDya6b+MQagvdTi8qKoRGw54qrqLQWTvXz8KhV//kGz4wDJ1uLLlmg1md xT0Ug035ZnU8HhC/n8ToLGCvzCpg0NNZ0zq9SBUOhVkqrbeyQ7LN0cbyd7UO+BTpNNQL HoOr73cbpjHxoZrfzwZ+MljfW6POdidbk3++72hVM3cmGIzJlIhlTfvsnXOcPWaa/aa6 vuKnSzaYId+imnviPMHkqD1GNETdYE5K2DTATZKkiUDL4nHnADVutYjqAW2aAFsOb9LV naHA== X-Forwarded-Encrypted: i=1; AFNElJ+av9U8RGemfQSpWhmP01BCNXKWumeTlRi/aQVgOXkE3dxOIme/0Ak/85xTmOkhY5QR4d5Tmq0BK5Yllhs=@vger.kernel.org X-Gm-Message-State: AOJu0YxqdkE+/5Pepz8VdMuuNp5DEYRY+vDzLkarLWTFpGccJu0sZ6HA CccCWjeSIyPH4HK8bLFBIkdpur1KyM9+HctRfR8XuYObDlHPj+u7WCH3IEmJQH66tLJms9NDSCc IZA== X-Received: from edqm24.prod.google.com ([2002:aa7:c498:0:b0:68b:eff7:97f1]) (user=tabba job=prod-delivery.src-stubby-dispatcher) by 2002:a17:907:c10:b0:be2:6e41:ba8f with SMTP id a640c23a62f3a-beab5bebadfmr383941866b.44.1780242348882; Sun, 31 May 2026 08:45:48 -0700 (PDT) Date: Sun, 31 May 2026 16:45:48 +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.929.g9b7fa37559-goog Message-ID: <20260531154548.1505799-1-tabba@google.com> Subject: [PATCH] KVM: arm64: Flush HCR_EL2.VSE to deliver SErrors to pKVM guests From: tabba@google.com To: Marc Zyngier , Oliver Upton , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Quentin Perret Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" With pKVM enabled, the host injects a virtual SError by setting HCR_EL2.VSE on its vCPU copy, but flush_hyp_vcpu() only flows TWI/TWE into the hyp vCPU that runs, so VSE never reaches it and a deferred (masked) SError is never delivered. VSE is a host-owned injection control, not a trap-configuration bit, so restricting the host's trap-register values should not have dropped it. Flow it on entry; sync_hyp_vcpu() already copies hcr_el2 back, so delivery is reflected to the host. Fixes: b56680de9c648 ("KVM: arm64: Initialize trap register values in hyp i= n pKVM") Reported-by: Sashiko (local):gemini-3.1-pro Signed-off-by: Fuad Tabba Reviewed-by: Oliver Upton --- Not an urgent fix. I should stop running Sashiko... --- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/h= yp-main.c index 06db299c37a8..9e4a20df6409 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -129,9 +129,14 @@ static void flush_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_v= cpu) hyp_vcpu->vcpu.arch.ctxt =3D host_vcpu->arch.ctxt; =20 hyp_vcpu->vcpu.arch.mdcr_el2 =3D host_vcpu->arch.mdcr_el2; - hyp_vcpu->vcpu.arch.hcr_el2 &=3D ~(HCR_TWI | HCR_TWE); + /* + * HCR_EL2.VSE is host-owned (a pending virtual SError to inject), not a + * trap-control bit, so it must flow to the hyp vCPU alongside TWI/TWE + * for the vSError to be delivered. sync_hyp_vcpu() reflects it back. + */ + hyp_vcpu->vcpu.arch.hcr_el2 &=3D ~(HCR_TWI | HCR_TWE | HCR_VSE); hyp_vcpu->vcpu.arch.hcr_el2 |=3D READ_ONCE(host_vcpu->arch.hcr_el2) & - (HCR_TWI | HCR_TWE); + (HCR_TWI | HCR_TWE | HCR_VSE); =20 hyp_vcpu->vcpu.arch.iflags =3D host_vcpu->arch.iflags; =20 --=20 2.54.0.929.g9b7fa37559-goog