coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
smm_helper.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <amdblocks/smm.h>
4 #include <console/console.h>
5 #include <cpu/x86/msr.h>
6 #include <cpu/amd/msr.h>
7 
8 /*
9  * For data stored in TSEG, ensure TValid is clear so R/W access can reach
10  * the DRAM when not in SMM.
11  */
12 void clear_tvalid(void)
13 {
14  msr_t hwcr = rdmsr(HWCR_MSR);
16  int tvalid = !!(mask.lo & SMM_TSEG_VALID);
17 
18  if (hwcr.lo & SMM_LOCK) {
19  if (!tvalid) /* not valid but locked means still accessible */
20  return;
21 
22  printk(BIOS_ERR, "can't clear TValid, already locked\n");
23  return;
24  }
25 
26  mask.lo &= ~SMM_TSEG_VALID;
28 }
#define printk(level,...)
Definition: stdlib.h:16
#define SMM_LOCK
Definition: msr.h:18
#define SMM_MASK_MSR
Definition: msr.h:61
#define HWCR_MSR
Definition: msr.h:17
#define SMM_TSEG_VALID
Definition: msr.h:62
static __always_inline msr_t rdmsr(unsigned int index)
Definition: msr.h:146
static __always_inline void wrmsr(unsigned int index, msr_t msr)
Definition: msr.h:157
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
void clear_tvalid(void)
Definition: smm_helper.c:12
static const int mask[4]
Definition: gpio.c:308
unsigned int lo
Definition: msr.h:111