aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/xen/mmu.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/xen/mmu.c')
-rw-r--r--arch/x86/xen/mmu.c53
1 files changed, 50 insertions, 3 deletions
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index b2371671b11c..67b41017f7b8 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -55,6 +55,7 @@
55#include <asm/e820.h> 55#include <asm/e820.h>
56#include <asm/linkage.h> 56#include <asm/linkage.h>
57#include <asm/page.h> 57#include <asm/page.h>
58#include <asm/pat.h>
58 59
59#include <asm/xen/hypercall.h> 60#include <asm/xen/hypercall.h>
60#include <asm/xen/hypervisor.h> 61#include <asm/xen/hypervisor.h>
@@ -780,10 +781,18 @@ static pteval_t iomap_pte(pteval_t val)
780 781
781pteval_t xen_pte_val(pte_t pte) 782pteval_t xen_pte_val(pte_t pte)
782{ 783{
783 if (xen_initial_domain() && (pte.pte & _PAGE_IOMAP)) 784 pteval_t pteval = pte.pte;
784 return pte.pte;
785 785
786 return pte_mfn_to_pfn(pte.pte); 786 /* If this is a WC pte, convert back from Xen WC to Linux WC */
787 if ((pteval & (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT)) == _PAGE_PAT) {
788 WARN_ON(!pat_enabled);
789 pteval = (pteval & ~_PAGE_PAT) | _PAGE_PWT;
790 }
791
792 if (xen_initial_domain() && (pteval & _PAGE_IOMAP))
793 return pteval;
794
795 return pte_mfn_to_pfn(pteval);
787} 796}
788PV_CALLEE_SAVE_REGS_THUNK(xen_pte_val); 797PV_CALLEE_SAVE_REGS_THUNK(xen_pte_val);
789 798
@@ -793,10 +802,48 @@ pgdval_t xen_pgd_val(pgd_t pgd)
793} 802}
794PV_CALLEE_SAVE_REGS_THUNK(xen_pgd_val); 803PV_CALLEE_SAVE_REGS_THUNK(xen_pgd_val);
795 804
805/*
806 * Xen's PAT setup is part of its ABI, though I assume entries 6 & 7
807 * are reserved for now, to correspond to the Intel-reserved PAT
808 * types.
809 *
810 * We expect Linux's PAT set as follows:
811 *
812 * Idx PTE flags Linux Xen Default
813 * 0 WB WB WB
814 * 1 PWT WC WT WT
815 * 2 PCD UC- UC- UC-
816 * 3 PCD PWT UC UC UC
817 * 4 PAT WB WC WB
818 * 5 PAT PWT WC WP WT
819 * 6 PAT PCD UC- UC UC-
820 * 7 PAT PCD PWT UC UC UC
821 */
822
823void xen_set_pat(u64 pat)
824{
825 /* We expect Linux to use a PAT setting of
826 * UC UC- WC WB (ignoring the PAT flag) */
827 WARN_ON(pat != 0x0007010600070106ull);
828}
829
796pte_t xen_make_pte(pteval_t pte) 830pte_t xen_make_pte(pteval_t pte)
797{ 831{
798 phys_addr_t addr = (pte & PTE_PFN_MASK); 832 phys_addr_t addr = (pte & PTE_PFN_MASK);
799 833
834 /* If Linux is trying to set a WC pte, then map to the Xen WC.
835 * If _PAGE_PAT is set, then it probably means it is really
836 * _PAGE_PSE, so avoid fiddling with the PAT mapping and hope
837 * things work out OK...
838 *
839 * (We should never see kernel mappings with _PAGE_PSE set,
840 * but we could see hugetlbfs mappings, I think.).
841 */
842 if (pat_enabled && !WARN_ON(pte & _PAGE_PAT)) {
843 if ((pte & (_PAGE_PCD | _PAGE_PWT)) == _PAGE_PWT)
844 pte = (pte & ~(_PAGE_PCD | _PAGE_PWT)) | _PAGE_PAT;
845 }
846
800 /* 847 /*
801 * Unprivileged domains are allowed to do IOMAPpings for 848 * Unprivileged domains are allowed to do IOMAPpings for
802 * PCI passthrough, but not map ISA space. The ISA 849 * PCI passthrough, but not map ISA space. The ISA