Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1801713ybv; Fri, 21 Feb 2020 03:45:41 -0800 (PST) X-Google-Smtp-Source: APXvYqycqKq7gGy3xISbrtmMGrOddal8+c0pvqX7+QTtcgI7z3HhTv0l98aqwgiyl1gdMyMd0T2M X-Received: by 2002:a9d:12a8:: with SMTP id g37mr28036236otg.261.1582285541631; Fri, 21 Feb 2020 03:45:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582285541; cv=none; d=google.com; s=arc-20160816; b=O7dHKAARlaimV1vT/K8Rm4AKZcvTpjCK2XYI/l7GaUZFbFMH17z6IVLtDHjzy3XywR llfvuBEyenDiCMjUVxHHmml+tOnA4RDdYwwFQm4qBlxzz07b351o3s3n1wPzshxKxN5o qg+/ACiioRLTb5WVvSlCbVWR3WucOwwgfMcTUPTIiV8d8tY+OMMes3qcDY3+cY2iS71l z8jgHzlwWbru0Z6jnnqKDWN9ZfxTCTLmyyYYf9eQ+b4fYZTj0AgTooYtlck8SyTjBjUp VEBGhsDOpBvGd0+8diwosguqPkLjqQCmBUTwToq4qAaCnGtYQNntjibIJQq07s+bApnA xhOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LJ4vTOTG9PJc9rMIaNzWyg/387NmUWaJi3GmtuvSWXU=; b=GWU6g9j1Xjx4yh1ab6tcBNt+AcScRDWR0TROQmBscd8aN4UUjTWnxg/9lwKd/Ug9li 9fROJ4L2CgupQLfyU5zcSk4kYY4k0tjDL1JQuRLpdPY5MiGgEef+qAZaazy9BsHNqjpg aXn5B+pWTFGQ1zKJhfLCssaf+D25oAM3SH92ZPn8hyp2VwZGaT4KK9YlD6Pnui0W5xyS FjhGTdGxS+nNLq8/5qhfYcNtCeSIcnRbhMvFtS5/IkMj3QvyE6RfFadaS7R/BSABwuBR hZKF4xOdawInus1hE/KN/MO9dyXrlrT8VaWPW/tqNydSNF2Rxl+fh577bTH3K2ufgDD6 mbRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="dNqXEs/0"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a22si1297620otp.84.2020.02.21.03.45.29; Fri, 21 Feb 2020 03:45:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="dNqXEs/0"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727699AbgBULoU (ORCPT + 99 others); Fri, 21 Feb 2020 06:44:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:42914 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726909AbgBULoS (ORCPT ); Fri, 21 Feb 2020 06:44:18 -0500 Received: from localhost.localdomain (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4BE9B24672; Fri, 21 Feb 2020 11:44:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582285458; bh=NQKrBHjBzSyeTsxpXWc3bXpl6Rq9kSaVFVHftSDfLtk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dNqXEs/0SjsGghgbfxqJ2dVMYIl9gQdmJr8S3ZowZnLjp0bb7Rnb/itUfDkGkHLIq FHgq5QEzQfViXvxG1HLQFAd6mTiGWzBxNeLRW/DGf5IgeNp5da75KNO6yVV4a2QHUN iGeJ4CrPbaB5/KpT6zvjX4NOt1yaFgLZnI4txGHg= From: Will Deacon To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, akpm@linux-foundation.org, Will Deacon , "K . Prasad" , Thomas Gleixner , Greg Kroah-Hartman , Frederic Weisbecker , Christoph Hellwig , Quentin Perret , Alexei Starovoitov , Masami Hiramatsu Subject: [PATCH 2/3] samples/hw_breakpoint: Drop use of kallsyms_lookup_name() Date: Fri, 21 Feb 2020 11:44:03 +0000 Message-Id: <20200221114404.14641-3-will@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200221114404.14641-1-will@kernel.org> References: <20200221114404.14641-1-will@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The 'data_breakpoint' test code is the only modular user of kallsyms_lookup_name(), which was exported as part of fixing the test in f60d24d2ad04 ("hw-breakpoints: Fix broken hw-breakpoint sample module"). In preparation for un-exporting this symbol, switch the test over to using __symbol_get(), which can be used to place breakpoints on exported symbols. Cc: K.Prasad Cc: Thomas Gleixner Cc: Greg Kroah-Hartman Cc: Frederic Weisbecker Cc: Christoph Hellwig Cc: Quentin Perret Signed-off-by: Will Deacon --- samples/hw_breakpoint/data_breakpoint.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/samples/hw_breakpoint/data_breakpoint.c b/samples/hw_breakpoint/data_breakpoint.c index 469b36f93696..418c46fe5ffc 100644 --- a/samples/hw_breakpoint/data_breakpoint.c +++ b/samples/hw_breakpoint/data_breakpoint.c @@ -23,7 +23,7 @@ struct perf_event * __percpu *sample_hbp; -static char ksym_name[KSYM_NAME_LEN] = "pid_max"; +static char ksym_name[KSYM_NAME_LEN] = "jiffies"; module_param_string(ksym, ksym_name, KSYM_NAME_LEN, S_IRUGO); MODULE_PARM_DESC(ksym, "Kernel symbol to monitor; this module will report any" " write operations on the kernel symbol"); @@ -41,9 +41,13 @@ static int __init hw_break_module_init(void) { int ret; struct perf_event_attr attr; + void *addr = __symbol_get(ksym_name); + + if (!addr) + return -ENXIO; hw_breakpoint_init(&attr); - attr.bp_addr = kallsyms_lookup_name(ksym_name); + attr.bp_addr = (unsigned long)addr; attr.bp_len = HW_BREAKPOINT_LEN_4; attr.bp_type = HW_BREAKPOINT_W; @@ -66,6 +70,7 @@ static int __init hw_break_module_init(void) static void __exit hw_break_module_exit(void) { unregister_wide_hw_breakpoint(sample_hbp); + symbol_put(ksym_name); printk(KERN_INFO "HW Breakpoint for %s write uninstalled\n", ksym_name); } -- 2.25.0.265.gbab2e86ba0-goog