Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp437409pxv; Thu, 1 Jul 2021 01:20:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuofX8QdsW59rrqMVPZNBbdDqs7aBUveiXdTPFxKWD67aVkn6kvmpDqe6BZpAmrA3Tu3lm X-Received: by 2002:a17:906:616:: with SMTP id s22mr39518828ejb.210.1625127616618; Thu, 01 Jul 2021 01:20:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625127616; cv=none; d=google.com; s=arc-20160816; b=cK2jCMgnpCdJ4V8IxdCqxsSm2KzMVALUSv8iBaomaFqU2nl6wV3/zITH4mLkTE3op1 CBBMae031hWbVYNCbsq4e4brabFgy9GArxKahsyI0zHzVnDa9AW32AHHkyd6yLFZr1xA N0TTHLEDYdaEBNqYXNwH1TK+ZV8y67wgrwb3bKZriQDuyReAtaewRjpPBDgXX5ZHiTY3 OHv41ba1THZHtoLnFK9DqhYr/1nmnhsEurB5GMoLWXrjU3Tn3aGpvjPi108ymtsWUWkf ULqX6oV7eb/7jBPpYDAAZHhK/q4L1lpJJu9sT5WWGmhktQCNvKwgC16q4zl/GJehlG5K z+0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=zcqmISKA385xJp8CFiTuVeDu3WrYH5PsOS49vQZ/pew=; b=hQyPn1mVNl1KYt8yNiOW48ZZWKWjRezQ3Y9nyzwwkHz6y4CIuVCF+FT/b80o6HsleS jqCV2nsLuUvGS3TGx+kM8WcnREPQR311lx7cSALjJcpwuR7F9zCSQQWfHGGjP+LuWlk/ AvNEfxW0uJIS6J24lCE7LRWo8UAdCl0boRGez2OuTZ/IcHyg0iIgeBch7kP94CceLg0f FuXbiHc0fFvPrs0bh9j1pUZ/MhFAy5m7/W92v5U04DrfbmyRx/mW2oMwN5ssw7A2uFNo z1zcseN8YqGwa3OtHOqy9ECQoZIXGeEdPi6u0xHXm5C6XHXUf72OYSVf1ufOBdBt53eF 1AJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cOT520El; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c9si22310417eds.173.2021.07.01.01.19.51; Thu, 01 Jul 2021 01:20:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cOT520El; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234953AbhGAIVX (ORCPT + 99 others); Thu, 1 Jul 2021 04:21:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234635AbhGAIVW (ORCPT ); Thu, 1 Jul 2021 04:21:22 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B46B8C061756 for ; Thu, 1 Jul 2021 01:18:52 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id g3so4556166iok.12 for ; Thu, 01 Jul 2021 01:18:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=zcqmISKA385xJp8CFiTuVeDu3WrYH5PsOS49vQZ/pew=; b=cOT520El7XXRvTn25OoIWz/UuqkPPkjH3NCMXTGBAJiK759W02pE6ZmxipH8ekHlOD 8Gd1ZOX7RHeXN4gSt6FL33Wn5c/aGHzHO0mkyQ/NF/mlB/E5rgugbbKsjah61GLchFif B2WZTKNvY7CE7sF6IMsmXtD7GWjmOhTwWlJc3jy/HbvUssQgn9OP6pxN0q/FM4pJv9P3 z0cDiteltn9YAgcxyAfZoXoBGE2lWr50Bv81ncJh0zHz7IqUpGPmimxalaeCZsodoZQv BibkjSrV8Hql4voUtxnW1kG/YNITEBEKbw2zuyQTPuFsuwHoF8HtSa/vj0RUrUzoAfEh 4wJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zcqmISKA385xJp8CFiTuVeDu3WrYH5PsOS49vQZ/pew=; b=KnHFvMkqlvfgSIot9u5GbxHq+fmZ1bXt8VKpVTI92keBTRnzMXKHbMq7X/kjmcvh5B tGUJfwj7b3MQ9DF9JxgEBWHP2K2jLQ5Cto5qyHW/aR2vTX2fphhxBvz9E2PpVfIs7BHe lS8GQ2/YAJ3VJKkSLGj6kvKbBfGfcVgbjRVa1+UxDCFxpszLteISmXL/+kLjD5yd+ZU9 HuHLnHNGUxT2JPWOwrAuhuXXoQksbFcz4k8gQX9icFV2kQsyY1R4kNtNIKQWce0QP7J8 zYRsq97Jor/u0bEOofNfSD3F2tzkmOPfX3balU0mrORqgzV4546ck5nZ5NFpx4TR1Dma DkXw== X-Gm-Message-State: AOAM531eROyvAF6QEWV6jr8ZMrBBVldTLzTzUDPW0AGzgQAJeWQWizis /24Yo584OD/1sAKQoSLYQVgJG5NU7Xb6atO8I4wBhg== X-Received: by 2002:a02:ca4a:: with SMTP id i10mr12479094jal.141.1625127531023; Thu, 01 Jul 2021 01:18:51 -0700 (PDT) MIME-Version: 1.0 References: <20210202135002.4024825-1-jackmanb@google.com> In-Reply-To: From: Brendan Jackman Date: Thu, 1 Jul 2021 10:18:39 +0200 Message-ID: Subject: Re: [BUG soft lockup] Re: [PATCH bpf-next v3] bpf: Propagate stack bounds to registers in atomics w/ BPF_FETCH To: Jiri Olsa , Sandipan Das , "Naveen N. Rao" Cc: bpf , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , KP Singh , Florent Revest , John Fastabend , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 30 Jun 2021 at 14:42, Jiri Olsa wrote: > > On Wed, Jun 30, 2021 at 12:34:58PM +0200, Brendan Jackman wrote: > > On Tue, 29 Jun 2021 at 23:09, Jiri Olsa wrote: > > > > > > On Tue, Jun 29, 2021 at 06:41:24PM +0200, Jiri Olsa wrote: > > > > On Tue, Jun 29, 2021 at 06:25:33PM +0200, Brendan Jackman wrote: > > > > > On Tue, 29 Jun 2021 at 18:04, Jiri Olsa wrote: > > > > > > On Tue, Jun 29, 2021 at 04:10:12PM +0200, Jiri Olsa wrote: > > > > > > > On Mon, Jun 28, 2021 at 11:21:42AM +0200, Brendan Jackman wrote: > > > > > > > > > > atomics in .imm). Any idea if this test was ever passing on PowerPC? > > > > > > > > > > > > > > > > > > > > > > hum, I guess not.. will check > > > > > > > > > > > > nope, it locks up the same: > > > > > > > > > > Do you mean it locks up at commit 91c960b0056 too? > > > > Sorry I was being stupid here - the test didn't exist at this commit > > > > > > I tried this one: > > > > 37086bfdc737 bpf: Propagate stack bounds to registers in atomics w/ BPF_FETCH > > > > > > > > I will check also 91c960b0056, but I think it's the new test issue > > > > So yeah hard to say whether this was broken on PowerPC all along. How > > hard is it for me to get set up to reproduce the failure? Is there a > > rootfs I can download, and some instructions for running a PowerPC > > QEMU VM? If so if you can also share your config and I'll take a look. > > > > If it's not as simple as that, I'll stare at the code for a while and > > see if anything jumps out. > > > > I have latest fedora ppc server and compile/install latest bpf-next tree > I think it will be reproduced also on vm, I attached my config OK, getting set up to boot a PowerPC QEMU isn't practical here unless someone's got commands I can copy-paste (suspect it will need .config hacking too). Looks like you need to build a proper bootloader, and boot an installer disk. Looked at the code for a bit but nothing jumped out. It seems like the verifier is seeing a BPF_ADD | BPF_FETCH, which means it doesn't detect an infinite loop, but then we lose the BPF_FETCH flag somewhere between do_check in verifier.c and bpf_jit_build_body in bpf_jit_comp64.c. That would explain why we don't get the "eBPF filter atomic op code %02x (@%d) unsupported", and would also explain the lockup because a normal atomic add without fetch would leave BPF R1 unchanged. We should be able to confirm that theory by disassembling the JITted code that gets hexdumped by bpf_jit_dump when bpf_jit_enable is set to 2... at least for PowerPC 32-bit... maybe you could paste those lines into the 64-bit version too? Here's some notes I made for disassembling the hexdump on x86, I guess you'd just need to change the objdump flags: -- - Enable console JIT output: ```shell echo 2 > /proc/sys/net/core/bpf_jit_enable ``` - Load & run the program of interest. - Copy the hex code from the kernel console to `/tmp/jit.txt`. Here's what a short program looks like. This includes a line of context - don't paste the `flen=` line. ``` [ 79.381020] flen=8 proglen=54 pass=4 image=000000001af6f390 from=test_verifier pid=258 [ 79.389568] JIT code: 00000000: 0f 1f 44 00 00 66 90 55 48 89 e5 48 81 ec 08 00 [ 79.397411] JIT code: 00000010: 00 00 48 c7 45 f8 64 00 00 00 bf 04 00 00 00 48 [ 79.405965] JIT code: 00000020: f7 df f0 48 29 7d f8 8b 45 f8 48 83 f8 60 74 02 [ 79.414719] JIT code: 00000030: c9 c3 31 c0 eb fa ``` - This incantation will split out and decode the hex, then disassemble the result: ```shell cat /tmp/jit.txt | cut -d: -f2- | xxd -r >/tmp/obj && objdump -D -b binary -m i386:x86-64 /tmp/obj ``` -- Sandipan, Naveen, do you know of anything in the PowerPC code that might be leading us to drop the BPF_FETCH flag from the atomic instruction in tools/testing/selftests/bpf/verifier/atomic_bounds.c?