From patchwork Tue Mar 28 21:34:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 9650565 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E3703602C8 for ; Tue, 28 Mar 2017 21:50:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC64D28405 for ; Tue, 28 Mar 2017 21:50:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D07A828420; Tue, 28 Mar 2017 21:50:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5DA9B28405 for ; Tue, 28 Mar 2017 21:50:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=T+I1BgJ6csN9Dy3E6hPKNZf7MEEyo9EsIFGxiFxZg4U=; b=eeVqClRCVpBhzIEhxJst6i0sD7 qs2tAofmojsXgTZKy9eiTU8CRl3eukwEr31Ybmm/TQuNcwk88xJPAhZBHOi4gTHc+JgaSHIfoMx8a aFS+WY+aneEj0/1GmDMeccTtv3WhhMYbgMvTXKTaJIWHBkJyiOp731/IutGGypcwF+axD32YzNnkA 2YcxlbM5GFjRcW2aHGDDxhroMaa0zl4A4YjNPgfIwP4MHmnvyVwnwI1GB1gFPPJP0/ND2uRrDv/7G WDlv1LDwJG2N6MfHKzJ0cKgQXR9rk5uAuflN2zmm4tktclAeQMMIIE+XVXo2DvmYdvZjLGNab2k2G gpYwEpKQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1csz0e-0004En-2f; Tue, 28 Mar 2017 21:50:36 +0000 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1csylz-0003Nd-Ei for linux-arm-kernel@lists.infradead.org; Tue, 28 Mar 2017 21:35:29 +0000 Received: by mail-qk0-x241.google.com with SMTP id r142so10550127qke.3 for ; Tue, 28 Mar 2017 14:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=874keLt89iXSYhrq2oHxCrx16gz3nx2NiGbuKjg+Ff4=; b=Ik8QMhcSTe795p4/bps+wj+o09SlteyrcPSisSl0j5KO0ygE5k2/bfD0UYRqGhM5iG dshfbGRre1W8XKhJn4TCnDUv5OpYbRK/qavuZZwzBtHze/iCpd4V2VUs98W824Iq16yO THV8nFOnxQg5tnBbtVHAP7goenqXhFdhBV372Sq/wXLDjrDqAMMmitcGSU+sWEGiatQF B9yynzDaUTtCJU/6sG++OaaEY7p+bXm0XoTXu5meV07ZOcqpcS0F24PPuL0u6YAb1ca0 av1kTbM/iuUh1NrQibGNAiEJ9uqdKXZvk6UvNTujdQQeScSz6HVRYzSLuRbhMBLznBY3 PjfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=874keLt89iXSYhrq2oHxCrx16gz3nx2NiGbuKjg+Ff4=; b=m+uFg0kYgzW/YLjTfSvAGQzqS1OEDoGwTkdqj6vNtl+S6XECFLzinnz07aKR9HQEpb bs8JL7HXeAy0Zir8+tpVAJJ7tHCqnrxqUoeuF58CQcG1PLqI+Gks1U0b1TAbzVxDEx7Z 6IivyfU5Q4Zf0oZjU7E3UaCqWIhD/TxDLd+/wlPt8I6pUlpJqRrvE0Ddo8J/UavMKfFa 7MN2UEwxKJ1a3dQ1GgGjoN1FtlbdmKRLRa25L0/GXIY2J/wGxV3TCuyYSHhY1HJ9W00Q 29NuahyHuR2wz3SWLyHk4fgdMZAwXetEZpvUN71Ns4x+AmqkINuPgJ41gR0/uzQGXjKs JdtA== X-Gm-Message-State: AFeK/H1JLXRrwmhHXZ44MGed7+eU20n32xQ06rjCjHbiAuElYTPT8ncVEek9sK6gmJVZfg== X-Received: by 10.55.91.66 with SMTP id p63mr27094770qkb.319.1490736906136; Tue, 28 Mar 2017 14:35:06 -0700 (PDT) Received: from stb-bld-02.irv.broadcom.com ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id a26sm3540762qtb.28.2017.03.28.14.35.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Mar 2017 14:35:05 -0700 (PDT) From: Doug Berger To: mark.rutland@arm.com Subject: [PATCH v2 1/8] arm64: mm: Allow installation of memory abort handlers Date: Tue, 28 Mar 2017 14:34:24 -0700 Message-Id: <20170328213431.10904-2-opendmb@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170328213431.10904-1-opendmb@gmail.com> References: <20170328213431.10904-1-opendmb@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170328_143527_652638_51A15CAB X-CRM114-Status: GOOD ( 14.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wangkefeng.wang@huawei.com, catalin.marinas@arm.com, linus.walleij@linaro.org, will.deacon@arm.com, mingo@kernel.org, f.fainelli@gmail.com, jonathanh@nvidia.com, bgolaszewski@baylibre.com, bcm-kernel-feedback-list@broadcom.com, shijie.huang@arm.com, opendmb@gmail.com, treding@nvidia.com, devicetree@vger.kernel.org, suzuki.poulose@arm.com, robh+dt@kernel.org, gregory.0xf0@gmail.com, sandeepa.s.prabhu@gmail.com, linux-arm-kernel@lists.infradead.org, mirza.krak@gmail.com, linux-kernel@vger.kernel.org, james.morse@arm.com, olof@lixom.net, computersforpeace@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Florian Fainelli Similarly to what the ARM/Linux kernel provides, add a hook_fault_code() function which allows drivers or other parts of the kernel to install custom memory abort handlers. This is useful when a given SoC's busing does not propagate the exact faulting physical address, but there is a way to read it through e.g: a special arbiter driver. Signed-off-by: Florian Fainelli --- arch/arm64/include/asm/system_misc.h | 3 +++ arch/arm64/mm/fault.c | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/system_misc.h b/arch/arm64/include/asm/system_misc.h index bc812435bc76..e05f5b8c7c1c 100644 --- a/arch/arm64/include/asm/system_misc.h +++ b/arch/arm64/include/asm/system_misc.h @@ -38,6 +38,9 @@ void arm64_notify_die(const char *str, struct pt_regs *regs, void hook_debug_fault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *), int sig, int code, const char *name); +void hook_fault_code(int nr, int (*fn)(unsigned long, unsigned int, + struct pt_regs *), + int sig, int code, const char *name); struct mm_struct; extern void show_pte(struct mm_struct *mm, unsigned long addr); diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 4bf899fb451b..cdf1260f1005 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -488,7 +488,7 @@ static int do_bad(unsigned long addr, unsigned int esr, struct pt_regs *regs) return 1; } -static const struct fault_info { +static struct fault_info { int (*fn)(unsigned long addr, unsigned int esr, struct pt_regs *regs); int sig; int code; @@ -560,6 +560,19 @@ static const struct fault_info { { do_bad, SIGBUS, 0, "unknown 63" }, }; +void __init hook_fault_code(int nr, + int (*fn)(unsigned long, unsigned int, struct pt_regs *), + int sig, int code, const char *name) +{ + BUG_ON(nr < 0 || nr >= ARRAY_SIZE(fault_info)); + + fault_info[nr].fn = fn; + fault_info[nr].sig = sig; + fault_info[nr].code = code; + fault_info[nr].name = name; +} + + static const char *fault_name(unsigned int esr) { const struct fault_info *inf = fault_info + (esr & 63);