All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yonghong Song <yonghong.song@linux.dev>
To: dthaler1968@googlemail.com, bpf@ietf.org, bpf@vger.kernel.org
Subject: Re: Sign extension ISA question
Date: Tue, 16 Jan 2024 14:34:41 -0800	[thread overview]
Message-ID: <829aa552-b04e-4f08-9874-b3f929741852@linux.dev> (raw)
In-Reply-To: <08ab01da48be$603541a0$209fc4e0$@gmail.com>


On 1/16/24 12:55 PM, dthaler1968@googlemail.com wrote:
> (Resending since a spam filter seems to have blocked the first attempt.)
>
> Is there any semantic difference between the following two instructions?
>
> {.opcode = BPF_ALU64 | BPF_MOV | BPF_K, .offset = 0, .imm = -1}

This is supported. Sign extension of -1 will be put into ALU64 reg.

>
> {.opcode = BPF_ALU64 | BPF_MOVSX | BPF_K, .offset = 32, .imm = -1}

This is not supported. BPF_MOVSX only supports register extension.
We should make it clear in the doc.

>
>  From my reading both of them treat imm as a signed 32-bit number and
> sign-extend it to 64 bits.
>
> Dave
>
>

WARNING: multiple messages have this Message-ID (diff)
From: Yonghong Song <yonghong.song@linux.dev>
To: dthaler1968@googlemail.com, bpf@ietf.org, bpf@vger.kernel.org
Subject: Re: [Bpf] Sign extension ISA question
Date: Tue, 16 Jan 2024 14:34:41 -0800	[thread overview]
Message-ID: <829aa552-b04e-4f08-9874-b3f929741852@linux.dev> (raw)
Message-ID: <20240116223441.Lik407Qog773W5MWn9IXIyB4k_hpO6f1q5KIM0Xo0-8@z> (raw)
In-Reply-To: <08ab01da48be$603541a0$209fc4e0$@gmail.com>


On 1/16/24 12:55 PM, dthaler1968@googlemail.com wrote:
> (Resending since a spam filter seems to have blocked the first attempt.)
>
> Is there any semantic difference between the following two instructions?
>
> {.opcode = BPF_ALU64 | BPF_MOV | BPF_K, .offset = 0, .imm = -1}

This is supported. Sign extension of -1 will be put into ALU64 reg.

>
> {.opcode = BPF_ALU64 | BPF_MOVSX | BPF_K, .offset = 32, .imm = -1}

This is not supported. BPF_MOVSX only supports register extension.
We should make it clear in the doc.

>
>  From my reading both of them treat imm as a signed 32-bit number and
> sign-extend it to 64 bits.
>
> Dave
>
>

-- 
Bpf mailing list
Bpf@ietf.org
https://www.ietf.org/mailman/listinfo/bpf

  reply	other threads:[~2024-01-16 22:34 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 [this message]
2024-01-16 22:34     ` 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
2024-01-26 22:27                   ` [Bpf] " 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=829aa552-b04e-4f08-9874-b3f929741852@linux.dev \
    --to=yonghong.song@linux.dev \
    --cc=bpf@ietf.org \
    --cc=bpf@vger.kernel.org \
    --cc=dthaler1968@googlemail.com \
    /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.