Re: [PATCH] mm/mmap: Define index macros for protection_map[]

From: Anshuman Khandual
Date: Tue Sep 28 2021 - 22:57:05 EST




On 9/28/21 10:12 AM, Christoph Hellwig wrote:
> On Tue, Sep 28, 2021 at 08:24:43AM +0530, Anshuman Khandual wrote:
>>> simple switch statement provided by each architecture. See the below
>>> WIP which just works for x86 and without pagetable debugging for where I
>>> think we should be going.
>>
>> Sure, this will work as well but all platforms need to be changed at once.
>> Is there any platform that would not subscribe ARCH_HAS_GET_PAGE_PROT and
>> export its own vm_get_page_prot() ? AFAICS all platforms are required to
>> export __PXXX and __SXXX elements currently.
>>
>> This seems to be a better idea than the current proposal. Probably all the
>> vm_flags combinations, which will be used in those switch statements can be
>> converted into macros just to improve readability. Are you planning to send
>> this as a proper patch soon ?
>
> This was just a quіck WIP patch. If you have some spare time to tackle
> it for real I'd sugget the following approach:

Sure, will try and get this working.

>
> 1) Remove the direct references to protection_map in debug_vm_pgtable.c
> 2) add the ARCH_HAS_GET_PAGE_PROT symbol that lets architectures
> provide vm_get_page_prot itself and not define protection_map at all
> in this case
> 3) convert all architectures that touch protection_map to provide
> vm_get_page_prot themselves
> 4) mark protection_map static
> 5) convert all architectures that provide arch_filter_pgprot and/or
> arch_vm_get_page_prot to provide vm_get_page_prot directly and
> remove those hooks
> 6) remove the __S???/__P??? macros and the generic vm_get_page_prot
> after providing an arch implementation for every architecture.
> This can maybe simplified with a new generic version that directly
> looks at PAGE_* macros, but that will need further investigation
> first.
>