From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A4B74ADD9B; Tue, 9 Jun 2026 18:52:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781031128; cv=none; b=BdPDazc5eHeQp0JwrUcm7FqokP3AwoxyL3uKyrGN9v57PQtIOlI90Bd2NcXPGTm8BcTM/EG0SPPrK7IYYTDxt1mq7PV8KgV1OAhlISME34D7OMS99NxBbccmpncRy4LSYSpRUTd6iHp5wxGm/JZ2N+kfiu7JI9D/JtFQEVS7XUM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781031128; c=relaxed/simple; bh=rmM2h8GPiP6MoMI4fdbRJIGoup7QY5VeOykAZJSsYvA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WdWah/H0LewINUU52/fZNaI+pKW9QXEkfjVd/Ty1KKiiOppTFVgx2kGSTje8gtvdsSzgahC+DbjibiubJGW04nPyf0DHCF+tgLSMheiMpI93aOw7uzNdTBz2meICnqQ91+p2iznb9x9YbZK7PFYBdndhXP0JG+3FCfU9+0Q91Jg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mw9I5KID; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mw9I5KID" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 561971F0089F; Tue, 9 Jun 2026 18:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781031127; bh=SJVsdp5eXpnLCRpqkZbpl+r3WI0hB3m/FBZaFoIcMlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=mw9I5KIDucf+q+XSi0Wqr8ib7EXhR49pRvIJSCZCb8n6gPC1RrwBqRL3XfuLZ55Gs VZHQ0kK6dMQg1cnu3P/FIdO7Am1WTRxDnq8sFum/lon/v/zNZor4N4uOQeugPyr8dZ fp60mHs0/PWZTTwWrkdijWCFQVn3X0ZLohlk1BYEqhrds/1CHmHofDFiEEG/ByxRZv fhQdiGZ5Km1uP2Bgo7W8vqJqGmT1a33Tv4OKdovof32h/mWgiB9PYD3UJtUDrKzCI1 AMS8yBGJEK9/h8vA4qJMH3rQ3Vumd4KElS3oXr5eBsFW6RpTbhpxL+UJmPM+YBWJm0 xJYIb+qVPpe8g== From: Oliver Upton To: kvmarm@lists.linux.dev Cc: Marc Zyngier , Joey Gouly , Suzuki K Poulose , Zenghui Yu , Wei-Lin Chang , Oliver Upton , stable@vger.kernel.org Subject: [PATCH v2 2/5] KVM: arm64: nv: Inject SEA if kvm_translate_vncr() can't resolve PFN Date: Tue, 9 Jun 2026 11:52:01 -0700 Message-ID: <20260609185204.745929-6-oupton@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260609185204.745929-1-oupton@kernel.org> References: <20260609185204.745929-1-oupton@kernel.org> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit kvm_handle_vncr_abort() assumes that s1_walk_result conveys an abort when kvm_translate_vncr() returns -EFAULT. This is not always the case as it's possible to encounter 'late' failures on the output of S1 translation, e.g. a GFN outside of the memslots. Fix it by preparing an external abort before returning from kvm_translate_vncr(). Cc: stable@vger.kernel.org Fixes: 2a359e072596 ("KVM: arm64: nv: Handle mapping of VNCR_EL2 at EL2") Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_nested.h | 8 ++++++++ arch/arm64/kvm/at.c | 8 -------- arch/arm64/kvm/nested.c | 8 ++++++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/arch/arm64/include/asm/kvm_nested.h b/arch/arm64/include/asm/kvm_nested.h index dc2957662ff2..cbdaaa2a2903 100644 --- a/arch/arm64/include/asm/kvm_nested.h +++ b/arch/arm64/include/asm/kvm_nested.h @@ -388,6 +388,14 @@ struct s1_walk_result { bool failed; }; +static inline void fail_s1_walk(struct s1_walk_result *wr, u8 fst, bool s1ptw) +{ + wr->fst = fst; + wr->ptw = s1ptw; + wr->s2 = s1ptw; + wr->failed = true; +} + int __kvm_translate_va(struct kvm_vcpu *vcpu, struct s1_walk_info *wi, struct s1_walk_result *wr, u64 va); int __kvm_find_s1_desc_level(struct kvm_vcpu *vcpu, u64 va, u64 ipa, diff --git a/arch/arm64/kvm/at.c b/arch/arm64/kvm/at.c index 30e6fa8ac07c..8263c648207b 100644 --- a/arch/arm64/kvm/at.c +++ b/arch/arm64/kvm/at.c @@ -11,14 +11,6 @@ #include #include -static void fail_s1_walk(struct s1_walk_result *wr, u8 fst, bool s1ptw) -{ - wr->fst = fst; - wr->ptw = s1ptw; - wr->s2 = s1ptw; - wr->failed = true; -} - #define S1_MMU_DISABLED (-127) static int get_ia_size(struct s1_walk_info *wi) diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c index 84b3bd528e11..ebd7ccfeee99 100644 --- a/arch/arm64/kvm/nested.c +++ b/arch/arm64/kvm/nested.c @@ -1389,15 +1389,19 @@ static int kvm_translate_vncr(struct kvm_vcpu *vcpu, bool *is_gmem) gfn = vt->wr.pa >> PAGE_SHIFT; memslot = gfn_to_memslot(vcpu->kvm, gfn); - if (!memslot) + if (!memslot) { + fail_s1_walk(&vt->wr, ESR_ELx_FSC_EXTABT, false); return -EFAULT; + } *is_gmem = kvm_slot_has_gmem(memslot); if (!*is_gmem) { pfn = __kvm_faultin_pfn(memslot, gfn, write_fault ? FOLL_WRITE : 0, &writable, &page); - if (is_error_noslot_pfn(pfn)) + if (is_error_noslot_pfn(pfn)) { + fail_s1_walk(&vt->wr, ESR_ELx_FSC_EXTABT, false); return -EFAULT; + } } else { ret = kvm_gmem_get_pfn(vcpu->kvm, memslot, gfn, &pfn, &page, NULL); if (ret) { -- 2.47.3