Skip to content

Commit b6c9d5a

Browse files
xzpeterakpm00
authored andcommitted
mm/kasan: use pXd_leaf() in shadow_mapped()
There is an old trick in shadow_mapped() to use pXd_bad() to detect huge pages. After commit 93fab1b ("mm: add generic p?d_leaf() macros") we have a global API for huge mappings. Use that to replace the trick. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Peter Xu <[email protected]> Reviewed-by: Mike Rapoport (IBM) <[email protected]> Cc: Andrey Ryabinin <[email protected]> Cc: Alexander Potapenko <[email protected]> Cc: Andrey Konovalov <[email protected]> Cc: Dmitry Vyukov <[email protected]> Cc: Vincenzo Frascino <[email protected]> Cc: "Aneesh Kumar K.V" <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Kirill A. Shutemov <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Muchun Song <[email protected]> Cc: "Naveen N. Rao" <[email protected]> Cc: Nicholas Piggin <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Yang Shi <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 924bd6a commit b6c9d5a

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

mm/kasan/shadow.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,19 +199,12 @@ static bool shadow_mapped(unsigned long addr)
199199
pud = pud_offset(p4d, addr);
200200
if (pud_none(*pud))
201201
return false;
202-
203-
/*
204-
* We can't use pud_large() or pud_huge(), the first one is
205-
* arch-specific, the last one depends on HUGETLB_PAGE. So let's abuse
206-
* pud_bad(), if pud is bad then it's bad because it's huge.
207-
*/
208-
if (pud_bad(*pud))
202+
if (pud_leaf(*pud))
209203
return true;
210204
pmd = pmd_offset(pud, addr);
211205
if (pmd_none(*pmd))
212206
return false;
213-
214-
if (pmd_bad(*pmd))
207+
if (pmd_leaf(*pmd))
215208
return true;
216209
pte = pte_offset_kernel(pmd, addr);
217210
return !pte_none(ptep_get(pte));

0 commit comments

Comments
 (0)