mbox series

[v1,0/2] mm/hugetlb: uffd-wp fixes for hugetlb_change_protection()

Message ID 20221222205511.675832-1-david@redhat.com (mailing list archive)
Headers show
Series mm/hugetlb: uffd-wp fixes for hugetlb_change_protection() | expand

Message

David Hildenbrand Dec. 22, 2022, 8:55 p.m. UTC
Playing with virtio-mem and background snapshots (using uffd-wp) on
hugetlb in QEMU, I managed to trigger a VM_BUG_ON(). Looking into the
details, hugetlb_change_protection() seems to not handle uffd-wp correctly
in all cases.

Patch #1 fixes my test case. I don't have reproducers for patch #2, as
it requires running into migration entries.

I did not yet check in detail yet if !hugetlb code requires similar care.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Miaohe Lin <linmiaohe@huawei.com>

David Hildenbrand (2):
  mm/hugetlb: fix PTE marker handling in hugetlb_change_protection()
  mm/hugetlb: fix uffd-wp handling for migration entries in
    hugetlb_change_protection()

 mm/hugetlb.c | 38 ++++++++++++++++----------------------
 1 file changed, 16 insertions(+), 22 deletions(-)

Comments

Peter Xu Dec. 22, 2022, 9:17 p.m. UTC | #1
On Thu, Dec 22, 2022 at 09:55:09PM +0100, David Hildenbrand wrote:
> Playing with virtio-mem and background snapshots (using uffd-wp) on
> hugetlb in QEMU, I managed to trigger a VM_BUG_ON(). Looking into the
> details, hugetlb_change_protection() seems to not handle uffd-wp correctly
> in all cases.
> 
> Patch #1 fixes my test case. I don't have reproducers for patch #2, as
> it requires running into migration entries.
> 
> I did not yet check in detail yet if !hugetlb code requires similar care.
> 
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Mike Kravetz <mike.kravetz@oracle.com>
> Cc: Peter Xu <peterx@redhat.com>
> Cc: Muchun Song <muchun.song@linux.dev>
> Cc: Miaohe Lin <linmiaohe@huawei.com>
> 
> David Hildenbrand (2):
>   mm/hugetlb: fix PTE marker handling in hugetlb_change_protection()
>   mm/hugetlb: fix uffd-wp handling for migration entries in
>     hugetlb_change_protection()

Reviewed-by: Peter Xu <peterx@redhat.com>

Thanks, David.
Peter Xu Dec. 22, 2022, 9:28 p.m. UTC | #2
On Thu, Dec 22, 2022 at 04:17:22PM -0500, Peter Xu wrote:
> On Thu, Dec 22, 2022 at 09:55:09PM +0100, David Hildenbrand wrote:
> > Playing with virtio-mem and background snapshots (using uffd-wp) on
> > hugetlb in QEMU, I managed to trigger a VM_BUG_ON(). Looking into the
> > details, hugetlb_change_protection() seems to not handle uffd-wp correctly
> > in all cases.
> > 
> > Patch #1 fixes my test case. I don't have reproducers for patch #2, as
> > it requires running into migration entries.
> > 
> > I did not yet check in detail yet if !hugetlb code requires similar care.

Ah I should have left a message here but I forgot - afaict shmem is all fine.

> > 
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: Mike Kravetz <mike.kravetz@oracle.com>
> > Cc: Peter Xu <peterx@redhat.com>
> > Cc: Muchun Song <muchun.song@linux.dev>
> > Cc: Miaohe Lin <linmiaohe@huawei.com>
> > 
> > David Hildenbrand (2):
> >   mm/hugetlb: fix PTE marker handling in hugetlb_change_protection()
> >   mm/hugetlb: fix uffd-wp handling for migration entries in
> >     hugetlb_change_protection()
> 
> Reviewed-by: Peter Xu <peterx@redhat.com>
> 
> Thanks, David.
> 
> -- 
> Peter Xu