public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] sim: bpf: remove negi, neg32i insns
@ 2023-08-21 17:02 David Faust
  2023-08-21 17:05 ` Jose E. Marchesi
  0 siblings, 1 reply; 2+ messages in thread
From: David Faust @ 2023-08-21 17:02 UTC (permalink / raw)
  To: gdb-patches; +Cc: jose.marchesi

The BPF virtual machine does not support neg instructions operating on
immediates, and these erroneous instructions were recently removed from
gas.  Remove them from the simulator as well.

binutils patch:
[PATCH] bpf: correct neg and neg32 instruction encoding
https://sourceware.org/pipermail/binutils/2023-August/129135.html

---
 sim/bpf/bpf-sim.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/sim/bpf/bpf-sim.c b/sim/bpf/bpf-sim.c
index 5e01ddeca9f..a4af22b2308 100644
--- a/sim/bpf/bpf-sim.c
+++ b/sim/bpf/bpf-sim.c
@@ -730,10 +730,6 @@ execute (SIM_CPU *cpu, struct bpf_insn *insn)
       BPF_TRACE ("BPF_INSN_NEGR\n");
       bpf_regs[insn->dst] = - (int64_t) bpf_regs[insn->dst];
       break;
-    case BPF_INSN_NEGI:
-      BPF_TRACE ("BPF_INSN_NEGI\n");
-      bpf_regs[insn->dst] = - (int64_t) insn->imm32;
-      break;
     case BPF_INSN_LSHR:
       BPF_TRACE ("BPF_INSN_LSHR\n");
       bpf_regs[insn->dst] <<= bpf_regs[insn->src];
@@ -867,10 +863,6 @@ execute (SIM_CPU *cpu, struct bpf_insn *insn)
       BPF_TRACE ("BPF_INSN_NEG32R\n");
       bpf_regs[insn->dst] = (uint32_t) (- (int32_t) bpf_regs[insn->dst]);
       break;
-    case BPF_INSN_NEG32I:
-      BPF_TRACE ("BPF_INSN_NEG32I\n");
-      bpf_regs[insn->dst] = (uint32_t) - (int32_t) insn->imm32;
-      break;
     case BPF_INSN_LSH32R:
       BPF_TRACE ("BPF_INSN_LSH32R\n");
       bpf_regs[insn->dst] = (uint32_t) bpf_regs[insn->dst] << bpf_regs[insn->src];
-- 
2.40.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] sim: bpf: remove negi, neg32i insns
  2023-08-21 17:02 [PATCH] sim: bpf: remove negi, neg32i insns David Faust
@ 2023-08-21 17:05 ` Jose E. Marchesi
  0 siblings, 0 replies; 2+ messages in thread
From: Jose E. Marchesi @ 2023-08-21 17:05 UTC (permalink / raw)
  To: David Faust; +Cc: gdb-patches


Hi Faust.
OK.  Thanks.

> The BPF virtual machine does not support neg instructions operating on
> immediates, and these erroneous instructions were recently removed from
> gas.  Remove them from the simulator as well.
>
> binutils patch:
> [PATCH] bpf: correct neg and neg32 instruction encoding
> https://sourceware.org/pipermail/binutils/2023-August/129135.html
>
> ---
>  sim/bpf/bpf-sim.c | 8 --------
>  1 file changed, 8 deletions(-)
>
> diff --git a/sim/bpf/bpf-sim.c b/sim/bpf/bpf-sim.c
> index 5e01ddeca9f..a4af22b2308 100644
> --- a/sim/bpf/bpf-sim.c
> +++ b/sim/bpf/bpf-sim.c
> @@ -730,10 +730,6 @@ execute (SIM_CPU *cpu, struct bpf_insn *insn)
>        BPF_TRACE ("BPF_INSN_NEGR\n");
>        bpf_regs[insn->dst] = - (int64_t) bpf_regs[insn->dst];
>        break;
> -    case BPF_INSN_NEGI:
> -      BPF_TRACE ("BPF_INSN_NEGI\n");
> -      bpf_regs[insn->dst] = - (int64_t) insn->imm32;
> -      break;
>      case BPF_INSN_LSHR:
>        BPF_TRACE ("BPF_INSN_LSHR\n");
>        bpf_regs[insn->dst] <<= bpf_regs[insn->src];
> @@ -867,10 +863,6 @@ execute (SIM_CPU *cpu, struct bpf_insn *insn)
>        BPF_TRACE ("BPF_INSN_NEG32R\n");
>        bpf_regs[insn->dst] = (uint32_t) (- (int32_t) bpf_regs[insn->dst]);
>        break;
> -    case BPF_INSN_NEG32I:
> -      BPF_TRACE ("BPF_INSN_NEG32I\n");
> -      bpf_regs[insn->dst] = (uint32_t) - (int32_t) insn->imm32;
> -      break;
>      case BPF_INSN_LSH32R:
>        BPF_TRACE ("BPF_INSN_LSH32R\n");
>        bpf_regs[insn->dst] = (uint32_t) bpf_regs[insn->dst] << bpf_regs[insn->src];

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-21 17:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-21 17:02 [PATCH] sim: bpf: remove negi, neg32i insns David Faust
2023-08-21 17:05 ` Jose E. Marchesi

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 read-only IMAP folder(s) and NNTP newsgroup(s).