Aaron Durbin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41849 )
Change subject: cpu/x86/mtrr: add helper for setting multiple MTRRs ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/41849/2/src/cpu/x86/mtrr/earlymtrr.... File src/cpu/x86/mtrr/earlymtrr.c:
https://review.coreboot.org/c/coreboot/+/41849/2/src/cpu/x86/mtrr/earlymtrr.... PS2, Line 72: ctx->max_var_mtrrs = get_var_mtrr_count();
Should this call clear_all_var_mtrr() to be sure that we start with no variable MTRRs already set?
I thought about that as well. We either need to clear all or sync the state. Sync'ing the state is way more complicated because all it can do is track the msr usage.
In the end I wanted to leave it to the callers because setting the MSRs directly may not be the intention. postcar_loader doesn't directly manipulate the MSRs, e.g.