diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-09-10 14:05:45 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-09-10 14:05:45 +0200 |
commit | 3ce9bcb583536c45a46c7302747029450e22279c (patch) | |
tree | 7a4167189ffc6dc909151d1a5d040f9f0656a9f4 /arch/x86/kernel/msr.c | |
parent | 26fd10517e810dd59ea050b052de24a75ee6dc07 (diff) | |
parent | f7d0b926ac8c8ec0c7a83ee69409bd2e6bb39f81 (diff) |
Merge branch 'core/xen' into x86/xen
Diffstat (limited to 'arch/x86/kernel/msr.c')
-rw-r--r-- | arch/x86/kernel/msr.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c index e43938086885..2e2af5d18191 100644 --- a/arch/x86/kernel/msr.c +++ b/arch/x86/kernel/msr.c @@ -72,21 +72,28 @@ static ssize_t msr_read(struct file *file, char __user *buf, u32 data[2]; u32 reg = *ppos; int cpu = iminor(file->f_path.dentry->d_inode); - int err; + int err = 0; + ssize_t bytes = 0; if (count % 8) return -EINVAL; /* Invalid chunk size */ for (; count; count -= 8) { err = rdmsr_safe_on_cpu(cpu, reg, &data[0], &data[1]); - if (err) - return -EIO; - if (copy_to_user(tmp, &data, 8)) - return -EFAULT; + if (err) { + if (err == -EFAULT) /* Fix idiotic error code */ + err = -EIO; + break; + } + if (copy_to_user(tmp, &data, 8)) { + err = -EFAULT; + break; + } tmp += 2; + bytes += 8; } - return ((char __user *)tmp) - buf; + return bytes ? bytes : err; } static ssize_t msr_write(struct file *file, const char __user *buf, @@ -96,21 +103,28 @@ static ssize_t msr_write(struct file *file, const char __user *buf, u32 data[2]; u32 reg = *ppos; int cpu = iminor(file->f_path.dentry->d_inode); - int err; + int err = 0; + ssize_t bytes = 0; if (count % 8) return -EINVAL; /* Invalid chunk size */ for (; count; count -= 8) { - if (copy_from_user(&data, tmp, 8)) - return -EFAULT; + if (copy_from_user(&data, tmp, 8)) { + err = -EFAULT; + break; + } err = wrmsr_safe_on_cpu(cpu, reg, data[0], data[1]); - if (err) - return -EIO; + if (err) { + if (err == -EFAULT) /* Fix idiotic error code */ + err = -EIO; + break; + } tmp += 2; + bytes += 8; } - return ((char __user *)tmp) - buf; + return bytes ? bytes : err; } static int msr_open(struct inode *inode, struct file *file) |