Skip to content

Instantly share code, notes, and snippets.

@morimolymoly
Created September 24, 2018 16:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morimolymoly/f4724eb95e32e68148977bd8cf790f3b to your computer and use it in GitHub Desktop.
Save morimolymoly/f4724eb95e32e68148977bd8cf790f3b to your computer and use it in GitHub Desktop.
#include <linux/module.h>
static inline uint64_t exec_rdmsr(uint64_t msr)
{
uint32_t low, high;
asm volatile (
"rdmsr"
: "=a"(low), "=d"(high)
: "c"(msr)
);
return ((uint64_t)high << 32) | low;
}
static int mymodule_init(void)
{
uint64_t res = exec_rdmsr(0xc0000082U);
printk(KERN_INFO "MOLY: MSR_IA32_LSTAR: %llx\n", res);
return 0;
}
static void mymodule_exit(void)
{
}
module_init(mymodule_init);
module_exit(mymodule_exit);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment