diff --git a/arch/x86/lib/usercopy.c b/arch/x86/lib/usercopy.c index ddf9ecb..938e45c 100644 --- a/arch/x86/lib/usercopy.c +++ b/arch/x86/lib/usercopy.c @@ -10,6 +10,8 @@ #include #include +#include + /* * We rely on the nested NMI work to allow atomic faults from the NMI path; the * nested NMI paths are careful to preserve CR2. @@ -18,6 +20,7 @@ unsigned long copy_from_user_nmi(void *to, const void __user *from, unsigned long n) { unsigned long ret; + unsigned long cr2; if (__range_not_ok(from, n, TASK_SIZE)) return 0; @@ -27,9 +30,11 @@ copy_from_user_nmi(void *to, const void __user *from, unsigned long n) * disable pagefaults so that its behaviour is consistent even when * called form other contexts. */ + cr2 = read_cr2(); pagefault_disable(); ret = __copy_from_user_inatomic(to, from, n); pagefault_enable(); + write_cr2(cr2); return ret; }