Add ioctl to msr driver to trigger int18 This is useful to inject machine checks on AMD CPUs. I could have written an own driver, but it seemed overkill. Signed-off-by: Andi Kleen --- arch/x86/kernel/msr.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) Index: linux/arch/x86/kernel/msr.c =================================================================== --- linux.orig/arch/x86/kernel/msr.c +++ linux/arch/x86/kernel/msr.c @@ -122,6 +122,24 @@ static int msr_open(struct inode *inode, return 0; } +#define MSR_INJECT_INT18 1 + +static void call_int18(void *arg) +{ + printk(KERN_INFO "Injecting machine check\n"); + asm("int $0x18"); +} + +static long msr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) +{ + if (cmd == MSR_INJECT_INT18) { + unsigned int cpu = iminor(f->f_path.dentry->d_inode); + smp_call_function_single(cpu, call_int18, NULL, 0, 1); + return 0; + } else + return -EINVAL; +} + /* * File operations we support */ @@ -131,6 +149,8 @@ static const struct file_operations msr_ .read = msr_read, .write = msr_write, .open = msr_open, + .unlocked_ioctl = msr_ioctl, + .compat_ioctl = msr_ioctl, }; static int __cpuinit msr_device_create(int cpu)