Vladimir Serbinenko | 22dcdd9 | 2013-06-06 22:10:45 +0200 | [diff] [blame] | 1 | /* |
| 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 Serbinenko | 22dcdd9 | 2013-06-06 22:10:45 +0200 | [diff] [blame] | 15 | */ |
| 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 Couzens | f251a6d | 2015-01-28 01:51:04 +0100 | [diff] [blame] | 24 | /* 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 Serbinenko | 22dcdd9 | 2013-06-06 22:10:45 +0200 | [diff] [blame] | 29 | static 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 | |
| 46 | void intel_model_2065x_finalize_smm(void) |
| 47 | { |
Alexander Couzens | f251a6d | 2015-01-28 01:51:04 +0100 | [diff] [blame] | 48 | /* Lock C-State MSR */ |
Vladimir Serbinenko | 22dcdd9 | 2013-06-06 22:10:45 +0200 | [diff] [blame] | 49 | 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 Couzens | f251a6d | 2015-01-28 01:51:04 +0100 | [diff] [blame] | 55 | /* Lock TM interupts - route thermal events to all processors */ |
Vladimir Serbinenko | 22dcdd9 | 2013-06-06 22:10:45 +0200 | [diff] [blame] | 56 | msr_set_bit(MSR_MISC_PWR_MGMT, 22); |
Alexander Couzens | f251a6d | 2015-01-28 01:51:04 +0100 | [diff] [blame] | 57 | |
| 58 | /* Lock memory configuration to protect SMM */ |
Vladimir Serbinenko | 22dcdd9 | 2013-06-06 22:10:45 +0200 | [diff] [blame] | 59 | msr_set_bit(MSR_LT_LOCK_MEMORY, 0); |
| 60 | } |