x86: Add a helper for loading cr2
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 26 Jan 2016 19:55:52 +0000 (14:55 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 2 Feb 2016 22:43:52 +0000 (17:43 -0500)
We'll need to manually save and restore it for VMs.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/arch/x86/x86.h

index 8b9b6e1..b50d9b0 100644 (file)
@@ -296,6 +296,11 @@ static inline unsigned long rcr0(void)
        return val;
 }
 
+static inline void lcr2(unsigned long val)
+{
+       asm volatile("mov %0,%%cr2" : : "r" (val));
+}
+
 static inline unsigned long rcr2(void)
 {
        unsigned long val;