I have an pre-existing code which tries to update WP bit of CR0 register. After upgrade to Kernel 6.8.0 in Ubuntu 22.04, now this code triggers a crash.Same code runs perfectly fine in Virtual environment. It crashes only when it is running on Physical machine with AMD processor.This is my sample code.
inline void modify_wp_flag(unsigned long cr0){# if defined(__FORCE_ORDER) asm volatile("mov %0,%%cr0" : "+r"(cr0) : __FORCE_ORDER);# else asm volatile("mov %0,%%cr0" : "+r"(cr0), "+m"(__force_order));# endif}static int sampledriver_init(void){ //reset WP flag modify_wp_flag((unsigned long)(read_cr0() & (~ X86_CR0_WP))); //set WP flag modify_wp_flag((unsigned long)(read_cr0() | X86_CR0_WP)); return 0;}
Any idea what has changed in kernel 6.8.0 which causing this. This operation was working correctly with previous kernel.