aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/xen
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-12-10 16:59:34 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-10 16:59:34 -0500
commita023748d53c10850650fe86b1c4a7d421d576451 (patch)
tree761d3f6d2a402ec0835c0ede44b7d55c1b15ec98 /arch/x86/xen
parent773fed910d41e443e495a6bfa9ab1c2b7b13e012 (diff)
parent0dbcae884779fdf7e2239a97ac7488877f0693d9 (diff)
Merge branch 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 mm tree changes from Ingo Molnar: "The biggest change is full PAT support from Jürgen Gross: The x86 architecture offers via the PAT (Page Attribute Table) a way to specify different caching modes in page table entries. The PAT MSR contains 8 entries each specifying one of 6 possible cache modes. A pte references one of those entries via 3 bits: _PAGE_PAT, _PAGE_PWT and _PAGE_PCD. The Linux kernel currently supports only 4 different cache modes. The PAT MSR is set up in a way that the setting of _PAGE_PAT in a pte doesn't matter: the top 4 entries in the PAT MSR are the same as the 4 lower entries. This results in the kernel not supporting e.g. write-through mode. Especially this cache mode would speed up drivers of video cards which now have to use uncached accesses. OTOH some old processors (Pentium) don't support PAT correctly and the Xen hypervisor has been using a different PAT MSR configuration for some time now and can't change that as this setting is part of the ABI. This patch set abstracts the cache mode from the pte and introduces tables to translate between cache mode and pte bits (the default cache mode "write back" is hard-wired to PAT entry 0). The tables are statically initialized with values being compatible to old processors and current usage. As soon as the PAT MSR is changed (or - in case of Xen - is read at boot time) the tables are changed accordingly. Requests of mappings with special cache modes are always possible now, in case they are not supported there will be a fallback to a compatible but slower mode. Summing it up, this patch set adds the following features: - capability to support WT and WP cache modes on processors with full PAT support - processors with no or uncorrect PAT support are still working as today, even if WT or WP cache mode are selected by drivers for some pages - reduction of Xen special handling regarding cache mode Another change is a boot speedup on ridiculously large RAM systems, plus other smaller fixes" * 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (22 commits) x86: mm: Move PAT only functions to mm/pat.c xen: Support Xen pv-domains using PAT x86: Enable PAT to use cache mode translation tables x86: Respect PAT bit when copying pte values between large and normal pages x86: Support PAT bit in pagetable dump for lower levels x86: Clean up pgtable_types.h x86: Use new cache mode type in memtype related functions x86: Use new cache mode type in mm/ioremap.c x86: Use new cache mode type in setting page attributes x86: Remove looking for setting of _PAGE_PAT_LARGE in pageattr.c x86: Use new cache mode type in track_pfn_remap() and track_pfn_insert() x86: Use new cache mode type in mm/iomap_32.c x86: Use new cache mode type in asm/pgtable.h x86: Use new cache mode type in arch/x86/mm/init_64.c x86: Use new cache mode type in arch/x86/pci x86: Use new cache mode type in drivers/video/fbdev/vermilion x86: Use new cache mode type in drivers/video/fbdev/gbefb.c x86: Use new cache mode type in include/asm/fb.h x86: Make page cache mode a real type x86: mm: Use 2GB memory block size on large-memory x86-64 systems ...
Diffstat (limited to 'arch/x86/xen')
-rw-r--r--arch/x86/xen/enlighten.c25
-rw-r--r--arch/x86/xen/mmu.c47
-rw-r--r--arch/x86/xen/xen-ops.h1
3 files changed, 8 insertions, 65 deletions
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index fac5e4f9607c..6bf3a13e3e0f 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1100,12 +1100,6 @@ static int xen_write_msr_safe(unsigned int msr, unsigned low, unsigned high)
1100 /* Fast syscall setup is all done in hypercalls, so 1100 /* Fast syscall setup is all done in hypercalls, so
1101 these are all ignored. Stub them out here to stop 1101 these are all ignored. Stub them out here to stop
1102 Xen console noise. */ 1102 Xen console noise. */
1103 break;
1104
1105 case MSR_IA32_CR_PAT:
1106 if (smp_processor_id() == 0)
1107 xen_set_pat(((u64)high << 32) | low);
1108 break;
1109 1103
1110 default: 1104 default:
1111 ret = native_write_msr_safe(msr, low, high); 1105 ret = native_write_msr_safe(msr, low, high);
@@ -1561,10 +1555,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
1561 1555
1562 /* Prevent unwanted bits from being set in PTEs. */ 1556 /* Prevent unwanted bits from being set in PTEs. */
1563 __supported_pte_mask &= ~_PAGE_GLOBAL; 1557 __supported_pte_mask &= ~_PAGE_GLOBAL;
1564#if 0
1565 if (!xen_initial_domain())
1566#endif
1567 __supported_pte_mask &= ~(_PAGE_PWT | _PAGE_PCD);
1568 1558
1569 /* 1559 /*
1570 * Prevent page tables from being allocated in highmem, even 1560 * Prevent page tables from being allocated in highmem, even
@@ -1618,14 +1608,6 @@ asmlinkage __visible void __init xen_start_kernel(void)
1618 */ 1608 */
1619 acpi_numa = -1; 1609 acpi_numa = -1;
1620#endif 1610#endif
1621#ifdef CONFIG_X86_PAT
1622 /*
1623 * For right now disable the PAT. We should remove this once
1624 * git commit 8eaffa67b43e99ae581622c5133e20b0f48bcef1
1625 * (xen/pat: Disable PAT support for now) is reverted.
1626 */
1627 pat_enabled = 0;
1628#endif
1629 /* Don't do the full vcpu_info placement stuff until we have a 1611 /* Don't do the full vcpu_info placement stuff until we have a
1630 possible map and a non-dummy shared_info. */ 1612 possible map and a non-dummy shared_info. */
1631 per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0]; 1613 per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0];
@@ -1636,6 +1618,13 @@ asmlinkage __visible void __init xen_start_kernel(void)
1636 xen_raw_console_write("mapping kernel into physical memory\n"); 1618 xen_raw_console_write("mapping kernel into physical memory\n");
1637 xen_setup_kernel_pagetable((pgd_t *)xen_start_info->pt_base, xen_start_info->nr_pages); 1619 xen_setup_kernel_pagetable((pgd_t *)xen_start_info->pt_base, xen_start_info->nr_pages);
1638 1620
1621 /*
1622 * Modify the cache mode translation tables to match Xen's PAT
1623 * configuration.
1624 */
1625
1626 pat_init_cache_modes();
1627
1639 /* keep using Xen gdt for now; no urgent need to change it */ 1628 /* keep using Xen gdt for now; no urgent need to change it */
1640 1629
1641#ifdef CONFIG_X86_32 1630#ifdef CONFIG_X86_32
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index a8a1a3d08d4d..9855eb8ee4b3 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -410,13 +410,7 @@ static pteval_t pte_pfn_to_mfn(pteval_t val)
410__visible pteval_t xen_pte_val(pte_t pte) 410__visible pteval_t xen_pte_val(pte_t pte)
411{ 411{
412 pteval_t pteval = pte.pte; 412 pteval_t pteval = pte.pte;
413#if 0 413
414 /* If this is a WC pte, convert back from Xen WC to Linux WC */
415 if ((pteval & (_PAGE_PAT | _PAGE_PCD | _PAGE_PWT)) == _PAGE_PAT) {
416 WARN_ON(!pat_enabled);
417 pteval = (pteval & ~_PAGE_PAT) | _PAGE_PWT;
418 }
419#endif
420 return pte_mfn_to_pfn(pteval); 414 return pte_mfn_to_pfn(pteval);
421} 415}
422PV_CALLEE_SAVE_REGS_THUNK(xen_pte_val); 416PV_CALLEE_SAVE_REGS_THUNK(xen_pte_val);
@@ -427,47 +421,8 @@ __visible pgdval_t xen_pgd_val(pgd_t pgd)
427} 421}
428PV_CALLEE_SAVE_REGS_THUNK(xen_pgd_val); 422PV_CALLEE_SAVE_REGS_THUNK(xen_pgd_val);
429 423
430/*
431 * Xen's PAT setup is part of its ABI, though I assume entries 6 & 7
432 * are reserved for now, to correspond to the Intel-reserved PAT
433 * types.
434 *
435 * We expect Linux's PAT set as follows:
436 *
437 * Idx PTE flags Linux Xen Default
438 * 0 WB WB WB
439 * 1 PWT WC WT WT
440 * 2 PCD UC- UC- UC-
441 * 3 PCD PWT UC UC UC
442 * 4 PAT WB WC WB
443 * 5 PAT PWT WC WP WT
444 * 6 PAT PCD UC- rsv UC-
445 * 7 PAT PCD PWT UC rsv UC
446 */
447
448void xen_set_pat(u64 pat)
449{
450 /* We expect Linux to use a PAT setting of
451 * UC UC- WC WB (ignoring the PAT flag) */
452 WARN_ON(pat != 0x0007010600070106ull);
453}
454
455__visible pte_t xen_make_pte(pteval_t pte) 424__visible pte_t xen_make_pte(pteval_t pte)
456{ 425{
457#if 0
458 /* If Linux is trying to set a WC pte, then map to the Xen WC.
459 * If _PAGE_PAT is set, then it probably means it is really
460 * _PAGE_PSE, so avoid fiddling with the PAT mapping and hope
461 * things work out OK...
462 *
463 * (We should never see kernel mappings with _PAGE_PSE set,
464 * but we could see hugetlbfs mappings, I think.).
465 */
466 if (pat_enabled && !WARN_ON(pte & _PAGE_PAT)) {
467 if ((pte & (_PAGE_PCD | _PAGE_PWT)) == _PAGE_PWT)
468 pte = (pte & ~(_PAGE_PCD | _PAGE_PWT)) | _PAGE_PAT;
469 }
470#endif
471 pte = pte_pfn_to_mfn(pte); 426 pte = pte_pfn_to_mfn(pte);
472 427
473 return native_make_pte(pte); 428 return native_make_pte(pte);
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
index 28c7e0be56e4..4ab9298c5e17 100644
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -33,7 +33,6 @@ extern unsigned long xen_max_p2m_pfn;
33 33
34void xen_mm_pin_all(void); 34void xen_mm_pin_all(void);
35void xen_mm_unpin_all(void); 35void xen_mm_unpin_all(void);
36void xen_set_pat(u64);
37 36
38char * __init xen_memory_setup(void); 37char * __init xen_memory_setup(void);
39char * xen_auto_xlated_memory_setup(void); 38char * xen_auto_xlated_memory_setup(void);