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] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 4 Feb 2020 16:14:18 +0000
From:   Joao Martins <joao.m.martins@...cle.com>
To:     Matthew Wilcox <willy@...radead.org>
Cc:     linux-nvdimm@...ts.01.org, Dan Williams <dan.j.williams@...el.com>,
        Vishal Verma <vishal.l.verma@...el.com>,
        Dave Jiang <dave.jiang@...el.com>,
        Ira Weiny <ira.weiny@...el.com>,
        Alex Williamson <alex.williamson@...hat.com>,
        Cornelia Huck <cohuck@...hat.com>, kvm@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        "H . Peter Anvin" <hpa@...or.com>, x86@...nel.org,
        Liran Alon <liran.alon@...cle.com>,
        Nikita Leshenko <nikita.leshchenko@...cle.com>,
        Barret Rhoden <brho@...gle.com>,
        Boris Ostrovsky <boris.ostrovsky@...cle.com>,
        Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
Subject: Re: [PATCH RFC 01/10] mm: Add pmd support for _PAGE_SPECIAL

On 2/3/20 9:34 PM, Matthew Wilcox wrote:
> On Fri, Jan 10, 2020 at 07:03:04PM +0000, Joao Martins wrote:
>> +++ b/arch/x86/include/asm/pgtable.h
>> @@ -293,6 +293,15 @@ static inline int pgd_devmap(pgd_t pgd)
>>  {
>>  	return 0;
>>  }
>> +#endif
>> +
>> +#ifdef CONFIG_ARCH_HAS_PTE_SPECIAL
>> +static inline int pmd_special(pmd_t pmd)
>> +{
>> +	return !!(pmd_flags(pmd) & _PAGE_SPECIAL);
>> +}
>> +#endif
> 
> The ifdef/endif don't make much sense here; x86 does have PTE_SPECIAL,
> and this is an x86 header file, so that can be assumed.
> 
Gotcha.

>> +++ b/mm/gup.c
>> @@ -2079,6 +2079,9 @@ static int gup_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr,
>>  		return __gup_device_huge_pmd(orig, pmdp, addr, end, pages, nr);
>>  	}
>>  
>> +	if (pmd_special(orig))
>> +		return 0;
> 
> Here, you're calling it unconditionally.  I think you need a pmd_special()
> conditionally defined in include/asm-generic/pgtable.h
> 
> +#ifndef CONFIG_ARCH_HAS_PTE_SPECIAL
> +static inline bool pmd_special(pmd_t pmd)
> +{
> +	return false;
> +}
> +#endif
> 
> (oh, and plese use bool instead of int; I know that's different from
> pte_special(), but pte_special() predates bool and nobody's done the work
> to convert it yet)
> 
Got it.

>> +++ b/mm/huge_memory.c
>> @@ -791,6 +791,8 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr,
>>  	entry = pmd_mkhuge(pfn_t_pmd(pfn, prot));
>>  	if (pfn_t_devmap(pfn))
>>  		entry = pmd_mkdevmap(entry);
>> +	else if (pfn_t_special(pfn))
>> +		entry = pmd_mkspecial(entry);
> 
> Again, we'll need a generic one.
> 
Will add it.

>> @@ -823,8 +825,7 @@ vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, pfn_t pfn, bool write)
>>  	 * but we need to be consistent with PTEs and architectures that
>>  	 * can't support a 'special' bit.
>>  	 */
>> -	BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) &&
>> -			!pfn_t_devmap(pfn));
>> +	BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)));
> 
> Should that rather be ...
> 
> +	BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) &&
> +			!pfn_t_devmap(pfn) && !pfn_t_special(pfn));
> 
Yes. That is indeed a mistake I had already fixed for v2. Patch 3 does the exact
same, so as the other comments you mentioned here too so will adjust that
accordingly.

> I also think this comment needs adjusting:
> 
>         /*
>          * There is no pmd_special() but there may be special pmds, e.g.
>          * in a direct-access (dax) mapping, so let's just replicate the
>          * !CONFIG_ARCH_HAS_PTE_SPECIAL case from vm_normal_page() here.
>          */
> 
> 
I'll replace with what vm_normal_page() equivalent has:

	/* !CONFIG_ARCH_HAS_PTE_SPECIAL case follows: */

  Joao

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ