Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3201117yba; Tue, 16 Apr 2019 06:48:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3LzQmYpN2HjmYhFu+65aF6sWbtCqT3xkke4Kw+rvIcj/eExjGmGeYlYTryBYe3OJLYi1q X-Received: by 2002:a63:f115:: with SMTP id f21mr71209143pgi.65.1555422510173; Tue, 16 Apr 2019 06:48:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555422510; cv=none; d=google.com; s=arc-20160816; b=XFkqsM5rMXlrr+OPEVXaXu8USJ5pDseX4FQKG3a77TWq+H0JmSWp+Mbn3kFhNqj22p PkfTaYjt4vV3AZcxVq/CjoPS6cJpo/LKMDfyT1xFTzE8R6CqQcOuM+bXONoAC4CunzP5 Ud1mGXfdUbylHlplDjCRcJs0WnUoXF0PPRWsXviyvpkR1pzWaZpr9Y2jEhxoJoSf0oo/ tVdZxOtVslv7+hTYDdI7eZR1fib2siVHxsHjsoC1xZ17kkCMpu2ajLfHiI5E5wZf6csl 2Uze69sMwj14L/XEXRag9/U4aQ2tepXMaqTIX5ObFLSDOyf7oWcMAbqey9zYutnEV7yt TsSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:subject:cc:to:from; bh=k9/z2p3j44DZBGh5PTqmYkMKjzVk66Vx/Q6VNa38JtM=; b=Pg5AH/AcSea70GEinkUilQ6zotB0k+YMxq7NDGtOWBmdSsIjLHwAPx2R5I6pW1RMmY /K4eDFPsIkyqYO87CD76F2o5RqXAHP2MtCD52X3ilCoVGn70xKTcXyNjXTQb7xrnGINy Fltq63CrNMQXCFPF0u4nYjXDAt7Hhz3Z5wjhPYULkcSVdQYrPsD1b+8wgqhwztVI08cJ 3i+lm3qN6IxTKa17ExBdSDM5Gs/OL/FojuHnmavEA1gEo0XaBR8yIIRXAd1YKi/eoOzy K91MqnJu6ZZ2ho7FQbTf9U4kaChxoa/QSpT9xPrqgSE9Ftki/pHUs8bCHituQ0uuDrd/ jp1w== 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 60si50214352plf.122.2019.04.16.06.48.13; Tue, 16 Apr 2019 06:48:30 -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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729575AbfDPNrL (ORCPT + 99 others); Tue, 16 Apr 2019 09:47:11 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35346 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729558AbfDPNrI (ORCPT ); Tue, 16 Apr 2019 09:47:08 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3GDkXhi178394 for ; Tue, 16 Apr 2019 09:47:06 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2rwfpusg9n-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 16 Apr 2019 09:47:05 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 16 Apr 2019 14:46:58 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 16 Apr 2019 14:46:47 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x3GDkjdC54067278 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Apr 2019 13:46:45 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E76AD4C05C; Tue, 16 Apr 2019 13:46:44 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6053D4C052; Tue, 16 Apr 2019 13:46:43 +0000 (GMT) Received: from nimbus.lab.toulouse-stg.fr.ibm.com (unknown [9.101.4.33]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 16 Apr 2019 13:46:43 +0000 (GMT) From: Laurent Dufour To: akpm@linux-foundation.org, mhocko@kernel.org, peterz@infradead.org, kirill@shutemov.name, ak@linux.intel.com, dave@stgolabs.net, jack@suse.cz, Matthew Wilcox , aneesh.kumar@linux.ibm.com, benh@kernel.crashing.org, mpe@ellerman.id.au, paulus@samba.org, Thomas Gleixner , Ingo Molnar , hpa@zytor.com, Will Deacon , Sergey Senozhatsky , sergey.senozhatsky.work@gmail.com, Andrea Arcangeli , Alexei Starovoitov , kemi.wang@intel.com, Daniel Jordan , David Rientjes , Jerome Glisse , Ganesh Mahendran , Minchan Kim , Punit Agrawal , vinayak menon , Yang Shi , zhong jiang , Haiyan Song , Balbir Singh , sj38.park@gmail.com, Michel Lespinasse , Mike Rapoport Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, haren@linux.vnet.ibm.com, npiggin@gmail.com, paulmck@linux.vnet.ibm.com, Tim Chen , linuxppc-dev@lists.ozlabs.org, x86@kernel.org Subject: [PATCH v12 28/31] x86/mm: add speculative pagefault handling Date: Tue, 16 Apr 2019 15:45:19 +0200 X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190416134522.17540-1-ldufour@linux.ibm.com> References: <20190416134522.17540-1-ldufour@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19041613-0016-0000-0000-0000026F7281 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19041613-0017-0000-0000-000032CBBD98 Message-Id: <20190416134522.17540-29-ldufour@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-04-16_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904160093 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Zijlstra Try a speculative fault before acquiring mmap_sem, if it returns with VM_FAULT_RETRY continue with the mmap_sem acquisition and do the traditional fault. Signed-off-by: Peter Zijlstra (Intel) [Clearing of FAULT_FLAG_ALLOW_RETRY is now done in handle_speculative_fault()] [Retry with usual fault path in the case VM_ERROR is returned by handle_speculative_fault(). This allows signal to be delivered] [Don't build SPF call if !CONFIG_SPECULATIVE_PAGE_FAULT] [Handle memory protection key fault] Signed-off-by: Laurent Dufour --- arch/x86/mm/fault.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index 667f1da36208..4390d207a7a1 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -1401,6 +1401,18 @@ void do_user_addr_fault(struct pt_regs *regs, } #endif + /* + * Do not try to do a speculative page fault if the fault was due to + * protection keys since it can't be resolved. + */ + if (!(hw_error_code & X86_PF_PK)) { + fault = handle_speculative_fault(mm, address, flags); + if (fault != VM_FAULT_RETRY) { + perf_sw_event(PERF_COUNT_SW_SPF, 1, regs, address); + goto done; + } + } + /* * Kernel-mode access to the user address space should only occur * on well-defined single instructions listed in the exception @@ -1499,6 +1511,8 @@ void do_user_addr_fault(struct pt_regs *regs, } up_read(&mm->mmap_sem); + +done: if (unlikely(fault & VM_FAULT_ERROR)) { mm_fault_error(regs, hw_error_code, address, fault); return; -- 2.21.0