Hızlı yanıt: kod örneği
Ok, so finally I wrote the following kernel module. Am not sure it is right, since I don't observe the drastic slowdown which should accompany when you disable cache. But this compiles and inserts properly.Any pointers will be helpful.Thanks!
#include <linux/init.h>#include <linux/module.h>MODULE_LICENSE("Dual BSD/GPL");static int hello_init(void){ printk(KERN_ALERT "Hello, world\n"); __asm__("push %rax\n\t" "mov %cr0,%rax;\n\t" "or $(1 << 30),%rax;\n\t" "mov %rax,%cr0;\n\t" "wbinvd\n\t" "pop %rax"); return 0;}static void hello_exit(void){ printk(KERN_ALERT "Goodbye, cruel world\n"); __asm__("push %rax\n\t" "mov %cr0,%rax;\n\t" "and $~(1 << 30),%rax;\n\t" "mov %rax,%cr0;\n\t" "wbinvd\n\t" "pop %rax");}module_init(hello_init);module_exit(hello_exit);