From nobody Fri Dec 19 17:36:36 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A2E21F6664 for ; Wed, 2 Apr 2025 22:57:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743634651; cv=none; b=Nxx2kHHR326KqNrEpN44Tio4oCZSI+rhcwcDF3sL1K7BjkchR0HUs2EEUU5mDaLqbeLLyQ5NMIZTIsDCFygKV+1QVympCnp45CPrQqh3F+Y/zIchAOuZzB+3Nw1N1aOVRXsZVb3Wh8g/gQWeNuHrYOoNX6CNNuM5Tq9V4WjILWM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743634651; c=relaxed/simple; bh=E4W35K1x9n/0/FCOiFt6Qm1Ll5SsXZbV1r9nxcBOqLs=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=A6ESG1fjszLgqpggsuOIhiJFjdVbHLTtSVBeKk7qpmLDd6cVL/0hZL4m0wgveod1TxcSI6fTd1HGRMNMEKHtEkuVjHBtW8x+Q5+YAeNJHhQQtimWGhDczuLsEx1KUHPx8HZdSR+LfzvQvI2N8yAv062E2Fy46rHZf3mUOrpyDeU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2EF3C4CEEB; Wed, 2 Apr 2025 22:57:30 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1u072Z-00000006Z11-0R4r; Wed, 02 Apr 2025 18:58:35 -0400 Message-ID: <20250402225834.954719009@goodmis.org> User-Agent: quilt/0.68 Date: Wed, 02 Apr 2025 18:57:36 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Vincent Donnefort , Vlastimil Babka , Mike Rapoport , Jann Horn , Linus Torvalds Subject: [for-linus][PATCH 1/4] tracing: Enforce the persistent ring buffer to be page aligned References: <20250402225735.849814084@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Steven Rostedt Enforce that the address and the size of the memory used by the persistent ring buffer is page aligned. Also update the documentation to reflect this requirement. Link: https://lore.kernel.org/all/CAHk-=3DwhUOfVucfJRt7E0AH+GV41ELmS4wJqxHD= nui6Giddfkzw@mail.gmail.com/ Cc: Masami Hiramatsu Cc: Mark Rutland Cc: Mathieu Desnoyers Cc: Andrew Morton Cc: Vincent Donnefort Cc: Vlastimil Babka Cc: Mike Rapoport Cc: Jann Horn Link: https://lore.kernel.org/20250402144953.412882844@goodmis.org Suggested-by: Linus Torvalds Signed-off-by: Steven Rostedt (Google) --- Documentation/admin-guide/kernel-parameters.txt | 2 ++ Documentation/trace/debugging.rst | 2 ++ kernel/trace/trace.c | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index fb8752b42ec8..71861643ef14 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -7241,6 +7241,8 @@ This is just one of many ways that can clear memory. Make sure your sys= tem keeps the content of memory across reboots before relying on this optio= n. =20 + NB: Both the mapped address and size must be page aligned for the archi= tecture. + See also Documentation/trace/debugging.rst =20 =20 diff --git a/Documentation/trace/debugging.rst b/Documentation/trace/debugg= ing.rst index 54fb16239d70..d54bc500af80 100644 --- a/Documentation/trace/debugging.rst +++ b/Documentation/trace/debugging.rst @@ -136,6 +136,8 @@ kernel, so only the same kernel is guaranteed to work i= f the mapping is preserved. Switching to a different kernel version may find a different layout and mark the buffer as invalid. =20 +NB: Both the mapped address and size must be page aligned for the architec= ture. + Using trace_printk() in the boot instance ----------------------------------------- By default, the content of trace_printk() goes into the top level tracing diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 14c38fcd6f9e..96129985e81c 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -10774,6 +10774,16 @@ __init static void enable_instances(void) } =20 if (start) { + /* Start and size must be page aligned */ + if (start & ~PAGE_MASK) { + pr_warn("Tracing: mapping start addr %pa is not page aligned\n", &star= t); + continue; + } + if (size & ~PAGE_MASK) { + pr_warn("Tracing: mapping size %pa is not page aligned\n", &size); + continue; + } + addr =3D map_pages(start, size); if (addr) { pr_info("Tracing: mapped boot instance %s at physical memory %pa of si= ze 0x%lx\n", --=20 2.47.2