RE: [PATCH v5 10/12] x86/mtrr/main.c: Ask the first online CPU tosave mtrr

From: Yu, Fenghua
Date: Wed Jan 25 2012 - 12:58:20 EST


> From: H. Peter Anvin [mailto:hpa@xxxxxxxxx]
> Sent: Sunday, January 15, 2012 4:08 PM
> On 01/12/2012 04:33 AM, Brian Gerst wrote:
> > On Wed, Jan 11, 2012 at 12:04 PM, Fenghua Yu <fenghua.yu@xxxxxxxxx>
> wrote:
> >> From: Fenghua Yu <fenghua.yu@xxxxxxxxx>
> >>
> >> Ask the first online CPU to save mtrr instead of asking BSP. BSP
> could be
> >> offline when mtrr_save_state() is called.
> >
> > If you can use any non-boot cpu to save the MTRRs why not just use
> the
> > current cpu? They should all be in sync anyways.
> >
>
> A much bigger question: why do we ever bother saving the MTRR state per
> se? We examine the MTRR state -- we have to -- during boot, and it
> should never diverge from the state set by the OS from that point on --
> we'll need to set it back to that. So we should just keep track of
> what
> the correct MTRR state is at all times.

The fixed MTRR state is saved when each CPU is up:
/*
* Save current MTRR state in case it was changed since early boot
* (e.g. by the ACPI SMI) to initialize new CPUs with MTRRs in sync:
*/
mtrr_save_state();
It's saved because MTRR state could be changed since early boot according to the above comment. I haven't found other info source except the comment. If that's true, we may need to save the state, right?

Thanks.

-Fenghua

N‹§²æìr¸›yúèšØb²X¬¶ÇvØ^–)Þ{.nÇ+‰·¥Š{±‘êçzX§¶›¡Ü}©ž²ÆzÚ&j:+v‰¨¾«‘êçzZ+€Ê+zf£¢·hšˆ§~†­†Ûiÿûàz¹®w¥¢¸?™¨è­Ú&¢)ßf”ù^jÇy§m…á@A«a¶Úÿ 0¶ìh®å’i