On 06/02/2017 04:27 AM, Ard Biesheuvel wrote:
quoted hunk ↗ jump to hunk
+static struct page *vmalloc_to_pud_page(unsigned long addr, pud_t *pud)
+{
+ struct page *page = NULL;
+#ifdef CONFIG_HUGETLB_PAGE
Do we really want this based on hugetlbfs? Won't this be dead code on x86?
Also, don't we discourage #ifdefs in .c files?
quoted hunk ↗ jump to hunk
+ pte_t pte = huge_ptep_get((pte_t *)pud);
+
+ if (pte_present(pte))
+ page = pud_page(*pud) + ((addr & ~PUD_MASK) >> PAGE_SHIFT);
x86 has pmd/pud_page(). Seems a bit silly to open-code it here.
quoted hunk ↗ jump to hunk
+#else
+ VIRTUAL_BUG_ON(1);
+#endif
+ return page;
+}
So if somebody manages to call this function on a huge page table entry,
but doesn't have hugetlbfs configured on, we kill the machine?