linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@fb.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <song@kernel.org>, bpf <bpf@vger.kernel.org>,
	Networking <netdev@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	Kernel Team <Kernel-team@fb.com>,
	"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH v2 bpf-next 5/7] x86/alternative: introduce text_poke_jit
Date: Thu, 16 Dec 2021 19:40:40 +0000	[thread overview]
Message-ID: <C82FEB90-B8F3-4869-B905-8940DEBD6889@fb.com> (raw)
In-Reply-To: <Ybmyr3GB5+nZbso2@hirez.programming.kicks-ass.net>



> On Dec 15, 2021, at 1:17 AM, Peter Zijlstra <peterz@infradead.org> wrote:
> 
> 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.

Yeah, it was a typo. I meant to say ROX. 

Thanks,
Song
> 
> 
>> +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;
>> +}


  reply	other threads:[~2021-12-16 19:40 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-15  6:00 [PATCH v2 bpf-next 0/7] bpf_prog_pack allocator Song Liu
2021-12-15  6:00 ` [PATCH v2 bpf-next 1/7] x86/Kconfig: select HAVE_ARCH_HUGE_VMALLOC with HAVE_ARCH_HUGE_VMAP Song Liu
2021-12-15  6:00 ` [PATCH v2 bpf-next 2/7] bpf: use bytes instead of pages for bpf_jit_[charge|uncharge]_modmem Song Liu
2021-12-15  8:56   ` Peter Zijlstra
2021-12-16 19:45     ` Song Liu
2021-12-15  6:00 ` [PATCH v2 bpf-next 3/7] bpf: use size instead of pages in bpf_binary_header Song Liu
2021-12-15  6:00 ` [PATCH v2 bpf-next 4/7] bpf: add a pointer of bpf_binary_header to bpf_prog Song Liu
2021-12-15  6:01 ` [PATCH v2 bpf-next 5/7] x86/alternative: introduce text_poke_jit Song Liu
2021-12-15  9:06   ` Peter Zijlstra
2021-12-15  9:17   ` Peter Zijlstra
2021-12-16 19:40     ` Song Liu [this message]
2021-12-15  6:01 ` [PATCH v2 bpf-next 6/7] bpf: introduce bpf_prog_pack allocator Song Liu
2021-12-15  6:01 ` [PATCH v2 bpf-next 7/7] bpf, x86_64: use " Song Liu
2021-12-16 20:06 ` [PATCH v2 bpf-next 0/7] " Andrii Nakryiko
2021-12-17  1:53   ` Song Liu
2021-12-17 16:42     ` Andrii Nakryiko
2021-12-17 16:43       ` Andrii Nakryiko
2021-12-17 17:13         ` Song Liu
2021-12-17 17:16           ` Andrii Nakryiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C82FEB90-B8F3-4869-B905-8940DEBD6889@fb.com \
    --to=songliubraving@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=song@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).