Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp474374pxj; Thu, 10 Jun 2021 05:30:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPzaGld8XtlGj1Ki+ijxZt5EmhXlLTBRvAVpWII4ZQknN+GiJxDt4pvhRTb8ntTcPgx0bt X-Received: by 2002:a05:6402:10c9:: with SMTP id p9mr4517183edu.370.1623328216355; Thu, 10 Jun 2021 05:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623328216; cv=none; d=google.com; s=arc-20160816; b=YIz98UVOg3xlkT6IXRSZ4V94ol0p4uXA4Q2TVKZkq+gOEYks+Do4hnHRVuX/cUZzPP XPNKg88p8tH8aC1kR8FIsrEIUsks7vXVlJCZBG557Ih+6d9SVsgGHYJwbK/3oIaK5ZML WgYBHgWxLfIAHG5KEyv8qt112Wxati2d9ihW1QsPkW0UNueFYMAxUC91XBXuphCGQc2Q eyusOaDogkIhiyPGbqVrcNZPFpJp206vvXHLO1w19o+WalIe4ocMlUVBBp07TTocAYcv CmauzqgHtYKebse06mVMuGZDqhyxORuebla+vbp32WD2ln8qDtnLDJRNH46XKXuELrTV zdPA== 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=bz+ILPUufMmbBmuBPtjDwXxnRT41kDLNby8wFZoE/DQ=; b=jxAqeiEXD82xYLkodx4jYQHd/eiN9MngxKI3SCJz7aumhHUShnZNZhhT9Z+rkz5TZh TUOyVMz9bEYSfjFgDC3+//xVLP/ep6/fYUlWyyLBv2TJC+nos0DvxG3syagl9JZ6NXIm 3DKbzNVn6VkmBjmFpoE+2w0iX9YB2yz0EriBZP6GeaDMhi/WTtnrHZVyFC4Gng3TYORt /5a+4+xL3gIUfo7OBNFBKWyYlfpEy78Yghpo8WOj4eLunR+5r2WMwWIgYDb14c1SIZNE Jp4zXUlUOHneVblqUuKxU059eu6r48e/jO2GCEAgl+NJmIYM9zeJTrnHW3DANaXdcmzL JDZA== 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 m7si2093636edq.604.2021.06.10.05.29.53; Thu, 10 Jun 2021 05:30:16 -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 S230452AbhFJM3t (ORCPT + 99 others); Thu, 10 Jun 2021 08:29:49 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:3835 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230392AbhFJM3R (ORCPT ); Thu, 10 Jun 2021 08:29:17 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4G135C0rWrzWsWR; Thu, 10 Jun 2021 20:22:23 +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:11 +0800 From: Kefeng Wang To: Russell King , CC: Catalin Marinas , , Andrew Morton , Jungseung Lee , Will Deacon , Kefeng Wang Subject: [PATCH v3 5/6] ARM: mm: Provide die_kernel_fault() helper Date: Thu, 10 Jun 2021 20:35:55 +0800 Message-ID: <20210610123556.171328-6-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 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 | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c index 76aced067b12..82bcfe57de20 100644 --- a/arch/arm/mm/fault.c +++ b/arch/arm/mm/fault.c @@ -99,6 +99,21 @@ void show_pte(const char *lvl, struct mm_struct *mm, unsigned long addr) { } #endif /* CONFIG_MMU */ +static void die_kernel_fault(const char *msg, struct mm_struct *mm, + 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, mm, addr); + die("Oops", regs, fsr); + bust_spinlocks(0); + do_exit(SIGKILL); +} + /* * Oops. The kernel tried to access some page that wasn't present. */ @@ -106,6 +121,7 @@ static void __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr, struct pt_regs *regs) { + const char *msg; /* * Are we prepared to handle this kernel fault? */ @@ -115,16 +131,12 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr, /* * 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, mm, addr); - die("Oops", regs, fsr); - bust_spinlocks(0); - do_exit(SIGKILL); + die_kernel_fault(msg, mm, addr, fsr, regs); } /* -- 2.26.2