From: David Hildenbrand <david@redhat.com>
To: Ralph Campbell <rcampbell@nvidia.com>,
Jerome Glisse <jglisse@redhat.com>,
John Hubbard <jhubbard@nvidia.com>,
Christoph Hellwig <hch@lst.de>,
Jason Gunthorpe <jgg@mellanox.com>
Cc: linux-rdma@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/3] mm/hmm: allow snapshot of the special zero page
Date: Thu, 24 Oct 2019 11:27:59 +0200 [thread overview]
Message-ID: <8e051e7f-fb41-4026-cc55-45eee85f8829@redhat.com> (raw)
In-Reply-To: <20191023195515.13168-3-rcampbell@nvidia.com>
On 23.10.19 21:55, Ralph Campbell wrote:
> If a device driver like nouveau tries to use hmm_range_fault() to access
> the special shared zero page in system memory, hmm_range_fault() will
> return -EFAULT and kill the process.
> Allow hmm_range_fault() to return success (0) when the CPU pagetable
> entry points to the special shared zero page.
> page_to_pfn() and pfn_to_page() are defined on the zero page so just
> handle it like any other page.
>
> Signed-off-by: Ralph Campbell <rcampbell@nvidia.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: "Jérôme Glisse" <jglisse@redhat.com>
> Cc: Jason Gunthorpe <jgg@mellanox.com>
> ---
> mm/hmm.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/mm/hmm.c b/mm/hmm.c
> index acf7a664b38c..8c96c9ddcae5 100644
> --- a/mm/hmm.c
> +++ b/mm/hmm.c
> @@ -529,8 +529,14 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr,
> if (unlikely(!hmm_vma_walk->pgmap))
> return -EBUSY;
> } else if (IS_ENABLED(CONFIG_ARCH_HAS_PTE_SPECIAL) && pte_special(pte)) {
> - *pfn = range->values[HMM_PFN_SPECIAL];
> - return -EFAULT;
> + if (!is_zero_pfn(pte_pfn(pte))) {
> + *pfn = range->values[HMM_PFN_SPECIAL];
> + return -EFAULT;
> + }
> + /*
> + * Since each architecture defines a struct page for the zero
> + * page, just fall through and treat it like a normal page.
> + */
> }
>
> *pfn = hmm_device_entry_from_pfn(range, pte_pfn(pte)) | cpu_flags;
>
Acked-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2019-10-24 9:28 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-23 19:55 [PATCH v3 0/3] HMM tests and minor fixes Ralph Campbell
2019-10-23 19:55 ` [PATCH v3 1/3] mm/hmm: make full use of walk_page_range() Ralph Campbell
2019-10-29 17:40 ` Jason Gunthorpe
2019-10-23 19:55 ` [PATCH v3 2/3] mm/hmm: allow snapshot of the special zero page Ralph Campbell
2019-10-23 20:27 ` Jerome Glisse
2019-10-24 9:27 ` David Hildenbrand [this message]
2019-10-29 17:27 ` Jason Gunthorpe
2019-10-23 19:55 ` [PATCH v3 3/3] mm/hmm/test: add self tests for HMM Ralph Campbell
2019-10-23 20:28 ` Jerome Glisse
2019-10-23 21:55 ` Ralph Campbell
2019-10-29 17:58 ` Jason Gunthorpe
2019-10-29 21:16 ` Ralph Campbell
2019-10-29 23:12 ` Jason Gunthorpe
2019-10-31 0:14 ` Ralph Campbell
2019-10-31 12:42 ` Jason Gunthorpe
2019-10-31 17:28 ` Ralph Campbell
2019-10-31 17:34 ` Jason Gunthorpe
2019-10-31 17:48 ` Ralph Campbell
2019-10-30 18:34 ` Qian Cai
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=8e051e7f-fb41-4026-cc55-45eee85f8829@redhat.com \
--to=david@redhat.com \
--cc=hch@lst.de \
--cc=jgg@mellanox.com \
--cc=jglisse@redhat.com \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rdma@vger.kernel.org \
--cc=rcampbell@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;
as well as URLs for NNTP newsgroup(s).