#define pr_fmt(fmt) …
#include <linux/module.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/fcntl.h>
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/smp.h>
#include <linux/major.h>
#include <linux/fs.h>
#include <linux/device.h>
#include <linux/cpu.h>
#include <linux/notifier.h>
#include <linux/uaccess.h>
#include <linux/gfp.h>
#include <linux/security.h>
#include <asm/cpufeature.h>
#include <asm/msr.h>
static enum cpuhp_state cpuhp_msr_state;
enum allow_write_msrs { … };
static enum allow_write_msrs allow_writes = …;
static ssize_t msr_read(struct file *file, char __user *buf,
size_t count, loff_t *ppos)
{ … }
static int filter_write(u32 reg)
{ … }
static ssize_t msr_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{ … }
static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg)
{ … }
static int msr_open(struct inode *inode, struct file *file)
{ … }
static const struct file_operations msr_fops = …;
static char *msr_devnode(const struct device *dev, umode_t *mode)
{ … }
static const struct class msr_class = …;
static int msr_device_create(unsigned int cpu)
{ … }
static int msr_device_destroy(unsigned int cpu)
{ … }
static int __init msr_init(void)
{ … }
module_init(…) …;
static void __exit msr_exit(void)
{ … }
module_exit(…)
static int set_allow_writes(const char *val, const struct kernel_param *cp)
{ … }
static int get_allow_writes(char *buf, const struct kernel_param *kp)
{ … }
static const struct kernel_param_ops allow_writes_ops = …;
module_param_cb(…);
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;