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]
Message-ID: <20191007181113.GC13229@ziepe.ca>
Date:   Mon, 7 Oct 2019 15:11:13 -0300
From:   Jason Gunthorpe <jgg@...pe.ca>
To:     Steven Price <steven.price@....com>
Cc:     Mark Rutland <Mark.Rutland@....com>, x86@...nel.org,
        Arnd Bergmann <arnd@...db.de>,
        Ard Biesheuvel <ard.biesheuvel@...aro.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Catalin Marinas <catalin.marinas@....com>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        Jérôme Glisse <jglisse@...hat.com>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        Andy Lutomirski <luto@...nel.org>,
        "H. Peter Anvin" <hpa@...or.com>,
        James Morse <james.morse@....com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Will Deacon <will@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        linux-arm-kernel@...ts.infradead.org,
        "Liang, Kan" <kan.liang@...ux.intel.com>
Subject: Re: [PATCH v11 14/22] mm: pagewalk: Add 'depth' parameter to pte_hole

On Mon, Oct 07, 2019 at 05:20:30PM +0100, Steven Price wrote:
> On 07/10/2019 17:10, Jason Gunthorpe wrote:
> > On Mon, Oct 07, 2019 at 04:38:14PM +0100, Steven Price wrote:
> >> diff --git a/mm/hmm.c b/mm/hmm.c
> >> index 902f5fa6bf93..34fe904dd417 100644
> >> +++ b/mm/hmm.c
> >> @@ -376,7 +376,7 @@ static void hmm_range_need_fault(const struct hmm_vma_walk *hmm_vma_walk,
> >>  }
> >>  
> >>  static int hmm_vma_walk_hole(unsigned long addr, unsigned long end,
> >> -			     struct mm_walk *walk)
> >> +			     __always_unused int depth, struct mm_walk *walk)
> > 
> > It this __always_unused on function arguments something we are doing
> > now?
> 
> $ git grep __always_unused | wc -l
> 191
> 
> It's elsewhere in the kernel tree. It seems like a good way of both
> documenting and silencing compiler warnings. But I'm open to other
> suggestions.

The normal kernel build doesn't generate warnings for unused function
parameters because there are alot of false positives, IIRC. So, seems
weird to see things like this.

> > Can we have negative depth? Should it be unsigned?
> 
> As per the documentation added in this patch:
> 
>  * @pte_hole:	if set, called for each hole at all levels,
>  *		depth is -1 if not known, 0:PGD, 1:P4D, 2:PUD, 3:PMD
>  *		4:PTE. Any folded depths (where PTRS_PER_P?D is equal
>  *		to 1) are skipped.
> 
> So it's signed to allow "-1" in the cases where pte_hole is called
> without knowing the actual depth. This is used in the function
> walk_page_test() because it don't walk the actual page tables, but is
> called on a VMA instead. This means that there may not be a single depth
> for the range provided.

So are the depth values below OK? I would have expected -1 by this
definition

> >>  {
> >>  	struct hmm_vma_walk *hmm_vma_walk = walk->private;
> >>  	struct hmm_range *range = hmm_vma_walk->range;
> >> @@ -564,7 +564,7 @@ static int hmm_vma_walk_pmd(pmd_t *pmdp,
> >>  again:
> >>  	pmd = READ_ONCE(*pmdp);
> >>  	if (pmd_none(pmd))
> >> -		return hmm_vma_walk_hole(start, end, walk);
> >> +		return hmm_vma_walk_hole(start, end, 0, walk);
> >>  
> >>  	if (thp_migration_supported() && is_pmd_migration_entry(pmd)) {
> >>  		bool fault, write_fault;
> >> @@ -666,7 +666,7 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long start, unsigned long end,
> >>  again:
> >>  	pud = READ_ONCE(*pudp);
> >>  	if (pud_none(pud))
> >> -		return hmm_vma_walk_hole(start, end, walk);
> >> +		return hmm_vma_walk_hole(start, end, 0, walk);
> >>  
> >>  	if (pud_huge(pud) && pud_devmap(pud)) {
> >>  		unsigned long i, npages, pfn;
> >> @@ -674,7 +674,7 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long start, unsigned long end,
> >>  		bool fault, write_fault;
> >>  
> >>  		if (!pud_present(pud))
> >> -			return hmm_vma_walk_hole(start, end, walk);
> >> +			return hmm_vma_walk_hole(start, end, 0, walk);
> >>  
> >>  		i = (addr - range->start) >> PAGE_SHIFT;
> >>  		npages = (end - addr) >> PAGE_SHIFT;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ