Detect PCH based on platform vendor ID

An alternative approach would be to use get_cpuid(eax=0) to recover the
vendor, but cpuid is only available when a driver is loaded. Assume that
there is always a PCI device 00:0.0 providing the correct vendor.

Currently supports AMD and Intel.

Bug: #825
Signed-off-by: Gabriel Kerneis <gabriel.kerneis@ssi.gouv.fr>
This commit is contained in:
Gabriel Kerneis
2021-08-11 15:14:21 +02:00
committed by Nathaniel Mitchell
parent 67912f14b9
commit 2691f50bae
+18 -14
View File
@@ -89,19 +89,19 @@ CHIPSET_FAMILY_QUARK = []
PCH_CODE_PREFIX = 'PCH_'
PCH_ADDRESS = {
# Intel: 0:1F.0
0x8086: (0, 0x1F, 0),
# AMD: 0:14.3
0x1022: (0, 0x14, 3)
}
try:
from chipsec.custom_chipsets import *
except ImportError:
pass
def f_xml(self, x):
XMLFILE_RE = re.compile("^\w+\.xml")
return ( x.find('common') == -1 and XMLFILE_RE.match(x) )
def map_xmlname(self, x):
return x.split('.')[0]
class Chipset:
def __init__(self, helper=None):
@@ -167,13 +167,17 @@ class Chipset:
rid = self.pci.read_byte(0, 0, 0, PCI_HDR_RID_OFF)
except:
if logger().DEBUG: logger().error("pci.read_dword couldn't read platform VID/DID")
try:
vid_did = self.pci.read_dword(0, 31, 0, 0)
pch_vid = vid_did & 0xFFFF
pch_did = (vid_did >> 16) & 0xFFFF
pch_rid = self.pci.read_byte(0, 31, 0, PCI_HDR_RID_OFF)
except:
if logger().DEBUG: logger().error("pci.read_dword couldn't read PCH VID/DID")
if not vid in PCH_ADDRESS:
if logger().DEBUG: logger().error("PCH address unknown for VID {}.".format(vid))
else:
try:
(bus,dev,fun) = PCH_ADDRESS[vid]
vid_did = self.pci.read_dword(bus, dev, fun, 0)
pch_vid = vid_did & 0xFFFF
pch_did = (vid_did >> 16) & 0xFFFF
pch_rid = self.pci.read_byte(0, 31, 0, PCI_HDR_RID_OFF)
except:
if logger().DEBUG: logger().error("pci.read_dword couldn't read PCH VID/DID")
return (vid, did, rid, pch_vid, pch_did, pch_rid)
def get_cpuid(self):