Maxim Polyakov has uploaded this change for review.

View Change

[WIP] util/inteltool: add opt to override cores number

In some cases, it is necessary to increase (if the server contains
several processors) or decrease (dump should be more compact) the
number of CPU cores for dump MSRs.

Change-Id: I3a037cf7ac270d2b51d6e453334c358ff47b4105
Signed-off-by: Maxim Polyakov <max.senia.poliak@gmail.com>
---
M util/inteltool/cpu.c
M util/inteltool/inteltool.c
M util/inteltool/inteltool.h
3 files changed, 15 insertions(+), 7 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/19/35919/1
diff --git a/util/inteltool/cpu.c b/util/inteltool/cpu.c
index f100851..9ae46c9 100644
--- a/util/inteltool/cpu.c
+++ b/util/inteltool/cpu.c
@@ -219,7 +219,7 @@
return error;
}

-int print_intel_core_msrs(void)
+int print_intel_core_msrs(unsigned int cores_num)
{
unsigned int i, core, id;
msr_t msr;
@@ -2256,8 +2256,10 @@

close(fd_msr);

- unsigned int max_core_limit = cpu->max_core_limit ? 8 : cpu->max_core_limit;
- for (core = 0; core < max_core_limit; core++) {
+ if (!cores_num)
+ cores_num = cpu->max_core_limit;
+
+ for (core = 0; core < cores_num; core++) {
#ifndef __DARWIN__
char msrfilename[64];
memset(msrfilename, 0, 64);
diff --git a/util/inteltool/inteltool.c b/util/inteltool/inteltool.c
index db80bd2..bc9af2b 100644
--- a/util/inteltool/inteltool.c
+++ b/util/inteltool/inteltool.c
@@ -476,7 +476,7 @@

static void print_usage(const char *name)
{
- printf("usage: %s [-vh?gGrpmedPMaAsfSRx]\n", name);
+ printf("usage: %s [-vh?gGrpmedPMcaAsfSRx]\n", name);
printf("\n"
" -v | --version: print the version\n"
" -h | --help: print this help\n\n"
@@ -493,6 +493,7 @@
" -d | --dmibar: dump northbridge DMIBAR registers\n"
" -P | --pciexpress: dump northbridge PCIEXBAR registers\n\n"
" -M | --msrs: dump CPU MSRs\n"
+ " -c <num> | --cores <num>: override CPU cores number for MSR dump\n\n"
" -A | --ambs: dump AMB registers\n"
" -x | --sgx: dump SGX status\n"
" -a | --all: dump all known (safe) registers\n"
@@ -508,6 +509,7 @@
struct pci_dev *sb = NULL, *nb, *gfx = NULL, *ahci = NULL, *dev;
const char *dump_spd_file = NULL;
int opt, option_index = 0;
+ unsigned int cores = 0;
unsigned int id, i;

char *sbname = "unknown", *nbname = "unknown", *gfxname = "unknown";
@@ -532,6 +534,7 @@
{"dmibar", 0, 0, 'd'},
{"pciexpress", 0, 0, 'P'},
{"msrs", 0, 0, 'M'},
+ {"cores", required_argument, 0, 'c'},
{"ambs", 0, 0, 'A'},
{"spi", 0, 0, 's'},
{"spd", 0, 0, 'S'},
@@ -543,7 +546,7 @@
{0, 0, 0, 0}
};

- while ((opt = getopt_long(argc, argv, "vh?gGrpmedPMaAsfRS:x",
+ while ((opt = getopt_long(argc, argv, "vh?gGrpmedPMc:aAsfRS:x",
long_options, &option_index)) != EOF) {
switch (opt) {
case 'v':
@@ -587,6 +590,9 @@
case 'M':
dump_coremsrs = 1;
break;
+ case 'c':
+ cores = strtoul(optarg, NULL, 0);
+ break;
case 'a':
dump_gpios = 1;
show_gpio_diffs = 1;
@@ -813,7 +819,7 @@
}

if (dump_coremsrs) {
- print_intel_core_msrs();
+ print_intel_core_msrs(cores);
printf("\n\n");
}

diff --git a/util/inteltool/inteltool.h b/util/inteltool/inteltool.h
index fc6dc4b..7708d70 100644
--- a/util/inteltool/inteltool.h
+++ b/util/inteltool/inteltool.h
@@ -385,7 +385,7 @@
void unmap_physical(void *virt_addr, size_t len);

unsigned int cpuid(unsigned int op);
-int print_intel_core_msrs(void);
+int print_intel_core_msrs(unsigned int cores_num);
int print_mchbar(struct pci_dev *nb, struct pci_access *pacc, const char *dump_spd_file);
int print_pmbase(struct pci_dev *sb, struct pci_access *pacc);
int print_rcba(struct pci_dev *sb);

To view, visit change 35919. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I3a037cf7ac270d2b51d6e453334c358ff47b4105
Gerrit-Change-Number: 35919
Gerrit-PatchSet: 1
Gerrit-Owner: Maxim Polyakov <max.senia.poliak@gmail.com>
Gerrit-Reviewer: Maxim Polyakov <max.senia.poliak@gmail.com>
Gerrit-Reviewer: Stefan Reinauer <stefan.reinauer@coreboot.org>
Gerrit-MessageType: newchange