From patchwork Fri Oct 15 02:34:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Madhavan T. Venkataraman" X-Patchwork-Id: 12559761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA315C433EF for ; Fri, 15 Oct 2021 02:39:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B2A8E610D1 for ; Fri, 15 Oct 2021 02:39:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B2A8E610D1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CyPQ0l0/ldhM1hdezxteQ1PcAEz1vVmlFg9syNHwE94=; b=Jh8qmPV5IGWPXp GyfivtSCJsSfzk319Cg3E4TEoNjP+LqBv+flrUNxGvFPl4ARgD2OfLDzsX59+c4hMU7ElSH0lJe+l K6wJMBr0LtN3zhN/9TkJ/A4bbz5Vtt7Wn8RgsMKzrbt3upVflD0G3N7mhSCBCeHkCIudhIIFSVMEb y+y7d7zbW7huvdiYby1ia9eyy8idmpXMJtxzdxvw2z5hrdg5YFtK0zMKdu4+nhO5uk7dK+T4MC8T1 CEtgJatZbRNtj+flK5lzJWxtj8RJGWXD/l2/Pv/RYf1UuuSKBTNp8zhl0q8KtzYqqA1KFCBzkMTIo NVYzWNSt38o8TaLZ9Fzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbD6z-0055zA-D8; Fri, 15 Oct 2021 02:38:21 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mbD3m-0054MR-Os for linux-arm-kernel@lists.infradead.org; Fri, 15 Oct 2021 02:35:04 +0000 Received: from x64host.home (unknown [47.187.212.181]) by linux.microsoft.com (Postfix) with ESMTPSA id BA0DD20B9D16; Thu, 14 Oct 2021 19:35:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com BA0DD20B9D16 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1634265302; bh=6bWkd/ZYo9iwC5D6ljtnqzr8MoO2MeG2exKw7wTf0A8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GVws1lANiCyiwHZ1Cfqa2x0UtsBpNg8ndLPRiI3HawTCH0uUp7LWmAp0wW14EA/fn xXhuXp0880Rs2+9WSAVpUpJRT0zkYoi4+zzKZdnlh6pe/h8x+hWguXAAjr5JgbHuq6 VxHIN8HOn+k8TAh1QLgGAA8oxPtz7kadg3Nqwwvk= From: madvenka@linux.microsoft.com To: mark.rutland@arm.com, broonie@kernel.org, jpoimboe@redhat.com, ardb@kernel.org, nobuta.keiya@fujitsu.com, sjitindarsingh@gmail.com, catalin.marinas@arm.com, will@kernel.org, jmorris@namei.org, linux-arm-kernel@lists.infradead.org, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, madvenka@linux.microsoft.com Subject: [PATCH v9 08/11] arm64: Rename unwinder functions, prevent them from being traced and kprobed Date: Thu, 14 Oct 2021 21:34:12 -0500 Message-Id: <20211015023413.16614-11-madvenka@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211015023413.16614-1-madvenka@linux.microsoft.com> References: <20211015023413.16614-1-madvenka@linux.microsoft.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211014_193502_912993_CEA69C2E X-CRM114-Status: GOOD ( 15.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: "Madhavan T. Venkataraman" Rename unwinder functions for consistency and better naming. - Rename start_backtrace() to unwind_start(). - Rename unwind_frame() to unwind_next(). - Rename walk_stackframe() to unwind(). Prevent the following unwinder functions from being traced: - unwind_start() - unwind_next() unwind() is already prevented from being traced. Prevent the following unwinder functions from being kprobed: - unwind_start() unwind_next() and unwind() are already prevented from being kprobed. Signed-off-by: Madhavan T. Venkataraman --- arch/arm64/kernel/stacktrace.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index 7d32cee9ef4b..f4f3575f71fd 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -33,8 +33,8 @@ */ -static void start_backtrace(struct stackframe *frame, unsigned long fp, - unsigned long pc) +static void notrace unwind_start(struct stackframe *frame, unsigned long fp, + unsigned long pc) { frame->fp = fp; frame->pc = pc; @@ -45,7 +45,7 @@ static void start_backtrace(struct stackframe *frame, unsigned long fp, /* * Prime the first unwind. * - * In unwind_frame() we'll check that the FP points to a valid stack, + * In unwind_next() we'll check that the FP points to a valid stack, * which can't be STACK_TYPE_UNKNOWN, and the first unwind will be * treated as a transition to whichever stack that happens to be. The * prev_fp value won't be used, but we set it to 0 such that it is @@ -56,6 +56,8 @@ static void start_backtrace(struct stackframe *frame, unsigned long fp, frame->prev_type = STACK_TYPE_UNKNOWN; } +NOKPROBE_SYMBOL(unwind_start); + /* * Unwind from one frame record (A) to the next frame record (B). * @@ -63,8 +65,8 @@ static void start_backtrace(struct stackframe *frame, unsigned long fp, * records (e.g. a cycle), determined based on the location and fp value of A * and the location (but not the fp value) of B. */ -static int notrace unwind_frame(struct task_struct *tsk, - struct stackframe *frame) +static int notrace unwind_next(struct task_struct *tsk, + struct stackframe *frame) { unsigned long fp = frame->fp; struct stack_info info; @@ -104,7 +106,7 @@ static int notrace unwind_frame(struct task_struct *tsk, /* * Record this frame record's values and location. The prev_fp and - * prev_type are only meaningful to the next unwind_frame() invocation. + * prev_type are only meaningful to the next unwind_next() invocation. */ frame->fp = READ_ONCE_NOCHECK(*(unsigned long *)(fp)); frame->pc = READ_ONCE_NOCHECK(*(unsigned long *)(fp + 8)); @@ -132,28 +134,30 @@ static int notrace unwind_frame(struct task_struct *tsk, return 0; } -NOKPROBE_SYMBOL(unwind_frame); -static void notrace walk_stackframe(struct task_struct *tsk, - unsigned long fp, unsigned long pc, - bool (*fn)(void *, unsigned long), - void *data) +NOKPROBE_SYMBOL(unwind_next); + +static void notrace unwind(struct task_struct *tsk, + unsigned long fp, unsigned long pc, + bool (*fn)(void *, unsigned long), + void *data) { struct stackframe frame; - start_backtrace(&frame, fp, pc); + unwind_start(&frame, fp, pc); while (1) { int ret; if (!fn(data, frame.pc)) break; - ret = unwind_frame(tsk, &frame); + ret = unwind_next(tsk, &frame); if (ret < 0) break; } } -NOKPROBE_SYMBOL(walk_stackframe); + +NOKPROBE_SYMBOL(unwind); static bool dump_backtrace_entry(void *arg, unsigned long where) { @@ -208,7 +212,7 @@ noinline notrace void arch_stack_walk(stack_trace_consume_fn consume_entry, fp = thread_saved_fp(task); pc = thread_saved_pc(task); } - walk_stackframe(task, fp, pc, consume_entry, cookie); + unwind(task, fp, pc, consume_entry, cookie); }