aboutsummaryrefslogtreecommitdiff
path: root/util/intelmetool/msr.c
diff options
context:
space:
mode:
authorPatrick Rudolph <siro@das-labor.org>2017-11-25 14:43:06 +0100
committerStefan Reinauer <stefan.reinauer@coreboot.org>2017-11-30 17:19:08 +0000
commit3df9dbe8864adf6d41df2fe617c8818d1bad9d42 (patch)
treeb91c8c5e8cf47f8d979799ce95972c39308db970 /util/intelmetool/msr.c
parent214dde058c876a7fc44c5da74d883c6856926a56 (diff)
util/intelmetool: Fix some platforms
Bootguard: * Fix Mac support (ME_version can't be detected) * Skip MSR read on older platforms (as it would fail anyway) * Refactor MSR error handling * Print Bootguard state "Unknown" on MSR read error Change-Id: Iafe3f5c22c6caeedc556933405b9f6d83ec876a1 Signed-off-by: Patrick Rudolph <siro@das-labor.org> Reviewed-on: https://review.coreboot.org/22598 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
Diffstat (limited to 'util/intelmetool/msr.c')
-rw-r--r--util/intelmetool/msr.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/util/intelmetool/msr.c b/util/intelmetool/msr.c
index 1010c0e324..d1e510fd14 100644
--- a/util/intelmetool/msr.c
+++ b/util/intelmetool/msr.c
@@ -26,28 +26,23 @@
#ifndef __DARWIN__
static int fd_msr = 0;
-static uint64_t rdmsr(int addr)
+static int rdmsr(int addr, uint64_t *msr)
{
- uint32_t buf[2];
- uint64_t msr = 0;
-
if (lseek(fd_msr, (off_t) addr, SEEK_SET) == -1) {
perror("Could not lseek() to MSR");
close(fd_msr);
return -1;
}
- if (read(fd_msr, buf, 8) == 8) {
- msr = buf[1];
- msr <<= 32;
- msr |= buf[0];
+ if (read(fd_msr, msr, 8) == 8) {
close(fd_msr);
- return msr;
+ return 0;
}
if (errno == EIO) {
perror("IO error couldn't read MSR.");
close(fd_msr);
+ /* On older platforms the MSR might not exists */
return -2;
}
@@ -68,7 +63,8 @@ int msr_bootguard(uint64_t *msr, int debug)
return -1;
}
- *msr = rdmsr(MSR_BOOTGUARD);
+ if (rdmsr(MSR_BOOTGUARD, msr) < 0)
+ return -1;
#endif
if (!debug)