Debian Codegraph @

src/soc/intel/xeon_sp/gnr/cpu.c

raw symbols SCIP
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 #include <cpu/intel/common/common.h>
4 #include <cpu/intel/microcode.h>
5 #include <cpu/intel/smm_reloc.h>
6 #include <cpu/x86/mp.h>
7 #include <cpu/x86/mtrr.h>
8 #include <intelblocks/cpulib.h>
9 #include <intelblocks/mp_init.h>
10 #include <soc/smmrelocate.h>
11 #include <soc/soc_util.h>
12 #include <soc/util.h>
13
14 #include "chip.h"
15
16 static const void *microcode_patch;
17
18 static const config_t *chip_config = NULL;
19
20 bool cpu_soc_is_in_untrusted_mode(void)
21 {
22 // FIXME: not implemented yet
23 return false;
24 }
25
26 void get_microcode_info(const void **microcode, int *parallel)
27 {
28 *microcode = intel_microcode_find();
29 *parallel = 0;
30 }
31
32 static void each_cpu_init(struct device *cpu)
33 {
34 printk(BIOS_SPEW, "%s dev: %s, cpu: %lu, apic_id: 0x%x\n",
35 __func__, dev_path(cpu), cpu_index(), cpu->path.apic.apic_id);
36
37 /* Only lock and let vmx enabled by FSP to avoid FSP always triggering power good reset
38 due to vmx configuration conflict */
39 set_feature_ctrl_lock();
40 }
41
42 static struct device_operations cpu_dev_ops = {
43 .init = each_cpu_init,
44 };
45
46 static const struct cpu_device_id cpu_table[] = {
47 { X86_VENDOR_INTEL, CPUID_GRANITERAPIDS, CPUID_ALL_STEPPINGS_MASK },
48 { X86_VENDOR_INTEL, CPUID_SIERRAFOREST, CPUID_ALL_STEPPINGS_MASK },
49 CPU_TABLE_END
50 };
51
52 static const struct cpu_driver driver __cpu_driver = {
53 .ops = &cpu_dev_ops,
54 .id_table = cpu_table,
55 };
56
57 /*
58 * Do essential initialization tasks before APs can be fired up
59 */
60 static void pre_mp_init(void)
61 {
62 x86_setup_mtrrs_with_detect();
63 x86_mtrr_check();
64 }
65
66 static void post_mp_init(void)
67 {
68 if (CONFIG(HAVE_SMI_HANDLER))
69 global_smi_enable();
70 }
71
72 static const struct mp_ops mp_ops = {
73 .pre_mp_init = pre_mp_init,
74 .get_cpu_count = get_platform_thread_count,
75 #if CONFIG(HAVE_SMI_HANDLER)
76 .get_smm_info = get_smm_info,
77 .pre_mp_smm_init = smm_southbridge_clear_state,
78 .relocation_handler = smm_relocation_handler,
79 #endif
80 .get_microcode_info = get_microcode_info,
81 .post_mp_init = post_mp_init,
82 };
83
84 void mp_init_cpus(struct bus *bus)
85 {
86 /*
87 * chip_config is used in CPU device callback. Other than CPU 0,
88 * rest of the CPU devices do not have chip_info updated.
89 */
90 chip_config = bus->dev->chip_info;
91
92 microcode_patch = intel_microcode_find();
93 intel_microcode_load_unlocked(microcode_patch);
94
95 enum cb_err ret = mp_init_with_smm(bus, &mp_ops);
96 if (ret != CB_SUCCESS)
97 printk(BIOS_ERR, "MP initialization failure %d.\n", ret);
98 }