| 14 | static int fd_msr = 0; |
| 15 | |
| 16 | static int rdmsr(int addr, uint64_t *msr) |
| 17 | { |
| 18 | if (lseek(fd_msr, (off_t) addr, SEEK_SET) == -1) { |
| 19 | perror("Could not lseek() to MSR"); |
| 20 | close(fd_msr); |
| 21 | return -1; |
| 22 | } |
| 23 | |
| 24 | if (read(fd_msr, msr, 8) == 8) { |
| 25 | close(fd_msr); |
| 26 | return 0; |
| 27 | } |
| 28 | |
| 29 | if (errno == EIO) { |
| 30 | perror("IO error couldn't read MSR."); |
| 31 | close(fd_msr); |
| 32 | /* On older platforms the MSR might not exists */ |
| 33 | return -2; |
| 34 | } |
| 35 | |
| 36 | perror("Couldn't read() MSR"); |
| 37 | close(fd_msr); |
| 38 | return -1; |
| 39 | } |
| 40 | #endif |
| 41 | |
| 42 | int msr_bootguard(uint64_t *msr) |
no test coverage detected