aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Beulich <JBeulich@suse.com>2017-12-18 11:37:45 -0500
committerBoris Ostrovsky <boris.ostrovsky@oracle.com>2017-12-19 11:33:25 -0500
commit2cc42bac1c795f75fcc062b95c6ca7ac1b84d5d8 (patch)
tree032d75fffa1848d5780f9b4b47e7ae25c52c6a98
parentc4f9d9cb2c29ff04c6b4bb09b72802d8aedfc7cb (diff)
x86-64/Xen: eliminate W+X mappings
A few thousand such pages are usually left around due to the re-use of L1 tables having been provided by the hypervisor (Dom0) or tool stack (DomU). Set NX in the direct map variant, which needs to be done in L2 due to the dual use of the re-used L1s. For x86_configure_nx() to actually do what it is supposed to do, call get_cpu_cap() first. This was broken by commit 4763ed4d45 ("x86, mm: Clean up and simplify NX enablement") when switching away from the direct EFER read. Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Juergen Gross <jgross@suse.com> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
-rw-r--r--arch/x86/xen/enlighten_pv.c3
-rw-r--r--arch/x86/xen/mmu_pv.c12
2 files changed, 15 insertions, 0 deletions
diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
index 69b9deff7e5c..86f26ea99324 100644
--- a/arch/x86/xen/enlighten_pv.c
+++ b/arch/x86/xen/enlighten_pv.c
@@ -87,6 +87,8 @@
87#include "multicalls.h" 87#include "multicalls.h"
88#include "pmu.h" 88#include "pmu.h"
89 89
90#include "../kernel/cpu/cpu.h" /* get_cpu_cap() */
91
90void *xen_initial_gdt; 92void *xen_initial_gdt;
91 93
92static int xen_cpu_up_prepare_pv(unsigned int cpu); 94static int xen_cpu_up_prepare_pv(unsigned int cpu);
@@ -1249,6 +1251,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
1249 __userpte_alloc_gfp &= ~__GFP_HIGHMEM; 1251 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
1250 1252
1251 /* Work out if we support NX */ 1253 /* Work out if we support NX */
1254 get_cpu_cap(&boot_cpu_data);
1252 x86_configure_nx(); 1255 x86_configure_nx();
1253 1256
1254 /* Get mfn list */ 1257 /* Get mfn list */
diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c
index 9d9cc3870722..7118f776cd49 100644
--- a/arch/x86/xen/mmu_pv.c
+++ b/arch/x86/xen/mmu_pv.c
@@ -1916,6 +1916,18 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
1916 /* Graft it onto L4[511][510] */ 1916 /* Graft it onto L4[511][510] */
1917 copy_page(level2_kernel_pgt, l2); 1917 copy_page(level2_kernel_pgt, l2);
1918 1918
1919 /*
1920 * Zap execute permission from the ident map. Due to the sharing of
1921 * L1 entries we need to do this in the L2.
1922 */
1923 if (__supported_pte_mask & _PAGE_NX) {
1924 for (i = 0; i < PTRS_PER_PMD; ++i) {
1925 if (pmd_none(level2_ident_pgt[i]))
1926 continue;
1927 level2_ident_pgt[i] = pmd_set_flags(level2_ident_pgt[i], _PAGE_NX);
1928 }
1929 }
1930
1919 /* Copy the initial P->M table mappings if necessary. */ 1931 /* Copy the initial P->M table mappings if necessary. */
1920 i = pgd_index(xen_start_info->mfn_list); 1932 i = pgd_index(xen_start_info->mfn_list);
1921 if (i && i < pgd_index(__START_KERNEL_map)) 1933 if (i && i < pgd_index(__START_KERNEL_map))