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
);
15
msr_t
mask
=
rdmsr
(
SMM_MASK_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
;
27
wrmsr
(
SMM_MASK_MSR
,
mask
);
28
}
printk
#define printk(level,...)
Definition:
stdlib.h:16
console.h
msr.h
SMM_LOCK
#define SMM_LOCK
Definition:
msr.h:18
SMM_MASK_MSR
#define SMM_MASK_MSR
Definition:
msr.h:61
HWCR_MSR
#define HWCR_MSR
Definition:
msr.h:17
SMM_TSEG_VALID
#define SMM_TSEG_VALID
Definition:
msr.h:62
msr.h
rdmsr
static __always_inline msr_t rdmsr(unsigned int index)
Definition:
msr.h:146
wrmsr
static __always_inline void wrmsr(unsigned int index, msr_t msr)
Definition:
msr.h:157
BIOS_ERR
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition:
loglevel.h:72
clear_tvalid
void clear_tvalid(void)
Definition:
smm_helper.c:12
smm.h
mask
static const int mask[4]
Definition:
gpio.c:308
msr_struct
Definition:
msr.h:110
msr_struct::lo
unsigned int lo
Definition:
msr.h:111
src
soc
amd
common
block
cpu
smm
smm_helper.c
Generated by
1.9.1