mirror of
				https://review.coreboot.org/flashrom.git
				synced 2025-11-04 15:10:39 +01:00 
			
		
		
		
	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>
This commit is contained in:
		
				
					committed by
					
						
						Michael Karcher
					
				
			
			
				
	
			
			
			
						parent
						
							8841d3e703
						
					
				
				
					commit
					be24d8198c
				
			@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user