summaryrefslogtreecommitdiffstats
path: root/physmap.c
diff options
context:
space:
mode:
authorAnti Sullin <anti.sullin@artecdesign.ee>2010-05-17 23:19:22 +0000
committerMichael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>2010-05-17 23:19:22 +0000
commitbe24d8198c56f8d2d6dc67c40a78c64b46860819 (patch)
treec26570ac185a8f1571728dfef2495f0b679dc43e /physmap.c
parent8841d3e703e3d3f7c7920b7f9439fc9333c15638 (diff)
downloadast2050-flashrom-be24d8198c56f8d2d6dc67c40a78c64b46860819.zip
ast2050-flashrom-be24d8198c56f8d2d6dc67c40a78c64b46860819.tar.gz
Write MSRs in a platform and compiler-independent form
Msr_t memory layout may depend on compiler; with optimizations this may lead to writing incorrect data to MSR. Create a temporary buffer with correct layout to avoid this problem. Corresponding to flashrom svn r999. Signed-off-by: Anti Sullin <anti.sullin@artecdesign.ee> Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Diffstat (limited to 'physmap.c')
-rw-r--r--physmap.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/physmap.c b/physmap.c
index 31db470..03fef95 100644
--- a/physmap.c
+++ b/physmap.c
@@ -282,13 +282,17 @@ msr_t rdmsr(int addr)
int wrmsr(int addr, msr_t msr)
{
+ uint32_t buf[2];
+ buf[0] = msr.lo;
+ buf[1] = msr.hi;
+
if (lseek(fd_msr, (off_t) addr, SEEK_SET) == -1) {
perror("Could not lseek() to MSR");
close(fd_msr);
exit(1);
}
- if (write(fd_msr, &msr, 8) != 8 && errno != EIO) {
+ if (write(fd_msr, buf, 8) != 8 && errno != EIO) {
perror("Could not write() MSR");
close(fd_msr);
exit(1);
OpenPOWER on IntegriCloud