x86: Fix devarch's MSR error handling
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 7 Mar 2016 18:58:59 +0000 (13:58 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 7 Mar 2016 19:36:21 +0000 (14:36 -0500)
commit69fb2c8823234f10687ca076b2a25ce25c80919b
tree17a7a8cbceb5a36d657a64c47560fc80742c1113
parent53109d06d29b38b6eea17d6818f5c5c4e11c0268
x86: Fix devarch's MSR error handling

In some cases, we weren't even setting errno, just returning -1.  Then on
error, we'd get crap from perror() like:

pread: Success

Now get meaningful errstrs and at least have errno set.

E.g.

(On a machine without IA32_PERF_CTL)
/ $ rdmsr 0x199
pread: Bad address, read_msr() faulted on MSR 0x199
/ $ wrmsr 0x198 88888
pwrite: Operation not permitted, MSR 0x198 not in write whitelist

Most of the other errors would be triggered by a rdmsr or wrmsr bugging
out.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/arch/x86/devarch.c