> Date: Sat, 10 Sep 2022 14:18:02 +0200
> From: Martin Pieuchot <m...@openbsd.org>
> 
> Diff below fixes a bug exposed when swapping on arm64.  When an anon is
> released make sure the all the pmap references to the related page are
> removed.

I'm a little bit puzzled by this.  So these pages are still mapped
even though there are no references to the anon anymore?

> We could move the pmap_page_protect(pg, PROT_NONE) inside uvm_pagefree()
> to avoid future issue but that's for a later refactoring.

I don't think that makes sense.  In cases where pages are explicitly
mapped (instead of faulted in) we call pmap_remove() before we end up
calling uvm_pagefree().  Calling pmap_page_protect() in that case
doesn't make sense.

> With this diff I can no longer reproduce the SIGBUS issue on the
> rockpro64 and swapping is stable as long as I/O from sdmmc(4) work.
> 
> This should be good enough to commit the diff that got reverted, but I'll
> wait to be sure there's no regression.
> 
> ok?
> 
> Index: uvm/uvm_anon.c
> ===================================================================
> RCS file: /cvs/src/sys/uvm/uvm_anon.c,v
> retrieving revision 1.54
> diff -u -p -r1.54 uvm_anon.c
> --- uvm/uvm_anon.c    26 Mar 2021 13:40:05 -0000      1.54
> +++ uvm/uvm_anon.c    10 Sep 2022 12:10:34 -0000
> @@ -255,6 +255,7 @@ uvm_anon_release(struct vm_anon *anon)
>       KASSERT(anon->an_ref == 0);
>  
>       uvm_lock_pageq();
> +     pmap_page_protect(pg, PROT_NONE);
>       uvm_pagefree(pg);
>       uvm_unlock_pageq();
>       KASSERT(anon->an_page == NULL);
> Index: uvm/uvm_fault.c
> ===================================================================
> RCS file: /cvs/src/sys/uvm/uvm_fault.c,v
> retrieving revision 1.132
> diff -u -p -r1.132 uvm_fault.c
> --- uvm/uvm_fault.c   31 Aug 2022 01:27:04 -0000      1.132
> +++ uvm/uvm_fault.c   10 Sep 2022 12:10:34 -0000
> @@ -396,7 +396,6 @@ uvmfault_anonget(struct uvm_faultinfo *u
>                        * anon and try again.
>                        */
>                       if (pg->pg_flags & PG_RELEASED) {
> -                             pmap_page_protect(pg, PROT_NONE);
>                               KASSERT(anon->an_ref == 0);
>                               /*
>                                * Released while we had unlocked amap.
> 
> 

Reply via email to