* Register constraint in NEG instructions
@ 2023-07-26 8:33 Jose E. Marchesi
2023-07-26 9:16 ` Jose E. Marchesi
0 siblings, 1 reply; 5+ messages in thread
From: Jose E. Marchesi @ 2023-07-26 8:33 UTC (permalink / raw)
To: bpf; +Cc: Yonghong Song, Eduard Zingerman
Hello.
The neg (and neg32) instructions are documented to use (and encode) both
src and dst register operands in standarization/instruction-set.rst:
BPF_NEG 0x80 dst = -src
However, in llvm's BPFAsmParser::PreMatchCheck, it is checked that both
source and destination registers refer to the same register. If they
are not, an error is raised.
Is this to speed up JIT to different architectures, some like x86
featuring `NEG reg' and others like aarch64 featuring `NEG reg1,reg2'?
Should I send a patch for instruction-set.rst documenting the
requirement?
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Register constraint in NEG instructions
2023-07-26 8:33 Register constraint in NEG instructions Jose E. Marchesi
@ 2023-07-26 9:16 ` Jose E. Marchesi
2023-07-26 13:30 ` Dave Thaler
2023-07-27 4:41 ` Yonghong Song
0 siblings, 2 replies; 5+ messages in thread
From: Jose E. Marchesi @ 2023-07-26 9:16 UTC (permalink / raw)
To: bpf; +Cc: Yonghong Song, Eduard Zingerman
I see this in the verifier (bpf-next):
if (opcode == BPF_NEG) {
if (BPF_SRC(insn->code) != BPF_K ||
insn->src_reg != BPF_REG_0 ||
insn->off != 0 || insn->imm != 0) {
verbose(env, "BPF_NEG uses reserved fields\n");
return -EINVAL;
}
And along this llvm assembler test:
|
v
// CHECK: 84 01 00 00 00 00 00 00 w1 = -w1
w1 = -w1
Is enough evidence that NEG is supposed to use only dst and not src. I
am sending a fix for standarization/instruction-set.rst.
> Hello.
>
> The neg (and neg32) instructions are documented to use (and encode) both
> src and dst register operands in standarization/instruction-set.rst:
>
> BPF_NEG 0x80 dst = -src
>
> However, in llvm's BPFAsmParser::PreMatchCheck, it is checked that both
> source and destination registers refer to the same register. If they
> are not, an error is raised.
>
> Is this to speed up JIT to different architectures, some like x86
> featuring `NEG reg' and others like aarch64 featuring `NEG reg1,reg2'?
>
> Should I send a patch for instruction-set.rst documenting the
> requirement?
>
> Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Register constraint in NEG instructions
2023-07-26 9:16 ` Jose E. Marchesi
@ 2023-07-26 13:30 ` Dave Thaler
2023-07-26 13:30 ` [Bpf] " Dave Thaler
2023-07-27 4:41 ` Yonghong Song
1 sibling, 1 reply; 5+ messages in thread
From: Dave Thaler @ 2023-07-26 13:30 UTC (permalink / raw)
To: Jose E. Marchesi, bpf@vger.kernel.org, bpf@ietf.org
Cc: Yonghong Song, Eduard Zingerman
> -----Original Message-----
> From: Jose E. Marchesi <jose.marchesi@oracle.com>
> Sent: Wednesday, July 26, 2023 2:17 AM
> To: bpf@vger.kernel.org
> Cc: Yonghong Song <yonghong.song@linux.dev>; Eduard Zingerman
> <eddyz87@gmail.com>
> Subject: Re: Register constraint in NEG instructions
>
>
> I see this in the verifier (bpf-next):
>
> if (opcode == BPF_NEG) {
> if (BPF_SRC(insn->code) != BPF_K ||
> insn->src_reg != BPF_REG_0 ||
> insn->off != 0 || insn->imm != 0) {
> verbose(env, "BPF_NEG uses reserved fields\n");
> return -EINVAL;
> }
>
> And along this llvm assembler test:
>
> |
> v
> // CHECK: 84 01 00 00 00 00 00 00 w1 = -w1
> w1 = -w1
>
> Is enough evidence that NEG is supposed to use only dst and not src. I am
> sending a fix for standarization/instruction-set.rst.
>
> > Hello.
> >
> > The neg (and neg32) instructions are documented to use (and encode)
> > both src and dst register operands in standarization/instruction-set.rst:
> >
> > BPF_NEG 0x80 dst = -src
> >
> > However, in llvm's BPFAsmParser::PreMatchCheck, it is checked that
> > both source and destination registers refer to the same register. If
> > they are not, an error is raised.
> >
> > Is this to speed up JIT to different architectures, some like x86
> > featuring `NEG reg' and others like aarch64 featuring `NEG reg1,reg2'?
> >
> > Should I send a patch for instruction-set.rst documenting the
> > requirement?
> >
> > Thanks.
I am adding bpf@ietf.org to this thread, for context.
Dave
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Bpf] Register constraint in NEG instructions
2023-07-26 13:30 ` Dave Thaler
@ 2023-07-26 13:30 ` Dave Thaler
0 siblings, 0 replies; 5+ messages in thread
From: Dave Thaler @ 2023-07-26 13:30 UTC (permalink / raw)
To: Jose E. Marchesi, bpf@vger.kernel.org, bpf@ietf.org
Cc: Yonghong Song, Eduard Zingerman
> -----Original Message-----
> From: Jose E. Marchesi <jose.marchesi@oracle.com>
> Sent: Wednesday, July 26, 2023 2:17 AM
> To: bpf@vger.kernel.org
> Cc: Yonghong Song <yonghong.song@linux.dev>; Eduard Zingerman
> <eddyz87@gmail.com>
> Subject: Re: Register constraint in NEG instructions
>
>
> I see this in the verifier (bpf-next):
>
> if (opcode == BPF_NEG) {
> if (BPF_SRC(insn->code) != BPF_K ||
> insn->src_reg != BPF_REG_0 ||
> insn->off != 0 || insn->imm != 0) {
> verbose(env, "BPF_NEG uses reserved fields\n");
> return -EINVAL;
> }
>
> And along this llvm assembler test:
>
> |
> v
> // CHECK: 84 01 00 00 00 00 00 00 w1 = -w1
> w1 = -w1
>
> Is enough evidence that NEG is supposed to use only dst and not src. I am
> sending a fix for standarization/instruction-set.rst.
>
> > Hello.
> >
> > The neg (and neg32) instructions are documented to use (and encode)
> > both src and dst register operands in standarization/instruction-set.rst:
> >
> > BPF_NEG 0x80 dst = -src
> >
> > However, in llvm's BPFAsmParser::PreMatchCheck, it is checked that
> > both source and destination registers refer to the same register. If
> > they are not, an error is raised.
> >
> > Is this to speed up JIT to different architectures, some like x86
> > featuring `NEG reg' and others like aarch64 featuring `NEG reg1,reg2'?
> >
> > Should I send a patch for instruction-set.rst documenting the
> > requirement?
> >
> > Thanks.
I am adding bpf@ietf.org to this thread, for context.
Dave
--
Bpf mailing list
Bpf@ietf.org
https://www.ietf.org/mailman/listinfo/bpf
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Register constraint in NEG instructions
2023-07-26 9:16 ` Jose E. Marchesi
2023-07-26 13:30 ` Dave Thaler
@ 2023-07-27 4:41 ` Yonghong Song
1 sibling, 0 replies; 5+ messages in thread
From: Yonghong Song @ 2023-07-27 4:41 UTC (permalink / raw)
To: Jose E. Marchesi, bpf; +Cc: Eduard Zingerman
On 7/26/23 2:16 AM, Jose E. Marchesi wrote:
>
> I see this in the verifier (bpf-next):
>
> if (opcode == BPF_NEG) {
> if (BPF_SRC(insn->code) != BPF_K ||
> insn->src_reg != BPF_REG_0 ||
> insn->off != 0 || insn->imm != 0) {
> verbose(env, "BPF_NEG uses reserved fields\n");
> return -EINVAL;
> }
>
> And along this llvm assembler test:
>
> |
> v
> // CHECK: 84 01 00 00 00 00 00 00 w1 = -w1
> w1 = -w1
>
> Is enough evidence that NEG is supposed to use only dst and not src. I
Yes, in llvm (BPFInstrInfo.td),
class NEG_RR<BPFOpClass Class, BPFArithOp Opc,
dag outs, dag ins, string asmstr, list<dag> pattern>
: TYPE_ALU_JMP<Opc.Value, 0, outs, ins, asmstr, pattern> {
bits<4> dst;
let Inst{51-48} = dst;
let BPFClass = Class;
}
You can see only dst register is used. The further evidence
is from the above kernel check.
> am sending a fix for standarization/instruction-set.rst.
>
>> Hello.
>>
>> The neg (and neg32) instructions are documented to use (and encode) both
>> src and dst register operands in standarization/instruction-set.rst:
>>
>> BPF_NEG 0x80 dst = -src
>>
>> However, in llvm's BPFAsmParser::PreMatchCheck, it is checked that both
>> source and destination registers refer to the same register. If they
>> are not, an error is raised.
>>
>> Is this to speed up JIT to different architectures, some like x86
>> featuring `NEG reg' and others like aarch64 featuring `NEG reg1,reg2'?
>>
>> Should I send a patch for instruction-set.rst documenting the
>> requirement?
>>
>> Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-27 4:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-26 8:33 Register constraint in NEG instructions Jose E. Marchesi
2023-07-26 9:16 ` Jose E. Marchesi
2023-07-26 13:30 ` Dave Thaler
2023-07-26 13:30 ` [Bpf] " Dave Thaler
2023-07-27 4:41 ` Yonghong Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox