[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <F8E1FCB9-C168-454D-B765-DF1F65370ABF@fb.com>
Date: Tue, 11 Jan 2022 17:26:55 +0000
From: Song Liu <songliubraving@...com>
To: Peter Zijlstra <peterz@...radead.org>
CC: Song Liu <song@...nel.org>, bpf <bpf@...r.kernel.org>,
Networking <netdev@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"ast@...nel.org" <ast@...nel.org>,
"daniel@...earbox.net" <daniel@...earbox.net>,
"andrii@...nel.org" <andrii@...nel.org>,
Kernel Team <Kernel-team@...com>,
"x86@...nel.org" <x86@...nel.org>
Subject: Re: [PATCH v3 bpf-next 7/7] bpf, x86_64: use bpf_prog_pack allocator
> On Jan 11, 2022, at 4:04 AM, Peter Zijlstra <peterz@...radead.org> wrote:
>
> On Wed, Jan 05, 2022 at 06:25:33PM -0800, Song Liu wrote:
>> From: Song Liu <songliubraving@...com>
>>
>> Use bpf_prog_pack allocator in x86_64 jit.
>>
>> The program header from bpf_prog_pack is read only during the jit process.
>> Therefore, the binary is first written to a temporary buffer, and later
>> copied to final location with text_poke_jit().
>>
>> Similarly, jit_fill_hole() is updated to fill the hole with 0xcc using
>> text_poke_jit().
>>
>> Signed-off-by: Song Liu <songliubraving@...com>
>> ---
>> arch/x86/net/bpf_jit_comp.c | 131 +++++++++++++++++++++++++++---------
>> 1 file changed, 100 insertions(+), 31 deletions(-)
>>
>> diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
>> index fe4f08e25a1d..ad69a64ee4fe 100644
>> --- a/arch/x86/net/bpf_jit_comp.c
>> +++ b/arch/x86/net/bpf_jit_comp.c
>> @@ -216,11 +216,33 @@ static u8 simple_alu_opcodes[] = {
>> [BPF_ARSH] = 0xF8,
>> };
>>
>> +static char jit_hole_buffer[PAGE_SIZE] = {};
>> +
>> static void jit_fill_hole(void *area, unsigned int size)
>> +{
>> + struct bpf_binary_header *hdr = area;
>> + int i;
>> +
>> + for (i = 0; i < roundup(size, PAGE_SIZE); i += PAGE_SIZE) {
>> + int s;
>> +
>> + s = min_t(int, PAGE_SIZE, size - i);
>> + text_poke_jit(area + i, jit_hole_buffer, s);
>> + }
>> +
>> + /* bpf_jit_binary_alloc_pack cannot write size directly to the ro
>> + * mapping. Write it here with text_poke_jit().
>> + */
>
> Could we move this file towards regular comment style please? It's
> already mixed style, let's take the opportunity and not add more
> net-style comments.
Aha, I didn't realize the file is about 50:50 with the two styles. I can
change it in v4.
Thanks,
Song
Powered by blists - more mailing lists