From patchwork Thu Apr 11 13:09:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13625901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2ADBCD1299 for ; Thu, 11 Apr 2024 12:42:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A07B16B0099; Thu, 11 Apr 2024 08:42:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B7216B009B; Thu, 11 Apr 2024 08:42:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 795446B009D; Thu, 11 Apr 2024 08:42:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 574CD6B0099 for ; Thu, 11 Apr 2024 08:42:15 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 1B2C1A09E8 for ; Thu, 11 Apr 2024 12:42:15 +0000 (UTC) X-FDA: 81997213830.09.E182598 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf30.hostedemail.com (Postfix) with ESMTP id BE3E98000A for ; Thu, 11 Apr 2024 12:42:11 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712839332; a=rsa-sha256; cv=none; b=W8vaxtcd613+O3w9uutkLz7p8jsYN58Wr3xujfCTSFy/9z1wqvZRzSPRm9+ovYEfBaAlSe rIZ5i3Y8htWqmcqixqUtc49kAhBJnqs39EwlV6by+8SeR7bttEX7px1ZDTe99GbsHDCQZm NcMsz2jw7Y6sJieg5sR82KvRO+430og= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=none; spf=pass (imf30.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712839332; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QFdHNQXcpU0BF6xHOTfPGJY6ysWRVSKq6JKrnc7RimA=; b=HbcjETqQ67sy1LtZECpAdm1VDg50D3tlTLls1rFkx3aj/hVjzlcet0ioPERoXuf9uyV/vD aqaLEUWK7RmboipzYySE3UBuc80S4LalGlMqCrUMvEfsweeo179/cS13hm1OidlF+SUfaj uFTbeiiUPEx2IIbYx4Q2dUw9fDCoeC8= Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VFfQR2lNyzwS29; Thu, 11 Apr 2024 20:39:11 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 0E0AE1400D1; Thu, 11 Apr 2024 20:42:08 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 11 Apr 2024 20:42:07 +0800 From: Kefeng Wang To: Andrew Morton , Russell King , Catalin Marinas CC: Will Deacon , , , Cristian Marussi , Mark Brown , Aishwarya TCV , Kefeng Wang Subject: [PATCH v2 1/2] arm64: mm: drop VM_FAULT_BADMAP/VM_FAULT_BADACCESS Date: Thu, 11 Apr 2024 21:09:24 +0800 Message-ID: <20240411130925.73281-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240411130925.73281-1-wangkefeng.wang@huawei.com> References: <20240411130925.73281-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: BE3E98000A X-Stat-Signature: 9mbtyodaw9tk7cww3kuanb633tk4grwq X-HE-Tag: 1712839331-569558 X-HE-Meta: U2FsdGVkX19Q3pE+z/67NSosZ5LBWxug0v9adavNFuIbAQHR0YPuGaLFI8pwcQiI0sI/XdnHEfoVjjT0hqmm5mkxc51AaOUWwuFrJE12mtfzKO94lE9NEM8+b4aVZsLS0bL+IAuilmF/HMNP6Egg1bDmfQ989d4BHwdMsrxaDUPDJDTtpVSksbU/fsoDzvkyc9OdPT4kkq5Q1qn9tdoJpppCxFvcpQKH/g825eubxuJ79UDgs/1LVSOLOx4jadRGfVkB7wK+mvMw1vDgtFMlZofP3HTWRkssQS7FeJHO8WNQ5U/TbSavaDOBmRJoPS0KIz0dqnZZ7nIB5CJXNSyazvp1O3Oy9QgnzDEi9/WRbcncwW81HEky5HmvSNnbEHI7QYYMrv6KFw1Xjwm8UQ5gBonOR6KeU/sjWpPIGG3LwPumaZ/RmGsACp9ojFuHBJGLlYRzHYYIgV0w4r7Afo7uUbBdpjS28Zdhch2cRfuZ60lxYgA4TTIeVtDWuVYYRrzrVqe6Mo2uNkwojsBeBXGukib75Z74gzUfj8aZLycPHzh73RCrpkIMK5trBEAe3R8RgAqBDdyiNasqzlmAPIYAxdykNfA9bN+V66h5/nx8BYj8cTO6abPptr3Kkog4SIxEE+udLAYLzzPiweDa1Y2SI4fd4DHkuT/kW6t3SRkmbwnwiGqmH82lDJNU3DTaZaSUiroj1vb2+SWPpDV0a7FlrjwQ62xbx8MIOA1vX82himSXNgvOlN4MIsbGG0Tq+1D9p+hCEOLcEUwGV7ucfX05RdIcJ4/ZEViBjDmfl4geDaI57Z58oX6BBNfhlDyYGv9mAoB4qUnnGOo/w6r1OTpe0Y3IRmg0Al5p3Sj0GAXe4F3Yqu4OU5ObhSFAiThqx9CqQdQvk3WdjSZT/pRWW5Dhhk0/S8H4xJbUdpquRMsyfxQghEiBSkoDiIcASjwvBFhWkLR5yOqNyctYFiH+lPc 6F8cDldD 6B/FYngJBe2c48JfbkkRUbNVz7E5dv4Wh77QOPsa/jv5SxzfEgSy1aKMs1alzaITiBUe0kghpLN9DfdXu1hJ9S5ug/lmGpynin60yZqJKd/OkiNvlamGpeKWwRl5LVY7425yPMQqZP//mdhs9hLf5Q2aCa+B6aQfmfBmV3N4gDzs7DGVaVM3wsybpp8DNWSnq/DOG X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: If bad map or access, directly set si_code to SEGV_MAPRR or SEGV_ACCERR, also set fault to 0 and goto error handling, which make us to drop the arch's special vm fault reason. Signed-off-by: Kefeng Wang Reviewed-by: Catalin Marinas --- arch/arm64/mm/fault.c | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 405f9aa831bd..5b7e6ada3125 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -500,9 +500,6 @@ static bool is_write_abort(unsigned long esr) return (esr & ESR_ELx_WNR) && !(esr & ESR_ELx_CM); } -#define VM_FAULT_BADMAP ((__force vm_fault_t)0x010000) -#define VM_FAULT_BADACCESS ((__force vm_fault_t)0x020000) - static int __kprobes do_page_fault(unsigned long far, unsigned long esr, struct pt_regs *regs) { @@ -513,6 +510,7 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, unsigned int mm_flags = FAULT_FLAG_DEFAULT; unsigned long addr = untagged_addr(far); struct vm_area_struct *vma; + int si_code; if (kprobe_page_fault(regs, esr)) return 0; @@ -572,9 +570,10 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, if (!(vma->vm_flags & vm_flags)) { vma_end_read(vma); - fault = VM_FAULT_BADACCESS; + fault = 0; + si_code = SEGV_ACCERR; count_vm_vma_lock_event(VMA_LOCK_SUCCESS); - goto done; + goto bad_area; } fault = handle_mm_fault(vma, addr, mm_flags | FAULT_FLAG_VMA_LOCK, regs); if (!(fault & (VM_FAULT_RETRY | VM_FAULT_COMPLETED))) @@ -599,15 +598,19 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, retry: vma = lock_mm_and_find_vma(mm, addr, regs); if (unlikely(!vma)) { - fault = VM_FAULT_BADMAP; - goto done; + fault = 0; + si_code = SEGV_MAPERR; + goto bad_area; } - if (!(vma->vm_flags & vm_flags)) - fault = VM_FAULT_BADACCESS; - else - fault = handle_mm_fault(vma, addr, mm_flags, regs); + if (!(vma->vm_flags & vm_flags)) { + mmap_read_unlock(mm); + fault = 0; + si_code = SEGV_ACCERR; + goto bad_area; + } + fault = handle_mm_fault(vma, addr, mm_flags, regs); /* Quick path to respond to signals */ if (fault_signal_pending(fault, regs)) { if (!user_mode(regs)) @@ -626,13 +629,12 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, mmap_read_unlock(mm); done: - /* - * Handle the "normal" (no error) case first. - */ - if (likely(!(fault & (VM_FAULT_ERROR | VM_FAULT_BADMAP | - VM_FAULT_BADACCESS)))) + /* Handle the "normal" (no error) case first. */ + if (likely(!(fault & VM_FAULT_ERROR))) return 0; + si_code = SEGV_MAPERR; +bad_area: /* * If we are in kernel mode at this point, we have no context to * handle this fault with. @@ -667,13 +669,8 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, arm64_force_sig_mceerr(BUS_MCEERR_AR, far, lsb, inf->name); } else { - /* - * Something tried to access memory that isn't in our memory - * map. - */ - arm64_force_sig_fault(SIGSEGV, - fault == VM_FAULT_BADACCESS ? SEGV_ACCERR : SEGV_MAPERR, - far, inf->name); + /* Something tried to access memory that out of memory map */ + arm64_force_sig_fault(SIGSEGV, si_code, far, inf->name); } return 0; From patchwork Thu Apr 11 13:09:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13625899 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81F39CD1284 for ; Thu, 11 Apr 2024 12:42:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 106556B0096; Thu, 11 Apr 2024 08:42:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B6446B0099; Thu, 11 Apr 2024 08:42:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE6606B009A; Thu, 11 Apr 2024 08:42:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D0D7F6B0096 for ; Thu, 11 Apr 2024 08:42:14 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8640F4097F for ; Thu, 11 Apr 2024 12:42:14 +0000 (UTC) X-FDA: 81997213788.01.52602ED Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf27.hostedemail.com (Postfix) with ESMTP id 0F30F40016 for ; Thu, 11 Apr 2024 12:42:11 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712839332; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=28f0VX2M6hSBDcLS7hKUb24II+NNMoNq5WtJDYOtkXI=; b=bLl0k3IFh0UbkSCIxndXcVl5ev/SK2CdEg07JRBzfD/3bn8kM+vlVI5pVpIeLjV45XwA0w d7/K/4G9OwRBkC5A0UlfWPrlq5WEuNwpBQNOCbuLVALHF7vPGfM0Co52XUgFtibF5OrJG1 Jlq4yX9ktySMKo9z/w15e7pHtwEj8G4= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712839332; a=rsa-sha256; cv=none; b=nY1ause4oGLwR4fStJX1On3vpL8V+mPPeJcMyaUehNKFiNh2NiQDaUIX8iCz9QhEMpQqEn CcPnEf1s7RwMDLlKFhepgDbv2CUO4H5gaLiogYj+HxSw+jrcIpvcYct0ZcCsMFT5A/9K5K vzjItWKitqp0hKMVQ0qZAhdABnfjKbk= Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VFfSj6j0PzYd7d; Thu, 11 Apr 2024 20:41:09 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 94BC11403D2; Thu, 11 Apr 2024 20:42:08 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 11 Apr 2024 20:42:07 +0800 From: Kefeng Wang To: Andrew Morton , Russell King , Catalin Marinas CC: Will Deacon , , , Cristian Marussi , Mark Brown , Aishwarya TCV , Kefeng Wang Subject: [PATCH v2 2/2] arm: mm: drop VM_FAULT_BADMAP/VM_FAULT_BADACCESS Date: Thu, 11 Apr 2024 21:09:25 +0800 Message-ID: <20240411130925.73281-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240411130925.73281-1-wangkefeng.wang@huawei.com> References: <20240411130925.73281-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 0F30F40016 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: h6nroxqmbot87aoyr9unwkbdbipoc7ta X-HE-Tag: 1712839331-389001 X-HE-Meta: U2FsdGVkX19LzqEj7jHQLRuED871fRVl5AKtO9Oq1K9kF4B06iSVSMyG+t7smqax5AQe2ixm/FATrL3DffTvrngN0hLuPL4YItmrjZG4T6xyLak/WKwKYQAAgzInifkPW0wrgMbTtyVqFmuGVB3gIYwUSUf0BIQLzbKNh+wTj0tySmb4tA6KEyPN/53ftulL9udU8Mci+uGrlymC4rnQRIBgsTnelPoU11ddE9sydCiAIzMhFR5kl1jjtqqJt3JkEKrziS2QqIFZrtWCFkUKwXVNQxU/i59F+ZFdKjvYS41a1bBwtoCFqrRdCHLrfdN9sTXcTPCgmMM6V4l0DGejAjkspS9xK0fowwACQjiqntQUMneAtmhtldPxs3kZ/9n7qkorFqc9hnAdzq8/4GLJh288HtdueuhgdTI00iXY4ELUznZuv8SL4ZxHL4gvlqytWEomRRnHAfiEFL2JjN2ntJUC57ABX2k3fsdSbgOmzsXuUY8LfwadXxUt9WqOyOx7BXqngTo+dfI+EdNMVega3s2FtKggmyzxNEU9Yrk6evElDiWN+lzQgB0h1OiXGRpnYHxeiI1wb95riMZ/9MKgK7+MjPZS1w71HZcey8XJlGfekNqT+PADcdAXNLrhdQFGa2E6PBYK8PqGFrmmaDC0TIXj4C08ysTtl638GRSnkdSAbenmb7NbVIvjGHcsE+pRveRCAIumo4VN+/tE7/h1PXYG5dBn9eWZFg4xBCvbt2Nxhtpl5h0jUYmFN+cG70D47IkkPeiVlRqP5qt+8CJ/U4TvP3lYhTihPR86VqZ683h5XIWFVYQ2x50tb+O89prXKOc5CXNTxDzk0hTrEZUdjlWNlIzMDPmY/OVqHM0NjWGP+k9g8bqbAzme13a1qJkM/qSoFlOMJkyxIv02vN4aP8R2e9VxMyqyhJQry0FRV69PI2N5apvo0fHPLkAoDGH6rJiEKA/0jG/vk/3Bppd FiITWJLH 2lhBwtiDkAcOJL/SCQeeg4FERM+m37oOSPoQutudVmMnvJsdNuGsHPgpTKdeWgn34Ekm4Up0a8wSrfpF40bx5ytKtnnVTCkpzY4cJ+Vq6u3vCC2Ex73BCH5vhbpfSCAiyE9VaIigr3saByDBdPoUJdZZUHRk8ENckJgHAjUN86jEdXSSwn3TVmSM2+YPn0u6QQ7f+ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: If bad map or access, directly set code to SEGV_MAPRR or SEGV_ACCERR, also set fault to 0 and goto error handling, which make us to drop the arch's special vm fault reason. Signed-off-by: Kefeng Wang --- arch/arm/mm/fault.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c index 5c4b417e24f9..45c141a6e087 100644 --- a/arch/arm/mm/fault.c +++ b/arch/arm/mm/fault.c @@ -226,9 +226,6 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs) } #ifdef CONFIG_MMU -#define VM_FAULT_BADMAP ((__force vm_fault_t)0x010000) -#define VM_FAULT_BADACCESS ((__force vm_fault_t)0x020000) - static inline bool is_permission_fault(unsigned int fsr) { int fs = fsr_fs(fsr); @@ -295,7 +292,8 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs) if (!(vma->vm_flags & vm_flags)) { vma_end_read(vma); count_vm_vma_lock_event(VMA_LOCK_SUCCESS); - fault = VM_FAULT_BADACCESS; + fault = 0; + code = SEGV_ACCERR; goto bad_area; } fault = handle_mm_fault(vma, addr, flags | FAULT_FLAG_VMA_LOCK, regs); @@ -321,7 +319,8 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs) retry: vma = lock_mm_and_find_vma(mm, addr, regs); if (unlikely(!vma)) { - fault = VM_FAULT_BADMAP; + fault = 0; + code = SEGV_MAPERR; goto bad_area; } @@ -329,10 +328,14 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs) * ok, we have a good vm_area for this memory access, check the * permissions on the VMA allow for the fault which occurred. */ - if (!(vma->vm_flags & vm_flags)) - fault = VM_FAULT_BADACCESS; - else - fault = handle_mm_fault(vma, addr & PAGE_MASK, flags, regs); + if (!(vma->vm_flags & vm_flags)) { + mmap_read_unlock(mm); + fault = 0; + code = SEGV_ACCERR; + goto bad_area; + } + + fault = handle_mm_fault(vma, addr & PAGE_MASK, flags, regs); /* If we need to retry but a fatal signal is pending, handle the * signal first. We do not need to release the mmap_lock because @@ -358,12 +361,11 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs) mmap_read_unlock(mm); done: - /* - * Handle the "normal" case first - VM_FAULT_MAJOR - */ - if (likely(!(fault & (VM_FAULT_ERROR | VM_FAULT_BADMAP | VM_FAULT_BADACCESS)))) + /* Handle the "normal" case first */ + if (likely(!(fault & VM_FAULT_ERROR))) return 0; + code = SEGV_MAPERR; bad_area: /* * If we are in kernel mode at this point, we @@ -395,8 +397,6 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs) * isn't in our memory map.. */ sig = SIGSEGV; - code = fault == VM_FAULT_BADACCESS ? - SEGV_ACCERR : SEGV_MAPERR; } __do_user_fault(addr, fsr, sig, code, regs);