[PATCH 0/2] Refactor MTRR and PAT initializations

From: Toshi Kani
Date: Thu Mar 10 2016 - 22:53:43 EST


Since 'commit 9cd25aac1f44 ("x86/mm/pat: Emulate PAT when it
is disabled")', we emulate a PAT table when PAT is disabled.
This requires pat_init() be called even if PAT is disabled,
which revealed a long standing issue that PAT is left enabled
without calling pat_init() at all.

pat_init() is called from MTRR code since it relies on MTRR's
rendezvous handler to initialize PAT for all APs . However,
when CPU does not support MTRR, ex. qemu32's virtual CPU, MTRR
is set disabled and does not call pat_init(). There is no
interface available for MTRR to disable PAT, either.

This patch-set refactors MTRR and PAT initializations to make
sure that PAT is properly initialized in all cases.

---
Toshi Kani (2):
1/2 x86/mm/pat: Change pat_disable() to emulate PAT table
2/2 x86/mtrr: Refactor PAT initialization code

---
arch/x86/include/asm/mtrr.h | 6 ++-
arch/x86/include/asm/pat.h | 1 +
arch/x86/kernel/cpu/mtrr/generic.c | 24 ++++++-----
arch/x86/kernel/cpu/mtrr/main.c | 13 +++++-
arch/x86/kernel/cpu/mtrr/mtrr.h | 1 +
arch/x86/mm/pat.c | 84 +++++++++++++++++++++++---------------
6 files changed, 84 insertions(+), 45 deletions(-)