From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9368CC9830B for ; Wed, 23 Sep 2026 15:17:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XFLThVHVojpEVUSy57OzgxDT30uqvYagO8r4EUiTrpo=; b=fGY8iYKF+UJkbTnZaaz7eHSIC8 HhgyxTBCM5Z3MPF5XH1vCDqRlZ6QfH9Pm7O98U5CiWBGxWOFL76Gb/XbaM2KDw6S8+YfMlKo88qHj bsvi58HWw/qfL4jX6UdDBr/3LrB9flKAcmuvP2YIXrDQm4AbVdf1s6oubCsg2y4Ya3rRa/4FMsbDq bgDnc/vvTtsih/HMILK6QEJfKplPvDkVxAYt9GMTWNEdt1XCaIfl8tETXFBckmdIbUUpjvhaT9nsB kfTDIvSJKbv7caQswJLy8cgxPGxIu8qKELkmk1+EKo8zG/zbAaWPP2qhUMWZ9iLQYlyXL/mBgIRFe 7rXkhxHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x9Oix-00000008gU4-2Yy2; Wed, 23 Sep 2026 15:17:31 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x9Oiv-00000008gSe-1T6Q for linux-arm-kernel@lists.infradead.org; Wed, 23 Sep 2026 15:17:29 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 1D18641140; Wed, 23 Sep 2026 15:17:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74ADA1F00893; Wed, 23 Sep 2026 15:17:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790176649; bh=XFLThVHVojpEVUSy57OzgxDT30uqvYagO8r4EUiTrpo=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Nd1tzxbUupmp39i9v7NxLW1mFVXBMOX/eSLEcGX0ecyR0PHYJekwz5icqDiYzFqU0 LswEIO9iNNZHJZ+KPEzitCY96UvuJk0Rrj6GT/+xJrwN4uwxeVDXOrDuL+DGwHlQEq ePfaO+41RQcLA0tcUrvY3JbgTwmaPX2mfBtKPOGG1d4lfzcbVixX2V2e9P/HEvOQ5H 7ljAMM5HexD9vFN4kNufxBBF7u9TLaurFX2Qlmddfp7qWno04KyoIw1m8+OJQ9FEuE zZWwp8BA3zy31fIRlEKvppBNTQKQi+SGsYTDKZp2PCW1WC9tQ8nNpaXP/ola4k0B/m MIE3tVWDv9z1A== From: "Lorenzo Stoakes (ARM)" Date: Wed, 23 Sep 2026 16:15:51 +0100 Subject: [PATCH v4 08/14] KVM: arm64: Propagate EHWPOISON in kvm_s2_fault_pin_pfn() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260923-kvm-arm-prefault-v4-8-d4b0b4dfa8c3@kernel.org> References: <20260923-kvm-arm-prefault-v4-0-d4b0b4dfa8c3@kernel.org> In-Reply-To: <20260923-kvm-arm-prefault-v4-0-d4b0b4dfa8c3@kernel.org> To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , Paolo Bonzini , Jonathan Corbet , Mark Rutland , Fuad Tabba , Randy Dunlap , Christian Borntraeger , Janosch Frank , David Hildenbrand , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Sven Schnelle , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Shuah Khan , Shuah Khan 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 , Jack Thomson , Alexandru Elisei , Vincent Donnefort , "Aneesh Kumar K.V" , Sean Christopherson , Claudio Imbrenda , Leo Soares Passos , Wei-Lin Chang , linux-s390@vger.kernel.org, "Lorenzo Stoakes (ARM)" X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2077; i=ljs@kernel.org; h=from:subject:message-id; bh=ZOeS30gofdCLOtXFawVIsqjJmujH+ZzrHXswM13UJw8=; b=owGbwMvMwCV2fu7ZrsZH9SKMp9WSGLI2v9Vt2MfWm/N2xtr7N844/I0u0+y+6Rq6OMV299KqW u3w+cyvOkpZGMS4GGTFFFmefxHfHyQSNq/zgr8bzBxWJpAhDFycAjCRT/8Z/vAXbd4uur/4xMoL NlHK0tJ2xdIX5U4IbNt6P030Wc/9CRcY/rsvCQsMlf6Xd0/4qriZpHaEGaN0wzz50LyQz/u53KZ OZgUA X-Developer-Key: i=ljs@kernel.org; a=openpgp; fpr=E7F417BF5214569E89D04F46CF9DCD8A81E27F14 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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. Reviewed-by: Oliver Upton Reviewed-by: Fuad Tabba Signed-off-by: Lorenzo Stoakes (ARM) --- 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 cd4bc1d1bcdb..476a98cbe05d 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -2018,10 +2018,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; } @@ -2263,6 +2261,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