Commit c6b6f363 authored by Borislav Petkov's avatar Borislav Petkov Committed by Matt Fleming

x86/mm/pageattr: Add a PTE pagetable populating function

Handle last level by unconditionally writing the PTEs into the PTE page
while paying attention to the NX bit.
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
parent f900a4b8
...@@ -686,7 +686,27 @@ static int alloc_pmd_page(pud_t *pud) ...@@ -686,7 +686,27 @@ static int alloc_pmd_page(pud_t *pud)
return 0; return 0;
} }
#define populate_pte(cpa, start, end, pages, pmd, pgprot) do {} while (0) static void populate_pte(struct cpa_data *cpa,
unsigned long start, unsigned long end,
unsigned num_pages, pmd_t *pmd, pgprot_t pgprot)
{
pte_t *pte;
pte = pte_offset_kernel(pmd, start);
while (num_pages-- && start < end) {
/* deal with the NX bit */
if (!(pgprot_val(pgprot) & _PAGE_NX))
cpa->pfn &= ~_PAGE_NX;
set_pte(pte, pfn_pte(cpa->pfn >> PAGE_SHIFT, pgprot));
start += PAGE_SIZE;
cpa->pfn += PAGE_SIZE;
pte++;
}
}
static int populate_pmd(struct cpa_data *cpa, static int populate_pmd(struct cpa_data *cpa,
unsigned long start, unsigned long end, unsigned long start, unsigned long end,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment