Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3569950ybd; Tue, 25 Jun 2019 05:01:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLqwV6/1iBgYvLoBEkgXvFVP+E21oabr8bzwAfc/mIB//NUselUMLjY9x+RiuIKOPSVzC4 X-Received: by 2002:a17:902:a5c5:: with SMTP id t5mr156744255plq.288.1561464112466; Tue, 25 Jun 2019 05:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561464112; cv=none; d=google.com; s=arc-20160816; b=SlrjX/wJgJxZUnJRI0C7ZvjRmIoiSFU499lq6STM8zd4BUR1xBJBK6O3/Fdp3Ax4GS t5WGcRUtsCIOFTznA8GbcLCgsnxaQ4y/OBCLXHVDTgthzWpRXL0MXsBaqMV08xqsh7jX M9PKvHhsPg670EjeFiF0EqVAxeaBtwwYuC5qqw+ICfpC93eC2ABbxr0+LX1tWp9aAO6y HnlvIa1vdN4b0TTL5d91lws9F9I/5JpAYWsC+jKDucXKDcAdfQvipNK8qfRYflcezD3M UvqOmStl/gPRrK4/c2W3phIS05ZMrXOOc+Booor7ylqZh3TKPEpQO4aEOHRqrVB8KVza Qq2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=4CFzT/lM/E28pNhe32YX+Lovs+qjkNtF2KGwmQpq2FY=; b=z8yGX8IZf4XzWNkIIAInCIkky7DJu2TJ085hY0b3egzSWkEGmqkf0GPxxsihQkW20c E+G4kc4LB3b0l33IJevHDLgeHdLHSKRxlRlnvdm5YRzLGTC3+balm/CL6+gSihC92+CG k+jj2EsRbDuMRynJK9KHCmDl/CZzUsnA1oRGk/BCJAQ4gIBhyUhwwpWwRTZ2j/ihWkxz dbWK3k5s+xanQrATRppVUO5RunwhUft+J2VCZIOUIj1dJmZF0Ltn+2zW7ECB9FeDL16b 7uSGhqlrwrNsjrxWjofJelaaFnnMw5EPqX+cCSb5M8pXXIADdcNj3xjNJH+u/5HmzRlL EukA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i3si12345857pgq.440.2019.06.25.05.01.35; Tue, 25 Jun 2019 05:01:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729342AbfFYJj1 (ORCPT + 99 others); Tue, 25 Jun 2019 05:39:27 -0400 Received: from www62.your-server.de ([213.133.104.62]:38364 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728860AbfFYJj1 (ORCPT ); Tue, 25 Jun 2019 05:39:27 -0400 Received: from [78.46.172.3] (helo=sslproxy06.your-server.de) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1hfhvB-000680-8l; Tue, 25 Jun 2019 11:39:25 +0200 Received: from [178.199.41.31] (helo=linux.home) by sslproxy06.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1hfhvB-000NFN-1B; Tue, 25 Jun 2019 11:39:25 +0200 Subject: Re: bpf: test_verifier: sanitation: alu with different scalars To: Yauheni Kaliuta Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Jiri Benc References: From: Daniel Borkmann Message-ID: Date: Tue, 25 Jun 2019 11:39:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.100.3/25491/Tue Jun 25 10:02:48 2019) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/25/2019 10:29 AM, Yauheni Kaliuta wrote: > Hi! > > I'm wondering, how the sanitaion tests (#903 5.2-rc6 for example) > are supposed to work on BE arches: > > { > "sanitation: alu with different scalars 1", > .insns = { > BPF_MOV64_IMM(BPF_REG_0, 1), > BPF_LD_MAP_FD(BPF_REG_ARG1, 0), > BPF_MOV64_REG(BPF_REG_ARG2, BPF_REG_FP), > BPF_ALU64_IMM(BPF_ADD, BPF_REG_ARG2, -16), > BPF_ST_MEM(BPF_DW, BPF_REG_FP, -16, 0), > BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem), > BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1), > BPF_EXIT_INSN(), > BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0), > > reads one byte 0 on BE and 28 on LE (from ->index) since > > struct test_val { > unsigned int index; > int foo[MAX_ENTRIES]; > }; > > struct test_val value = { > .index = (6 + 1) * sizeof(int), > .foo[6] = 0xabcdef12, > }; > > BPF_JMP_IMM(BPF_JEQ, BPF_REG_1, 0, 3), > > So different branches are taken depending of the endianness. > > BPF_MOV64_IMM(BPF_REG_2, 0), > BPF_MOV64_IMM(BPF_REG_3, 0x100000), > BPF_JMP_A(2), > BPF_MOV64_IMM(BPF_REG_2, 42), > BPF_MOV64_IMM(BPF_REG_3, 0x100001), > BPF_ALU64_REG(BPF_ADD, BPF_REG_2, BPF_REG_3), > BPF_MOV64_REG(BPF_REG_0, BPF_REG_2), > BPF_EXIT_INSN(), > }, > .fixup_map_array_48b = { 1 }, > .result = ACCEPT, > .retval = 0x100000, > }, Let me get my hands on a s390x box later today and get back to you. Thanks, Daniel