From: <ankita@nvidia.com>
To: <ankita@nvidia.com>, <jgg@nvidia.com>,
<alex.williamson@redhat.com>, <akpm@linux-foundation.org>,
<tony.luck@intel.com>, <bp@alien8.de>, <naoya.horiguchi@nec.com>,
<linmiaohe@huawei.com>
Cc: <aniketa@nvidia.com>, <cjia@nvidia.com>, <kwankhede@nvidia.com>,
<targupta@nvidia.com>, <vsethi@nvidia.com>, <acurrid@nvidia.com>,
<anuaggarwal@nvidia.com>, <linux-kernel@vger.kernel.org>,
<linux-mm@kvack.org>, <linux-edac@vger.kernel.org>,
<kvm@vger.kernel.org>
Subject: [PATCH v1 2/4] mm: Add poison error check in fixup_user_fault() for mapped pfn
Date: Wed, 20 Sep 2023 19:32:08 +0530 [thread overview]
Message-ID: <20230920140210.12663-3-ankita@nvidia.com> (raw)
In-Reply-To: <20230920140210.12663-1-ankita@nvidia.com>
From: Ankit Agrawal <ankita@nvidia.com>
The fixup_user_fault() currently does not expect a VM_FAULT_HWPOISON
and hence does not check for it while calling vm_fault_to_errno(). Since
we now have a new code path which can trigger such case, change
fixup_user_fault to look for VM_FAULT_HWPOISON.
Also make hva_to_pfn_remapped check for -EHWPOISON and communicate the
poison fault up to the user_mem_abort().
Signed-off-by: Ankit Agrawal <ankita@nvidia.com>
---
mm/gup.c | 2 +-
virt/kvm/kvm_main.c | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/mm/gup.c b/mm/gup.c
index 2f8a2d89fde1..fe469326dbe6 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1414,7 +1414,7 @@ int fixup_user_fault(struct mm_struct *mm,
}
if (ret & VM_FAULT_ERROR) {
- int err = vm_fault_to_errno(ret, 0);
+ int err = vm_fault_to_errno(ret, FOLL_HWPOISON);
if (err)
return err;
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 486800a7024b..2ff067f21a7c 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -2731,6 +2731,12 @@ kvm_pfn_t hva_to_pfn(unsigned long addr, bool atomic, bool interruptible,
r = hva_to_pfn_remapped(vma, addr, write_fault, writable, &pfn);
if (r == -EAGAIN)
goto retry;
+
+ if (r == -EHWPOISON) {
+ pfn = KVM_PFN_ERR_HWPOISON;
+ goto exit;
+ }
+
if (r < 0)
pfn = KVM_PFN_ERR_FAULT;
} else {
--
2.17.1
next prev parent reply other threads:[~2023-09-20 14:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 14:02 [PATCH v1 0/4] mm: Implement ECC handling for pfn with no struct page ankita
2023-09-20 14:02 ` [PATCH v1 1/4] mm: handle poisoning of pfn without struct pages ankita
2023-09-23 3:20 ` Miaohe Lin
2023-09-25 12:36 ` Jason Gunthorpe
2023-09-26 7:23 ` Naoya Horiguchi
2023-09-20 14:02 ` ankita [this message]
2023-09-20 14:02 ` [PATCH v1 3/4] mm: Change ghes code to allow poison of non-struct pfn ankita
2023-09-20 14:02 ` [PATCH v1 4/4] vfio/nvgpu: register device memory for poison handling ankita
2023-09-26 5:36 ` kernel test robot
2023-09-26 7:38 ` Naoya Horiguchi
2023-09-28 19:45 ` Alex Williamson
2023-09-20 16:02 ` [PATCH v1 0/4] mm: Implement ECC handling for pfn with no struct page Andrew Morton
2023-09-20 16:04 ` Jason Gunthorpe
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=20230920140210.12663-3-ankita@nvidia.com \
--to=ankita@nvidia.com \
--cc=acurrid@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=alex.williamson@redhat.com \
--cc=aniketa@nvidia.com \
--cc=anuaggarwal@nvidia.com \
--cc=bp@alien8.de \
--cc=cjia@nvidia.com \
--cc=jgg@nvidia.com \
--cc=kvm@vger.kernel.org \
--cc=kwankhede@nvidia.com \
--cc=linmiaohe@huawei.com \
--cc=linux-edac@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=naoya.horiguchi@nec.com \
--cc=targupta@nvidia.com \
--cc=tony.luck@intel.com \
--cc=vsethi@nvidia.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