From: dthaler1968@googlemail.com
To: "'Yonghong Song'" <yonghong.song@linux.dev>
Cc: <bpf@ietf.org>, <bpf@vger.kernel.org>
Subject: RE: 64-bit immediate instructions clarification
Date: Fri, 26 Jan 2024 14:27:10 -0800 [thread overview]
Message-ID: <294f01da50a6$ce3d0670$6ab71350$@gmail.com> (raw)
In-Reply-To: <dc839efe-2382-440d-bcf6-b9ddc252f35e@linux.dev>
Yonghong Song <yonghong.song@linux.dev> wrote:
> On 1/25/24 5:12 PM, dthaler1968@googlemail.com wrote:
> > The spec defines:
> >> As discussed below in `64-bit immediate instructions`_, a 64-bit
> >> immediate instruction uses a 64-bit immediate value that is constructed as
> follows.
> >> The 64 bits following the basic instruction contain a pseudo
> >> instruction using the same format but with opcode, dst_reg, src_reg,
> >> and offset all set to zero, and imm containing the high 32 bits of the
> immediate value.
> > [...]
> >> imm64 = (next_imm << 32) | imm
> > The 64-bit immediate instructions section then says:
> >> Instructions with the ``BPF_IMM`` 'mode' modifier use the wide
> >> instruction encoding defined in `Instruction encoding`_, and use the
> >> 'src' field of the basic instruction to hold an opcode subtype.
> > Some instructions then nicely state how to use the full 64 bit
> > immediate value, such as
> >> BPF_IMM | BPF_DW | BPF_LD 0x18 0x0 dst = imm64
> integer integer
> >> BPF_IMM | BPF_DW | BPF_LD 0x18 0x2 dst = map_val(map_by_fd(imm))
> + next_imm map fd data pointer
> >> BPF_IMM | BPF_DW | BPF_LD 0x18 0x6 dst = map_val(map_by_idx(imm))
> + next_imm map index data pointer
> > Others don't:
> >> BPF_IMM | BPF_DW | BPF_LD 0x18 0x1 dst = map_by_fd(imm)
> map fd map
> >> BPF_IMM | BPF_DW | BPF_LD 0x18 0x3 dst = var_addr(imm)
> variable id data pointer
> >> BPF_IMM | BPF_DW | BPF_LD 0x18 0x4 dst = code_addr(imm)
> integer code pointer
> >> BPF_IMM | BPF_DW | BPF_LD 0x18 0x5 dst = map_by_idx(imm)
> map index map
> > How is next_imm used in those four? Must it be 0? Or can it be anything and
> it's ignored?
> > Or is it used for something?
>
> The other four must have next_imm to be 0. No use of next_imm in thee four
> insns kindly implies this.
> See uapi bpf.h for details (search BPF_PSEUDO_MAP_FD).
Thanks for confirming. The "Instruction encoding" section has misleading text
in my opinion.
It nicely says:
> Note that most instructions do not use all of the fields. Unused fields shall be cleared to zero.
But then goes on to say:
> As discussed below in 64-bit immediate instructions (Section 4.4), a 64-bit immediate instruction
> uses a 64-bit immediate value that is constructed as follows.
[...]
> imm64 = (next_imm << 32) | imm
Under a normal English reading, that could imply that all 64-bit immediate instructions use imm64,
which is not the case. The whole imm64 discussion there only applies today to src=0 (though I
suppose it could be used by future 64-bit immediate instructions). Minimally I think
"a 64-bit immediate instruction uses" should be "some 64-bit immediate instructions use"
but at present there's only one.
It would actually be simpler to remove the imm64 text and just have the
definition of src 0x0 change from: "dst = imm64" to "dst = (next_imm << 32) | imm".
What do you think?
Dave
WARNING: multiple messages have this Message-ID (diff)
From: dthaler1968=40googlemail.com@dmarc.ietf.org
To: "'Yonghong Song'" <yonghong.song@linux.dev>
Cc: <bpf@ietf.org>, <bpf@vger.kernel.org>
Subject: Re: [Bpf] 64-bit immediate instructions clarification
Date: Fri, 26 Jan 2024 14:27:10 -0800 [thread overview]
Message-ID: <294f01da50a6$ce3d0670$6ab71350$@gmail.com> (raw)
Message-ID: <20240126222710.OFZzrh-Bw8iL5CRnCZL8f_2dDIKlSYGNBFqyhIsfy1U@z> (raw)
In-Reply-To: <dc839efe-2382-440d-bcf6-b9ddc252f35e@linux.dev>
Yonghong Song <yonghong.song@linux.dev> wrote:
> On 1/25/24 5:12 PM, dthaler1968@googlemail.com wrote:
> > The spec defines:
> >> As discussed below in `64-bit immediate instructions`_, a 64-bit
> >> immediate instruction uses a 64-bit immediate value that is constructed as
> follows.
> >> The 64 bits following the basic instruction contain a pseudo
> >> instruction using the same format but with opcode, dst_reg, src_reg,
> >> and offset all set to zero, and imm containing the high 32 bits of the
> immediate value.
> > [...]
> >> imm64 = (next_imm << 32) | imm
> > The 64-bit immediate instructions section then says:
> >> Instructions with the ``BPF_IMM`` 'mode' modifier use the wide
> >> instruction encoding defined in `Instruction encoding`_, and use the
> >> 'src' field of the basic instruction to hold an opcode subtype.
> > Some instructions then nicely state how to use the full 64 bit
> > immediate value, such as
> >> BPF_IMM | BPF_DW | BPF_LD 0x18 0x0 dst = imm64
> integer integer
> >> BPF_IMM | BPF_DW | BPF_LD 0x18 0x2 dst = map_val(map_by_fd(imm))
> + next_imm map fd data pointer
> >> BPF_IMM | BPF_DW | BPF_LD 0x18 0x6 dst = map_val(map_by_idx(imm))
> + next_imm map index data pointer
> > Others don't:
> >> BPF_IMM | BPF_DW | BPF_LD 0x18 0x1 dst = map_by_fd(imm)
> map fd map
> >> BPF_IMM | BPF_DW | BPF_LD 0x18 0x3 dst = var_addr(imm)
> variable id data pointer
> >> BPF_IMM | BPF_DW | BPF_LD 0x18 0x4 dst = code_addr(imm)
> integer code pointer
> >> BPF_IMM | BPF_DW | BPF_LD 0x18 0x5 dst = map_by_idx(imm)
> map index map
> > How is next_imm used in those four? Must it be 0? Or can it be anything and
> it's ignored?
> > Or is it used for something?
>
> The other four must have next_imm to be 0. No use of next_imm in thee four
> insns kindly implies this.
> See uapi bpf.h for details (search BPF_PSEUDO_MAP_FD).
Thanks for confirming. The "Instruction encoding" section has misleading text
in my opinion.
It nicely says:
> Note that most instructions do not use all of the fields. Unused fields shall be cleared to zero.
But then goes on to say:
> As discussed below in 64-bit immediate instructions (Section 4.4), a 64-bit immediate instruction
> uses a 64-bit immediate value that is constructed as follows.
[...]
> imm64 = (next_imm << 32) | imm
Under a normal English reading, that could imply that all 64-bit immediate instructions use imm64,
which is not the case. The whole imm64 discussion there only applies today to src=0 (though I
suppose it could be used by future 64-bit immediate instructions). Minimally I think
"a 64-bit immediate instruction uses" should be "some 64-bit immediate instructions use"
but at present there's only one.
It would actually be simpler to remove the imm64 text and just have the
definition of src 0x0 change from: "dst = imm64" to "dst = (next_imm << 32) | imm".
What do you think?
Dave
--
Bpf mailing list
Bpf@ietf.org
https://www.ietf.org/mailman/listinfo/bpf
next prev parent reply other threads:[~2024-01-26 22:27 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-16 20:38 [Bpf] Sign extension ISA question dthaler1968=40googlemail.com
2024-01-16 20:55 ` dthaler1968
2024-01-16 20:55 ` [Bpf] " dthaler1968=40googlemail.com
2024-01-16 22:34 ` Yonghong Song
2024-01-16 22:34 ` [Bpf] " Yonghong Song
2024-01-17 1:56 ` dthaler1968
2024-01-17 1:56 ` [Bpf] " dthaler1968=40googlemail.com
2024-01-17 3:48 ` Yonghong Song
2024-01-17 3:48 ` [Bpf] " Yonghong Song
2024-01-24 2:07 ` Jump instructions clarification dthaler1968
2024-01-24 2:07 ` [Bpf] " dthaler1968=40googlemail.com
2024-01-24 19:33 ` Yonghong Song
2024-01-24 19:33 ` [Bpf] " Yonghong Song
2024-01-26 1:12 ` 64-bit immediate " dthaler1968
2024-01-26 1:12 ` [Bpf] " dthaler1968=40googlemail.com
2024-01-26 5:34 ` Yonghong Song
2024-01-26 5:34 ` [Bpf] " Yonghong Song
2024-01-26 22:27 ` dthaler1968 [this message]
2024-01-26 22:27 ` dthaler1968=40googlemail.com
2024-01-27 3:41 ` Yonghong Song
2024-01-27 3:41 ` [Bpf] " Yonghong Song
2024-01-27 6:56 ` dthaler1968
2024-01-27 6:56 ` [Bpf] " dthaler1968=40googlemail.com
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='294f01da50a6$ce3d0670$6ab71350$@gmail.com' \
--to=dthaler1968@googlemail.com \
--cc=bpf@ietf.org \
--cc=bpf@vger.kernel.org \
--cc=yonghong.song@linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.