[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABi2SkVj8c7Cw_4DQ-U55Nkv5YCYR4WhjU3U_cw-cU2o7MAhMQ@mail.gmail.com>
Date: Fri, 16 Aug 2024 11:20:11 -0700
From: Jeff Xu <jeffxu@...omium.org>
To: Pedro Falcato <pedro.falcato@...il.com>
Cc: Jeff Xu <jeffxu@...gle.com>, Andrew Morton <akpm@...ux-foundation.org>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>, Vlastimil Babka <vbabka@...e.cz>,
Lorenzo Stoakes <lorenzo.stoakes@...cle.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, oliver.sang@...el.com,
torvalds@...ux-foundation.org, Michael Ellerman <mpe@...erman.id.au>
Subject: Re: [PATCH v2 0/6] mm: Optimize mseal checks
On Fri, Aug 16, 2024 at 11:09 AM Pedro Falcato <pedro.falcato@...il.com> wrote:
>
> On Fri, Aug 16, 2024 at 6:07 PM Jeff Xu <jeffxu@...omium.org> wrote:
> > Please run this test on the latest kernel branch to verify:
> >
> > static void test_munmap_free_multiple_ranges(bool seal)
> > {
> > void *ptr;
> > unsigned long page_size = getpagesize();
> > unsigned long size = 8 * page_size;
> > int ret;
> > int prot;
> >
> > setup_single_address(size, &ptr);
> > FAIL_TEST_IF_FALSE(ptr != (void *)-1);
> >
> > /* unmap one page from beginning. */
> > ret = sys_munmap(ptr, page_size);
> > FAIL_TEST_IF_FALSE(!ret);
> >
> > /* unmap one page from middle. */
> > ret = sys_munmap(ptr + 4 * page_size, page_size);
> > FAIL_TEST_IF_FALSE(!ret);
> >
> > /* seal the last page */
> > if (seal) {
> > ret = sys_mseal(ptr + 7 * page_size, page_size);
> > FAIL_TEST_IF_FALSE(!ret);
> > }
> >
> > /* munmap all 8 pages from beginning */
> > ret = sys_munmap(ptr, 8 * page_size);
> > if (seal) {
> > FAIL_TEST_IF_FALSE(ret < 0);
> >
> > /* verify none of existing pages in the range are unmapped */
> > size = get_vma_size(ptr + page_size, &prot);
> > FAIL_TEST_IF_FALSE(size == 3 * page_size);
> > FAIL_TEST_IF_FALSE(prot == 4);
> >
> > size = get_vma_size(ptr + 5 * page_size, &prot);
> > FAIL_TEST_IF_FALSE(size == 2 * page_size);
> > FAIL_TEST_IF_FALSE(prot == 4);
> >
> > size = get_vma_size(ptr + 7 * page_size, &prot);
> > FAIL_TEST_IF_FALSE(size == 1 * page_size);
> > FAIL_TEST_IF_FALSE(prot == 4);
> > } else {
> > FAIL_TEST_IF_FALSE(!ret);
> >
> > /* verify all pages are unmapped */
> > for (int i = 0; i < 8; i++) {
> > size = get_vma_size(ptr, &prot);
> > FAIL_TEST_IF_FALSE(size == 0);
> > }
> > }
> >
> > REPORT_TEST_PASS();
> > }
> >
>
> FWIW this test does not work correctly on my end due to sealed VMAs
> getting merged. I hacked up setup_single_address to work around that,
> and the test does pass on both 6.10.5 and my local mseal changes
> branch.
Yes. you would need to comment out other tests and run this test only,
it didn't consider the case that sealed vma will merge with another
sealed vma (created from another test)
The test didn't pass with the V2 patch (the seal = true) case.
-Jeff
>
> --
> Pedro
Powered by blists - more mailing lists