lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e7e31eaa04234dddaac660a38adedee4@AcuMS.aculab.com>
Date: Mon, 15 Jul 2024 12:42:08 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Nicholas Piggin' <npiggin@...il.com>, Naveen N Rao <naveen@...nel.org>,
	"linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>,
	"linux-trace-kernel@...r.kernel.org" <linux-trace-kernel@...r.kernel.org>,
	"bpf@...r.kernel.org" <bpf@...r.kernel.org>, "linux-kbuild@...r.kernel.org"
	<linux-kbuild@...r.kernel.org>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>
CC: Mark Rutland <mark.rutland@....com>, Daniel Borkmann
	<daniel@...earbox.net>, Masahiro Yamada <masahiroy@...nel.org>, "Alexei
 Starovoitov" <ast@...nel.org>, Steven Rostedt <rostedt@...dmis.org>, "Andrii
 Nakryiko" <andrii@...nel.org>, Christophe Leroy
	<christophe.leroy@...roup.eu>, Vishal Chourasia <vishalc@...ux.ibm.com>,
	Mahesh Salgaonkar <mahesh@...ux.ibm.com>, Hari Bathini
	<hbathini@...ux.ibm.com>, "Masami Hiramatsu" <mhiramat@...nel.org>
Subject: RE: [RFC PATCH v4 12/17] powerpc64/ftrace: Move ftrace sequence out
 of line

From: Nicholas Piggin
> Sent: 15 July 2024 09:25
> 
> On Sun Jul 14, 2024 at 6:27 PM AEST, Naveen N Rao wrote:
> > Function profile sequence on powerpc includes two instructions at the
> > beginning of each function:
> > 	mflr	r0
> > 	bl	ftrace_caller
> >
> > The call to ftrace_caller() gets nop'ed out during kernel boot and is
> > patched in when ftrace is enabled.
> >
> > Given the sequence, we cannot return from ftrace_caller with 'blr' as we
> > need to keep LR and r0 intact. This results in link stack (return
> > address predictor) imbalance when ftrace is enabled. To address that, we
> > would like to use a three instruction sequence:
> > 	mflr	r0
> > 	bl	ftrace_caller
> > 	mtlr	r0
> >
> > Further more, to support DYNAMIC_FTRACE_WITH_CALL_OPS, we need to
> > reserve two instruction slots before the function. This results in a
> > total of five instruction slots to be reserved for ftrace use on each
> > function that is traced.
> >
> > Move the function profile sequence out-of-line to minimize its impact.
> > To do this, we reserve a single nop at function entry using
> > -fpatchable-function-entry=1 and add a pass on vmlinux.o to determine
> > the total number of functions that can be traced. This is then used to
> > generate a .S file reserving the appropriate amount of space for use as
> > ftrace stubs, which is built and linked into vmlinux.
> 
> These are all going into .tramp.ftrace.text AFAIKS? Should that be
> moved after some of the other text in the linker script then if it
> could get quite large? sched and lock and other things should be
> closer to the rest of text and hot code.

Can't you allocate the space for the 'function profile sequence'
at run-time when (if) ftrace is enabled?
When ftrace gets disabled it is likely possible to save the trampoline
number in the nop - so the same memory can be used next time.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ