From 65deb24a8e908825789d74950bcdaf4637697929 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Tue, 13 Jul 2021 22:35:39 +0200 Subject: soc/amd/stoneyridge: add and use mca_is_valid_bank & mca_get_bank_name This patch changes the way how the not implemented MCA bank 3 gets skipped. For the not implemented bank 3 the name gets set to NULL resulting in mca_is_valid_bank returning false causing the bank to get skipped. This is a preparation for commonizing the MCA(X) handing in the soc/amd sub-tree. Change-Id: I40d6a6752504d804c45b445fce7e763e80161211 Signed-off-by: Felix Held Reviewed-on: https://review.coreboot.org/c/coreboot/+/56277 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth --- src/soc/amd/stoneyridge/mca.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/soc/amd/stoneyridge/mca.c b/src/soc/amd/stoneyridge/mca.c index 50e7fdd6f3..bdb06ccfa2 100644 --- a/src/soc/amd/stoneyridge/mca.c +++ b/src/soc/amd/stoneyridge/mca.c @@ -139,18 +139,33 @@ static const char *const mca_bank_name[] = { [0] = "Load-store unit", [1] = "Instruction fetch unit", [2] = "Combined unit", - [3] = "Reserved", + /* Bank 3 is reserved and not all corresponding MSRs are implemented in Family 15h. + Accessing non-existing MSRs causes a general protection fault. */ + [3] = NULL, [4] = "Northbridge", [5] = "Execution unit", [6] = "Floating point unit" }; +static bool mca_is_valid_bank(unsigned int bank) +{ + return (bank < ARRAY_SIZE(mca_bank_name) && mca_bank_name[bank] != NULL); +} + +static const char *mca_get_bank_name(unsigned int bank) +{ + if (mca_is_valid_bank(bank)) + return mca_bank_name[bank]; + else + return ""; +} + static void mca_print_error(unsigned int bank) { msr_t msr; printk(BIOS_WARNING, "#MC Error: core %u, bank %u %s\n", initial_lapicid(), bank, - mca_bank_name[bank]); + mca_get_bank_name(bank)); msr = rdmsr(IA32_MC_STATUS(bank)); printk(BIOS_WARNING, " MC%u_STATUS = %08x_%08x\n", bank, msr.hi, msr.lo); @@ -173,7 +188,7 @@ static void mca_check_all_banks(void) return; for (unsigned int i = 0 ; i < num_banks ; i++) { - if (i == 3) /* Reserved in Family 15h */ + if (!mca_is_valid_bank(i)) continue; mci.bank = i; -- cgit v1.2.3