From patchwork Wed Feb 28 04:57:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 10246797 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 2BAC960362 for ; Wed, 28 Feb 2018 04:59:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 190F828BEF for ; Wed, 28 Feb 2018 04:59:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DEA228BF1; Wed, 28 Feb 2018 04:59:13 +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_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 8212E28BEF for ; Wed, 28 Feb 2018 04:59:12 +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=McLpUISjISgToSSAUcJGcC0ysY9bEgx4dm+UsyRnAAE=; b=H0In12VWj6nrcxYwVRFD6xFgsN KW21a6Dhu7hqaJytPc/wAm1kv8vcy2XrZIywPLYgNrJiQHCXiHnkk/2A70bh/1s+n7oiGCDHz6Y1E borYrntGILWaOezvabSjWDLYHN1SYhME8kdlnPaMMTcScnAtn6qXH0EG9VNtIN6EQf+eyIdRpp5rQ KoY8gI6F5clGl90pQp1uBVE8Xb71ZdrEOmPIjJwbs6Qug06Oikr+CtianRiZiaDMta1TXXqNtszPf M9p1MT/hLfbS4uZpV9C15ea8pVYWUo5pIWdblPMIBkmo6TBQeBCf7pBOzw6pneO+NsYaCZGsj5eNO oUKCV7tg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eqtpX-0006rl-7T; Wed, 28 Feb 2018 04:59:03 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqtop-0006Ww-Kv for linux-arm-kernel@bombadil.infradead.org; Wed, 28 Feb 2018 04:58:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=92EJtBL4N3SLjrTQoEB9FKGoOZGD0WAbCCnlpuZ4v8E=; b=1JNec/vs8o2EUM36FBwaIyexb bo4a0cHuW2tPd3JN1GxxnmVsyXeJDc6+UqCb8H2bH0tDP4HUvkGJsFfA5RHtfcK+DSjTgTub9qHcb i3j41b50u/iiXvfOwbWrAhHceSztOCfuCac0l2mcEIc583PwyZ7SiUrLEkyeq0qfjIWwSPXWVphja 1HaKW9ob8xaQ9QGIfWXVNpw7cuYiQqjZ8GSOB3D9GliD8znVN1uDG13a54PiGpOYJvPWKLWC1gHYZ A7TtD+K5KjoNw+LXZb/6Rkkk2lzjC4O/RashoNMXsnkuxI02Ok9bqyxJUL5hgrevoCnlt4hlsM9Dz XdnqtWTEA==; Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]) by merlin.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqtol-0004tw-UB for linux-arm-kernel@lists.infradead.org; Wed, 28 Feb 2018 04:58:17 +0000 Received: by mail-pg0-x241.google.com with SMTP id l131so541281pga.2 for ; Tue, 27 Feb 2018 20:58:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=92EJtBL4N3SLjrTQoEB9FKGoOZGD0WAbCCnlpuZ4v8E=; b=Wn77DseeDGOj9LXnNaZDImNjN4ESoB0L/H1MYOToPGY1PJeYyw2D2Vvvgnutxb9n8B N1o/93fRn/I1phrm9HmxzNLjJEWQ31Q1Up3PFdTKShYQ1I4g6nrVlOi9HjjpyN81IRR0 1awj6viiKCFZA1IhqmmY3okjNCPjFjlZof26Y= 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=92EJtBL4N3SLjrTQoEB9FKGoOZGD0WAbCCnlpuZ4v8E=; b=SWPm7sD5qnSHeFRT4+FnSkvKQAKNPNIHCfGWLAGEmpxIXkpkQBJvb94Ueywygpj47C sIYy20riBxE2PnLSxfARJYJt2TN45TzxRNFCV5GE1Z7F7nycUGF+FtVT0C4dEkLquz/D u7ES1l7mI2JaVwNsasLJf2ELzZtKMeY53WUC5fwgSTj3h8fqDMA86WZuoRaFQULLObDP 8Hv7nqJWsoeTfpdR8CgL8paRzyJjVDDO7t4EBFS9yi+Qu/6t4afccCLJR9dbASXXaxpz 58V2wR7E0+ohlvp0qylmF6Jx6nKR5JtY8ZoeiMwqb+N3ptSgt6ghafh0esEyljN4zafV vqgQ== X-Gm-Message-State: APf1xPASak93P/zWfkLNeoEH3ezvlxPpLx9CZu82Eil5sv+iWvhaY8Pe oQpBgZAEh8x9uAJ64eybA/yuug== X-Google-Smtp-Source: AH8x226ZFzGip20C/StZpILoOg5I1bY92/tNVuCgrEjaLgctUUcksV+lliUnIAVxIZuSbxZmN8zjWw== X-Received: by 10.99.182.76 with SMTP id v12mr12971354pgt.158.1519793880865; Tue, 27 Feb 2018 20:58:00 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id 83sm1174106pfj.151.2018.02.27.20.58.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Feb 2018 20:58:00 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com, keescook@chromium.org Subject: [PATCH v2 2/3] lkdtm: handle unresolved name for probing Date: Wed, 28 Feb 2018 13:57:43 +0900 Message-Id: <20180228045744.12914-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180228045744.12914-1-takahiro.akashi@linaro.org> References: <20180228045744.12914-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180227_235816_021143_72A31D02 X-CRM114-Status: GOOD ( 16.89 ) 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: linux-arm-kernel@lists.infradead.org, AKASHI Takahiro , dave.long@linaro.org, masami.hiramatsu@linaro.org 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 Since arm64 doesn't have "do_IRQ" function, INT_HARDWARE_ENTRY just doesn't work. This patch provides a generalized approach for handling such an unresolved name for probing. Currently we handle only INT_HARDWARE_ENTRY, but may extend this workaround for others, if applicable, in the future. Signed-off-by: AKASHI Takahiro --- drivers/misc/lkdtm_core.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/misc/lkdtm_core.c b/drivers/misc/lkdtm_core.c index 2154d1bfd18b..737e7e0f50f4 100644 --- a/drivers/misc/lkdtm_core.c +++ b/drivers/misc/lkdtm_core.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -235,6 +236,9 @@ static noinline void lkdtm_do_action(const struct crashtype *crashtype) crashtype->func(); } +/* Architecture may overwrite this. */ +unsigned long __weak get_handle_irq(void) { return 0; } + static int lkdtm_register_cpoint(struct crashpoint *crashpoint, const struct crashtype *crashtype) { @@ -249,13 +253,38 @@ static int lkdtm_register_cpoint(struct crashpoint *crashpoint, if (lkdtm_kprobe != NULL) unregister_kprobe(lkdtm_kprobe); + if (!kallsyms_lookup_name(crashpoint->kprobe.symbol_name)) { + /* This symbol is not arhcitecture agnostic. */ + if (!strcmp(crashpoint->name, "INT_HARDWARE_ENTRY")) { + unsigned long func; + + func = get_handle_irq(); + if (func) { + crashpoint->kprobe.addr = + (kprobe_opcode_t *)func; + /* + * Instantiating kprobe.symbol_name here, say + * with lookup_symbol_name(*handle_arch_irq), + * would cause register_kprobe() to fail. + */ + crashpoint->kprobe.symbol_name = NULL; + } else { + pr_info("Couldn't find a function for INT_HARDWARE_ENTRY\n"); + return -EINVAL; + } + } + } lkdtm_crashpoint = crashpoint; lkdtm_crashtype = crashtype; lkdtm_kprobe = &crashpoint->kprobe; ret = register_kprobe(lkdtm_kprobe); if (ret < 0) { - pr_info("Couldn't register kprobe %s\n", - crashpoint->kprobe.symbol_name); + if (crashpoint->kprobe.symbol_name) + pr_info("Couldn't register kprobe %s\n", + crashpoint->kprobe.symbol_name); + else + pr_info("Couldn't register kprobe 0x%lx\n", + (unsigned long)crashpoint->kprobe.addr); lkdtm_kprobe = NULL; lkdtm_crashpoint = NULL; lkdtm_crashtype = NULL;