diff mbox series

[RFC,v8,18/56] x86/fault: fix handle_split_page_fault() to work with memfd backed pages

Message ID 20230220183847.59159-19-michael.roth@amd.com (mailing list archive)
State Not Applicable
Delegated to: Herbert Xu
Headers show
Series Add AMD Secure Nested Paging (SEV-SNP) Hypervisor Support | expand

Commit Message

Michael Roth Feb. 20, 2023, 6:38 p.m. UTC
From: Hugh Dickins <hughd@google.com>

When the address is backed by a memfd, the code to split the page does
nothing more than remove the PMD from the page tables. So immediately
install a PTE to ensure that any other pages in that 2MB region are
brought back as in 4K pages.

Signed-off-by: Hugh Dickins <hughd@google.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
Signed-off-by: Michael Roth <michael.roth@amd.com>
---
 mm/memory.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Hugh Dickins Feb. 20, 2023, 7:57 p.m. UTC | #1
On Mon, 20 Feb 2023, Michael Roth wrote:

> From: Hugh Dickins <hughd@google.com>

No.

> 
> When the address is backed by a memfd, the code to split the page does
> nothing more than remove the PMD from the page tables. So immediately
> install a PTE to ensure that any other pages in that 2MB region are
> brought back as in 4K pages.
> 
> Signed-off-by: Hugh Dickins <hughd@google.com>

No.  Suggested-by would be okay.

> Cc: Hugh Dickins <hughd@google.com>

Thanks.  I'm really sorry to be such a jobsworth,
and have nothing more constructive to say than I did before in
https://lore.kernel.org/linux-mm/7f2228c4-1586-2934-7b92-1a9d23b6046@google.com/
(please re-read), but adding a Signed-off-by where none was given is wrong;
and I'm not ever going to comprehend enough of the context to give it.

Best of luck for the series,
Hugh

> Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
> Signed-off-by: Michael Roth <michael.roth@amd.com>
> ---
>  mm/memory.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/mm/memory.c b/mm/memory.c
> index e68da7e403c6..33c9020ba1f8 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -4999,6 +4999,11 @@ static vm_fault_t handle_pte_fault(struct vm_fault *vmf)
>  static int handle_split_page_fault(struct vm_fault *vmf)
>  {
>  	__split_huge_pmd(vmf->vma, vmf->pmd, vmf->address, false, NULL);
> +	/*
> +	 * Install a PTE immediately to ensure that any other pages in
> +	 * this 2MB region are brought back in as 4K pages.
> +	 */
> +	__pte_alloc(vmf->vma->vm_mm, vmf->pmd);
>  	return 0;
>  }
>  
> -- 
> 2.25.1
Michael Roth Feb. 20, 2023, 8:31 p.m. UTC | #2
On Mon, Feb 20, 2023 at 11:57:59AM -0800, Hugh Dickins wrote:
> On Mon, 20 Feb 2023, Michael Roth wrote:
> 
> > From: Hugh Dickins <hughd@google.com>
> 
> No.
> 
> > 
> > When the address is backed by a memfd, the code to split the page does
> > nothing more than remove the PMD from the page tables. So immediately
> > install a PTE to ensure that any other pages in that 2MB region are
> > brought back as in 4K pages.
> > 
> > Signed-off-by: Hugh Dickins <hughd@google.com>
> 
> No.  Suggested-by would be okay.
> 
> > Cc: Hugh Dickins <hughd@google.com>
> 
> Thanks.  I'm really sorry to be such a jobsworth,
> and have nothing more constructive to say than I did before in
> https://lore.kernel.org/linux-mm/7f2228c4-1586-2934-7b92-1a9d23b6046@google.com/
> (please re-read), but adding a Signed-off-by where none was given is wrong;
> and I'm not ever going to comprehend enough of the context to give it.

Hi Hugh,

Sorry for the mix-up, I'd intended to remove this patch before submitting. I'll
make sure to remove it from future postings.

> 
> Best of luck for the series,

Thank you!

-Mike

> Hugh
> 
> > Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
> > Signed-off-by: Michael Roth <michael.roth@amd.com>
> > ---
> >  mm/memory.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/mm/memory.c b/mm/memory.c
> > index e68da7e403c6..33c9020ba1f8 100644
> > --- a/mm/memory.c
> > +++ b/mm/memory.c
> > @@ -4999,6 +4999,11 @@ static vm_fault_t handle_pte_fault(struct vm_fault *vmf)
> >  static int handle_split_page_fault(struct vm_fault *vmf)
> >  {
> >  	__split_huge_pmd(vmf->vma, vmf->pmd, vmf->address, false, NULL);
> > +	/*
> > +	 * Install a PTE immediately to ensure that any other pages in
> > +	 * this 2MB region are brought back in as 4K pages.
> > +	 */
> > +	__pte_alloc(vmf->vma->vm_mm, vmf->pmd);
> >  	return 0;
> >  }
> >  
> > -- 
> > 2.25.1
diff mbox series

Patch

diff --git a/mm/memory.c b/mm/memory.c
index e68da7e403c6..33c9020ba1f8 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4999,6 +4999,11 @@  static vm_fault_t handle_pte_fault(struct vm_fault *vmf)
 static int handle_split_page_fault(struct vm_fault *vmf)
 {
 	__split_huge_pmd(vmf->vma, vmf->pmd, vmf->address, false, NULL);
+	/*
+	 * Install a PTE immediately to ensure that any other pages in
+	 * this 2MB region are brought back in as 4K pages.
+	 */
+	__pte_alloc(vmf->vma->vm_mm, vmf->pmd);
 	return 0;
 }