添加对比crs和pgd的值的驱动...

This commit is contained in:
gatieme
2016-05-16 22:14:05 +08:00
parent f5d83411b0
commit cbfac406cd
2 changed files with 49 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
ifneq ($(KERNELRELEASE),)
obj-m := crs_pgd.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
all:
make -C $(KERNELDIR) M=$(PWD) modules
clean:
make -C $(KERNELDIR) M=$(PWD) clean
endif
+31
View File
@@ -0,0 +1,31 @@
//#include <asm/system.h>
#include <linux/mm.h>
#include <linux/mm_types.h>
#include <linux/sched.h>
#include <linux/types.h>
static unsigned long read_pgd(void)
{
return (unsigned long)current->mm->pgd;
}
static int __init init_cr3_pgd(void)
{
unsigned long cr3;
unsigned long pgd = 0;
cr3 = read_cr3();
printk("cr3----------------->0x%lx\n",cr3);
pgd = __pa(read_pgd());
printk("pgd----------------->0x%lx\n",pgd);
return 0;
}
static void __exit exit_cr3_pgd(void)
{
printk("--------------------->exit!\n");
return ;
}
module_init(init_cr3_pgd);
module_exit(exit_cr3_pgd);