Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp392018pxj; Wed, 2 Jun 2021 01:36:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPc8hZNwwHPizjgUr9nssN4AorMk9Kfo1pVN6cIWkcStMTxPxX/28TxbBczV+8rWzDr8L6 X-Received: by 2002:a92:c152:: with SMTP id b18mr6729777ilh.282.1622622974860; Wed, 02 Jun 2021 01:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622622974; cv=none; d=google.com; s=arc-20160816; b=n8MIS2YFLw8Z05l3F75Jx4B3Oqm/VTQ6YMQstTan+pmFTY+injHylmABVmsTp5tH2K 9/cj+nDEc4KwApHIVRY38FMh0+6NpV/DF4wS6TUKTXUVLjXQhp+djKT8+gPAAkGopHA/ HJx/JPAoIY5XjmB6K0KZuSKS80MMW+cc50FWfX4bPT7/uxOfHtPlWRe/wz43dsfS+EzF 3HGi6sZ+m2SDGOrkGD5AZUmhKzyG464ADh/9w6VUiAP0840SycP+P0nkKTboU1ODnn0z ilsTZJAp8WeEHbvbg0QPCAzRl2Y0cnbsqEsHSciArkZYgyOEmisoTM45m7+CYXe96QjQ dZlg== 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=LVPNzMavKnSfChvfddcNM6ZquPutuvyX1ghJRUqkBvI=; b=0WX9muf2BkEtRnGNDSPlXL/Lw4mmi8Hhuws57GxX5JQUUcq3yY0bGrY3tngdziuAuw m4xPCA9KkbSPssOEatHoOrqPby2sT6y8toVaRwC1/ag72ZRJnD5NxLfqb9kIX5fDS65w qStXj6Mx94gbTmbAJF9y408n2qR3d845mW29bgU+tbOIHO52FHUGSwAYUykoUaUvFDhU dscqQCwehTkQk5N5Fjm2WdP2BcrBeqTq3jiLLFZpm58M3iF2YlQaMe9u7fsSQIvWlp38 skZfh4Tt8lfHecmFgThLD63f1IY8DTN2g8pOlJgVSo59ua2L3xpyqhuJPywIzKcsE+4k cAcg== 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 f4si21663433ilq.138.2021.06.02.01.36.00; Wed, 02 Jun 2021 01:36:14 -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 S230116AbhFBGzu (ORCPT + 99 others); Wed, 2 Jun 2021 02:55:50 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:3337 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230093AbhFBGzt (ORCPT ); Wed, 2 Jun 2021 02:55:49 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Fw04b3Vyfz19S9b; Wed, 2 Jun 2021 14:49:19 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 2 Jun 2021 14:53:49 +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; Wed, 2 Jun 2021 14:53:48 +0800 From: Kefeng Wang To: Russell King , CC: Catalin Marinas , , Andrew Morton , Jungseung Lee , Kefeng Wang Subject: [PATCH v2 6/7] ARM: mm: Provide die_kernel_fault() helper Date: Wed, 2 Jun 2021 15:02:45 +0800 Message-ID: <20210602070246.83990-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210602070246.83990-1-wangkefeng.wang@huawei.com> References: <20210602070246.83990-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: dggems704-chm.china.huawei.com (10.3.19.181) 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 Provide die_kernel_fault() helper to do the kernel fault reporting, which with msg argument, it could report different message in different scenes, and the later patch "ARM: mm: Fix PXN process with LPAE feature" will use it. Signed-off-by: Kefeng Wang --- arch/arm/mm/fault.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c index 1383d465399b..7cfa9a59d3ec 100644 --- a/arch/arm/mm/fault.c +++ b/arch/arm/mm/fault.c @@ -108,12 +108,27 @@ void show_pte(const char *lvl, unsigned long addr) { } #endif /* CONFIG_MMU */ +static void die_kernel_fault(const char *msg, unsigned long addr, + unsigned int fsr, struct pt_regs *regs) +{ + bust_spinlocks(1); + pr_alert("8<--- cut here ---\n"); + pr_alert("Unable to handle kernel %s at virtual address %08lx\n", + msg, addr); + + show_pte(KERN_ALERT, addr); + die("Oops", regs, fsr); + bust_spinlocks(0); + do_exit(SIGKILL); +} + /* * Oops. The kernel tried to access some page that wasn't present. */ static void __do_kernel_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs) { + const char *msg; /* * Are we prepared to handle this kernel fault? */ @@ -123,16 +138,12 @@ __do_kernel_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs) /* * No handler, we'll have to terminate things with extreme prejudice. */ - bust_spinlocks(1); - pr_alert("8<--- cut here ---\n"); - pr_alert("Unable to handle kernel %s at virtual address %08lx\n", - (addr < PAGE_SIZE) ? "NULL pointer dereference" : - "paging request", addr); + if (addr < PAGE_SIZE) + msg = "NULL pointer dereference"; + else + msg = "paging request"; - show_pte(KERN_ALERT, addr); - die("Oops", regs, fsr); - bust_spinlocks(0); - do_exit(SIGKILL); + die_kernel_fault(msg, addr, fsr, regs); } /* -- 2.26.2