Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752558AbbEHIql (ORCPT ); Fri, 8 May 2015 04:46:41 -0400 Received: from mail-yh0-f41.google.com ([209.85.213.41]:34188 "EHLO mail-yh0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752341AbbEHIqk (ORCPT ); Fri, 8 May 2015 04:46:40 -0400 MIME-Version: 1.0 In-Reply-To: <20150508083856.GA2125@arm.com> References: <1431063591-16668-1-git-send-email-xi.wang@gmail.com> <20150508083856.GA2125@arm.com> From: Xi Wang Date: Fri, 8 May 2015 01:45:59 -0700 Message-ID: Subject: Re: [PATCH] arm64: bpf: fix signedness bug in loading 64-bit immediate To: Will Deacon Cc: "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Zi Shen Lim , Alexei Starovoitov , Catalin Marinas Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1219 Lines: 28 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 redundant. You're right - the second (u64) is redundant; the hope was to make the code easier to understand. It's from the interpreter code in kernel/core/bpf.c, which uses (u64)(u32) as well. >> - BPF_ALU64_IMM(BPF_MOV, R0, 1), >> + BPF_LD_IMM64(R0, 0x1ffffffffLL), >> + BPF_ALU64_IMM(BPF_RSH, R0, 32), /* R0 = 1 */ >> BPF_EXIT_INSN(), > > This hunk should probably be a separate patch, unless you get Alexei's ack > for me to take it via the arm64 tree too. I would be happy to split this into a separate patch if that works better, or simply drop this part. - xi -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/