lkml.org 
[lkml]   [2021]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 bpf-next 5/7] x86/alternative: introduce text_poke_jit
On Tue, Dec 14, 2021 at 10:01:00PM -0800, Song Liu wrote:
> This will be used by BPF jit compiler to dump JITed binary to a RWX huge

OK, I read the actually allocator you use and the relevant code for this
patch and the above is a typo, you meant: RX. Those pages are most
definitely not writable.


> +void *text_poke_jit(void *addr, const void *opcode, size_t len)
> +{
> + unsigned long start = (unsigned long)addr;
> + size_t patched = 0;
> +
> + if (WARN_ON_ONCE(core_kernel_text(start)))
> + return NULL;
> +
> + while (patched < len) {
> + unsigned long ptr = start + patched;
> + size_t s;
> +
> + s = min_t(size_t, PAGE_SIZE * 2 - offset_in_page(ptr), len - patched);

Cute, should work.

> +
> + __text_poke((void *)ptr, opcode + patched, s);
> + patched += s;
> + }
> + return addr;
> +}

\
 
 \ /
  Last update: 2021-12-15 10:18    [W:2.106 / U:0.456 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site