mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: Catalin Marinas <catalin.marinas@arm.com>,
	 Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>,
	 Oliver Upton <oupton@kernel.org>,
	Joey Gouly <joey.gouly@arm.com>,
	 Steffen Eiden <seiden@linux.ibm.com>,
	 Suzuki K Poulose <suzuki.poulose@arm.com>,
	 Zenghui Yu <yuzenghui@huawei.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	 Jonathan Corbet <corbet@lwn.net>,
	Mark Rutland <mark.rutland@arm.com>,
	 Fuad Tabba <fuad.tabba@linux.dev>,
	Randy Dunlap <rdunlap@infradead.org>,
	 Fuad Tabba <fuad.tabba@linux.dev>
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,  kvmarm@lists.linux.dev,
	kvm@vger.kernel.org, linux-doc@vger.kernel.org,
	 linux-kselftest@vger.kernel.org,
	Jack Thomson <jackabt@amazon.com>,
	 Jack Thomson <jackabt.amazon@gmail.com>,
	 Alexandru Elisei <alexandru.elisei@arm.com>,
	 Vincent Donnefort <vdonnefort@google.com>,
	 "Aneesh Kumar K.V" <aneesh.kumar@kernel.org>,
	 Sean Christopherson <seanjc@google.com>,
	 Claudio Imbrenda <imbrenda@linux.ibm.com>,
	 Leo Soares Passos <Leo.Bras@arm.com>,
	Wei-Lin Chang <weilin.chang@arm.com>,
	 "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Subject: [PATCH v3 08/14] KVM: arm64: Propagate EHWPOISON in kvm_s2_fault_pin_pfn()
Date: Tue, 22 Sep 2026 15:18:02 +0100	[thread overview]
Message-ID: <20260922-kvm-arm-prefault-v3-8-787bd3bc7e3f@kernel.org> (raw)
In-Reply-To: <20260922-kvm-arm-prefault-v3-0-787bd3bc7e3f@kernel.org>

Currently kvm_s2_fault_pin_pfn() handles a poisoned page directly by
sending a SIGBUS signal itself.

This is an odd place to do it, the caller should decide what to do with
errors, so move the handling to the sole caller, user_mem_abort().

This lays the foundation for stage 2 pre-faulting which, arising from a
synthetic fault, should not send a signal.

In order to do so, check to see if user_mem_abort()'s caller has set result
- i.e. whether it wants to be informed about the outcome of the fault
handling.

If it does, then it is implied that it should handle the -EHWPOISON error
itself. This is the case for pre-faulting.

Otherwise this is real hardware, so send the signal.

No functional change intended.

Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
 arch/arm64/kvm/mmu.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
index 221ea069f9bb..2576b967d20e 100644
--- a/arch/arm64/kvm/mmu.c
+++ b/arch/arm64/kvm/mmu.c
@@ -2016,10 +2016,8 @@ static int kvm_s2_fault_pin_pfn(const struct kvm_s2_fault_desc *s2fd,
 				      kvm_s2_fault_is_write(s2fd) ? FOLL_WRITE : 0,
 				      &s2vi->map_writable, &s2vi->page);
 	if (unlikely(is_error_noslot_pfn(s2vi->pfn))) {
-		if (s2vi->pfn == KVM_PFN_ERR_HWPOISON) {
-			kvm_send_hwpoison_signal(s2fd->hva, __ffs(s2vi->vma_pagesize));
-			return 0;
-		}
+		if (s2vi->pfn == KVM_PFN_ERR_HWPOISON)
+			return -EHWPOISON;
 		return -EFAULT;
 	}
 
@@ -2261,6 +2259,13 @@ static int user_mem_abort(const struct kvm_s2_fault_desc *s2fd,
 	 * get block mapping for device MMIO region.
 	 */
 	ret = kvm_s2_fault_pin_pfn(s2fd, &s2vi);
+	if (ret == -EHWPOISON) {
+		/* If result is specified, let the caller handle this. */
+		if (result)
+			return -EHWPOISON;
+		kvm_send_hwpoison_signal(s2fd->hva, __ffs(s2vi.vma_pagesize));
+		return 0;
+	}
 	if (ret != 1)
 		return ret;
 

-- 
2.55.0


  parent reply	other threads:[~2026-09-22 14:19 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 14:17 [PATCH v3 00/14] KVM: arm64: Add KVM_PRE_FAULT_MEMORY support Lorenzo Stoakes (ARM)
2026-09-22 14:17 ` [PATCH v3 01/14] KVM: Allow architectures to disallow pre-fault Lorenzo Stoakes (ARM)
2026-09-22 16:49   ` Oliver Upton
2026-09-22 17:23     ` Sean Christopherson
2026-09-22 17:30       ` Lorenzo Stoakes (ARM)
2026-09-22 17:36         ` Sean Christopherson
2026-09-22 18:01           ` Lorenzo Stoakes (ARM)
2026-09-22 18:40             ` Sean Christopherson
2026-09-22 18:52               ` Lorenzo Stoakes (ARM)
2026-09-22 18:07           ` Oliver Upton
2026-09-22 18:35             ` Lorenzo Stoakes (ARM)
2026-09-22 18:46               ` Sean Christopherson
2026-09-22 18:54                 ` Lorenzo Stoakes (ARM)
2026-09-23 10:54             ` Fuad Tabba
2026-09-23 13:26               ` Lorenzo Stoakes (ARM)
2026-09-22 17:31     ` Lorenzo Stoakes (ARM)
2026-09-22 14:17 ` [PATCH v3 02/14] arm64: Add ESR fault helpers Lorenzo Stoakes (ARM)
2026-09-22 17:00   ` Oliver Upton
2026-09-22 17:45     ` Lorenzo Stoakes (ARM)
2026-09-22 18:13       ` Oliver Upton
2026-09-22 14:17 ` [PATCH v3 03/14] KVM: arm64: Use ESR helpers in guest abort handling Lorenzo Stoakes (ARM)
2026-09-22 14:17 ` [PATCH v3 04/14] KVM: arm64: Propagate and use esr in s2fd when handling guest aborts Lorenzo Stoakes (ARM)
2026-09-22 14:17 ` [PATCH v3 05/14] KVM: arm64: Propagate and use mmu " Lorenzo Stoakes (ARM)
2026-09-22 14:18 ` [PATCH v3 06/14] KVM: arm64: Propagate and use kvm_s2_fault_result on S2 fault Lorenzo Stoakes (ARM)
2026-09-22 14:18 ` [PATCH v3 07/14] KVM: arm64: Size the stage-2 memcache from the fault MMU Lorenzo Stoakes (ARM)
2026-09-22 14:18 ` Lorenzo Stoakes (ARM) [this message]
2026-09-23 11:05   ` [PATCH v3 08/14] KVM: arm64: Propagate EHWPOISON in kvm_s2_fault_pin_pfn() Fuad Tabba
2026-09-22 14:18 ` [PATCH v3 09/14] KVM: arm64: Pass walk flags to kvm_pgtable_get_leaf() Lorenzo Stoakes (ARM)
2026-09-23 11:07   ` Fuad Tabba
2026-09-22 14:18 ` [PATCH v3 10/14] KVM: arm64: Implement KVM_PRE_FAULT_MEMORY Lorenzo Stoakes (ARM)
2026-09-23 11:18   ` Fuad Tabba
2026-09-23 13:28     ` Lorenzo Stoakes (ARM)
2026-09-23 13:32       ` Lorenzo Stoakes (ARM)
2026-09-23 13:33         ` Lorenzo Stoakes (ARM)
2026-09-22 14:18 ` [PATCH v3 11/14] Documentation: KVM: document arm64 KVM_PRE_FAULT_MEMORY Lorenzo Stoakes (ARM)
2026-09-22 14:18 ` [PATCH v3 12/14] KVM: selftests: Enable pre_fault_memory_test for arm64 Lorenzo Stoakes (ARM)
2026-09-22 14:18 ` [PATCH v3 13/14] KVM: selftests: Add option for different backing in pre-fault tests Lorenzo Stoakes (ARM)
2026-09-22 14:18 ` [PATCH v3 14/14] KVM: selftests: Add nested pre-fault test for arm64 Lorenzo Stoakes (ARM)
2026-09-22 20:42 ` [PATCH v3 00/14] KVM: arm64: Add KVM_PRE_FAULT_MEMORY support Oliver Upton
2026-09-23 10:03 ` Fuad Tabba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260922-kvm-arm-prefault-v3-8-787bd3bc7e3f@kernel.org \
    --to=ljs@kernel.org \
    --cc=Leo.Bras@arm.com \
    --cc=alexandru.elisei@arm.com \
    --cc=aneesh.kumar@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=corbet@lwn.net \
    --cc=fuad.tabba@linux.dev \
    --cc=imbrenda@linux.ibm.com \
    --cc=jackabt.amazon@gmail.com \
    --cc=jackabt@amazon.com \
    --cc=joey.gouly@arm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=oupton@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rdunlap@infradead.org \
    --cc=seanjc@google.com \
    --cc=seiden@linux.ibm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=vdonnefort@google.com \
    --cc=weilin.chang@arm.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®