util/intelmetool: Add support for platforms without RCBA

Only try to unhide MEI if the PCI device wasn't found and
probe for RCBA before trying to use it.

Allows to run the utility on Skylake and newer hardware that
do not have RCBA any more.

TODO: Use sideband interface to unhide MEI.

Change-Id: I7926aa80b132d5be9fece0724516701d74dd4d3d
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/25399
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
This commit is contained in:
Patrick Rudolph 2018-02-01 16:14:19 +01:00 committed by Philipp Deppenwiese
parent aac3b31dbb
commit 0391d0b023
3 changed files with 56 additions and 37 deletions

View File

@ -179,6 +179,10 @@ static int pci_platform_scan(void)
static int activate_me(void)
{
const uint32_t rcba = get_rcba_phys();
if (debug)
printf("RCBA addr: 0x%08x\n", rcba);
if (rcba > 0) {
if (read_rcba32(FD2, &fd2)) {
printf("Error reading RCBA\n");
return 1;
@ -187,17 +191,19 @@ static int activate_me(void)
printf("Error writing RCBA\n");
return 1;
}
if (debug) {
if (fd2 & 0x2)
if (debug && (fd2 & 0x2))
printf("MEI was hidden on PCI, now unlocked\n");
else
else if (debug)
printf("MEI not hidden on PCI, checking if visible\n");
}
return 0;
}
static void rehide_me(void)
{
const uint32_t rcba = get_rcba_phys();
if (rcba > 0) {
if (fd2 & 0x2) {
if (debug)
printf("Re-hiding MEI device...");
@ -213,6 +219,7 @@ static void rehide_me(void)
printf("done\n");
}
}
}
static struct pci_dev *pci_me_interface_scan(const char **name, char *namebuf,
int namebuf_size)
@ -244,7 +251,6 @@ static struct pci_dev *pci_me_interface_scan(const char **name, char *namebuf,
if (!me) {
rehide_me();
printf("MEI device not found\n");
pci_cleanup(pacc);
return NULL;
}
@ -260,14 +266,21 @@ static void dump_me_info(void)
const char *name = NULL;
if (pci_platform_scan())
exit(1);
if (activate_me())
exit(1);
return;
dev = pci_me_interface_scan(&name, namebuf, sizeof(namebuf));
if (!dev)
exit(1);
if (!dev) {
if (debug)
printf("ME PCI device is hidden\n");
if (activate_me())
return;
dev = pci_me_interface_scan(&name, namebuf, sizeof(namebuf));
if (!dev) {
printf("Can't find ME PCI device\n");
return;
}
}
if (name == NULL)
name = "<unknown>";
@ -314,15 +327,20 @@ static void dump_bootguard_info(void)
uint64_t bootguard = 0;
if (pci_platform_scan())
exit(1);
if (activate_me())
exit(1);
return;
dev = pci_me_interface_scan(&name, namebuf, sizeof(namebuf));
if (!dev) {
printf("Can't access ME PCI device\n");
if (debug)
printf("ME PCI device is hidden\n");
if (activate_me())
return;
dev = pci_me_interface_scan(&name, namebuf, sizeof(namebuf));
if (!dev) {
printf("Can't find ME PCI device\n");
return;
}
}
if (debug) {

View File

@ -22,7 +22,7 @@
static const int size = 0x4000;
/* Returns the physical RCBA base address or zero on error. */
static u32 get_rcba_phys(void)
u32 get_rcba_phys(void)
{
struct pci_access *pacc;
struct pci_dev *sb;

View File

@ -13,3 +13,4 @@
int write_rcba32(uint32_t addr, uint32_t val);
int read_rcba32(uint32_t addr, uint32_t *val);
u32 get_rcba_phys(void);