Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp220681pxb; Fri, 15 Oct 2021 04:18:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsXVZ+R79uX5+z/zoXcc2VoF3PoQ9gNLoI4P7JXmQKvBR4fmNo8xwxL++dNG3XY4RsKYYJ X-Received: by 2002:a17:90a:f292:: with SMTP id fs18mr12534904pjb.229.1634296680432; Fri, 15 Oct 2021 04:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634296680; cv=none; d=google.com; s=arc-20160816; b=tZ68SQ784rlDZ7Ot+4QZsRfhoOeAJz+4+IOJp0kb+71vIOV+uJd7b1V7MRiLpf8s9t Sbow/dzPwrMexXP/DSo6JAjKbNKdcGf36Ipq37tdKrX768fJaRwp3PsQtUDznAlRdGSN wDs5ZlGa6CEoa3Pj4UPqLHFgwyiRI4ltmysXfuCYinNW3f46c1wOd9QOiluWFSAoYydM EtH4Nbnl9u4gKCr9z/9aAxZIJEDORwa3XJT2mYHxXPjFEOYXb2LRXgpk/31AX9/4hQeE G2bDJ5x3+F41VxctwB1MxNChKKeZSlSvXXRsKbIjvS9j0b5VM4EJRl77vjhoX6Xyrj3Y RzaA== 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:to:from :dkim-signature:dkim-filter; bh=6bWkd/ZYo9iwC5D6ljtnqzr8MoO2MeG2exKw7wTf0A8=; b=cd4L2QK9XVtvp3Q+Y1pyEaQxN+M1GB9rhk6ylBsh0OcMRC2a0mJToGctu7rebLALle V3Cqwkfvw5swrV3Y5tkfs8U7s3iqY81VBh9XWf/LBrDgaoYWe0h7Nd3wJpTG5e9zqPJ5 sFS31LomVfWZlX/vzIajys2E/bloT+9X6rQyE5Gko9m+jzHFW+Zj1mm18TrKBGukf4qp QS7l2VabavAW0nzvtP693rvc2x53wkeCk7eCiN3hCp8n4W07h98SweGcLOy2wt0YBXTR 1VHW4WxJtRNz29OnBlYoGO0A+S3U8tioacBQtmmdct5XV7a3h5V4CJhGsYqJ8rR+ZnlA f2vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=aiS3cVux; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i14si295710pgv.125.2021.10.15.04.17.47; Fri, 15 Oct 2021 04:18:00 -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; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=aiS3cVux; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235273AbhJODBh (ORCPT + 99 others); Thu, 14 Oct 2021 23:01:37 -0400 Received: from linux.microsoft.com ([13.77.154.182]:58248 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232447AbhJODBR (ORCPT ); Thu, 14 Oct 2021 23:01:17 -0400 Received: from x64host.home (unknown [47.187.212.181]) by linux.microsoft.com (Postfix) with ESMTPSA id E7D2120B9D21; Thu, 14 Oct 2021 19:59:10 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E7D2120B9D21 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1634266751; bh=6bWkd/ZYo9iwC5D6ljtnqzr8MoO2MeG2exKw7wTf0A8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=aiS3cVux9FCKsVix3SaXW/0koiK0Oxq8ZfyTRpRo7ty5gw6WgfhpgQSREPsIIeZHR HdrXCNoiWO1PwwnxV2yrA1mRfeGfUoP5HHTFcl4U+OFT6POPkabsa6bDZoonDbIzvH A7N/wBvi03oKwT38Y2PcOjv6l/KdsqgOjvXuWwnk= 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 v10 08/11] arm64: Rename unwinder functions, prevent them from being traced and kprobed Date: Thu, 14 Oct 2021 21:58:44 -0500 Message-Id: <20211015025847.17694-9-madvenka@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211015025847.17694-1-madvenka@linux.microsoft.com> References: <20211015025847.17694-1-madvenka@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); } -- 2.25.1