Re: [PATCHv2 bpf-next 3/6] bpf: Use given function address for trampoline ip arg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 15, 2022 at 02:51:32PM +0200, Peter Zijlstra wrote:
> On Mon, Aug 15, 2022 at 12:57:39PM +0200, Jiri Olsa wrote:
> > On Mon, Aug 15, 2022 at 12:18:38PM +0200, Peter Zijlstra wrote:
> > > On Thu, Aug 11, 2022 at 11:15:23AM +0200, Jiri Olsa wrote:
> > > > Using function address given at the generation time as the trampoline
> > > > ip argument. This way we get directly the function address that we
> > > > need, so we don't need to:
> > > >   - read the ip from the stack
> > > >   - subtract X86_PATCH_SIZE
> > > >   - subtract ENDBR_INSN_SIZE if CONFIG_X86_KERNEL_IBT is enabled
> > > >     which is not even implemented yet ;-)
> > > 
> > > Can you please tell me what all this does and why?
> > > 
> > 
> > arch_prepare_bpf_trampoline prepares bpf trampoline for given function
> > specified by 'func_addr' argument
> 
> The bpf trampoline is what's used for ftrace direct call, no?

sorry I forgot to answer this one.. yes ;-)

> 
> > the changed code is storing/preparing caller's 'ip' address on the
> > trampoline's stack so the get_func_ip helper can use it
> 
> I've no idea what get_func_ip() helper is...

it's kernel code that can be executed by bpf program,
get_func_ip returns ip address of the probed function
that triggered bpf program

jirka

> 
> > currently the trampoline code gets the caller's ip address by reading
> > caller's return address from stack and subtracting X86_PATCH_SIZE from
> > it
> > 
> > the change uses 'func_addr' as caller's 'ip' address when trampoline is
> > generated .. this way we don't need to retrieve the return address from
> > stack and care about endbr instruction if IBT is enabled
> 
> Ok, I *think* I sorta understand that.



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux