From patchwork Sun Apr 7 08:12:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13620045 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 B66F1CD11C2 for ; Sun, 7 Apr 2024 08:12:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D25096B0096; Sun, 7 Apr 2024 04:12:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AAA8B6B009B; Sun, 7 Apr 2024 04:12:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79D1F6B0098; Sun, 7 Apr 2024 04:12:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 49FB96B0098 for ; Sun, 7 Apr 2024 04:12:26 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1751E1A0896 for ; Sun, 7 Apr 2024 08:12:26 +0000 (UTC) X-FDA: 81982018692.07.66976CD Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf28.hostedemail.com (Postfix) with ESMTP id 70859C000A for ; Sun, 7 Apr 2024 08:12:23 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.32 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=1712477544; a=rsa-sha256; cv=none; b=NJHP0QoASy81b+rbGLMEKIJmUGCaTHTKrzCcvleISmkd5ZJklMAsOPNPO3rs9/LkxMCWMX G5oWnlMDSw0egqMuYDlmiNXlrMTaFc2D8/dpaFebpmhGkPYikEU4VuTdneR1f/3GHQYaeh 0vZdfwQEqCtFp70nSCyYcQ2nfQXhsaY= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; spf=pass (imf28.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.32 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=1712477544; 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=ygusvHhx/DBi0dVHeZXtU7T8FdMMILKbB7MvlnNHhD4=; b=Udm3SW8Bulc7TJ3t+5QfGPaLfW6LZ0l/GTtRXAhitwx4X0uXQ1Kr3B6aTYmI/EvV0xculM LbfMaEf91PwxOMQ5wqQeI5WNk1xmObeQBvxQvQS0m+R3IqLdwRKe4JMMiO6G6Pv963Az4N ZKWgWTeDo16DMSGILPESo2P1gT7nLTY= Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4VC4gL06Yzz1wqMK; Sun, 7 Apr 2024 16:11:26 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 1B7B61400D3; Sun, 7 Apr 2024 16:12:20 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) 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; Sun, 7 Apr 2024 16:12:19 +0800 From: Kefeng Wang To: Andrew Morton , Russell King , Catalin Marinas , Will Deacon CC: , , Kefeng Wang Subject: [PATCH 2/2] arm: mm: drop VM_FAULT_BADMAP/VM_FAULT_BADACCESS Date: Sun, 7 Apr 2024 16:12:11 +0800 Message-ID: <20240407081211.2292362-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240407081211.2292362-1-wangkefeng.wang@huawei.com> References: <20240407081211.2292362-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 70859C000A X-Stat-Signature: 4x8dacxypj7hr15yasf4nyk59su89j6a X-HE-Tag: 1712477543-535490 X-HE-Meta: U2FsdGVkX1+zOpoIWJebinAri7TI6Qo9Dyof6ubx87wkmI7HEVyENLdHQ6h2a6pLfNhoRLD89Ir4OW27TEiQYp9VO2KwTvkaghZtVv5h/8//UqXtRH9EM1pJT7AJnq2/xB1VobGcXK0xiPsr8d3M4mNX3XZWX/3ZVCeGmKFkBOR18XttzdF62WEWJKh6W3XzQjvbNvV7sV4wEDGCFjDhq/T7ydKHmfnuw0Xy7/qYdTjGql7vXZekJpJcrShGM83G7MXcCRPgyw7sPEB252RQe0XqEqZtIRgIC4bFz5wIZ5PkEWrQ8D8bxNHdk9snXisTKZ5TgqaqGc+iXUfm900tWbUUebaYrW9y83kcn4AGYnxtjLvs7iVF0vXVen5SbZfoOHZekgKl5iLQMpjezoe3eBwRajb4W3vog9XW86hRukzwBQZZG6TvFu9/Ydhp8z+Srtaj7fJ0jhNnkV/B5jIEDNwtlxenN+MRH28EBsnj/AkC7TxnhHdspo1w0qIUkgCzD3uUkYGi1jSgBYUtoTft6y8O8yI3KStj9j0XDeqzDntz0fVbWZGR4vQOeXHUZ6PSIm+vczZlRrRN7Yb2xraIqp/Uqe0AIuCiVS2CdmB+TVCwwMb7KZq3jvTSwlelXJdFbTctY4ij5Yf62cKJBBQyJ7Ttw1KZ6w6zZ15lAB+9Q8HmppTeT0HzHZKnyYhoetqyTr7BoxjIfKvsgcjgMo2Ko58cLRYM6kVwCkA+/zpS0CiQEG5FwWKgw6u3gME5Ji7abho1XQ+LearfFtGdC7yutMIfyLYLD6ZldXSuy74P93ipCoVHr5n/+eemlfnYPEO4fwCxS7uAuWgV/cxJCAqSFY05l1ZezCeOJGAC1hAIj2EOQdYSw2/9akGy4w3odQ9Cz86At3+i2t0ALm6H/5OWhEMc5dq2UCg1aXiUrlGuIqWZ3poS87yDA8XzABZhVsfhANLjV4y8fP/JIwhQCdn 4bmCX4fK pqgkILbkYsfEbxHcn7RVMEaJOKQyDRgw+DKs9TtECguZpmWVz3wkfKeMLs1eueS2PaBSeDhcm24aSpX5Uc4Nk31hWPsXZJSa/fGZbWVoSE0E7bUbTZy7hs+kDooTj680Mb57cNxhbkN/1DUZJClUM22ZDGGNKMl+Qys5nzMB9uEATAjZZKi7qtq+e0AA6tp4xxIzy 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 --- arch/arm/mm/fault.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c index 5c4b417e24f9..cab24fb17c4b 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,13 @@ 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)) { + 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,10 +360,8 @@ 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; bad_area: @@ -395,8 +395,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);