From patchwork Wed Apr 3 08:37:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13615368 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 B1B61CD1288 for ; Wed, 3 Apr 2024 08:38:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 224116B0087; Wed, 3 Apr 2024 04:38:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1AFAE6B0089; Wed, 3 Apr 2024 04:38:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF2AC6B008C; Wed, 3 Apr 2024 04:38:30 -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 C1D796B0087 for ; Wed, 3 Apr 2024 04:38:30 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id EA8B7C0DA0 for ; Wed, 3 Apr 2024 08:38:29 +0000 (UTC) X-FDA: 81967569138.08.53EB47B Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf22.hostedemail.com (Postfix) with ESMTP id 5361FC000A for ; Wed, 3 Apr 2024 08:38:26 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 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=1712133508; 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=QRwkJuD+wwWKi9hQAlECfpj4bZ/nFN+mVshnbbGJMKQ=; b=rmwH+g7updDreBHf+2bTBDUp5muCn4tToMiQFxz4R3v/JlPQrujiFv3pV5Y/ggu7HFUaDu b+bbLJaP8JOr1OpJUIsCnecwS40DxhC9Byn8olRljP4jvyatbmigOSK0JapCfQ6T3ZzO+1 qWImdQRJX+CtGBlyS+03g/yR2LTn6CE= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 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=1712133508; a=rsa-sha256; cv=none; b=aMr/QZFFgWX4Kz+Zn/RPIWAfX7p6VYs86L1MtNXHOENsCi+Te2OafUdB/BaTK1zeKCA7be noSDN+cqFb+Perq9MC4eDhIWXRJZrY9QQcqNBGGjE9OILS/GrSwm7HqWf+l3OjogwT+piN QGfTl0FLlZ1Nf0aFy/maKwMXmAYyASk= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4V8dP626VPz29lXb; Wed, 3 Apr 2024 16:35:38 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id EC3921A0172; Wed, 3 Apr 2024 16:38:23 +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; Wed, 3 Apr 2024 16:38:22 +0800 From: Kefeng Wang To: CC: Russell King , Catalin Marinas , Will Deacon , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Gordeev , Gerald Schaefer , Dave Hansen , Andy Lutomirski , Peter Zijlstra , , , , , , , , Kefeng Wang Subject: [PATCH v2 1/7] arm64: mm: cleanup __do_page_fault() Date: Wed, 3 Apr 2024 16:37:59 +0800 Message-ID: <20240403083805.1818160-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240403083805.1818160-1-wangkefeng.wang@huawei.com> References: <20240403083805.1818160-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 5361FC000A X-Rspam-User: X-Stat-Signature: gfj4x3e1uw8af5tpd8jjqam1qpas5yzn X-Rspamd-Server: rspam01 X-HE-Tag: 1712133506-848064 X-HE-Meta: U2FsdGVkX185c2EkHxPf5gqFZG7d/lnKLSSCmqGZBSfQ72V1uYp2i90dV1/pqmnUW7KZ8cAJQfj9SIsFLDNtqTKFR8GWV/KCV1MU5kX8oWe7eOw7ueKCNCgwG9BYF9wQ1iaQ9JNWb2NmUuKZQ27OwoxBEcqGHx5GQl1FjdJysb8xj+4ipHk9QjW7i2HyHy9SNkCyhVSzhvl0KLV9CizTa6NLQJ1Bn8y3YQlQeck1qE9BmxiGCIxd6oWG4jAaOYUbp0v6CYCCgce/40Ka8pNDqSZq47VimgYqkcodec+Vf/KTjLw38XymhTLYPdOA1OOjIWr4WbETb/d/HKYPfByd+L8q7tNWw6DFz7v7H00eHR6hIeCxzEK9UiIYUqs2NxlH9pbYD7DAR+ngx3WPQB1dzzkRtVRZEjl3so9eqHvTPvZ77TXRVdygdpBl04FsL5JJELOkMuXyvDYXQ/MGDHidQzn/wRE7kTBYe4fmGHQqy/7x8hChpos0bSaOqAnYrdS+8CEVEOiegP6z3VJXoBVi50ZXx/+wITMu1XdEtCuOh8AhcYr6MuERvJ2E2Shy3E9wPAU/meaKOqXnClRP/4hZgfRiITsi8JCCAH4wClNZblw7uue1XJNczDuRzSCoGkSJYBfS6K7JDJeQuSLZDb+ke8dwg1JT7ItxYBrdvnE1CalAQA1OGHvdnowODeLyWOVzuovI+AxQ1AzM9X0A3IhDr1TJKkgRPWT1rOdxKLz7Z6++TUgWba8DogK8xPL9QsdNI39nI9q4FUGby0AJucnd6IH8BRgdKzSlSndxBTt5Cmv9s4zMfvbnWfN9iF7adizLPRh3JB0Q7S5d6SUW+yYDzcmpFi3T1UF3ZXflhSsxnZ1slnW50uf5E9O2ir+68i8n30gFvoubB6x/KPy62t5kTBvQsdhL0QPGl8YKM+G/AGo6MA5P6c9dp/1ElTMiifeb7f/aLDqETjxyqxmMFNV GkhdAlMn 5XuB7SfSsqXwaM7mRof3pwoqidTDnVsl9d+zvuQT7jO1BtGy+GzuQGQACZtp7AOJm21fRL86mQTf3nfXdfaSp6J5TW+/cdHo8azo+t86P+H0SA1JZie079vhXB4T6N9Co+OIydVueMAFcg8IUENbK3GwuJpNVNDkYE23lEwJQeborzvCEb1zgVhKJc0lrGUcMbCdP3pA0m4K5nUV87AaE60HoyA== 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: The __do_page_fault() only calls handle_mm_fault() after vm_flags checked, and it is only called by do_page_fault(), let's squash it into do_page_fault() to cleanup code. Reviewed-by: Suren Baghdasaryan Signed-off-by: Kefeng Wang Reviewed-by: Catalin Marinas --- arch/arm64/mm/fault.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 8251e2fea9c7..9bb9f395351a 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -486,25 +486,6 @@ static void do_bad_area(unsigned long far, unsigned long esr, } } -#define VM_FAULT_BADMAP ((__force vm_fault_t)0x010000) -#define VM_FAULT_BADACCESS ((__force vm_fault_t)0x020000) - -static vm_fault_t __do_page_fault(struct mm_struct *mm, - struct vm_area_struct *vma, unsigned long addr, - unsigned int mm_flags, unsigned long vm_flags, - struct pt_regs *regs) -{ - /* - * Ok, we have a good vm_area for this memory access, so we can handle - * it. - * Check that the permissions on the VMA allow for the fault which - * occurred. - */ - if (!(vma->vm_flags & vm_flags)) - return VM_FAULT_BADACCESS; - return handle_mm_fault(vma, addr, mm_flags, regs); -} - static bool is_el0_instruction_abort(unsigned long esr) { return ESR_ELx_EC(esr) == ESR_ELx_EC_IABT_LOW; @@ -519,6 +500,9 @@ 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) { @@ -617,7 +601,10 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr, goto done; } - fault = __do_page_fault(mm, vma, addr, mm_flags, vm_flags, regs); + if (!(vma->vm_flags & vm_flags)) + fault = VM_FAULT_BADACCESS; + else + fault = handle_mm_fault(vma, addr, mm_flags, regs); /* Quick path to respond to signals */ if (fault_signal_pending(fault, regs)) {