Skip to content

Commit

Permalink
Workaround for module errors on macOS (#184)
Browse files Browse the repository at this point in the history
- added is_macos()
- calling is_macos in modules which require functionality not yet
implemented by osx helper such as MSR, port IO and EFI variables
- added EFI_supported always returning False in osx helper to skip
modules requiring EFI runtime API
  • Loading branch information
c7zero committed Mar 18, 2017
1 parent 0ad817d commit 5102229
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 6 deletions.
2 changes: 2 additions & 0 deletions chipsec/helper/oshelper.py
Expand Up @@ -166,6 +166,8 @@ def is_windows( self ):
def is_win8_or_greater( self ):
win8_or_greater = self.is_windows() and ( self.os_release.startswith('8') or ('2008Server' in self.os_release) or ('2012Server' in self.os_release) )
return win8_or_greater
def is_macos( self ):
return ('darwin' == self.os_system.lower())


#################################################################################################
Expand Down
40 changes: 37 additions & 3 deletions chipsec/helper/osx/helper.py
Expand Up @@ -197,14 +197,48 @@ def decompress_file( self, CompressedFileName, OutputFileName, CompressionType )
return chipsec.file.read_file( OutputFileName )



def get_tool_info( self, tool_type ):
raise NotImplementedError()

def read_io_port(self):
#########################################################
# EFI Runtime API
#########################################################

# @TODO: macOS helper doesn't support EFI runtime API yet
def EFI_supported(self):
return False

# Placeholders for EFI Variable API

def delete_EFI_variable(self, name, guid):
raise NotImplementedError()
def native_delete_EFI_variable(self, name, guid):
raise NotImplementedError()

def list_EFI_variables(self):
raise NotImplementedError()
def native_list_EFI_variables(self):
raise NotImplementedError()

def get_EFI_variable(self, name, guid, attrs=None):
raise NotImplementedError()
def native_get_EFI_variable(self, name, guid, attrs=None):
raise NotImplementedError()

def set_EFI_variable(self, name, guid, data, datasize, attrs=None):
raise NotImplementedError()
def native_set_EFI_variable(self, name, guid, data, datasize, attrs=None):
raise NotImplementedError()


#########################################################
# Port I/O
#########################################################

def read_io_port(self, io_port, size):
raise NotImplementedError()

def write_io_port(self):
def write_io_port(self, io_port, value, size):
raise NotImplementedError()

def read_cr(self, cpu_thread_id, cr_number):
Expand Down
5 changes: 4 additions & 1 deletion chipsec/modules/common/bios_smi.py
Expand Up @@ -45,7 +45,10 @@ def __init__(self):
self.iobar = iobar.IOBAR(self.cs)

def is_supported(self):
return (self.cs.get_chipset_id() not in chipsec.chipset.CHIPSET_FAMILY_ATOM)
# @TODO: currently, this module cannot run on macOS
if self.cs.helper.is_macos(): return False

return (not self.cs.is_atom())

def check_SMI_locks(self):

Expand Down
6 changes: 4 additions & 2 deletions chipsec/modules/common/ia32cfg.py
Expand Up @@ -37,8 +37,10 @@ def __init__(self):
self.res = ModuleResult.PASSED

def is_supported(self):
if self.cs.is_atom(): return False
else: return True
# @TODO: currently, this module cannot run on macOS
if self.cs.helper.is_macos(): return False

return (not self.cs.is_atom())

def check_ia32feature_control(self):
self.logger.start_test( "IA32 Feature Control Lock" )
Expand Down
2 changes: 2 additions & 0 deletions chipsec/modules/common/smrr.py
Expand Up @@ -37,6 +37,8 @@ def __init__(self):
BaseModule.__init__(self)

def is_supported(self):
# @TODO: currently, this module cannot run on macOS
if self.cs.helper.is_macos(): return False
return True

#
Expand Down
2 changes: 2 additions & 0 deletions chipsec/modules/smm_dma.py
Expand Up @@ -43,6 +43,8 @@ def __init__(self):
BaseModule.__init__(self)

def is_supported(self):
# @TODO: currently, this module cannot run on macOS
if self.cs.helper.is_macos(): return False
if self.cs.is_atom(): return False
if self.cs.is_server(): return False
else: return True
Expand Down

0 comments on commit 5102229

Please sign in to comment.