Commit ebb9cfe2 authored by Jeremy Fitzhardinge's avatar Jeremy Fitzhardinge Committed by Ingo Molnar

xen: don't drop NX bit

Because NX is now enforced properly, we must put the hypercall page
into the .text segment so that it is executable.
Signed-off-by: default avatarJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Cc: Stable Kernel <stable@kernel.org>
Cc: the arch/x86 maintainers <x86@kernel.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 05345b0f
...@@ -179,46 +179,54 @@ void xen_set_pte_at(struct mm_struct *mm, unsigned long addr, ...@@ -179,46 +179,54 @@ void xen_set_pte_at(struct mm_struct *mm, unsigned long addr,
preempt_enable(); preempt_enable();
} }
pteval_t xen_pte_val(pte_t pte) /* Assume pteval_t is equivalent to all the other *val_t types. */
static pteval_t pte_mfn_to_pfn(pteval_t val)
{ {
pteval_t ret = pte.pte; if (val & _PAGE_PRESENT) {
unsigned long mfn = (val & PTE_MASK) >> PAGE_SHIFT;
pteval_t flags = val & ~PTE_MASK;
val = (mfn_to_pfn(mfn) << PAGE_SHIFT) | flags;
}
if (ret & _PAGE_PRESENT) return val;
ret = machine_to_phys(XMADDR(ret)).paddr | _PAGE_PRESENT; }
return ret; static pteval_t pte_pfn_to_mfn(pteval_t val)
{
if (val & _PAGE_PRESENT) {
unsigned long pfn = (val & PTE_MASK) >> PAGE_SHIFT;
pteval_t flags = val & ~PTE_MASK;
val = (pfn_to_mfn(pfn) << PAGE_SHIFT) | flags;
}
return val;
}
pteval_t xen_pte_val(pte_t pte)
{
return pte_mfn_to_pfn(pte.pte);
} }
pgdval_t xen_pgd_val(pgd_t pgd) pgdval_t xen_pgd_val(pgd_t pgd)
{ {
pgdval_t ret = pgd.pgd; return pte_mfn_to_pfn(pgd.pgd);
if (ret & _PAGE_PRESENT)
ret = machine_to_phys(XMADDR(ret)).paddr | _PAGE_PRESENT;
return ret;
} }
pte_t xen_make_pte(pteval_t pte) pte_t xen_make_pte(pteval_t pte)
{ {
if (pte & _PAGE_PRESENT) pte = pte_pfn_to_mfn(pte);
pte = phys_to_machine(XPADDR(pte)).maddr; return native_make_pte(pte);
return (pte_t){ .pte = pte };
} }
pgd_t xen_make_pgd(pgdval_t pgd) pgd_t xen_make_pgd(pgdval_t pgd)
{ {
if (pgd & _PAGE_PRESENT) pgd = pte_pfn_to_mfn(pgd);
pgd = phys_to_machine(XPADDR(pgd)).maddr; return native_make_pgd(pgd);
return (pgd_t){ pgd };
} }
pmdval_t xen_pmd_val(pmd_t pmd) pmdval_t xen_pmd_val(pmd_t pmd)
{ {
pmdval_t ret = native_pmd_val(pmd); return pte_mfn_to_pfn(pmd.pmd);
if (ret & _PAGE_PRESENT)
ret = machine_to_phys(XMADDR(ret)).paddr | _PAGE_PRESENT;
return ret;
} }
#ifdef CONFIG_X86_PAE #ifdef CONFIG_X86_PAE
void xen_set_pud(pud_t *ptr, pud_t val) void xen_set_pud(pud_t *ptr, pud_t val)
...@@ -265,9 +273,7 @@ void xen_pmd_clear(pmd_t *pmdp) ...@@ -265,9 +273,7 @@ void xen_pmd_clear(pmd_t *pmdp)
pmd_t xen_make_pmd(pmdval_t pmd) pmd_t xen_make_pmd(pmdval_t pmd)
{ {
if (pmd & _PAGE_PRESENT) pmd = pte_pfn_to_mfn(pmd);
pmd = phys_to_machine(XPADDR(pmd)).maddr;
return native_make_pmd(pmd); return native_make_pmd(pmd);
} }
#else /* !PAE */ #else /* !PAE */
......
...@@ -17,7 +17,7 @@ ENTRY(startup_xen) ...@@ -17,7 +17,7 @@ ENTRY(startup_xen)
__FINIT __FINIT
.pushsection .bss.page_aligned .pushsection .text
.align PAGE_SIZE_asm .align PAGE_SIZE_asm
ENTRY(hypercall_page) ENTRY(hypercall_page)
.skip 0x1000 .skip 0x1000
......
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