Anton Kochkov (anton.kochkov@gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1260
-gerrit
commit e63d25feacf674b9e07bc9b71bba8f03a09d5fe7 Author: Anton Kochkov anton.kochkov@gmail.com Date: Sat Jul 21 11:14:50 2012 +0400
msrtool: Add new "-lf" option to decode all MSRs
Added new -lf option - list all read only MSRs and force decoding them for detected or selected platform.
Change-Id: I237583618d0af72512b6084bd3486b67c9af54ba Signed-off-by: Anton Kochkov anton.kochkov@gmail.com --- util/msrtool/linux.c | 1 + util/msrtool/msrtool.c | 17 +++++++++++++++-- util/msrtool/msrtool.h | 1 + util/msrtool/msrutils.c | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/util/msrtool/linux.c b/util/msrtool/linux.c index ac94d80..e6df1b8 100644 --- a/util/msrtool/linux.c +++ b/util/msrtool/linux.c @@ -78,6 +78,7 @@ int linux_close(uint8_t cpu) { int linux_rdmsr(uint8_t cpu, uint32_t addr, struct msr *val) { struct msr tmp; if (lseek(msr_fd[cpu], addr, SEEK_SET) == -1) { + printf("linux_rdmsr(): cpu = %d\n", cpu); SYSERROR(lseek, addr); return 0; } diff --git a/util/msrtool/msrtool.c b/util/msrtool/msrtool.c index 433fc32..0a4c998 100644 --- a/util/msrtool/msrtool.c +++ b/util/msrtool/msrtool.c @@ -71,6 +71,7 @@ static void syntax(char *argv[]) { printf(" -r\t include [Reserved] values\n"); printf(" -k\t list all known systems and targets\n"); printf(" -l\t list MSRs and bit fields for current target(s) (-kl for ALL targets!)\n"); + printf(" -lf\t list MSRs and enforce decoding for current target\n"); printf(" -c\t access MSRs on the specified CPU, default=%d\n", DEFAULT_CPU); printf(" -m\t force a system, e.g: -m linux\n"); printf(" -t\t force a target, can be used multiple times, e.g: -t geodelx -t cs5536\n"); @@ -270,11 +271,11 @@ int main(int argc, char *argv[]) { int ret = 1; const struct sysdef *s; const struct targetdef *t; - uint8_t tn, listmsrs = 0, listknown = 0, input = 0; + uint8_t tn, listmsrs = 0, listknown = 0, input = 0, forcedecode = 0; uint32_t addr = 0; const char *streamfn = NULL, *difffn = NULL; struct msr msrval = MSR2(-1, -1); - while ((c = getopt(argc, argv, "hqvrklc:m:t:a:i:s:d:")) != -1) + while ((c = getopt(argc, argv, "hqvrklfc:m:t:a:i:s:d:")) != -1) switch (c) { case 'h': syntax(argv); @@ -294,6 +295,9 @@ int main(int argc, char *argv[]) { case 'l': listmsrs = 1; break; + case 'f': + forcedecode = 1; + break; case 'c': cpu = atoi(optarg); break; @@ -395,6 +399,15 @@ int main(int argc, char *argv[]) { }
if (listmsrs) { + if (forcedecode) { + for (tn = 0; tn < targets_found; tn++) { + if (tn) + printf("\n"); + dumpmsrs(targets[tn], cpu); + } + printf("\n"); + return 0; + } if (streamfn) return do_stream(streamfn, 1); for (tn = 0; tn < targets_found; tn++) { diff --git a/util/msrtool/msrtool.h b/util/msrtool/msrtool.h index 73671e5..25ddc6d 100644 --- a/util/msrtool/msrtool.h +++ b/util/msrtool/msrtool.h @@ -172,6 +172,7 @@ const struct msrdef *findmsrdef(const uint32_t addr); uint32_t msraddrbyname(const char *name); void dumpmsrdefs(const struct targetdef *t); int dumpmsrdefsvals(FILE *f, const struct targetdef *t, const uint8_t cpu); +int dumpmsrs(const struct targetdef *t, const uint8_t cpu); uint8_t str2msr(char *str, struct msr *msr, char **endptr); void decodemsr(const uint8_t cpu, const uint32_t addr, const struct msr val); uint8_t diff_msr(FILE *fout, const uint32_t addr, const struct msr a, const struct msr b); diff --git a/util/msrtool/msrutils.c b/util/msrtool/msrutils.c index 2ceb60c..922df14 100644 --- a/util/msrtool/msrutils.c +++ b/util/msrtool/msrutils.c @@ -211,6 +211,39 @@ int dumpmsrdefsvals(FILE *f, const struct targetdef *t, const uint8_t cpu) { return 0; }
+int dumpmsrs(const struct targetdef *t, const uint8_t cpu) { + struct msr bitval, mask; + struct msr val = MSR1(0); + const struct msrdef *m; + const struct msrbits *mb; + if (NULL == t) + return 1; + if (!sys->open(cpu, SYS_RDONLY)) + return 1; + printf("# %s MSRs:\n", t->name); + for (m = t->msrs; !MSR_ISEOT(*m); m++) { + if (t->msrs != m) + printf("\n"); + if (m->type != MSRTYPE_WRONLY) { + if (!sys->rdmsr(cpu, m->addr, &val)) + return 1; + printf("# %s\n", m->symbol); + for (mb = m->bits; mb->size; mb++) { + if (!reserved && 0 == strcmp(mb->name, "RSVD")) + continue; + print_bitdef(stdout, mb, " = "); + mask.hi = mask.lo = 0xffffffff; + mask = msr_shr(mask, 64 - mb->size); + bitval = msr_shr(val, mb->start - mb->size + 1); + msr_and(&bitval, mask); + print_bitval(stdout, mb, bitval); + } + } + } + sys->close(cpu); + return 0; +} + /** * Parse a hexadecimal string into an MSR value. *