cpu/x86/mtrr: Assert that MSR arrays are fully initialized
commit5b922726e1220585cbae4e0392817dcca3a2b11f
authorJacob Garber <jgarber1@ualberta.ca>
Tue, 28 May 2019 17:47:49 +0000 (28 11:47 -0600)
committerPatrick Georgi <pgeorgi@google.com>
Wed, 29 May 2019 20:11:50 +0000 (29 20:11 +0000)
treeb4380b10e57720697a64ea522a7be1acd8e96498
parentbdcb4d37506f04e205f11ff45fd0925cf2a5cbc1
cpu/x86/mtrr: Assert that MSR arrays are fully initialized

The initialization logic for the fixed_msrs and msr_index arrays depends
on the contents of the fixed MTRR descriptor. However, Coverity is unable
to check these values and believes (incorrectly) that the arrays may not
be entirely initialized. An assert was added in commit b28025a434 to
ensure that one of the loops is entered, but it is simplest to just
check that msr_num has iterated over the entire array after the loops
are over. This also acts as a sanity check that the values in the MTRR
descriptor were hardcoded correctly.

Change-Id: Ia573792f74aa6ea5e659c1e2253f112184fbb0a5
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Found-by: Coverity CID 1370582
Reviewed-on: https://review.coreboot.org/c/coreboot/+/33048
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Lance Zhao <lance.zhao@gmail.com>
src/cpu/x86/mtrr/mtrr.c