Skip to content

Commit e73f4d2

Browse files
committed
Add fix to interrupts_cmd
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
1 parent 8a88e63 commit e73f4d2

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

chipsec/hal/common/iobar.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ def is_IO_BAR_defined(self, bar_name: str) -> bool:
6060
#
6161
def get_IO_BAR_base_address(self, bar_name: str, instance) -> Tuple[int, int]:
6262
reglist = self.cs.register.get_list_by_name(bar_name)
63-
bar = reglist[0].get_def(bar_name)
63+
try:
64+
bar = reglist[0].get_def(bar_name)
65+
except IndexError:
66+
raise IOBARNotFoundError(f'IOBARNotFound: {bar_name} is not defined. Check scoping and configuration')
6467
if not bar:
65-
raise IOBARNotFoundError(f'IOBARNotFound: {bar_name}')
68+
raise IOBARNotFoundError(f'IOBARNotFound: {bar_name} is not defined. Check scoping and configuration')
6669
base = 0
6770
empmty_base = 0
6871

chipsec/hal/common/mmio.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"""
4646
from typing import List, Optional, Tuple
4747
from chipsec.hal import hal_base
48-
from chipsec.library.exceptions import CSReadError
48+
from chipsec.library.exceptions import CSReadError, MMIOBARNotFoundError
4949
from chipsec.library.logger import logger
5050
from chipsec.library.defines import get_bits, is_all_ones
5151

@@ -193,11 +193,12 @@ def flush_bar_address_cache(self) -> None:
193193
def get_MMIO_BAR_base_address(self, bar_name: str, pciobj: Optional[int] = None) -> Tuple[int, int]:
194194
if self.cache_bar_addresses_resolution and (bar_name, pciobj) in self.cached_bar_addresses:
195195
return self.cached_bar_addresses[(bar_name, pciobj)]
196-
bar = self.cs.register.mmio.get_def(bar_name) #self.cs.Cfg.MMIO_BARS[bar_name]
197-
# if bar is None or bar == {}:
198-
# return -1, -1
196+
try:
197+
bar = self.cs.register.mmio.get_def(bar_name) #self.cs.Cfg.MMIO_BARS[bar_name]
198+
except KeyError:
199+
raise MMIOBARNotFoundError(f'MMIOBARNotFound: {bar_name} is not defined. Check scoping and configuration')
199200
if not bar:
200-
raise CSReadError(f'{bar_name} is not defined. check scoping and configuration')
201+
raise MMIOBARNotFoundError(f'MMIOBARNotFound: {bar_name} is not defined. Check scoping and configuration')
201202
base, size = bar.get_base(pciobj)
202203
if base:
203204
return base, size

chipsec/library/exceptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ class IOBARRuntimeError (RuntimeError):
110110
class IOBARNotFoundError (RuntimeError):
111111
pass
112112

113+
class MMIOBARNotFoundError (RuntimeError):
114+
pass
113115

114116
class IOMMUError (RuntimeError):
115117
pass

chipsec/utilcmd/interrupts_cmd.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ def parse_arguments(self) -> None:
105105

106106
def smi_count(self) -> None:
107107
self.logger.log("[CHIPSEC] SMI count:")
108-
for tid in range(self.cs.hals.Msr.get_cpu_thread_count()):
109-
smi_cnt = self.cs.register.read_field('MSR_SMI_COUNT', 'Count', cpu_thread=tid)
110-
self.logger.log(f' CPU{tid:d}: {smi_cnt:d}')
108+
smi_cnt = self.cs.register.get_list_by_name('8086.MSR.MSR_SMI_COUNT')
109+
for reg in smi_cnt:
110+
self.logger.log(f' CPU{reg.instance:d}: {reg.read_field('Count'):d}')
111111

112112
def smi_smmc(self) -> None:
113113
if os.path.isfile(self.payload):
@@ -180,7 +180,10 @@ def run(self) -> None:
180180
return
181181

182182
self.logger.log("[CHIPSEC] Sending NMI#...")
183-
interrupts.send_NMI()
183+
try:
184+
interrupts.send_NMI()
185+
except Exception as err:
186+
self.logger.log(err)
184187

185188

186189
commands = {'smi': SMICommand, 'nmi': NMICommand}

0 commit comments

Comments
 (0)