Skip to content

x86: Full support of PAT

Juergen Gross lkml xen-devel 6 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest18 patches 10 repliesIn review
  2. v43 patches 5 repliesSuperseded
  3. v3 posting 2/23 patches 3 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v3 posting 1/23 patches4 repliesSuperseded
v23 patches3 repliesSuperseded
v13 patches10 repliesSuperseded

Changes in v6 from the cover letter

- add new patch 10 (x86: Remove looking for setting of _PAGE_PAT_LARGE in pageattr.c) as suggested by Thomas Gleixner
- replaced SOB of Stefan Bader by "Based-on-patch-by:" as suggested by Borislav Petkov

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/18x86: Make page cache mode a real typearch/x86/include/asm/pgtable_types.h arch/x86/mm/init.c+101 -14 replies
2/18x86: Use new cache mode type in include/asm/fb.harch/x86/include/asm/fb.h+5 -10 replies
3/18x86: Use new cache mode type in drivers/video/fbdev/gbefb.cdrivers/video/fbdev/gbefb.c+2 -11 reply
4/18x86: Use new cache mode type in drivers/video/fbdev/vermiliondrivers/video/fbdev/vermilion/vermilion.c+4 -20 replies
5/18x86: Use new cache mode type in arch/x86/pciarch/x86/pci/i386.c+2 -20 replies
6/18x86: Use new cache mode type in arch/x86/mm/init_64.carch/x86/mm/init_64.c+6 -30 replies
7/18x86: Use new cache mode type in asm/pgtable.harch/x86/include/asm/pgtable.h arch/x86/mm/ioremap.c arch/x86/mm/pat.c+18 -120 replies
8/18x86: Use new cache mode type in mm/iomap_32.carch/x86/include/asm/pat.h arch/x86/mm/iomap_32.c arch/x86/mm/pat.c+18 -140 replies
9/18x86: Use new cache mode type in track_pfn_remap() and track_pfn_insert()arch/x86/mm/pat.c+16 -160 replies
10/18x86: Remove looking for setting of _PAGE_PAT_LARGE in pageattr.carch/x86/mm/pageattr.c+1 -11 reply
11/18x86: Use new cache mode type in setting page attributesarch/x86/mm/pageattr.c+28 -240 replies
12/18x86: Use new cache mode type in mm/ioremap.carch/x86/include/asm/io.h arch/x86/include/asm/pat.h arch/x86/mm/ioremap.c +1 more+44 -370 replies
13/18x86: Use new cache mode type in memtype related functionsarch/x86/include/asm/cacheflush.h arch/x86/include/asm/pat.h arch/x86/mm/ioremap.c +4 more+96 -900 replies
14/18x86: Clean up pgtable_types.harch/x86/include/asm/pgtable_types.h+1 -200 replies
15/18x86: Support PAT bit in pagetable dump for lower levelsarch/x86/mm/dump_pagetables.c+11 -130 replies
16/18x86: Respect PAT bit when copying pte values between large and normal pagesarch/x86/mm/pageattr.c+23 -100 replies
17/18x86: Enable PAT to use cache mode translation tablesarch/x86/include/asm/pat.h arch/x86/include/asm/pgtable_types.h arch/x86/mm/init.c +2 more+63 -20 replies
18/18xen: Support Xen pv-domains using PATarch/x86/xen/enlighten.c arch/x86/xen/mmu.c arch/x86/xen/xen-ops.h+8 -650 replies

Reviews trailers per patch

All 18 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchStefan BaderThomas GleixnerToshi KaniKonrad Rzeszutek WilkDavid VrabelTomi Valkeinen
SeriesR-b
1/18Based-on-patch-by R-b
2/18Based-on-patch-by R-b
3/18Based-on-patch-by R-b A-b
4/18Based-on-patch-by R-b
5/18Based-on-patch-by R-b
6/18Based-on-patch-by R-b
7/18Based-on-patch-by R-b
8/18Based-on-patch-by R-b
9/18Based-on-patch-by R-b
10/18R-b
11/18Based-on-patch-by R-b
12/18Based-on-patch-by R-b
13/18Based-on-patch-by R-b
14/18Based-on-patch-by R-b
15/18Based-on-patch-by R-b
16/18Based-on-patch-by R-b
17/18R-b R-b R-b
18/18R-b R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 6 reviewers.

Read the v6 thread

Cover letter [PATCH V6 00/18] x86: Full support of PAT

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

Changes in V6:
- add new patch 10 (x86: Remove looking for setting of _PAGE_PAT_LARGE in pageattr.c) as suggested by Thomas Gleixner
- replaced SOB of Stefan Bader by "Based-on-patch-by:" as suggested by Borislav Petkov

Changes in V5:
- split up first patch as requested by Ingo Molnar and Thomas Gleixner
- add a helper function in pat_init_cache_modes() as requested by Ingo Molnar

Changes in V4:
- rebased to 3.18-rc2

Changes in V3:
- corrected two minor nits (UC_MINUS, again) detected by Toshi Kani

Changes in V2:
- simplified handling of PAT MSR write under Xen as suggested by David Vrabel
- removed resetting of pat_enabled under Xen
- two small corrections requested by Toshi Kani (UC_MINUS cache mode in vermilion driver, fix 32 bit kernel build failure)
- correct build error on non-x86 arch by moving definition of update_cache_mode_entry() to x86 specific header

Changes since RFC:
- renamed functions and variables as suggested by Toshi Kani
- corrected cache mode bits for WT and WP
- modified handling of PAT MSR write under Xen as suggested by Jan Beulich

Juergen Gross (18):
x86: Make page cache mode a real type
x86: Use new cache mode type in include/asm/fb.h
x86: Use new cache mode type in drivers/video/fbdev/gbefb.c
x86: Use new cache mode type in drivers/video/fbdev/vermilion
x86: Use new cache mode type in arch/x86/pci
x86: Use new cache mode type in arch/x86/mm/init_64.c
x86: Use new cache mode type in asm/pgtable.h
x86: Use new cache mode type in mm/iomap_32.c
x86: Use new cache mode type in track_pfn_remap() and
track_pfn_insert()
x86: Remove looking for setting of _PAGE_PAT_LARGE in pageattr.c
x86: Use new cache mode type in setting page attributes
x86: Use new cache mode type in mm/ioremap.c
x86: Use new cache mode type in memtype related functions
x86: Clean up pgtable_types.h
x86: Support PAT bit in pagetable dump for lower levels
x86: Respect PAT bit when copying pte values between large and normal
pages
x86: Enable PAT to use cache mode translation tables
xen: Support Xen pv-domains using PAT

 arch/x86/include/asm/cacheflush.h         |  38 ++++---
 arch/x86/include/asm/fb.h                 |   6 +-
 arch/x86/include/asm/io.h                 |   2 +-
 arch/x86/include/asm/pat.h                |   7 +-
 arch/x86/include/asm/pgtable.h            |  19 ++--
 arch/x86/include/asm/pgtable_types.h      |  96 ++++++++++++----
 arch/x86/mm/dump_pagetables.c             |  24 ++--
 arch/x86/mm/init.c                        |  37 +++++++
 arch/x86/mm/init_64.c                     |   9 +-
 arch/x86/mm/iomap_32.c                    |  12 +-
 arch/x86/mm/ioremap.c                     |  63 ++++++-----
 arch/x86/mm/mm_internal.h                 |   2 +
 arch/x86/mm/pageattr.c                    |  84 ++++++++------
 arch/x86/mm/pat.c                         | 176 +++++++++++++++++++-----------
 arch/x86/mm/pat_internal.h                |  22 ++--
 arch/x86/mm/pat_rbtree.c                  |   8 +-
 arch/x86/pci/i386.c                       |   4 +-
 arch/x86/xen/enlighten.c                  |  25 ++---
 arch/x86/xen/mmu.c                        |  47 +-------
 arch/x86/xen/xen-ops.h                    |   1 -
 drivers/video/fbdev/gbefb.c               |   3 +-
 drivers/video/fbdev/vermilion/vermilion.c |   6 +-
 22 files changed, 412 insertions(+), 279 deletions(-)
Signature · 1 line
1.8.4.5