Re: [PATCH v2 2/2] arm64/mm: Move {tramp_pg_dir, swapper_pg_dir} to .rodata section

From: James Morse
Date: Wed Jun 27 2018 - 07:23:09 EST


Hi Suzuki, Jun,

On 27/06/18 12:07, Suzuki K Poulose wrote:
> On 25/06/18 12:39, Jun Yao wrote:
>> When CONFIG_ARM64_VA_BITS_36/CONFIG_ARM64_VA_BITS_39/
>> CONFIG_ARM64_VA_BITS_42 are selected, a block-mapping can be
>> written to swapper_pg_dir. To defend 'KSMA', we move swapper_pg_dir
>> to .rodata section when these configurations are selected. At the
>> same time, we update swapper_pg_dir by fixmap.

>> diff --git a/arch/arm64/include/asm/pgalloc.h b/arch/arm64/include/asm/pgalloc.h
>> index 2e05bcd944c8..62512ad9c310 100644
>> --- a/arch/arm64/include/asm/pgalloc.h
>> +++ b/arch/arm64/include/asm/pgalloc.h
>> @@ -49,6 +49,22 @@ static inline void __pud_populate(pud_t *pudp, phys_addr_t
>> pmdp, pudval_t prot)
>> Â Â static inline void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t
>> *pmdp)
>> Â {
>> +#ifdef CONFIG_ARM64_VA_BITS_39
>
> Could we please use
>
> #ifdef __PAGETABLE_PUD_FOLDED ^^

>> @@ -142,6 +158,23 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp,
>> pte_t *ptep)
>> ÂÂÂÂÂ /*
>> ÂÂÂÂÂÂ * The pmd must be loaded with the physical address of the PTE table
>> ÂÂÂÂÂÂ */
>> +#if defined(CONFIG_ARM64_VA_BITS_42) || \
>> +ÂÂÂ defined(CONFIG_ARM64_VA_BITS_36)
>
> and
>
> #ifdef __PGTABLE_PMD_FOLDED here ^^
>
>
>> +#if defined(CONFIG_ARM64_VA_BITS_39) || \
>> +ÂÂÂ defined(CONFIG_ARM64_VA_BITS_36) || \
>> +ÂÂÂ defined(CONFIG_ARM64_VA_BITS_42)
>
> and
>
> #ifdef __PGTABLE_PMD_FOLDED ^^ (as it implies
> __PGTABLE_PUD_FOLDED )
>
> instead ?

Aha, I didn't know these existed. As we are only interested in matching one
level for now, this is even clearer.


Thanks,

James