From nobody Thu Sep 24 20:02:29 2026 Received: from mta1.migadu.com (out-250.mta1.migadu.com [95.215.58.250]) (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 19D7043785D for ; Mon, 21 Sep 2026 10:10:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.250 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789985440; cv=none; b=RrnbXgkwV6LDiCHa8OGoMHQ/2qS/zx9Cz2u9A+a6/ZKz3QGU8iany1lL05XDAK+Msay/S6bLWZ6OdiEOmtFWHoJFoBe3VH9VfvynNnxX9/bQAsrTdNamkNecGzJlMEmHEnLi5by3nHBxlU/Feflc1+AAv7hUM2mcRwlVTIB+uf0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789985440; c=relaxed/simple; bh=0wCiBy6TA7ljCdnc/O5BU8FZQMg+0QDVGtb0Tw4ehTY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GxY+GRKDdmRYGxuDZeoev2zOvXsaJLfrL0ubBT/7tTsES0/0RnVF9hx8aCo9uDIR/SCvcH1VCw1H5ZH6AV8QrUZHKViWqz/j0+UXGt35W6ti1HO40ipzssGuiJCYT20sjaX749CvI0bGxKbQKFOTdlNUegZQx8BM0DCxEzEW5k4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=krvkOpOO; arc=none smtp.client-ip=95.215.58.250 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="krvkOpOO" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=0wCiBy6TA7ljCdnc/O5BU8FZQMg+0QDVGtb0Tw4ehTY=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1789985436; v=1; x=1790590236; b=krvkOpOOg5Dih9DSA+TzV4al2eT4hzotQwWf6/3EEffKy0lmE8Ynlm+lxRZbS3UhwafT+86Y II57njlEek+KraNmC6EULSM1MrXzXUAQ9859RZKzB32I7VGAe32jDI+e+pOTiBn5KaJoaSHex48 8J5MAXRtFhDMZaIzIEgmCwcs= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id ded491277fcd8d98; Mon, 21 Sep 2026 10:10:36 +0000 X-Mizu-Trace-ID: ded491277fcd8d98 X-Migadu-Flow: FLOW_OUT From: Fuad Tabba To: Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , Vincent Donnefort , Quentin Perret , Sebastian Ene , Hyunwoo Kim , kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan , Fuad Tabba Subject: [PATCH v2 1/2] KVM: arm64: Sync HCR_EL2.VSE back to the host vCPU under pKVM Date: Mon, 21 Sep 2026 11:10:29 +0100 Message-Id: <20260921101030.1231605-2-fuad.tabba@linux.dev> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260921101030.1231605-1-fuad.tabba@linux.dev> References: <20260921101030.1231605-1-fuad.tabba@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" flush_hyp_vcpu() copies HCR_EL2.VSE from the host vCPU into the hyp vCPU on every entry, and nothing copies it back. Once the guest takes the vSError the hyp vCPU's copy clears with the hardware bit while the host's stays set, so the next entry pends the same SError again, KVM_GET_VCPU_EVENTS keeps reporting it, and kvm_arch_vcpu_runnable() never lets the vCPU block in WFI. Reflect VSE back on every exit, which the flush-side comment already promises. Fixes: 734dc8c01c838 ("KVM: arm64: Implement lazy vCPU state sync for non-p= rotected guests") Signed-off-by: Fuad Tabba --- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/h= yp-main.c index 9a3b92e626adb..b6bfe502bcd04 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -276,6 +276,10 @@ static void sync_hyp_vcpu(struct pkvm_hyp_vcpu *hyp_vc= pu) =20 host_vcpu->arch.iflags =3D hyp_vcpu->vcpu.arch.iflags; =20 + /* Cleared by hardware once the guest takes the vSError. */ + host_vcpu->arch.hcr_el2 &=3D ~HCR_VSE; + host_vcpu->arch.hcr_el2 |=3D hyp_vcpu->vcpu.arch.hcr_el2 & HCR_VSE; + sync_hyp_vgic_state(hyp_vcpu); } =20 --=20 2.39.5 From nobody Thu Sep 24 20:02:29 2026 Received: from mta1.migadu.com (out-4.mta1.migadu.com [95.215.58.4]) (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 0384143785D for ; Mon, 21 Sep 2026 10:10:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789985445; cv=none; b=T3WxPH2HkJiyhBUDfDPqlwJGcxuwvwG/B7priqg7PL2AFoZaSnbLcKASBgTyzvgEdn6DSHu5gauL4IyGB3fzs/ZN0TAOKJpuO57oFnQrSZRoelUiDU9rifXje52sJWSJyvZr3tykLevXhxjfojp/TD7cl4TaJoLbNestPAsO0+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789985445; c=relaxed/simple; bh=0WEUwWA13h6lSIRRHugW7N81xLfWs7SnLHtINewqeBo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Mp9cNkPI6NhQtp6osUZ1KxCu0p5zIFoW8X96IjNqO29bfUJOOI6IutAC9qPIe75Bp3pymSBAXpXaWCmDzTqsBKiCpt6JD0HdRAnN6y1uo3y5bGpeVIkTTIGwhC7t6M9/IhjQsirZeNrWB5MviunNBNBqu6gk2A19ecZwV+q7Mwg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=hdhewLO8; arc=none smtp.client-ip=95.215.58.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="hdhewLO8" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=0WEUwWA13h6lSIRRHugW7N81xLfWs7SnLHtINewqeBo=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1789985441; v=1; x=1790590241; b=hdhewLO8IRIHObIEz8+0C9kBmser7+1cdmUfPOwOB3HAz7dt73431HNwews1PbNLVfusSj/B xJIlGH5fuZFXHpzzpNlAoBNQkkJL8cHKbcHXy0rZlTvnOn4f9tQAu1ILq5UAwn6aCb01ipY+GRW Ip5FJF01O2pwmFCFQmnhNlhc= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id cf336d2bb085442c; Mon, 21 Sep 2026 10:10:41 +0000 X-Mizu-Trace-ID: cf336d2bb085442c X-Migadu-Flow: FLOW_OUT From: Fuad Tabba To: Marc Zyngier , Oliver Upton , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , Vincent Donnefort , Quentin Perret , Sebastian Ene , Hyunwoo Kim , kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan , Fuad Tabba Subject: [PATCH v2 2/2] KVM: arm64: selftests: Check SError is not pending after delivery Date: Mon, 21 Sep 2026 11:10:30 +0100 Message-Id: <20260921101030.1231605-3-fuad.tabba@linux.dev> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260921101030.1231605-1-fuad.tabba@linux.dev> References: <20260921101030.1231605-1-fuad.tabba@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" test_serror() never looks at the vCPU after the SError is delivered, so a stale pending SError goes unnoticed. Read the vCPU events back and check the SError is no longer pending. Signed-off-by: Fuad Tabba --- tools/testing/selftests/kvm/arm64/external_aborts.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/kvm/arm64/external_aborts.c b/tools/te= sting/selftests/kvm/arm64/external_aborts.c index d8fe17a6cc592..b276a4998a92c 100644 --- a/tools/testing/selftests/kvm/arm64/external_aborts.c +++ b/tools/testing/selftests/kvm/arm64/external_aborts.c @@ -239,6 +239,7 @@ static void test_serror_guest(void) =20 static void test_serror(void) { + struct kvm_vcpu_events events; struct kvm_vcpu *vcpu; struct kvm_vm *vm =3D vm_create_with_dabt_handler(&vcpu, test_serror_gues= t, unexpected_dabt_handler); @@ -247,6 +248,11 @@ static void test_serror(void) =20 vcpu_inject_serror(vcpu); vcpu_run_expect_done(vcpu); + + vcpu_events_get(vcpu, &events); + TEST_ASSERT(!events.exception.serror_pending, + "SError still pending after the guest took it"); + kvm_vm_free(vm); } =20 --=20 2.39.5