Re: [PATCH] arm64: bpf: fix signedness bug in loading 64-bit immediate

2015-05-08 Thread Alexei Starovoitov
On 5/8/15 8:17 AM, Will Deacon wrote: Ok, I plan to apply the patch below for 4.1. great catch. Looks good to me. Xi, could you send a separate patch for test_bpf update to net-next? Thanks! -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to

Re: [PATCH] arm64: bpf: fix signedness bug in loading 64-bit immediate

2015-05-08 Thread Will Deacon
t. Ok, I plan to apply the patch below for 4.1. Will --->8 >From 1e4df6b7208140f3c49f316d33a409d3a161f350 Mon Sep 17 00:00:00 2001 From: Xi Wang Date: Fri, 8 May 2015 06:39:51 +0100 Subject: [PATCH] arm64: bpf: fix signedness bug in loading 64-bit immediate Consider "(u64)insn1.imm &

Re: [PATCH] arm64: bpf: fix signedness bug in loading 64-bit immediate

2015-05-08 Thread Xi Wang
On Fri, May 8, 2015 at 1:38 AM, Will Deacon wrote: >> - imm64 = (u64)insn1.imm << 32 | imm; >> + imm64 = ((u64)(u32)insn1.imm) << 32 | (u64)(u32)imm; > > This seems a bit convoluted to me. Don't you just need to add a (u32) > cast to imm and that's it? The (u64)(u32) looks

Re: [PATCH] arm64: bpf: fix signedness bug in loading 64-bit immediate

2015-05-08 Thread Will Deacon
On Fri, May 08, 2015 at 06:39:51AM +0100, Xi Wang wrote: > Consider "(u64)insn1.imm << 32 | imm" in the arm64 JIT. Since imm is > signed 32-bit, it is sign-extended to 64-bit, losing the high 32 bits. > The fix is to convert imm to u32 first and zero-extend it to u64. > > Also extend test_bpf to

[PATCH] arm64: bpf: fix signedness bug in loading 64-bit immediate

2015-05-07 Thread Xi Wang
Consider "(u64)insn1.imm << 32 | imm" in the arm64 JIT. Since imm is signed 32-bit, it is sign-extended to 64-bit, losing the high 32 bits. The fix is to convert imm to u32 first and zero-extend it to u64. Also extend test_bpf to catch this JIT bug; the interpreter is correct. Before: test_bpf: