From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752627AbbKPXXU (ORCPT ); Mon, 16 Nov 2015 18:23:20 -0500 Received: from mga09.intel.com ([134.134.136.24]:3788 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752304AbbKPXXQ (ORCPT ); Mon, 16 Nov 2015 18:23:16 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,304,1444719600"; d="scan'208";a="821678450" From: Andi Kleen To: peterz@infradead.org Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Andi Kleen Subject: [PATCH 1/2] x86: Add a __copy_from_user_nmi Date: Mon, 16 Nov 2015 15:23:02 -0800 Message-Id: <1447716183-854-1-git-send-email-andi@firstfloor.org> X-Mailer: git-send-email 2.4.3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andi Kleen Add a inlined __ variant of copy_from_user_nmi. The inlined variant allows the user to: - batch the access_ok check for multiple accesses - avoid having a pagefault_disable/enable on every access if the caller already ensures disabled page faults due to its context. - get all the optimizations in copy_*_user for small constant sized transfers It is just a define to __copy_from_user_inatomic. Signed-off-by: Andi Kleen --- arch/x86/include/asm/uaccess.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index a8df874..1d0766c 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -745,5 +745,14 @@ copy_to_user(void __user *to, const void *from, unsigned long n) #undef __copy_from_user_overflow #undef __copy_to_user_overflow +/* + * We rely on the nested NMI work to allow atomic faults from the NMI path; the + * nested NMI paths are careful to preserve CR2. + * + * Caller must use pagefault_enable/disable, or run in interrupt context, + * and also do a uaccess_ok() check + */ +#define __copy_from_user_nmi __copy_from_user_inatomic + #endif /* _ASM_X86_UACCESS_H */ -- 2.4.3