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);