Commit 2cc42bac authored by Jan Beulich's avatar Jan Beulich Committed by Boris Ostrovsky

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 4763ed4d ("x86, mm:
Clean up and simplify NX enablement") when switching away from the
direct EFER read.
Signed-off-by: default avatarJan Beulich <jbeulich@suse.com>
Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
parent c4f9d9cb
...@@ -87,6 +87,8 @@ ...@@ -87,6 +87,8 @@
#include "multicalls.h" #include "multicalls.h"
#include "pmu.h" #include "pmu.h"
#include "../kernel/cpu/cpu.h" /* get_cpu_cap() */
void *xen_initial_gdt; void *xen_initial_gdt;
static int xen_cpu_up_prepare_pv(unsigned int cpu); static int xen_cpu_up_prepare_pv(unsigned int cpu);
...@@ -1249,6 +1251,7 @@ asmlinkage __visible void __init xen_start_kernel(void) ...@@ -1249,6 +1251,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
__userpte_alloc_gfp &= ~__GFP_HIGHMEM; __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
/* Work out if we support NX */ /* Work out if we support NX */
get_cpu_cap(&boot_cpu_data);
x86_configure_nx(); x86_configure_nx();
/* Get mfn list */ /* Get mfn list */
......
...@@ -1916,6 +1916,18 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn) ...@@ -1916,6 +1916,18 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
/* Graft it onto L4[511][510] */ /* Graft it onto L4[511][510] */
copy_page(level2_kernel_pgt, l2); copy_page(level2_kernel_pgt, l2);
/*
* Zap execute permission from the ident map. Due to the sharing of
* L1 entries we need to do this in the L2.
*/
if (__supported_pte_mask & _PAGE_NX) {
for (i = 0; i < PTRS_PER_PMD; ++i) {
if (pmd_none(level2_ident_pgt[i]))
continue;
level2_ident_pgt[i] = pmd_set_flags(level2_ident_pgt[i], _PAGE_NX);
}
}
/* Copy the initial P->M table mappings if necessary. */ /* Copy the initial P->M table mappings if necessary. */
i = pgd_index(xen_start_info->mfn_list); i = pgd_index(xen_start_info->mfn_list);
if (i && i < pgd_index(__START_KERNEL_map)) if (i && i < pgd_index(__START_KERNEL_map))
......
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