coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
smm_reloc.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef __INTEL_SMM_RELOC_H__
4 #define __INTEL_SMM_RELOC_H__
5 
6 #include <console/console.h>
7 #include <types.h>
8 #include <cpu/x86/msr.h>
9 #include <cpu/x86/mtrr.h>
10 
13  size_t ied_size;
20  /*
21  * The smm_save_state_in_msrs field indicates if SMM save state
22  * locations live in MSRs. This indicates to the CPUs how to adjust
23  * the SMMBASE and IEDBASE
24  */
26 };
27 
29 
30 struct ied_header {
31  char signature[10];
33  u8 reserved[34];
35 
36 /* These helpers are for performing SMM relocation. */
37 void northbridge_write_smram(u8 smram);
38 
39 void smm_lock(void);
40 void smm_relocate(void);
41 
42 /* The initialization of the southbridge is split into 2 components. One is
43  * for clearing the state in the SMM registers. The other is for enabling
44  * SMIs. They are split so that other work between the 2 actions. */
46 
47 /* To be removed. */
48 void smm_initialize(void);
49 void smm_info(uintptr_t *perm_smbase, size_t *perm_smsize, size_t *smm_save_state_size);
50 void smm_relocation_handler(int cpu, uintptr_t curr_smbase, uintptr_t staggered_smbase);
51 
52 bool cpu_has_alternative_smrr(void);
53 
54 #define MSR_PRMRR_PHYS_BASE 0x1f4
55 #define MSR_PRMRR_PHYS_MASK 0x1f5
56 #define MSR_UNCORE_PRMRR_PHYS_BASE 0x2f4
57 #define MSR_UNCORE_PRMRR_PHYS_MASK 0x2f5
58 
59 static inline void write_smrr(struct smm_relocation_params *relo_params)
60 {
61  printk(BIOS_DEBUG, "Writing SMRR. base = 0x%08x, mask=0x%08x\n",
62  relo_params->smrr_base.lo, relo_params->smrr_mask.lo);
63  wrmsr(IA32_SMRR_PHYS_BASE, relo_params->smrr_base);
64  wrmsr(IA32_SMRR_PHYS_MASK, relo_params->smrr_mask);
65 }
66 
67 static inline void write_prmrr(struct smm_relocation_params *relo_params)
68 {
69  printk(BIOS_DEBUG, "Writing PRMRR. base = 0x%08x, mask=0x%08x\n",
70  relo_params->prmrr_base.lo, relo_params->prmrr_mask.lo);
71  wrmsr(MSR_PRMRR_PHYS_BASE, relo_params->prmrr_base);
72  wrmsr(MSR_PRMRR_PHYS_MASK, relo_params->prmrr_mask);
73 }
74 
75 static inline void write_uncore_prmrr(struct smm_relocation_params *relo_params)
76 {
78  "Writing UNCORE_PRMRR. base = 0x%08x, mask=0x%08x\n",
79  relo_params->uncore_prmrr_base.lo,
80  relo_params->uncore_prmrr_mask.lo);
83 }
84 
85 #endif
#define printk(level,...)
Definition: stdlib.h:16
static __always_inline void wrmsr(unsigned int index, msr_t msr)
Definition: msr.h:157
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
void smm_relocate(void)
Definition: smmrelocate.c:247
void smm_relocation_handler(int cpu, uintptr_t curr_smbase, uintptr_t staggered_smbase)
Definition: smmrelocate.c:90
void smm_initialize(void)
Definition: smmrelocate.c:227
#define MSR_UNCORE_PRMRR_PHYS_BASE
Definition: smm_reloc.h:56
#define MSR_PRMRR_PHYS_BASE
Definition: smm_reloc.h:54
#define MSR_UNCORE_PRMRR_PHYS_MASK
Definition: smm_reloc.h:57
void smm_lock(void)
Definition: smmrelocate.c:261
bool cpu_has_alternative_smrr(void)
Definition: smmrelocate.c:31
static void write_uncore_prmrr(struct smm_relocation_params *relo_params)
Definition: smm_reloc.h:75
void smm_southbridge_clear_state(void)
Definition: smm.c:22
void smm_info(uintptr_t *perm_smbase, size_t *perm_smsize, size_t *smm_save_state_size)
Definition: smmrelocate.c:213
struct smm_relocation_params smm_reloc_params
Definition: smm_reloc.c:5
#define MSR_PRMRR_PHYS_MASK
Definition: smm_reloc.h:55
static void write_prmrr(struct smm_relocation_params *relo_params)
Definition: smm_reloc.h:67
static void write_smrr(struct smm_relocation_params *relo_params)
Definition: smm_reloc.h:59
void northbridge_write_smram(u8 smram)
Definition: memmap.c:27
struct ied_header __packed
uint32_t u32
Definition: stdint.h:51
unsigned long uintptr_t
Definition: stdint.h:21
uint8_t u8
Definition: stdint.h:45
char signature[10]
Definition: smm_reloc.h:31
u8 reserved[34]
Definition: smm_reloc.h:33
u32 size
Definition: smm_reloc.h:32
unsigned int lo
Definition: msr.h:111
uintptr_t ied_base
Definition: smm_reloc.h:12
#define IA32_SMRR_PHYS_MASK
Definition: mtrr.h:31
#define IA32_SMRR_PHYS_BASE
Definition: mtrr.h:30