From patchwork Wed Apr 12 16:43:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13209359 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C46FBC7619A for ; Wed, 12 Apr 2023 16:44:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 635C3900009; Wed, 12 Apr 2023 12:44:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E536900003; Wed, 12 Apr 2023 12:44:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 486BE900009; Wed, 12 Apr 2023 12:44:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 39465900003 for ; Wed, 12 Apr 2023 12:44:04 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0C7EC1401CB for ; Wed, 12 Apr 2023 16:44:04 +0000 (UTC) X-FDA: 80673311208.20.DEC5B74 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf07.hostedemail.com (Postfix) with ESMTP id CD8E14001A for ; Wed, 12 Apr 2023 16:44:01 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=i5ClqfsB; spf=pass (imf07.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681317841; a=rsa-sha256; cv=none; b=N0GZCduPdPW2N5+yDBwGNUKfCKtg5OXyr0x9XWTEhOgPa5uGRhYqkY/rUUaj5T6RI9bayy vUGEIyXYIn1uoJVc61ZLDKnAVX/r412F4cUjKPdKMIjyHWi1aTsmmIjZUK7beO6vupcNf/ AiRKLSqVPHLgCgAJI1GotdG3mNspJMI= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=i5ClqfsB; spf=pass (imf07.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681317841; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EPLVHwmG1JWLQdfe+bC3h4cMLKGLNsksPTamWwKRdSQ=; b=TDjB+eBYzI14nrF3HWrGg1XbMv1HLaIZg57FTFn6UkfPRnLTEr0TWiLd01TPQ5dBxzhmdl yQP0Nc1D4PoQWnrihz5cBKZhENtD/K+Z/AyM08My57zznIDi/2dceiN4MD+RGG//FsJhUD ASZLILpqXd+PA9RTrTtYz2O2RVjKDis= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681317841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EPLVHwmG1JWLQdfe+bC3h4cMLKGLNsksPTamWwKRdSQ=; b=i5ClqfsBrqjunAa1cUzLeso1HiIDsV+za7C6n6mBdhjYf4IlgSzHW1xRwaUzj0FP+1dy3y eZ4vdIW4qAbwA+pA+JzS/gmI9VU2iC1mWl27H4TZog6FjRux2nD3Vs9Yo/L1Uf9QcJSUgL /QFy0STi5m82Jnptk/xjIBH82s0hCgY= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-189-8rnC2bYEMYm3nvnWSFilIA-1; Wed, 12 Apr 2023 12:43:57 -0400 X-MC-Unique: 8rnC2bYEMYm3nvnWSFilIA-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-74a9035256eso54273785a.0 for ; Wed, 12 Apr 2023 09:43:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681317837; x=1683909837; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EPLVHwmG1JWLQdfe+bC3h4cMLKGLNsksPTamWwKRdSQ=; b=MU4PK13xGGVK1C0c14zydwqb69Xb7QgoGzxjRUuiF1aXa8z/Ih6YJiSHbC89ZD/u2r VPqPszGYiIrT6THNWW7QJYLzX7IrMQZypDinlfoNe1DL0jY/TKgpV9GdH714BN6QUvKv jc0AKg7Ns1mKEyPUuFYN/kXBD7olh0Lrt+LgxZZ5LMXGp6+EoAZ+uLpri0KxqPe51NCH GA0GQzGHmVNXmhfYMH82vlEWj00HWYOmnRGZkO9lCx8eO4Krb2X0C9bKES1NAHzRqY4d MPMfwlNkF7kgPrQzjRbDV1K3avs+VAJ8MjGnagXruL9BeyrW42cAunkDbbdPdjq59O3w RG5A== X-Gm-Message-State: AAQBX9e8MLd/byrrzLCz5nF2bJAVd9R0o2cvpZxmiTuVYRkCGl1/akl5 +BjKUS/EiNlEesbI77Azfs6TwoCIVE9Ll92aikKbmZGaZxTXBbzRr/HExOIC3WUxvSVUfvpbozO ZKlafp3SMmGM= X-Received: by 2002:ac8:5cc8:0:b0:3e6:707e:d3b1 with SMTP id s8-20020ac85cc8000000b003e6707ed3b1mr5019828qta.0.1681317837038; Wed, 12 Apr 2023 09:43:57 -0700 (PDT) X-Google-Smtp-Source: AKy350ZbuxgmUhLJPUZsc/XbkJJrLLicXSsAvTA4gBiNZfg/X0rald8nfCHkMiAjHNJAZFk97T+JTQ== X-Received: by 2002:ac8:5cc8:0:b0:3e6:707e:d3b1 with SMTP id s8-20020ac85cc8000000b003e6707ed3b1mr5019794qta.0.1681317836679; Wed, 12 Apr 2023 09:43:56 -0700 (PDT) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-40-70-52-229-124.dsl.bell.ca. [70.52.229.124]) by smtp.gmail.com with ESMTPSA id d23-20020a05620a141700b00746803d7e8dsm4760743qkj.113.2023.04.12.09.43.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 09:43:55 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: David Hildenbrand , Andrew Morton , Leonardo Bras Soares Passos , peterx@redhat.com, Andrea Arcangeli , Nadav Amit , Mike Rapoport , Axel Rasmussen , Mike Kravetz , Mike Rapoport Subject: [PATCH v2 23/31] selftests/mm: Move uffd pagemap test to unit test Date: Wed, 12 Apr 2023 12:43:52 -0400 Message-Id: <20230412164352.328733-1-peterx@redhat.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230412163922.327282-1-peterx@redhat.com> References: <20230412163922.327282-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspam-User: X-Rspamd-Queue-Id: CD8E14001A X-Rspamd-Server: rspam01 X-Stat-Signature: 8rqdko1thrd99w8bcit99su7xaqzbdut X-HE-Tag: 1681317841-50640 X-HE-Meta: U2FsdGVkX18U6uhuHt1k/7DGgk7Kx9mWmOuEX9DOeq/iaIOBup0INEnhX0ZO2GhSDmLl+A594fre57jvGruDi6dp7xMCdwHlDO9RYrAqF7qyu/afJCO9nC3qkK5MlpoJwkRlmu+mEZoGN3p/ErLF6DxDrYh9EDDJ+cQK57dHGUuL9RchlT+QlZVwHK05VmD546gp8AZWOA8cvH/7MP4EqVX+C6Li0pkE0pSv5lPI50lkzmXPMy7rI5tOpKFIke4uQwXEtSGsGgnXVGEYtjfxya/BFsF9/5o/E1Hpk4BbWLbgFh5dV+iS0ivq0eaGxfT7C6uiHEbpCzZ4awHCWa/Fd0vfM5rkM1fNZGO9lwjKorpnaJ1kyCvjrqlnoPzzeyWDW/FCWpo54YF5bTgo9jVxGD9DJFskvQr6Affy1wXczy/w8ZXajW2M0Nh9Ft/oYtiZmBW3eeYge/Vie3IKlIMucPFQFIC5w2mLjzq1vKKZMUK0reEbwnp0E7lwv/r4FXvSCdg4xjF5hNOhc7A4vzgbc2RYV6Yr7F/URGYNeRgdrr3EllVw0PcydZtVAA3n0uaN9enSUXXZiBQc5y3KyvIKOAE1JRNpZvihdxLDQXV0tgQUKKQKbCY/M45StZlKottujidWN+4wfQ0VZvLCspdy65Zj8TG106zOIVZryxWyvm5BtTFBkfjZaymhUopjkt0qZ8kcH/mL65sc+NhfVQO/x+tzyB92TLM9G+GejJ8lfYzAAwGkQP3/6HeeJIytFWGvFQoxlO22WwPtIxYGa+MXQ+whABVToGVlcXBZg8uAqzPt/M+2EV9WffQfs2It5UEjBSBnaAJHqgLclrGu1SjS6y1TbOICko+p8PcQtSjQ8cejOLVy1J1SNZII9WuMhoxomO+TNUyqtY0OnvWyJojxp2d0o+Xke1EWgaTb3EIRl3pGkE5/UMU4d94TNsY4pqzRzqQCPfGosirRrqy8HKI tB4GQb2n ogQDgq3dS0FNMKcJ4ohnoO+hcu9xaJlhqnX30vnil2z7xQMKue645wbq13zD1RTGUtB8mr4oNuwyXKhfYs8aLcKYcal+tqw2P2dR0A7G3MQb0JRz0kvhBcrsj5J9spLPb8TLvkxyYlmSLtWJOVa1XoXee9/HprabemNSpAd5ruehjjdEb/xtpcBMuAJ+NTLDlMsGn7DHqklH8yw6g6snlqxMDMTeE51rOYD0ZgCT4r5p88EPmpztkeZKo5J/14/d/cB3IRLrsnA8/taee3Rq3f5SYbkcfyo5yVnQpBdE6kecIaP1NJPqpbsjB68AAbT+cXOyPpHPlmq+RWeiNz6IA88fWqASRo/kZqU23N88mxxWoudCednoeFGwDw+pzYgz4NFr0aMReMD0pjm4iYT9gmZSX8/iYvQkeeDv8iVTw2b3Vuo8aKyh0fJNHgbIH0jCAQXA++UC9qrOUlahNfe9+eudIdGjDc34sdbbuXGkCcoAvso3SRwYWAqpQ6I9XymR0qw6rtKAoKcMlagWkLBWOlhyZV6+q6Srxd3LV X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Move it over and make it split into two tests, one for pagemap and one for the new WP_UNPOPULATED (to be a separate one). The thp pagemap test wasn't really working (with MADV_HUGEPAGE). Let's just drop it (since it never really worked anyway..) and leave that for later. Reviewed-by: Mike Rapoport (IBM) Signed-off-by: Peter Xu --- tools/testing/selftests/mm/uffd-stress.c | 166 ------------------- tools/testing/selftests/mm/uffd-unit-tests.c | 145 ++++++++++++++++ 2 files changed, 145 insertions(+), 166 deletions(-) diff --git a/tools/testing/selftests/mm/uffd-stress.c b/tools/testing/selftests/mm/uffd-stress.c index 747d588c0d69..61d025d87bf2 100644 --- a/tools/testing/selftests/mm/uffd-stress.c +++ b/tools/testing/selftests/mm/uffd-stress.c @@ -670,157 +670,6 @@ static int userfaultfd_minor_test(void) return args.missing_faults != 0 || args.minor_faults != nr_pages; } -static int pagemap_open(void) -{ - int fd = open("/proc/self/pagemap", O_RDONLY); - - if (fd < 0) - err("open pagemap"); - - return fd; -} - -/* This macro let __LINE__ works in err() */ -#define pagemap_check_wp(value, wp) do { \ - if (!!(value & PM_UFFD_WP) != wp) \ - err("pagemap uffd-wp bit error: 0x%"PRIx64, value); \ - } while (0) - -static int pagemap_test_fork(bool present) -{ - pid_t child = fork(); - uint64_t value; - int fd, result; - - if (!child) { - /* Open the pagemap fd of the child itself */ - fd = pagemap_open(); - value = pagemap_get_entry(fd, area_dst); - /* - * After fork() uffd-wp bit should be gone as long as we're - * without UFFD_FEATURE_EVENT_FORK - */ - pagemap_check_wp(value, false); - /* Succeed */ - exit(0); - } - waitpid(child, &result, 0); - return result; -} - -static void userfaultfd_wp_unpopulated_test(int pagemap_fd) -{ - uint64_t value; - - /* Test applying pte marker to anon unpopulated */ - wp_range(uffd, (uint64_t)area_dst, page_size, true); - value = pagemap_get_entry(pagemap_fd, area_dst); - pagemap_check_wp(value, true); - - /* Test unprotect on anon pte marker */ - wp_range(uffd, (uint64_t)area_dst, page_size, false); - value = pagemap_get_entry(pagemap_fd, area_dst); - pagemap_check_wp(value, false); - - /* Test zap on anon marker */ - wp_range(uffd, (uint64_t)area_dst, page_size, true); - if (madvise(area_dst, page_size, MADV_DONTNEED)) - err("madvise(MADV_DONTNEED) failed"); - value = pagemap_get_entry(pagemap_fd, area_dst); - pagemap_check_wp(value, false); - - /* Test fault in after marker removed */ - *area_dst = 1; - value = pagemap_get_entry(pagemap_fd, area_dst); - pagemap_check_wp(value, false); - /* Drop it to make pte none again */ - if (madvise(area_dst, page_size, MADV_DONTNEED)) - err("madvise(MADV_DONTNEED) failed"); - - /* Test read-zero-page upon pte marker */ - wp_range(uffd, (uint64_t)area_dst, page_size, true); - *(volatile char *)area_dst; - /* Drop it to make pte none again */ - if (madvise(area_dst, page_size, MADV_DONTNEED)) - err("madvise(MADV_DONTNEED) failed"); -} - -static void userfaultfd_pagemap_test(unsigned int test_pgsize) -{ - int pagemap_fd; - uint64_t value; - - /* Pagemap tests uffd-wp only */ - if (!test_uffdio_wp) - return; - - /* Not enough memory to test this page size */ - if (test_pgsize > nr_pages * page_size) - return; - - printf("testing uffd-wp with pagemap (pgsize=%u): ", test_pgsize); - /* Flush so it doesn't flush twice in parent/child later */ - fflush(stdout); - - uffd_test_ctx_init(UFFD_FEATURE_WP_UNPOPULATED); - - if (test_pgsize > page_size) { - /* This is a thp test */ - if (madvise(area_dst, nr_pages * page_size, MADV_HUGEPAGE)) - err("madvise(MADV_HUGEPAGE) failed"); - } else if (test_pgsize == page_size) { - /* This is normal page test; force no thp */ - if (madvise(area_dst, nr_pages * page_size, MADV_NOHUGEPAGE)) - err("madvise(MADV_NOHUGEPAGE) failed"); - } - - if (uffd_register(uffd, area_dst, nr_pages * page_size, - false, true, false)) - err("register failed"); - - pagemap_fd = pagemap_open(); - - /* Smoke test WP_UNPOPULATED first when it's still empty */ - if (test_pgsize == page_size) - userfaultfd_wp_unpopulated_test(pagemap_fd); - - /* Touch the page */ - *area_dst = 1; - wp_range(uffd, (uint64_t)area_dst, test_pgsize, true); - value = pagemap_get_entry(pagemap_fd, area_dst); - pagemap_check_wp(value, true); - /* Make sure uffd-wp bit dropped when fork */ - if (pagemap_test_fork(true)) - err("Detected stall uffd-wp bit in child"); - - /* Exclusive required or PAGEOUT won't work */ - if (!(value & PM_MMAP_EXCLUSIVE)) - err("multiple mapping detected: 0x%"PRIx64, value); - - if (madvise(area_dst, test_pgsize, MADV_PAGEOUT)) - err("madvise(MADV_PAGEOUT) failed"); - - /* Uffd-wp should persist even swapped out */ - value = pagemap_get_entry(pagemap_fd, area_dst); - pagemap_check_wp(value, true); - /* Make sure uffd-wp bit dropped when fork */ - if (pagemap_test_fork(false)) - err("Detected stall uffd-wp bit in child"); - - /* Unprotect; this tests swap pte modifications */ - wp_range(uffd, (uint64_t)area_dst, page_size, false); - value = pagemap_get_entry(pagemap_fd, area_dst); - pagemap_check_wp(value, false); - - /* Fault in the page from disk */ - *area_dst = 2; - value = pagemap_get_entry(pagemap_fd, area_dst); - pagemap_check_wp(value, false); - - close(pagemap_fd); - printf("done\n"); -} - static int userfaultfd_stress(void) { void *area; @@ -932,21 +781,6 @@ static int userfaultfd_stress(void) uffd_stats_report(args, nr_cpus); } - if (test_type == TEST_ANON) { - /* - * shmem/hugetlb won't be able to run since they have different - * behavior on fork() (file-backed memory normally drops ptes - * directly when fork), meanwhile the pagemap test will verify - * pgtable entry of fork()ed child. - */ - userfaultfd_pagemap_test(page_size); - /* - * Hard-code for x86_64 for now for 2M THP, as x86_64 is - * currently the only one that supports uffd-wp - */ - userfaultfd_pagemap_test(page_size * 512); - } - return userfaultfd_zeropage_test() || userfaultfd_sig_test() || userfaultfd_events_test() || userfaultfd_minor_test(); } diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c index 936b24a6f468..4690c95a9420 100644 --- a/tools/testing/selftests/mm/uffd-unit-tests.c +++ b/tools/testing/selftests/mm/uffd-unit-tests.c @@ -197,7 +197,152 @@ static bool uffd_feature_supported(uffd_test_case_t *test) test->uffd_feature_required; } +static int pagemap_open(void) +{ + int fd = open("/proc/self/pagemap", O_RDONLY); + + if (fd < 0) + err("open pagemap"); + + return fd; +} + +/* This macro let __LINE__ works in err() */ +#define pagemap_check_wp(value, wp) do { \ + if (!!(value & PM_UFFD_WP) != wp) \ + err("pagemap uffd-wp bit error: 0x%"PRIx64, value); \ + } while (0) + +static int pagemap_test_fork(bool present) +{ + pid_t child = fork(); + uint64_t value; + int fd, result; + + if (!child) { + /* Open the pagemap fd of the child itself */ + fd = pagemap_open(); + value = pagemap_get_entry(fd, area_dst); + /* + * After fork() uffd-wp bit should be gone as long as we're + * without UFFD_FEATURE_EVENT_FORK + */ + pagemap_check_wp(value, false); + /* Succeed */ + exit(0); + } + waitpid(child, &result, 0); + return result; +} + +static void uffd_wp_unpopulated_test(void) +{ + uint64_t value; + int pagemap_fd; + + if (uffd_register(uffd, area_dst, nr_pages * page_size, + false, true, false)) + err("register failed"); + + pagemap_fd = pagemap_open(); + + /* Test applying pte marker to anon unpopulated */ + wp_range(uffd, (uint64_t)area_dst, page_size, true); + value = pagemap_get_entry(pagemap_fd, area_dst); + pagemap_check_wp(value, true); + + /* Test unprotect on anon pte marker */ + wp_range(uffd, (uint64_t)area_dst, page_size, false); + value = pagemap_get_entry(pagemap_fd, area_dst); + pagemap_check_wp(value, false); + + /* Test zap on anon marker */ + wp_range(uffd, (uint64_t)area_dst, page_size, true); + if (madvise(area_dst, page_size, MADV_DONTNEED)) + err("madvise(MADV_DONTNEED) failed"); + value = pagemap_get_entry(pagemap_fd, area_dst); + pagemap_check_wp(value, false); + + /* Test fault in after marker removed */ + *area_dst = 1; + value = pagemap_get_entry(pagemap_fd, area_dst); + pagemap_check_wp(value, false); + /* Drop it to make pte none again */ + if (madvise(area_dst, page_size, MADV_DONTNEED)) + err("madvise(MADV_DONTNEED) failed"); + + /* Test read-zero-page upon pte marker */ + wp_range(uffd, (uint64_t)area_dst, page_size, true); + *(volatile char *)area_dst; + /* Drop it to make pte none again */ + if (madvise(area_dst, page_size, MADV_DONTNEED)) + err("madvise(MADV_DONTNEED) failed"); + + uffd_test_pass(); +} + +static void uffd_pagemap_test(void) +{ + int pagemap_fd; + uint64_t value; + + if (uffd_register(uffd, area_dst, nr_pages * page_size, + false, true, false)) + err("register failed"); + + pagemap_fd = pagemap_open(); + + /* Touch the page */ + *area_dst = 1; + wp_range(uffd, (uint64_t)area_dst, page_size, true); + value = pagemap_get_entry(pagemap_fd, area_dst); + pagemap_check_wp(value, true); + /* Make sure uffd-wp bit dropped when fork */ + if (pagemap_test_fork(true)) + err("Detected stall uffd-wp bit in child"); + + /* Exclusive required or PAGEOUT won't work */ + if (!(value & PM_MMAP_EXCLUSIVE)) + err("multiple mapping detected: 0x%"PRIx64, value); + + if (madvise(area_dst, page_size, MADV_PAGEOUT)) + err("madvise(MADV_PAGEOUT) failed"); + + /* Uffd-wp should persist even swapped out */ + value = pagemap_get_entry(pagemap_fd, area_dst); + pagemap_check_wp(value, true); + /* Make sure uffd-wp bit dropped when fork */ + if (pagemap_test_fork(false)) + err("Detected stall uffd-wp bit in child"); + + /* Unprotect; this tests swap pte modifications */ + wp_range(uffd, (uint64_t)area_dst, page_size, false); + value = pagemap_get_entry(pagemap_fd, area_dst); + pagemap_check_wp(value, false); + + /* Fault in the page from disk */ + *area_dst = 2; + value = pagemap_get_entry(pagemap_fd, area_dst); + pagemap_check_wp(value, false); + + close(pagemap_fd); + uffd_test_pass(); +} + uffd_test_case_t uffd_tests[] = { + { + .name = "pagemap", + .uffd_fn = uffd_pagemap_test, + .mem_targets = MEM_ANON, + .uffd_feature_required = UFFD_FEATURE_PAGEFAULT_FLAG_WP, + }, + { + .name = "wp-unpopulated", + .uffd_fn = uffd_wp_unpopulated_test, + .mem_targets = MEM_ANON, + .uffd_feature_required = + UFFD_FEATURE_PAGEFAULT_FLAG_WP | UFFD_FEATURE_WP_UNPOPULATED, + }, }; int main(int argc, char *argv[])