util/inteltool: Add support for SGX status

Add support for dumping Intel Software Guard Extension (SGX)
status. --sgx or -x is the command line switch to get SGX status.
The code iterates through all cores and reads MSRs to check if SGX is
supported, enabled and the feature is locked.

Change-Id: I1f5046c1f6703f5429c8717053ffe9c981cedf6f
Signed-off-by: Pratik Prajapati <pratikkumar.v.prajapati@intel.com>
Reviewed-on: https://review.coreboot.org/20758
Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
This commit is contained in:
Pratik Prajapati
2017-07-24 13:53:26 -07:00
committed by Martin Roth
parent a1af090002
commit 91664d4d6f
3 changed files with 158 additions and 3 deletions

View File

@@ -244,7 +244,7 @@ void print_version(void)
void print_usage(const char *name)
{
printf("usage: %s [-vh?gGrpmedPMaAsfSR]\n", name);
printf("usage: %s [-vh?gGrpmedPMaAsfSRx]\n", name);
printf("\n"
" -v | --version: print the version\n"
" -h | --help: print this help\n\n"
@@ -262,6 +262,7 @@ void print_usage(const char *name)
" -P | --pciexpress: dump northbridge PCIEXBAR registers\n\n"
" -M | --msrs: dump CPU MSRs\n"
" -A | --ambs: dump AMB registers\n"
" -x | --sgx: dump SGX status\n"
" -a | --all: dump all known (safe) registers\n"
"\n");
exit(1);
@@ -280,7 +281,7 @@ int main(int argc, char *argv[])
int dump_gpios = 0, dump_mchbar = 0, dump_rcba = 0;
int dump_pmbase = 0, dump_epbar = 0, dump_dmibar = 0;
int dump_pciexbar = 0, dump_coremsrs = 0, dump_ambs = 0;
int dump_spi = 0, dump_gfx = 0, dump_ahci = 0;
int dump_spi = 0, dump_gfx = 0, dump_ahci = 0, dump_sgx = 0;
int show_gpio_diffs = 0;
static struct option long_options[] = {
@@ -301,10 +302,11 @@ int main(int argc, char *argv[])
{"all", 0, 0, 'a'},
{"gfx", 0, 0, 'f'},
{"ahci", 0, 0, 'R'},
{"sgx", 0, 0, 'x'},
{0, 0, 0, 0}
};
while ((opt = getopt_long(argc, argv, "vh?gGrpmedPMaAsfRS:",
while ((opt = getopt_long(argc, argv, "vh?gGrpmedPMaAsfRS:x",
long_options, &option_index)) != EOF) {
switch (opt) {
case 'v':
@@ -361,6 +363,7 @@ int main(int argc, char *argv[])
dump_ambs = 1;
dump_spi = 1;
dump_ahci = 1;
dump_sgx = 1;
break;
case 'A':
dump_ambs = 1;
@@ -368,6 +371,9 @@ int main(int argc, char *argv[])
case 's':
dump_spi = 1;
break;
case 'x':
dump_sgx = 1;
break;
case 'h':
case '?':
default:
@@ -575,6 +581,9 @@ int main(int argc, char *argv[])
print_ahci(ahci);
}
if (dump_sgx)
print_sgx();
/* Clean up */
if (ahci)
pci_free_dev(ahci);