We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 873d50d commit 8dbec27Copy full SHA for 8dbec27
arch/x86/include/asm/special_insns.h
@@ -31,7 +31,20 @@ static inline unsigned long native_read_cr0(void)
31
32
static inline void native_write_cr0(unsigned long val)
33
{
34
- asm volatile("mov %0,%%cr0": : "r" (val), "m" (__force_order));
+ unsigned long bits_missing = 0;
35
+
36
+set_register:
37
+ asm volatile("mov %0,%%cr0": "+r" (val), "+m" (__force_order));
38
39
+ if (static_branch_likely(&cr_pinning)) {
40
+ if (unlikely((val & X86_CR0_WP) != X86_CR0_WP)) {
41
+ bits_missing = X86_CR0_WP;
42
+ val |= bits_missing;
43
+ goto set_register;
44
+ }
45
+ /* Warn after we've set the missing bits. */
46
+ WARN_ONCE(bits_missing, "CR0 WP bit went missing!?\n");
47
48
}
49
50
static inline unsigned long native_read_cr2(void)
0 commit comments