Bug 675734

Summary: cpufreq-aperf on 32-bit not working
Product: Red Hat Enterprise Linux 6 Reporter: Frank Arnold <frank.arnold>
Component: cpufrequtilsAssignee: Petr Šabata <psabata>
Status: CLOSED ERRATA QA Contact: Evan McNabb <emcnabb>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.0CC: kthiruma
Target Milestone: rcKeywords: EasyFix, Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: cpufrequtils-007-6.el6 Doc Type: Bug Fix
Doc Text:
Prior to this update, the cpufreq-aperf utility did not run on 32-bit systems due to an incorrect argument passed to the read() call. This problem has been fixed: the buffer size is now used instead of the size of the pointer and the cpufreq-aperf utility runs as expected.
Story Points: ---
Clone Of:
: 675743 (view as bug list) Environment:
Last Closed: 2011-08-31 09:19:53 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 675743    

Description Frank Arnold 2011-02-07 15:13:40 UTC
This is already fixed in RHEL 5 (bug 568754), and we need to get this into RHEL 6 too. The Fedora packages are also affected.

Upstream commit:

From d4490efed068a552e8b67d52a0726458a224c9a0 Mon Sep 17 00:00:00 2001
From: Frank Arnold <frank.arnold>
Date: Wed, 8 Dec 2010 17:39:14 +0100
Subject: [PATCH] cpufrequtils aperf: Fix MSR read on 32-bit

The cpufreq-aperf command does not work on 32-bit systems. The reason
for that is a wrong count argument passed to the read() call. Instead
of the buffer size, the size of the pointer to the buffer is used. On
64-bit systems this just happened to work, because we need to read an
8 byte value and a pointer has a size of 8 bytes on 64-bit. On 32-bit
systems only 4 bytes are read, which then triggers the error path.

Signed-off-by: Frank Arnold <frank.arnold>
Reviewed-by: Thomas Renninger <trenn>
Signed-off-by: Dominik Brodowski <linux>
---
 utils/aperf.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/utils/aperf.c b/utils/aperf.c
index 1c64501..6302f5a 100644
--- a/utils/aperf.c
+++ b/utils/aperf.c
@@ -100,7 +100,7 @@ static int read_msr(int cpu, unsigned int idx, unsigned long long *val)
 		return -1;
 	if (lseek(fd, idx, SEEK_CUR) == -1)
 		goto err;
-	if (read(fd, val, sizeof val) != sizeof *val)
+	if (read(fd, val, sizeof *val) != sizeof *val)
 		goto err;
 	close(fd);
 	return 0;
-- 
1.7.4

Comment 1 Petr Šabata 2011-02-07 15:39:59 UTC
Cloned this bug for Fedora 14+.

Comment 3 Petr Šabata 2011-06-30 14:09:02 UTC
Fixed in CVS, cpufrequtils-007-6.el6

Comment 5 Eliska Slobodova 2011-08-10 08:42:19 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Prior to this update, the cpufreq-aperf utility did not run on 32-bit systems due to a incorrect argument passed to the read() call. This problem has been fixed: the buffer size is now used instead of the size of the pointer and the cpufreq-aperf utility runs as expected.

Comment 6 Eliska Slobodova 2011-08-10 08:52:00 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1 +1 @@
-Prior to this update, the cpufreq-aperf utility did not run on 32-bit systems due to a incorrect argument passed to the read() call. This problem has been fixed: the buffer size is now used instead of the size of the pointer and the cpufreq-aperf utility runs as expected.+Prior to this update, the cpufreq-aperf utility did not run on 32-bit systems due to an incorrect argument passed to the read() call. This problem has been fixed: the buffer size is now used instead of the size of the pointer and the cpufreq-aperf utility runs as expected.

Comment 8 errata-xmlrpc 2011-08-31 09:19:53 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-1224.html