Author: mkarcher Date: Tue May 18 01:19:22 2010 New Revision: 999 URL: http://flashrom.org/trac/coreboot/changeset/999
Log: 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.
Signed-off-by: Anti Sullin anti.sullin@artecdesign.ee Acked-by: Michael Karcher flashrom@mkarcher.dialup.fu-berlin.de
Modified: trunk/physmap.c
Modified: trunk/physmap.c ============================================================================== --- trunk/physmap.c Sat May 15 17:04:37 2010 (r998) +++ trunk/physmap.c Tue May 18 01:19:22 2010 (r999) @@ -282,13 +282,17 @@
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);