diff options
author | Borislav Petkov <bp@suse.de> | 2013-10-31 12:25:04 -0400 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2013-11-02 07:09:24 -0400 |
commit | c6b6f363f7b24aa448994e3a65c4d5b3116acfcc (patch) | |
tree | d607339c3c28381166563bccfcf7098c8630902e /arch/x86/mm | |
parent | f900a4b8ab0f462d89a9fcb6173cac1403415b16 (diff) |
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: Borislav Petkov <bp@suse.de>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'arch/x86/mm')
-rw-r--r-- | arch/x86/mm/pageattr.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index 968398b023c0..2a1308a8c072 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c | |||
@@ -686,7 +686,27 @@ static int alloc_pmd_page(pud_t *pud) | |||
686 | return 0; | 686 | return 0; |
687 | } | 687 | } |
688 | 688 | ||
689 | #define populate_pte(cpa, start, end, pages, pmd, pgprot) do {} while (0) | 689 | static void populate_pte(struct cpa_data *cpa, |
690 | unsigned long start, unsigned long end, | ||
691 | unsigned num_pages, pmd_t *pmd, pgprot_t pgprot) | ||
692 | { | ||
693 | pte_t *pte; | ||
694 | |||
695 | pte = pte_offset_kernel(pmd, start); | ||
696 | |||
697 | while (num_pages-- && start < end) { | ||
698 | |||
699 | /* deal with the NX bit */ | ||
700 | if (!(pgprot_val(pgprot) & _PAGE_NX)) | ||
701 | cpa->pfn &= ~_PAGE_NX; | ||
702 | |||
703 | set_pte(pte, pfn_pte(cpa->pfn >> PAGE_SHIFT, pgprot)); | ||
704 | |||
705 | start += PAGE_SIZE; | ||
706 | cpa->pfn += PAGE_SIZE; | ||
707 | pte++; | ||
708 | } | ||
709 | } | ||
690 | 710 | ||
691 | static int populate_pmd(struct cpa_data *cpa, | 711 | static int populate_pmd(struct cpa_data *cpa, |
692 | unsigned long start, unsigned long end, | 712 | unsigned long start, unsigned long end, |