[coreboot-gerrit] Change in coreboot[master]: util/intelmetool: Add support for platforms without RCBA

Patrick Rudolph (Code Review) gerrit at coreboot.org
Wed Mar 28 16:14:58 CEST 2018


Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/25399


Change subject: util/intelmetool: Add support for platforms without RCBA
......................................................................

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 at 9elements.com>
---
M util/intelmetool/intelmetool.c
M util/intelmetool/rcba.c
M util/intelmetool/rcba.h
3 files changed, 56 insertions(+), 37 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/99/25399/1

diff --git a/util/intelmetool/intelmetool.c b/util/intelmetool/intelmetool.c
index 9de6bb5..4c74a0a 100644
--- a/util/intelmetool/intelmetool.c
+++ b/util/intelmetool/intelmetool.c
@@ -178,38 +178,45 @@
 
 static int activate_me(void)
 {
-	if (read_rcba32(FD2, &fd2)) {
-		printf("Error reading RCBA\n");
-		return 1;
-	}
-	if (write_rcba32(FD2, fd2 & ~0x2)) {
-		printf("Error writing RCBA\n");
-		return 1;
-	}
-	if (debug) {
-		if (fd2 & 0x2)
+	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;
+		}
+		if (write_rcba32(FD2, fd2 & ~0x2)) {
+			printf("Error writing RCBA\n");
+			return 1;
+		}
+		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)
 {
-	if (fd2 & 0x2) {
-		if (debug)
-			printf("Re-hiding MEI device...");
-		if (read_rcba32(FD2, &fd2)) {
-			printf("Error reading RCBA\n");
-			return;
+	const uint32_t rcba = get_rcba_phys();
+	if (rcba > 0) {
+		if (fd2 & 0x2) {
+			if (debug)
+				printf("Re-hiding MEI device...");
+			if (read_rcba32(FD2, &fd2)) {
+				printf("Error reading RCBA\n");
+				return;
+			}
+			if (write_rcba32(FD2, fd2 | 0x2)) {
+				printf("Error writing RCBA\n");
+				return;
+			}
+			if (debug)
+				printf("done\n");
 		}
-		if (write_rcba32(FD2, fd2 | 0x2)) {
-			printf("Error writing RCBA\n");
-			return;
-		}
-		if (debug)
-			printf("done\n");
 	}
 }
 
@@ -243,7 +250,6 @@
 	if (!me) {
 		rehide_me();
 
-		printf("MEI device not found\n");
 		pci_cleanup(pacc);
 		return NULL;
 	}
@@ -259,14 +265,21 @@
 	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>";
@@ -313,15 +326,20 @@
 	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");
-		return;
+		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) {
diff --git a/util/intelmetool/rcba.c b/util/intelmetool/rcba.c
index fcc9bc5..c138e89 100644
--- a/util/intelmetool/rcba.c
+++ b/util/intelmetool/rcba.c
@@ -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;
diff --git a/util/intelmetool/rcba.h b/util/intelmetool/rcba.h
index e1a22be..e349d3d 100644
--- a/util/intelmetool/rcba.h
+++ b/util/intelmetool/rcba.h
@@ -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);

-- 
To view, visit https://review.coreboot.org/25399
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7926aa80b132d5be9fece0724516701d74dd4d3d
Gerrit-Change-Number: 25399
Gerrit-PatchSet: 1
Gerrit-Owner: Patrick Rudolph <patrick.rudolph at 9elements.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180328/acf2f19c/attachment-0001.html>


More information about the coreboot-gerrit mailing list