mirror of
https://github.com/chipsec/chipsec
synced 2026-06-08 13:31:00 +00:00
0654edca19
Revision 1.2.0 -------------- This version includes the following new or updated modules: #. Merged common.secureboot.keys module into common.secureboot.variables module #. Updated tools.secureboot.te module to be able to test PE/TE issue on Linux or UEFI shell #. Updated tools.smm.smm_ptr module This version includes the following updates: #. Added the *controls* abstraction. Modules are encouraged to use ``get_control`` and ``set_control`` when interacting with platform registers. This permits greater flexibility in case the register that controls a given feature or configuration changes between platform generations. The controls are defined in the platform XML file. At this time, only a small number of controls are defined. We plan to move existing modules over to this new mechanism. #. Added XML Schema for the XML configuration files #. Support for reading, writing, and listing UEFI variables from the UEFI Shell environment has been added. #. Added support for decompression while SPI flash parsing via ``decode`` or ``uefi decode`` commands in Linux #. Added basic ACPI table parsing to HAL (RSDP, RSDT/XSDT, APIC, DMAR) #. Added UEFI tables searching and parsing to HAL (EFI system table, runtime services table, boot services table, DXE services table, EFI configuration table) #. Added DIMM Serial Presence Detect (SPD) ROM dumping and parsing to HAL #. Added ``uefi s3bootscript`` command parsing the S3 boot script to chipsec_util.py #. Added virtual-to-physical address translation function to Linux/EFI/Windows helpers #. Added support of server platforms (Haswell server and Ivy Town) to chipset.py This version has the following known issues: #. Decompression of images in SPI flash parsing is not available in UEFI shell. #. When calling alloc_phys_mem, the argument to set maximum physical address (max_pa) for allocation is ignored on linux. A message will be printed in dmesg if the allocation is above the max_pa that is passed in, but the call will return anyway. #. UEFI Shell environment does not support ``cpuid`` or ``get_thread_count``. There are functions that simply warn that they are not supported. #. Size of PCIEXBAR (MMCFG) is calculated incorrectly
89 lines
3.4 KiB
Python
89 lines
3.4 KiB
Python
#!/usr/local/bin/python
|
|
#CHIPSEC: Platform Security Assessment Framework
|
|
#Copyright (c) 2010-2015, Intel Corporation
|
|
#
|
|
#This program is free software; you can redistribute it and/or
|
|
#modify it under the terms of the GNU General Public License
|
|
#as published by the Free Software Foundation; Version 2.
|
|
#
|
|
#This program is distributed in the hope that it will be useful,
|
|
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
#GNU General Public License for more details.
|
|
#
|
|
#You should have received a copy of the GNU General Public License
|
|
#along with this program; if not, write to the Free Software
|
|
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
#
|
|
#Contact information:
|
|
#chipsec@intel.com
|
|
#
|
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------
|
|
#
|
|
# CHIPSEC: Platform Hardware Security Assessment Framework
|
|
# (c) 2010-2012 Intel Corporation
|
|
#
|
|
# -------------------------------------------------------------------------------
|
|
|
|
"""
|
|
Functionality encapsulating interrupt generation
|
|
CPU Interrupts specific functions (SMI, NMI)
|
|
|
|
usage:
|
|
>>> send_SMI_APMC( 0xDE )
|
|
>>> send_NMI()
|
|
"""
|
|
|
|
#TODO IPIs through Local APIC??
|
|
|
|
__version__ = '1.0'
|
|
|
|
import struct
|
|
import sys
|
|
|
|
from chipsec.logger import *
|
|
from chipsec.cfg.common import *
|
|
|
|
SMI_APMC_PORT = 0xB2
|
|
|
|
NMI_TCO1_CTL = 0x8 # NMI_NOW is bit [8] in TCO1_CTL (or bit [1] in TCO1_CTL + 1)
|
|
NMI_NOW = 0x1
|
|
|
|
|
|
class Interrupts:
|
|
def __init__( self, cs ):
|
|
self.cs = cs
|
|
|
|
def send_SW_SMI( self, thread_id, SMI_code_port_value, SMI_data_port_value, _rax, _rbx, _rcx, _rdx, _rsi, _rdi ):
|
|
SMI_code_data = (SMI_data_port_value << 8 | SMI_code_port_value)
|
|
if logger().HAL:
|
|
logger().log( "[intr] sending SW SMI: code port 0x%02X <- 0x%02X, data port 0x%02X <- 0x%02X (0x%04X)" % (SMI_APMC_PORT, SMI_code_port_value, SMI_APMC_PORT+1, SMI_data_port_value, SMI_code_data) )
|
|
logger().log( " RAX = 0x%016X (AX will be overwridden with values of SW SMI ports B2/B3)" % _rax )
|
|
logger().log( " RBX = 0x%016X" % _rbx )
|
|
logger().log( " RCX = 0x%016X" % _rcx )
|
|
logger().log( " RDX = 0x%016X (DX will be overwridden with 0x00B2)" % _rdx )
|
|
logger().log( " RSI = 0x%016X" % _rsi )
|
|
logger().log( " RDI = 0x%016X" % _rdi )
|
|
return self.cs.helper.send_sw_smi( thread_id, SMI_code_data, _rax, _rbx, _rcx, _rdx, _rsi, _rdi )
|
|
|
|
def send_SMI_APMC( self, SMI_code_port_value, SMI_data_port_value ):
|
|
SMI_code_data = (SMI_data_port_value << 8 | SMI_code_port_value)
|
|
if logger().HAL: logger().log( "[intr] sending SMI via APMC ports: code 0xB2 <- 0x%02X, data 0xB3 <- 0x%02X (0x%04X)" % (SMI_code_port_value, SMI_data_port_value, SMI_code_data) )
|
|
return self.cs.io.write_port_word( SMI_APMC_PORT, SMI_code_data )
|
|
|
|
|
|
def get_PMBASE(self):
|
|
return (self.cs.pci.read_dword( 0, 31, 0, Cfg.CFG_REG_PCH_LPC_PMBASE ) & ~0x1)
|
|
|
|
def get_TCOBASE(self):
|
|
return (self.get_PMBASE() + Cfg.TCOBASE_ABASE_OFFSET)
|
|
|
|
|
|
def send_NMI( self ):
|
|
if logger().HAL: logger().log( "[intr] sending NMI# through TCO1_CTL[NMI_NOW]" )
|
|
tcobase = self.get_TCOBASE()
|
|
return self.cs.io.write_port_byte( tcobase + NMI_TCO1_CTL + 1, NMI_NOW )
|