Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2230073imm; Fri, 7 Sep 2018 12:54:23 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYxxzy6F3c0qfG0h8eeObfuXKwGnydYlFesAW8Gc6TU3X7vCR1QDBEV2Hm4hVm02ChJLtZy X-Received: by 2002:a62:9042:: with SMTP id a63-v6mr10408997pfe.52.1536350063324; Fri, 07 Sep 2018 12:54:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536350063; cv=none; d=google.com; s=arc-20160816; b=Vv6jKiQMixpeKJ1xE4fs4lXfrhT3bOJHTIVxIbaYq1pNBRqWb22GFsZgZRp12hNdoP bX5d35lfeRFj/yXrxnp6ninR7hY9O95w8Cy0om+pSh44Fz5HHTwrNFcz2vy89FgH8DC0 9fFI0grwz1gb/b05mu66+xEmb/huxYd+RzJy6XPnmyTlDRMpIXE5bYkU85ZKZbyPEKHk KGRPaWdpZaBByklVYMvH+ZfPaOFvbBYwSJ1csd/HE4WqgB6NBOBmpS8/dzPiIndHKwip gua6FfGH2qFKk9c8dagjS1nKAZp9fct70vGF+6jTaYMsw7//cWuucY/RFqNPzRFa7VX0 tICQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:in-reply-to:references:date :from:cc:to:subject; bh=tlRfdkiSfNnrgei8Y5m6AWR4IcKZFtOGz/Phlh1I9Vo=; b=T/mPRNM9Ef9mX8gzpINgCUZ4Gv70jQ/DeUdXgYfWz7jQdNPC8JQOD1f+3FdKobXV+2 T+9my19IKToeaeBLeJ8b5rgJebbv0AszlvmlXSznmDxbM5xAcwDjglkCIbpVeYfqD2Z3 YnGQ8qcg1CtIw6I8x+J6UuJdpoDXhL2WlU0EWIbItiQbwKuhxDnyF7cHk3w5ikLmhUaQ 9SP5crU/R4dx3BnOwJQ78tSuUtsZVD5EXqF3LIzVbibkccDXS+qYgD2b8Y9mMSJ44pF1 8/5utoAEhQ3Q4wXlK0ZcOQxEG96lp0HTAmjvbzEMZNQVbfkKIpgf/H6SIrDhXV17yeeH 9K0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i3-v6si9076911pld.454.2018.09.07.12.54.07; Fri, 07 Sep 2018 12:54:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727726AbeIHAfS (ORCPT + 99 others); Fri, 7 Sep 2018 20:35:18 -0400 Received: from mga12.intel.com ([192.55.52.136]:44940 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726107AbeIHAfR (ORCPT ); Fri, 7 Sep 2018 20:35:17 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Sep 2018 12:52:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,343,1531810800"; d="scan'208";a="260780738" Received: from viggo.jf.intel.com (HELO localhost.localdomain) ([10.54.77.144]) by fmsmga005.fm.intel.com with ESMTP; 07 Sep 2018 12:51:28 -0700 Subject: [RFC][PATCH 3/8] x86/mm: break out user address space handling To: linux-kernel@vger.kernel.org Cc: Dave Hansen , sean.j.christopherson@intel.com, peterz@infradead.org, tglx@linutronix.de, x86@kernel.org, luto@kernel.org From: Dave Hansen Date: Fri, 07 Sep 2018 12:48:57 -0700 References: <20180907194852.3C351B82@viggo.jf.intel.com> In-Reply-To: <20180907194852.3C351B82@viggo.jf.intel.com> Message-Id: <20180907194857.93621ACE@viggo.jf.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Hansen The last patch broke out kernel address space handing into its own helper. Now, do the same for user address space handling. Signed-off-by: Dave Hansen Cc: Sean Christopherson Cc: "Peter Zijlstra (Intel)" Cc: Thomas Gleixner Cc: x86@kernel.org Cc: Andy Lutomirski --- b/arch/x86/mm/fault.c | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff -puN arch/x86/mm/fault.c~pkeys-fault-warnings-01 arch/x86/mm/fault.c --- a/arch/x86/mm/fault.c~pkeys-fault-warnings-01 2018-09-07 11:21:46.663751901 -0700 +++ b/arch/x86/mm/fault.c 2018-09-07 11:21:46.667751901 -0700 @@ -1203,6 +1203,7 @@ static inline bool smap_violation(int er return true; } +/* Handle faults in the kernel portion of the address space */ static void do_kern_addr_space_fault(struct pt_regs *regs, unsigned long hw_error_code, unsigned long address) @@ -1252,14 +1253,11 @@ do_kern_addr_space_fault(struct pt_regs } NOKPROBE_SYMBOL(do_kern_addr_space_fault); -/* - * This routine handles page faults. It determines the address, - * and the problem, and then passes it off to one of the appropriate - * routines. - */ -static noinline void -__do_page_fault(struct pt_regs *regs, unsigned long hw_error_code, - unsigned long address) +/* Handle faults in the user portion of the address space */ +static inline +void do_user_addr_space_fault(struct pt_regs *regs, + unsigned long hw_error_code, + unsigned long address) { unsigned long sw_error_code; struct vm_area_struct *vma; @@ -1272,17 +1270,6 @@ __do_page_fault(struct pt_regs *regs, un tsk = current; mm = tsk->mm; - prefetchw(&mm->mmap_sem); - - if (unlikely(kmmio_fault(regs, address))) - return; - - /* Was the fault on kernel-controlled part of the address space? */ - if (unlikely(fault_in_kernel_space(address))) { - do_kern_addr_space_fault(regs, hw_error_code, address); - return; - } - /* kprobes don't want to hook the spurious faults: */ if (unlikely(kprobes_fault(regs))) return; @@ -1486,6 +1473,28 @@ good_area: check_v8086_mode(regs, address, tsk); } +NOKPROBE_SYMBOL(do_user_addr_space_fault); + +/* + * This routine handles page faults. It determines the address, + * and the problem, and then passes it off to one of the appropriate + * routines. + */ +static noinline void +__do_page_fault(struct pt_regs *regs, unsigned long hw_error_code, + unsigned long address) +{ + prefetchw(¤t->mm->mmap_sem); + + if (unlikely(kmmio_fault(regs, address))) + return; + + /* Was the fault on kernel-controlled part of the address space? */ + if (unlikely(fault_in_kernel_space(address))) + do_kern_addr_space_fault(regs, hw_error_code, address); + else + do_user_addr_space_fault(regs, hw_error_code, address); +} NOKPROBE_SYMBOL(__do_page_fault); static nokprobe_inline void _