coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mca_bert.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <amdblocks/mca.h>
4 #include <cpu/amd/msr.h>
5 #include <cpu/x86/msr.h>
6 #include <acpi/acpi.h>
7 #include <console/console.h>
8 #include <arch/bert_storage.h>
9 #include <cper.h>
10 #include <types.h>
11 #include "mca_common_defs.h"
12 
13 static inline size_t mca_report_size_reqd(void)
14 {
15  size_t size;
16 
17  size = sizeof(acpi_generic_error_status_t);
18 
19  size += sizeof(acpi_hest_generic_data_v300_t);
20  size += sizeof(cper_proc_generic_error_section_t);
21 
22  size += sizeof(acpi_hest_generic_data_v300_t);
23  size += sizeof(cper_ia32x64_proc_error_section_t);
24 
25  /* Check Error */
26  size += cper_ia32x64_check_sz();
27 
28  /* Context of MCG_CAP, MCG_STAT, MCG_CTL */
30 
31  /* Context of MCi_CTL, MCi_STATUS, MCi_ADDR, MCi_MISC */
33 
34  /* Context of CTL_MASK */
36 
37  return size;
38 }
39 
40 /* Convert an error reported by an MCA bank into BERT information to be reported
41  * by the OS. The ACPI driver doesn't recognize/parse the IA32/X64 structure,
42  * which is the best method to report MSR context. As a result, add two
43  * structures: A "processor generic error" that is parsed, and an IA32/X64 one
44  * to capture complete information.
45  *
46  * Future work may attempt to interpret the specific Family 15h error symptoms
47  * found in the MCA registers. This data could enhance the reporting of the
48  * Processor Generic section and the failing error/check added to the
49  * IA32/X64 section.
50  */
52 {
60 
62  goto failed;
63 
65  if (!status)
66  goto failed;
67 
68  gen_entry = acpi_hest_generic_data3(status);
69  gen_sec = section_of_acpientry(gen_sec, gen_entry);
70 
71  fill_generic_section(gen_sec, mci);
72 
73  x86_entry = bert_append_ia32x64(status);
74  x86_sec = section_of_acpientry(x86_sec, x86_entry);
75 
76  chk = new_cper_ia32x64_check(status, x86_sec, error_to_chktype(mci));
77  if (!chk)
78  goto failed;
79 
80  ctx = cper_new_ia32x64_context_msr(status, x86_sec, IA32_MCG_CAP, 3);
81  if (!ctx)
82  goto failed;
83  ctx = cper_new_ia32x64_context_msr(status, x86_sec, IA32_MC_CTL(mci->bank), 4);
84  if (!ctx)
85  goto failed;
86  ctx = cper_new_ia32x64_context_msr(status, x86_sec, MC_CTL_MASK(mci->bank), 1);
87  if (!ctx)
88  goto failed;
89 
90  return;
91 
92 failed:
93  /* We're here because of a hardware error, don't break something else */
94  printk(BIOS_ERR, "Not enough room in BERT region for Machine Check error\n");
95 }
size_t bert_storage_remaining(void)
cper_ia32x64_context_t * cper_new_ia32x64_context_msr(acpi_generic_error_status_t *status, cper_ia32x64_proc_error_section_t *x86err, u32 addr, int num)
cper_ia32x64_proc_error_info_t * new_cper_ia32x64_check(acpi_generic_error_status_t *status, cper_ia32x64_proc_error_section_t *x86err, enum cper_x86_check_type type)
acpi_generic_error_status_t * bert_new_event(guid_t *guid)
acpi_hest_generic_data_v300_t * bert_append_ia32x64(acpi_generic_error_status_t *status)
#define section_of_acpientry(A, B)
Definition: bert_storage.h:91
static acpi_hest_generic_data_v300_t * acpi_hest_generic_data3(acpi_generic_error_status_t *status)
Definition: bert_storage.h:83
#define printk(level,...)
Definition: stdlib.h:16
struct cper_proc_generic_error_section cper_proc_generic_error_section_t
static size_t cper_ia32x64_ctx_sz_bytype(int type, int arr_num)
Definition: cper.h:430
static size_t cper_ia32x64_check_sz(void)
Definition: cper.h:451
struct cper_ia32x64_proc_error_section cper_ia32x64_proc_error_section_t
#define CPER_SEC_PROC_GENERIC_GUID
Definition: cper.h:45
#define CPER_IA32X64_CTX_MSR
Definition: cper.h:297
struct acpi_generic_error_status acpi_generic_error_status_t
struct acpi_hest_generic_data_v300 acpi_hest_generic_data_v300_t
#define MC_CTL_MASK(bank)
Definition: msr.h:22
#define IA32_MC_CTL(bank)
Definition: msr.h:60
#define IA32_MCG_CAP
Definition: msr.h:39
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
void build_bert_mca_error(struct mca_bank_status *mci)
Definition: mca_bert.c:51
static size_t mca_report_size_reqd(void)
Definition: mca_bert.c:13
void fill_generic_section(cper_proc_generic_error_section_t *sec, struct mca_bank_status *mci)
enum cper_x86_check_type error_to_chktype(struct mca_bank_status *mci)
unsigned int bank
Definition: mca.h:10