John Zhao has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/34249 )
Change subject: cpu/x86: Initialize the argument value msr_index ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/34249/1/src/cpu/x86/mtrr/mtrr.c File src/cpu/x86/mtrr/mtrr.c:
https://review.coreboot.org/c/coreboot/+/34249/1/src/cpu/x86/mtrr/mtrr.c@361 PS1, Line 361: ARRAY_SIZE(fixed_msrs)
I think another way to fix this would be to use msr_num here and in the loop below. […]
"ASSERT(msr_num == NUM_FIXED_MTRRS)" would ensure msr_num equal to NUM_FIXED_MTRRS. By fixed_msrs's definition, "msr_t fixed_msrs[NUM_FIXED_MTRRS]", ARRAY_SIZE(fixed_msrs) equals to NUM_FIXED_MTRRS. so msr_num would be the same value as ARRAY_SIZE(fixed_msrs).
Agreed with you that it would need to add check to prevent writing MRS 0 while we are with memset initially for msr_index. Just updated by adding "ASSERT (msr_index[i] != 0)" in the loop