[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2 1/6] x86/mm/pat: Change PAT to support non-default PAT MSR
$Subject is misleading - there's no non-default PAT MSR - the setting is non-default. On Wed, Mar 16, 2016 at 06:44:57PM -0600, Toshi Kani wrote: > In preparation to fix a regression caused by 'commit 9cd25aac1f44 > ("x86/mm/pat: Emulate PAT when it is disabled")', PAT needs to > support a case that PAT MSR is initialized with a non-default > value. > > When pat_init() is called in PAT disable state, it initializes is called and PAT is disabled > PAT table with the BIOS default value. Xen, however, sets PAT MSR > with a non-default value to enable WC. This causes inconsistency > between PAT table and PAT MSR when PAT is set to disable on Xen. > > Change pat_init() to handle the PAT disable cases properly. Add > pat_keep_handoff_state() to handle two cases when PAT is set to > disable. > 1. CPU supports PAT: Set PAT table to be consistent with PAT MSR. > 2. CPU does not support PAT: Set PAT table to be consistent with > PWT and PCD bits in a PTE. > > Signed-off-by: Toshi Kani <toshi.kani@xxxxxxx> > Cc: Borislav Petkov <bp@xxxxxxx> > Cc: Luis R. Rodriguez <mcgrof@xxxxxxxx> > Cc: Juergen Gross <jgross@xxxxxxxx> > Cc: Ingo Molnar <mingo@xxxxxxxxxx> > Cc: H. Peter Anvin <hpa@xxxxxxxxx> > Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> > --- > arch/x86/mm/pat.c | 80 > +++++++++++++++++++++++++++++++++++++++++------------ > 1 file changed, 62 insertions(+), 18 deletions(-) > > diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c > index 04e2e71..e0a34b0 100644 > --- a/arch/x86/mm/pat.c > +++ b/arch/x86/mm/pat.c > @@ -207,9 +207,6 @@ static void pat_bsp_init(u64 pat) > return; > } > > - if (!pat_enabled()) > - goto done; > - > rdmsrl(MSR_IA32_CR_PAT, tmp_pat); > if (!tmp_pat) { > pat_disable("PAT MSR is 0, disabled."); > @@ -218,15 +215,11 @@ static void pat_bsp_init(u64 pat) > > wrmsrl(MSR_IA32_CR_PAT, pat); > > -done: > pat_init_cache_modes(pat); > } > > static void pat_ap_init(u64 pat) > { > - if (!pat_enabled()) > - return; > - > if (!cpu_has_pat) { > /* > * If this happens we are on a secondary CPU, but switched to > @@ -238,18 +231,43 @@ static void pat_ap_init(u64 pat) > wrmsrl(MSR_IA32_CR_PAT, pat); > } > > -void pat_init(void) > +/** > + * pat_keep_handoff_state - Set PAT table to the handoff state > + * > + * This function keeps PAT in the BIOS handoff state. When CPU supports > + * PAT, it sets PAT table to be consistent with PAT MSR. When CPU does not > + * support PAT, it emulates PAT by setting PAT table consistent with PWT > + * and PCD bits in a PTE. > + * > + * The PAT table is global to all CPUs, which is initialized once at > + * boot-time. Any subsequent calls to this function have no effect. > + */ > +static void pat_keep_handoff_state(void) Static function, no need for "pat_" prefix. Also, no need for the kernel-doc comment. Also, no need for all that handoff nomenclature etc, just call it setup_pat(). Because it does exactly that - it sets up the PAT bits unconditionally, regardless of enabled or not. > { > - u64 pat; > - struct cpuinfo_x86 *c = &boot_cpu_data; > + u64 pat = 0; > + static int set_handoff_done; s/set_handoff_done/pat_setup_done/ -- Regards/Gruss, Boris. SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg) -- _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |