blob: 6a729b224c3096426758ad10cffca1bef855788c [file] [log] [blame]
Vladimir Serbinenko22dcdd92013-06-06 22:10:45 +02001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2012 The Chromium OS Authors. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; version 2 of
9 * the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Vladimir Serbinenko22dcdd92013-06-06 22:10:45 +020015 */
16
17#include <stdint.h>
18#include <stdlib.h>
19#include <cpu/cpu.h>
20#include <cpu/x86/msr.h>
21#include <cpu/intel/speedstep.h>
22#include "model_2065x.h"
23
Alexander Couzensf251a6d2015-01-28 01:51:04 +010024/* MSR Documentation based on
25 * "Sandy Bridge Processor Family BIOS Writer's Guide (BWG)"
26 * Document Number 504790
27 * Revision 1.6.0, June 2012 */
28
Vladimir Serbinenko22dcdd92013-06-06 22:10:45 +020029static void msr_set_bit(unsigned reg, unsigned bit)
30{
31 msr_t msr = rdmsr(reg);
32
33 if (bit < 32) {
34 if (msr.lo & (1 << bit))
35 return;
36 msr.lo |= 1 << bit;
37 } else {
38 if (msr.hi & (1 << (bit - 32)))
39 return;
40 msr.hi |= 1 << (bit - 32);
41 }
42
43 wrmsr(reg, msr);
44}
45
46void intel_model_2065x_finalize_smm(void)
47{
Alexander Couzensf251a6d2015-01-28 01:51:04 +010048 /* Lock C-State MSR */
Vladimir Serbinenko22dcdd92013-06-06 22:10:45 +020049 msr_set_bit(MSR_PMG_CST_CONFIG_CONTROL, 15);
50
51 /* Lock AES-NI only if supported */
52 if (cpuid_ecx(1) & (1 << 25))
53 msr_set_bit(MSR_FEATURE_CONFIG, 0);
54
Alexander Couzensf251a6d2015-01-28 01:51:04 +010055 /* Lock TM interupts - route thermal events to all processors */
Vladimir Serbinenko22dcdd92013-06-06 22:10:45 +020056 msr_set_bit(MSR_MISC_PWR_MGMT, 22);
Alexander Couzensf251a6d2015-01-28 01:51:04 +010057
58 /* Lock memory configuration to protect SMM */
Vladimir Serbinenko22dcdd92013-06-06 22:10:45 +020059 msr_set_bit(MSR_LT_LOCK_MEMORY, 0);
60}