x86/mm/pageattr: Add a PTE pagetable populating function
authorBorislav Petkov <bp@suse.de>
Thu, 31 Oct 2013 16:25:04 +0000 (17:25 +0100)
committerMatt Fleming <matt.fleming@intel.com>
Sat, 2 Nov 2013 11:09:24 +0000 (11:09 +0000)
Handle last level by unconditionally writing the PTEs into the PTE page
while paying attention to the NX bit.

Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
arch/x86/mm/pageattr.c

index 968398b023c0d7c1b454c04e18b2b2f2fcb31a57..2a1308a8c072db01b82cfab70196072ab3f2b591 100644 (file)
@@ -686,7 +686,27 @@ static int alloc_pmd_page(pud_t *pud)
        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,
                        unsigned long start, unsigned long end,