lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87o6rfid5y.fsf@oracle.com>
Date: Fri, 12 Sep 2025 14:17:13 -0700
From: Ankur Arora <ankur.a.arora@...cle.com>
To: Ankur Arora <ankur.a.arora@...cle.com>
Cc: David Hildenbrand <david@...hat.com>, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org, x86@...nel.org, akpm@...ux-foundation.org,
        bp@...en8.de, dave.hansen@...ux.intel.com, hpa@...or.com,
        mingo@...hat.com, mjguzik@...il.com, luto@...nel.org,
        peterz@...radead.org, acme@...nel.org, namhyung@...nel.org,
        tglx@...utronix.de, willy@...radead.org, raghavendra.kt@....com,
        boris.ostrovsky@...cle.com, konrad.wilk@...cle.com
Subject: Re: [PATCH v6 11/15] mm: define clear_pages(), clear_user_pages()


Ankur Arora <ankur.a.arora@...cle.com> writes:

> David Hildenbrand <david@...hat.com> writes:
>
>> On 02.09.25 10:08, Ankur Arora wrote:

[ ... ]

>>> + * clear_pages() - clear kernel page range.
>>> + * @addr: start address of page range
>>> + * @npages: number of pages
>>> + *
>>> + * Assumes that (@addr, +@...ges) references a kernel region.
>>> + * Like clear_page(), this does absolutely no exception handling.
>>> + */
>>> +static inline void clear_pages(void *addr, unsigned int npages)
>>> +{
>>> +	for (int i = 0; i < npages; i++)
>>> +		clear_page(addr + i * PAGE_SIZE);
>>
>> If we know that we will clear at least one page (which we can document)
>>
>> do {
>> 	clear_page(addr);
>> 	addr += PAGE_SIZE;
>> } while (--npages);
>>
>> Similarly for the case below.
>
> Ack. Though how about the following instead? Slightly less clear but
> probably better suited for caching the likely access pattern.
>
>    addr += (npages - 1) * PAGE_SIZE;
>    do {
>            clear_page(addr);
>            addr -= PAGE_SIZE;
>    } while (--npages);

Decided against using this reverse access pattern. I would need
to replicate it at three places  (clear_pages(), clear_user_pages() and
clear_highpages()) and this kind of policy should probably be dictated
from folio_zero_user() or clear_contig_pages() etc.

--
ankur

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ