inteltool: Add dumping of full PCR ports
SoCs from Skylake on have many settings as so called private con- figuration registers (PCRs). These are organized as 256 ports with a 64KiB space each. We use the Primary to Sideband (P2SB) bridge's BAR to access them. Change-Id: Iede4ac601355e2be377bc986d62d20098980ec35 Signed-off-by: Nico Huber <nico.huber@secunet.com> Reviewed-on: https://review.coreboot.org/19593 Reviewed-by: Youness Alaoui <snifikino@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
cfd8929ac6
commit
d8214d7e0e
|
@ -24,6 +24,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
#include "inteltool.h"
|
#include "inteltool.h"
|
||||||
#include "pcr.h"
|
#include "pcr.h"
|
||||||
|
|
||||||
|
@ -31,6 +32,12 @@
|
||||||
#include <machine/sysarch.h>
|
#include <machine/sysarch.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define MAX_PCR_PORTS 8 /* how often may `--pcr` be specified */
|
||||||
|
|
||||||
|
enum long_only_opts {
|
||||||
|
LONG_OPT_PCR = 0x100,
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* http://pci-ids.ucw.cz/read/PC/8086
|
* http://pci-ids.ucw.cz/read/PC/8086
|
||||||
* http://en.wikipedia.org/wiki/Intel_Tick-Tock
|
* http://en.wikipedia.org/wiki/Intel_Tick-Tock
|
||||||
|
@ -369,7 +376,9 @@ void print_usage(const char *name)
|
||||||
" -A | --ambs: dump AMB registers\n"
|
" -A | --ambs: dump AMB registers\n"
|
||||||
" -x | --sgx: dump SGX status\n"
|
" -x | --sgx: dump SGX status\n"
|
||||||
" -a | --all: dump all known (safe) registers\n"
|
" -a | --all: dump all known (safe) registers\n"
|
||||||
"\n");
|
" --pcr=PORT_ID: dump all registers of a PCR port\n"
|
||||||
|
" (may be specified max %d times)\n"
|
||||||
|
"\n", MAX_PCR_PORTS);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,6 +397,8 @@ int main(int argc, char *argv[])
|
||||||
int dump_pciexbar = 0, dump_coremsrs = 0, dump_ambs = 0;
|
int dump_pciexbar = 0, dump_coremsrs = 0, dump_ambs = 0;
|
||||||
int dump_spi = 0, dump_gfx = 0, dump_ahci = 0, dump_sgx = 0;
|
int dump_spi = 0, dump_gfx = 0, dump_ahci = 0, dump_sgx = 0;
|
||||||
int show_gpio_diffs = 0;
|
int show_gpio_diffs = 0;
|
||||||
|
size_t pcr_count = 0;
|
||||||
|
uint8_t dump_pcr[MAX_PCR_PORTS];
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
{"version", 0, 0, 'v'},
|
{"version", 0, 0, 'v'},
|
||||||
|
@ -408,6 +419,7 @@ int main(int argc, char *argv[])
|
||||||
{"gfx", 0, 0, 'f'},
|
{"gfx", 0, 0, 'f'},
|
||||||
{"ahci", 0, 0, 'R'},
|
{"ahci", 0, 0, 'R'},
|
||||||
{"sgx", 0, 0, 'x'},
|
{"sgx", 0, 0, 'x'},
|
||||||
|
{"pcr", required_argument, 0, LONG_OPT_PCR},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -479,6 +491,21 @@ int main(int argc, char *argv[])
|
||||||
case 'x':
|
case 'x':
|
||||||
dump_sgx = 1;
|
dump_sgx = 1;
|
||||||
break;
|
break;
|
||||||
|
case LONG_OPT_PCR:
|
||||||
|
if (pcr_count < MAX_PCR_PORTS) {
|
||||||
|
errno = 0;
|
||||||
|
const unsigned long int pcr =
|
||||||
|
strtoul(optarg, NULL, 0);
|
||||||
|
if (strlen(optarg) == 0 || errno) {
|
||||||
|
print_usage(argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
dump_pcr[pcr_count++] = (uint8_t)pcr;
|
||||||
|
} else {
|
||||||
|
print_usage(argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
case '?':
|
case '?':
|
||||||
default:
|
default:
|
||||||
|
@ -685,6 +712,9 @@ int main(int argc, char *argv[])
|
||||||
if (dump_sgx)
|
if (dump_sgx)
|
||||||
print_sgx();
|
print_sgx();
|
||||||
|
|
||||||
|
if (pcr_count)
|
||||||
|
print_pcr_ports(sb, dump_pcr, pcr_count);
|
||||||
|
|
||||||
/* Clean up */
|
/* Clean up */
|
||||||
pcr_cleanup();
|
pcr_cleanup();
|
||||||
if (ahci)
|
if (ahci)
|
||||||
|
|
|
@ -29,6 +29,43 @@ uint32_t read_pcr32(const uint8_t port, const uint16_t offset)
|
||||||
return *(const uint32_t *)(sbbar + (port << 16) + offset);
|
return *(const uint32_t *)(sbbar + (port << 16) + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void print_pcr_port(const uint8_t port)
|
||||||
|
{
|
||||||
|
size_t i = 0;
|
||||||
|
uint32_t last_reg = 0;
|
||||||
|
bool last_printed = true;
|
||||||
|
|
||||||
|
printf("PCR port offset: 0x%06zx\n\n", (size_t)port << 16);
|
||||||
|
|
||||||
|
for (i = 0; i < PCR_PORT_SIZE; i += 4) {
|
||||||
|
const uint32_t reg = read_pcr32(port, i);
|
||||||
|
const bool rep = i && last_reg == reg;
|
||||||
|
if (!rep) {
|
||||||
|
if (!last_printed)
|
||||||
|
printf("*\n");
|
||||||
|
printf("0x%04zx: 0x%08"PRIx32"\n", i, reg);
|
||||||
|
}
|
||||||
|
|
||||||
|
last_reg = reg;
|
||||||
|
last_printed = !rep;
|
||||||
|
}
|
||||||
|
if (!last_printed)
|
||||||
|
printf("*\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_pcr_ports(struct pci_dev *const sb,
|
||||||
|
const uint8_t *const ports, const size_t count)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
pcr_init(sb);
|
||||||
|
|
||||||
|
for (i = 0; i < count; ++i) {
|
||||||
|
printf("\n========== PCR 0x%02x ==========\n\n", ports[i]);
|
||||||
|
print_pcr_port(ports[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void pcr_init(struct pci_dev *const sb)
|
void pcr_init(struct pci_dev *const sb)
|
||||||
{
|
{
|
||||||
bool error_exit = false;
|
bool error_exit = false;
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
uint32_t read_pcr32(uint8_t port, uint16_t offset);
|
uint32_t read_pcr32(uint8_t port, uint16_t offset);
|
||||||
|
|
||||||
|
void print_pcr_ports(struct pci_dev *sb, const uint8_t *ports, size_t count);
|
||||||
|
|
||||||
void pcr_init(struct pci_dev *sb);
|
void pcr_init(struct pci_dev *sb);
|
||||||
void pcr_cleanup(void);
|
void pcr_cleanup(void);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue