msr.c (75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37) | msr.c (aefcf2f4b58155d27340ba5f9ddbe9513da8286d) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* ----------------------------------------------------------------------- * 3 * 4 * Copyright 2000-2008 H. Peter Anvin - All Rights Reserved 5 * Copyright 2009 Intel Corporation; author: H. Peter Anvin 6 * 7 * ----------------------------------------------------------------------- */ 8 --- 20 unchanged lines hidden (view full) --- 29#include <linux/smp.h> 30#include <linux/major.h> 31#include <linux/fs.h> 32#include <linux/device.h> 33#include <linux/cpu.h> 34#include <linux/notifier.h> 35#include <linux/uaccess.h> 36#include <linux/gfp.h> | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* ----------------------------------------------------------------------- * 3 * 4 * Copyright 2000-2008 H. Peter Anvin - All Rights Reserved 5 * Copyright 2009 Intel Corporation; author: H. Peter Anvin 6 * 7 * ----------------------------------------------------------------------- */ 8 --- 20 unchanged lines hidden (view full) --- 29#include <linux/smp.h> 30#include <linux/major.h> 31#include <linux/fs.h> 32#include <linux/device.h> 33#include <linux/cpu.h> 34#include <linux/notifier.h> 35#include <linux/uaccess.h> 36#include <linux/gfp.h> |
37#include <linux/security.h> |
|
37 38#include <asm/cpufeature.h> 39#include <asm/msr.h> 40 41static struct class *msr_class; 42static enum cpuhp_state cpuhp_msr_state; 43 44static ssize_t msr_read(struct file *file, char __user *buf, --- 29 unchanged lines hidden (view full) --- 74{ 75 const u32 __user *tmp = (const u32 __user *)buf; 76 u32 data[2]; 77 u32 reg = *ppos; 78 int cpu = iminor(file_inode(file)); 79 int err = 0; 80 ssize_t bytes = 0; 81 | 38 39#include <asm/cpufeature.h> 40#include <asm/msr.h> 41 42static struct class *msr_class; 43static enum cpuhp_state cpuhp_msr_state; 44 45static ssize_t msr_read(struct file *file, char __user *buf, --- 29 unchanged lines hidden (view full) --- 75{ 76 const u32 __user *tmp = (const u32 __user *)buf; 77 u32 data[2]; 78 u32 reg = *ppos; 79 int cpu = iminor(file_inode(file)); 80 int err = 0; 81 ssize_t bytes = 0; 82 |
83 err = security_locked_down(LOCKDOWN_MSR); 84 if (err) 85 return err; 86 |
|
82 if (count % 8) 83 return -EINVAL; /* Invalid chunk size */ 84 85 for (; count; count -= 8) { 86 if (copy_from_user(&data, tmp, 8)) { 87 err = -EFAULT; 88 break; 89 } --- 35 unchanged lines hidden (view full) --- 125 if (!(file->f_mode & FMODE_WRITE)) { 126 err = -EBADF; 127 break; 128 } 129 if (copy_from_user(®s, uregs, sizeof(regs))) { 130 err = -EFAULT; 131 break; 132 } | 87 if (count % 8) 88 return -EINVAL; /* Invalid chunk size */ 89 90 for (; count; count -= 8) { 91 if (copy_from_user(&data, tmp, 8)) { 92 err = -EFAULT; 93 break; 94 } --- 35 unchanged lines hidden (view full) --- 130 if (!(file->f_mode & FMODE_WRITE)) { 131 err = -EBADF; 132 break; 133 } 134 if (copy_from_user(®s, uregs, sizeof(regs))) { 135 err = -EFAULT; 136 break; 137 } |
138 err = security_locked_down(LOCKDOWN_MSR); 139 if (err) 140 break; |
|
133 err = wrmsr_safe_regs_on_cpu(cpu, regs); 134 if (err) 135 break; 136 if (copy_to_user(uregs, ®s, sizeof(regs))) 137 err = -EFAULT; 138 break; 139 140 default: --- 99 unchanged lines hidden --- | 141 err = wrmsr_safe_regs_on_cpu(cpu, regs); 142 if (err) 143 break; 144 if (copy_to_user(uregs, ®s, sizeof(regs))) 145 err = -EFAULT; 146 break; 147 148 default: --- 99 unchanged lines hidden --- |