Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp474158pxj; Thu, 10 Jun 2021 05:29:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOntT4IWBCMEAHMD2iTo1LVlfx9+eCGwBR/eCWCVJasARxY1VCSRkM3s+Ux0i6yFxUB//r X-Received: by 2002:aa7:c9c5:: with SMTP id i5mr4467696edt.160.1623328194743; Thu, 10 Jun 2021 05:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623328194; cv=none; d=google.com; s=arc-20160816; b=XnPDV1bgMDGeS2oXbzyf0UVP86GNdUWhIkTJV03xovMuyMnbHHY9ogn31sMt3JtImD rpc1i2CwnzJEsJlP1xysiio7RJqOFja2jdc+17mtgIqVR0OCjF/US9xKb9jwkq2Le7+9 k+i3hd1SxJi/zmnKXqrIjvJSqY0TrZjvIt42CICTo63J8H9146yZGFwnqDkbO0+Og6R7 N3e9y3czFl9LBgg521rT5SK6cHqwhS85FqBQ1mf8d4aSl9qOby5TnrZ94gtU6iyiqjbT OBf8EgZFfzW6fmxUk1K1bSGZpORiTGIeC6lM5jH1Iap8Xn8XMttXWj/uR118nOpU2xda pozA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=7Oj4F7mwbXT6ErDpsrArcMCyULpZ64mr0LUx7ceF7Ww=; b=P8gdVrKzncSyhQ+EOGaRgLgXaC6zalyhFDrF+z6pkTBM7vTua+CBoTZaiV+kb/h3bo qqQBp4f9+IBhIQUA4pF+xPkPiBN39P6iTyQmVNINLgDIcQvh7qQfdVQvCaYlrTfyRC5W HnU55YgpzWnMjXm7UXfrtqVNJveS6VU8rDJE3DI+nRWo691xr+TmtiCNJP0ISN/Z6r5F +IAJ//EjMzN+lpydvXpcLiX24jv+1Avn84M036BAJYE8tGkZwgJ/CuZO22ZJI2oXEef8 IeZEsv88e8ctrJ4nf/7PXuCidh8aM+AnDJ3avevam4sCQftgH2iuVK3ZtyYoNJoZDX9r SweQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l15si2184797ejq.530.2021.06.10.05.29.31; Thu, 10 Jun 2021 05:29:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230445AbhFJM3Y (ORCPT + 99 others); Thu, 10 Jun 2021 08:29:24 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:3946 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230426AbhFJM3N (ORCPT ); Thu, 10 Jun 2021 08:29:13 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4G137H2fZfz6v1P; Thu, 10 Jun 2021 20:24:11 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 10 Jun 2021 20:27:16 +0800 Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Thu, 10 Jun 2021 20:27:09 +0800 From: Kefeng Wang To: Russell King , CC: Catalin Marinas , , Andrew Morton , Jungseung Lee , Will Deacon , Kefeng Wang Subject: [PATCH v3 1/6] ARM: mm: Rafactor the __do_page_fault() Date: Thu, 10 Jun 2021 20:35:51 +0800 Message-ID: <20210610123556.171328-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210610123556.171328-1-wangkefeng.wang@huawei.com> References: <20210610123556.171328-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clean up the multiple goto statements and drops local variable vm_fault_t fault, which will make the __do_page_fault() much more readability. No functional change. Signed-off-by: Kefeng Wang --- arch/arm/mm/fault.c | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c index efa402025031..662ac3ca3c8a 100644 --- a/arch/arm/mm/fault.c +++ b/arch/arm/mm/fault.c @@ -205,35 +205,27 @@ __do_page_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr, unsigned int flags, struct task_struct *tsk, struct pt_regs *regs) { - struct vm_area_struct *vma; - vm_fault_t fault; - - vma = find_vma(mm, addr); - fault = VM_FAULT_BADMAP; + struct vm_area_struct *vma = find_vma(mm, addr); if (unlikely(!vma)) - goto out; - if (unlikely(vma->vm_start > addr)) - goto check_stack; + return VM_FAULT_BADMAP; + + if (unlikely(vma->vm_start > addr)) { + if (!(vma->vm_flags & VM_GROWSDOWN)) + return VM_FAULT_BADMAP; + if (addr < FIRST_USER_ADDRESS) + return VM_FAULT_BADMAP; + if (expand_stack(vma, addr)) + return VM_FAULT_BADMAP; + } /* * Ok, we have a good vm_area for this * memory access, so we can handle it. */ -good_area: - if (access_error(fsr, vma)) { - fault = VM_FAULT_BADACCESS; - goto out; - } + if (access_error(fsr, vma)) + return VM_FAULT_BADACCESS; return handle_mm_fault(vma, addr & PAGE_MASK, flags, regs); - -check_stack: - /* Don't allow expansion below FIRST_USER_ADDRESS */ - if (vma->vm_flags & VM_GROWSDOWN && - addr >= FIRST_USER_ADDRESS && !expand_stack(vma, addr)) - goto good_area; -out: - return fault; } static int __kprobes -- 2.26.2