Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"python chipsec_util.py config show MMIO_BARS" errors out and acts like the Windows kernel driver isn't loaded, despite kernel-requiring functionality working #1262

Open
throwaway-a opened this issue Sep 13, 2021 · 8 comments
Assignees

Comments

@throwaway-a
Copy link

throwaway-a commented Sep 13, 2021

I think you're probably missing a regression test for "python chipsec_util.py config show MMIO_BARS" and that it probably broke at some point.

I can run commands like "python chipsec_util.py spi dump foo.bin" or "python chipsec_util.py reg read BC" which work, and show the chipsec_hlpr.sys is loaded, but once I run "python chipsec_util.py config show MMIO_BARS" I see "ERROR: chipsec kernel driver is not loaded (in native API mode?)". See below.

C:\Users\ta\Downloads\chipsec-1.7.0>python chipsec_util.py reg read BC

################################################################
##                                                            ##
##  CHIPSEC: Platform Hardware Security Assessment Framework  ##
##                                                            ##
################################################################
[CHIPSEC] Version : 1.7.0
[CHIPSEC] OS      : Windows 10 10.0.19043 AMD64
[CHIPSEC] Python  : 3.9.6 (64-bit)


WARNING: *******************************************************************
WARNING: Chipsec should only be used on test systems!
WARNING: It should not be installed/deployed on production end-user systems.
WARNING: See WARNING.txt
WARNING: *******************************************************************

[CHIPSEC] API mode: using CHIPSEC kernel module API
[!]       Unknown PCH: VID = 0x8086, DID = 0x8C4E, RID = 0x05; Using Default.
[!]            Results from this system may be incorrect.
[CHIPSEC] Helper  : Win32Helper (\??\C:\Users\ta\Downloads\chipsec-1.7.0\chipsec\helper\win\win7_amd64\chipsec_hlpr.sys)
[CHIPSEC] Platform: Desktop 4th Generation Core Processor (Haswell CPU / Lynx Point PCH
[CHIPSEC]      VID: 8086
[CHIPSEC]      DID: 0C00
[CHIPSEC]      RID: 06
[CHIPSEC] PCH     : Default PCH
[CHIPSEC]      VID: FFFF
[CHIPSEC]      DID: FFFF
[CHIPSEC]      RID: FF
[CHIPSEC] Executing command 'reg' with args ['read', 'BC']

[CHIPSEC] BC=0x2A
[*] BC = 0x2A << BIOS Control (b:d.f 00:31.0 + 0xDC)
    [00] BIOSWE           = 0 << BIOS Write Enable
    [01] BLE              = 1 << BIOS Lock Enable
    [02] SRC              = 2 << SPI Read Configuration
    [04] TSS              = 0 << Top Swap Status
    [05] SMM_BWP          = 1 << SMM BIOS Write Protection

C:\Users\ta\Downloads\chipsec-1.7.0>python chipsec_util.py config show MMIO_BARS

################################################################
##                                                            ##
##  CHIPSEC: Platform Hardware Security Assessment Framework  ##
##                                                            ##
################################################################
[CHIPSEC] Version : 1.7.0
[CHIPSEC] OS      : Windows 10 10.0.19043 AMD64
[CHIPSEC] Python  : 3.9.6 (64-bit)

[CHIPSEC] API mode: using OS native API (not using CHIPSEC kernel module)
ERROR: chipsec kernel driver is not loaded (in native API mode?)
ERROR: chipsec kernel driver is not loaded (in native API mode?)
[!]       Unknown Platform: VID = 0xFFFF, DID = 0xFFFF, RID = 0xFF; Using Default.
[!]       Unknown PCH: VID = 0xFFFF, DID = 0xFFFF, RID = 0xFF; Using Default.
[!]            Results from this system may be incorrect.
[CHIPSEC] Helper  : Win32Helper (None)
[CHIPSEC] Platform: UnknownPlatform
[CHIPSEC]      VID: FFFF
[CHIPSEC]      DID: FFFF
[CHIPSEC]      RID: FF
[CHIPSEC] PCH     : Default PCH
[CHIPSEC]      VID: FFFF
[CHIPSEC]      DID: FFFF
[CHIPSEC]      RID: FF
[CHIPSEC] Executing command 'config' with args ['show', 'MMIO_BARS']

MMIO_BARS
[CHIPSEC] (config) time elapsed 0.000
@throwaway-a
Copy link
Author

throwaway-a commented Sep 13, 2021

And possibly related to this, here's some more commands that don't work because of it seeming to think the kernel driver isn't loaded and then using 0xFFs for the VID/DID. Here they're literally supposed to just be parsing files of disk, so there really shouldn't be any call for using the kernel driver...

C:\Users\ta\Downloads\chipsec-1.7.0>python chipsec_util.py spidesc .\myflash.bin

################################################################
##                                                            ##
##  CHIPSEC: Platform Hardware Security Assessment Framework  ##
##                                                            ##
################################################################
[CHIPSEC] Version : 1.7.0
[CHIPSEC] OS      : Windows 10 10.0.19043 AMD64
[CHIPSEC] Python  : 3.9.6 (64-bit)

[CHIPSEC] API mode: using OS native API (not using CHIPSEC kernel module)
ERROR: chipsec kernel driver is not loaded (in native API mode?)
ERROR: chipsec kernel driver is not loaded (in native API mode?)
[!]       Unknown Platform: VID = 0xFFFF, DID = 0xFFFF, RID = 0xFF; Using Default.
[!]       Unknown PCH: VID = 0xFFFF, DID = 0xFFFF, RID = 0xFF; Using Default.
[!]            Results from this system may be incorrect.
[CHIPSEC] Helper  : Win32Helper (None)
[CHIPSEC] Platform: UnknownPlatform
[CHIPSEC]      VID: FFFF
[CHIPSEC]      DID: FFFF
[CHIPSEC]      RID: FF
[CHIPSEC] PCH     : Default PCH
[CHIPSEC]      VID: FFFF
[CHIPSEC]      DID: FFFF
[CHIPSEC]      RID: FF
[CHIPSEC] Executing command 'spidesc' with args ['.\\myflash.bin']

[CHIPSEC] Parsing SPI Flash Descriptor from file '.\myflash.bin'

[spi_fd] Valid SPI flash descriptor found at offset 0x00000000

########################################################
# SPI FLASH DESCRIPTOR
########################################################

+ 0x0000 Reserved : 0xb'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'
+ 0x0010 Signature: 0x0FF0A55A
Traceback (most recent call last):
  File "C:\Users\ta\Downloads\chipsec-1.7.0\chipsec_util.py", line 218, in <module>
    sys.exit( main() )
  File "C:\Users\ta\Downloads\chipsec-1.7.0\chipsec_util.py", line 214, in main
    return chipsecUtil.main()
  File "C:\Users\ta\Downloads\chipsec-1.7.0\chipsec_util.py", line 189, in main
    comm.run()
  File "C:\Users\ta\Downloads\chipsec-1.7.0\chipsec\utilcmd\spidesc_cmd.py", line 51, in run
    parse_spi_flash_descriptor( self.cs, fd )
  File "C:\Users\ta\Downloads\chipsec-1.7.0\chipsec\hal\spi_descriptor.py", line 116, in parse_spi_flash_descriptor
    cs.print_register('FLMAP0', flmap0)
  File "C:\Users\ta\Downloads\chipsec-1.7.0\chipsec\chipset.py", line 1129, in print_register
    reg = self.get_register_def(reg_name)
  File "C:\Users\ta\Downloads\chipsec-1.7.0\chipsec\chipset.py", line 795, in get_register_def
    reg_def = self.Cfg.REGISTERS[reg_name]
KeyError: 'FLMAP0'
C:\Users\ta\Downloads\chipsec-1.7.0>python chipsec_util.py decode .\myflash.bin

################################################################
##                                                            ##
##  CHIPSEC: Platform Hardware Security Assessment Framework  ##
##                                                            ##
################################################################
[CHIPSEC] Version : 1.7.0
[CHIPSEC] OS      : Windows 10 10.0.19043 AMD64
[CHIPSEC] Python  : 3.9.6 (64-bit)

[CHIPSEC] API mode: using OS native API (not using CHIPSEC kernel module)
ERROR: chipsec kernel driver is not loaded (in native API mode?)
ERROR: chipsec kernel driver is not loaded (in native API mode?)
[!]       Unknown Platform: VID = 0xFFFF, DID = 0xFFFF, RID = 0xFF; Using Default.
[!]       Unknown PCH: VID = 0xFFFF, DID = 0xFFFF, RID = 0xFF; Using Default.
[!]            Results from this system may be incorrect.
[CHIPSEC] Helper  : Win32Helper (None)
[CHIPSEC] Platform: UnknownPlatform
[CHIPSEC]      VID: FFFF
[CHIPSEC]      DID: FFFF
[CHIPSEC]      RID: FF
[CHIPSEC] PCH     : Default PCH
[CHIPSEC]      VID: FFFF
[CHIPSEC]      DID: FFFF
[CHIPSEC]      RID: FF
[CHIPSEC] Executing command 'decode' with args ['.\\myflash.bin']

[CHIPSEC] Decoding SPI ROM image from a file '.\myflash.bin'
[CHIPSEC] Found SPI Flash descriptor at offset 0x0 in the binary '.\myflash.bin'
Traceback (most recent call last):
  File "C:\Users\ta\Downloads\chipsec-1.7.0\chipsec_util.py", line 218, in <module>
    sys.exit( main() )
  File "C:\Users\ta\Downloads\chipsec-1.7.0\chipsec_util.py", line 214, in main
    return chipsecUtil.main()
  File "C:\Users\ta\Downloads\chipsec-1.7.0\chipsec_util.py", line 189, in main
    comm.run()
  File "C:\Users\ta\Downloads\chipsec-1.7.0\chipsec\utilcmd\decode_cmd.py", line 126, in run
    self.decode_rom()
  File "C:\Users\ta\Downloads\chipsec-1.7.0\chipsec\utilcmd\decode_cmd.py", line 97, in decode_rom
    os.makedirs( pth )
  File "C:\Users\ta\AppData\Local\Programs\Python\Python39\lib\os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "C:\Users\ta\AppData\Local\Programs\Python\Python39\lib\os.py", line 225, in makedirs
    mkdir(name, mode)
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '\\\\?\\C:\\Users\\user\\Downloads\\chipsec-1.7.0\\.'

@throwaway-a
Copy link
Author

Confirmed the same inability to parse the files off disk in 1.7.1 too

@npmitche npmitche self-assigned this Sep 14, 2021
@throwaway-a
Copy link
Author

Any thoughts on why Chipsec 1.7.2 on Linux would succeed in parsing the SPI flash dump (python chipsec_util.py spidesc .\myflash.bin) on the same machine where 1.7.2 fails from within Windows?

@frinzell
Copy link
Member

frinzell commented Nov 2, 2021

There could be a number of reasons. Is it possible to forward a verbose log file (-vv) to chipsec@intel.com?

@throwaway-a
Copy link
Author

throwaway-a commented Nov 2, 2021

I'll just attach here. Here's the linux log...

chipsec_linux_log.txt

And here's the Windows Log...

chipsec_windows_spidesc_log.txt

@frinzell
Copy link
Member

frinzell commented Nov 2, 2021

It doesn't appear that the CHIPSEC Windows driver is loading. Do any of the steps from the Install in Windows page help?

@frinzell
Copy link
Member

frinzell commented Nov 2, 2021

Also, if you don't need the driver to load, you can use the -n or --no_driver switch.

@oarbildo
Copy link

oarbildo commented Nov 4, 2021

For the spidesc issue, it was failing for me as well on chipsec 1.7.1 under Windows. I found out that the method SPIDescCommand.requires_driver located on the file chipsec\utilcmd\spidesc_cmd.py was set to return False, so the driver would not be loaded. Once I changed it to true everything started working as expected. I haven't tried the decode command, but a quick look at the code also shows that DecodeCommand.requires_driver is set to return False. Could a quick fix for both issues be to set the requires_driver function to return True?
Following the code flow for the spidesc case; it uses chipsec\hal\spi_descriptor.py which depends on the chipset module to get some register objects to parse the flash contents; and when the driver is not leaded, then the chipset module cannot identify the platform to parse the register files to get these definitions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants