+static inline unsigned long read_cr4(void)
+{
+ unsigned long cr4;
+
+ asm volatile ("mov %%cr4, %0" : "=r" (cr4));
+
+ return cr4;
+}
+
+static inline unsigned long read_cr8(void)
+{
+ unsigned long cr8;
+
+ asm volatile ("mov %%cr8, %0" : "=r" (cr8));
+
+ return cr8;
+}
+
+static inline void write_cr0(unsigned long cr0)
+{
+ asm volatile ("mov %0, %%cr0" :: "r" (cr0));
+}
+
+static inline void write_cr2(unsigned long cr2)
+{
+ asm volatile ("mov %0, %%cr2" :: "r" (cr2));
+}
+
+static inline void write_cr3(unsigned long cr3)
+{
+ asm volatile ("mov %0, %%cr3" :: "r" (cr3));
+}
+
+static inline void write_cr4(unsigned long cr4)
+{
+ asm volatile ("mov %0, %%cr4" :: "r" (cr4));
+}
+
+static inline void write_cr8(unsigned long cr8)
+{
+ asm volatile ("mov %0, %%cr8" :: "r" (cr8));
+}
+