Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5652476img; Wed, 27 Mar 2019 12:29:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqzH9PZsjPQ4Zmxb619JHM6IU0X58i26F+fTleAswNF05G6EuMnLPRk53nBXEWwEfdIyVYjf X-Received: by 2002:a17:902:864b:: with SMTP id y11mr8137420plt.1.1553714985062; Wed, 27 Mar 2019 12:29:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714985; cv=none; d=google.com; s=arc-20160816; b=PHOASFfhi9ECiL6Iwn7f9caVcj5A8RwKbQl8za5XLH8wWrr5zQXDC8L6hfZ9n/soXF nKO3NwVyAaogGlPYYsDTxSEsUQ+Ax4r7QSizYgPnONNHnGSZj8oGRZ/LhP3QYXz/uFse QhOaKapDtNFZmIuKXa+r5gX6r31ZhS6ChVOmOQc8qng2OX8zPsAywf08JceBjzD7KM7b 4v7v+9D9mIeFMAhUUkHEdqD9PS9C+cJPpINH20UQ6oaayFmJlyg0220QXP9QPepCR1kG kITFqPDBZsbplAU/w9LFi0sZFz4to1MXFHKvQIyXYGvth5TUpXMp5zygu/Ww76lAC2Os 238g== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GR98kOaUSOw2376BFR2gLFCySTRN6RLshaKfwT5WJWk=; b=BP3mf3LX2J3y07omLihP7WrFHOg33XXewe0hCFBRk3c3Wjc9Li3cFLEYqwDfDFFmqj LQ8uy9YjqXjePvikbuNnM+6hAllmRtM8yDnx20TUcXSir8e+vhlT8H8CLbFLZb1gqWI/ s6+HHOPYoFNZd/AEvt9fiJagl76ok7nT3NwIxqFSOpZU58jZl5Hl9KXzdj1lZGJX6RNs ZBovZSWR8+H0u29U1sPrqTsIf5gHOnk+oPS9c2ulp7WVnX6HAl1CJUn8oM+3IEBjF1cs pIyxMXWLGnIZ0DkIkHq+KHDr2AAx5ax2IuXPP++yTXGhaC2R4Zxxn3AYaUMcghPT8Ote CxNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="GJ6jy/Cs"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10si19317569pga.315.2019.03.27.12.29.29; Wed, 27 Mar 2019 12:29:45 -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; dkim=pass header.i=@kernel.org header.s=default header.b="GJ6jy/Cs"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387688AbfC0T24 (ORCPT + 99 others); Wed, 27 Mar 2019 15:28:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:44544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733098AbfC0SEC (ORCPT ); Wed, 27 Mar 2019 14:04:02 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ECEDD21738; Wed, 27 Mar 2019 18:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709841; bh=2K1NsZ8pgY0DBWjO3DAoYyXaNrz4IRlgOMiO/ylmQ8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GJ6jy/Cs87GGh/X8LImttaagJEOFjdlO9Tq3Vh3shEGXB/NHQ2+dsuVmndNUsNYAi fpg3fE/23MFIhRCwPVzlWz8ZmDmEC4t/EVPjGnld8piu3ba0NHuUun5NMDSJ+TEDJy UTIF/aQsKDC5WNlXv0evSYOCEzKa4FQvL6rxfyQs= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yonghong Song , Alexei Starovoitov , Sasha Levin , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 069/262] tools/bpf: selftests: add map lookup to test_map_in_map bpf prog Date: Wed, 27 Mar 2019 13:58:44 -0400 Message-Id: <20190327180158.10245-69-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yonghong Song [ Upstream commit 9eca5083757b679b37f210092c871916c2c222d0 ] The bpf_map_lookup_elem is added in the bpf program. Without previous patch, the test change will trigger the following error: $ ./test_maps ... ; value_p = bpf_map_lookup_elem(map, &key); 20: (bf) r1 = r7 21: (bf) r2 = r8 22: (85) call bpf_map_lookup_elem#1 ; if (!value_p || *value_p != 123) 23: (15) if r0 == 0x0 goto pc+16 R0=map_value(id=2,off=0,ks=4,vs=4,imm=0) R6=inv1 R7=map_ptr(id=0,off=0,ks=4,vs=4,imm=0) R8=fp-8,call_-1 R10=fp0,call_-1 fp-8=mmmmmmmm ; if (!value_p || *value_p != 123) 24: (61) r1 = *(u32 *)(r0 +0) R0=map_value(id=2,off=0,ks=4,vs=4,imm=0) R6=inv1 R7=map_ptr(id=0,off=0,ks=4,vs=4,imm=0) R8=fp-8,call_-1 R10=fp0,call_-1 fp-8=mmmmmmmm bpf_spin_lock cannot be accessed directly by load/store With the kernel fix in the previous commit, the error goes away. Signed-off-by: Yonghong Song Acked-by: Andrii Nakryiko Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- tools/testing/selftests/bpf/test_map_in_map.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/bpf/test_map_in_map.c b/tools/testing/selftests/bpf/test_map_in_map.c index ce923e67e08e..2985f262846e 100644 --- a/tools/testing/selftests/bpf/test_map_in_map.c +++ b/tools/testing/selftests/bpf/test_map_in_map.c @@ -27,6 +27,7 @@ SEC("xdp_mimtest") int xdp_mimtest0(struct xdp_md *ctx) { int value = 123; + int *value_p; int key = 0; void *map; @@ -35,6 +36,9 @@ int xdp_mimtest0(struct xdp_md *ctx) return XDP_DROP; bpf_map_update_elem(map, &key, &value, 0); + value_p = bpf_map_lookup_elem(map, &key); + if (!value_p || *value_p != 123) + return XDP_DROP; map = bpf_map_lookup_elem(&mim_hash, &key); if (!map) -- 2.19.1