Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp407581pxb; Thu, 21 Oct 2021 01:49:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7A0nkNvNPguLDR8a8tGGgi01nc4Obn3HdxZrO9n6GwOoEWO4lCIDOxoeST7FWD5DHFpJQ X-Received: by 2002:a65:6a4b:: with SMTP id o11mr3347329pgu.278.1634806143836; Thu, 21 Oct 2021 01:49:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634806143; cv=none; d=google.com; s=arc-20160816; b=dCuqfhnDIx0lQsQxHnXBXkq4UwqfT0GCB/WMlnuHgc/CmWoqXMxrVa34o+eOHWrWhA iKTRS0asyyTPneGZG223wCyHlRfqSQkfmi3P24kk5LXCRzybPw0+WHpAChI1tKN7FAnZ Kzk69yl0X7hH/jKM+noa47vhuMWCKLJ3HmJNMIJrLyDtUnrEmJeRsr/8bGaDsoq5E32B GLQMfDwUs90R0hZqZj6Ey+ta9hTn4gWah8bYa+HhuZA/ZFKOyIq1vnBb2YKPNnknyZ+y 0ZIAGAeow4FI6nARoGoGrxNRHi4pwjQvcPnVASDGbwu4QxvtWsaPB51zf77XscVqCRJe yA2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/1hQGMgB+pbBjKU+GtBo7/RGdYg+za5wlQN/5rpq/IM=; b=ahnAM5vL0marxWBzbyO+ThVYNrgWrkA3GdHWgzh2ce38K3nBz0ZH3FW0jgZT1rM22t 2Bv8olxCDGFmUNHFLKgjpdCPKjwIC+uJL8qPbFyv5UdXnnD2UBFKvxKujtrgX2hm1wTC qQp+rgm7EuMmqfKnRW0sdWBNa3hSY4wY58RI4qnU6FYhRsYuKM4oUzoqfVcQCujOMoi6 PnF/qjG8YS8ynN9lwSDN6oJdXMgY+MQSuvhXEFmyWDzAqgQldzkPbeyY1Ze+0ia/Nwd0 c9YszdKTjKy+ZduWNNy5zimptwTtH0hUaRk3VB9MxKBLjYaaMlqmouk1orOMwIrxck7f N/+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=m0CFh2xp; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k10si6469413plt.217.2021.10.21.01.48.50; Thu, 21 Oct 2021 01:49:03 -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=@infradead.org header.s=desiato.20200630 header.b=m0CFh2xp; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231464AbhJUItl (ORCPT + 99 others); Thu, 21 Oct 2021 04:49:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230269AbhJUItd (ORCPT ); Thu, 21 Oct 2021 04:49:33 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B358C06161C; Thu, 21 Oct 2021 01:47:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=/1hQGMgB+pbBjKU+GtBo7/RGdYg+za5wlQN/5rpq/IM=; b=m0CFh2xpa30BQIh8WFy2hP3iRW f+llIEBdmbeYYsigAu0L2a/9h6IR5g/VqHFHJN7hgJHFP6P1bJLBoI/BLroWZ+QuIuLkqqFlUNGh6 RZVQZ89p8WOSakL3j6f7RN2fbD16H1aRyft9etjZUIHYgEx79yFg3JHjPii431N4qI27fegI6o9RG xaNKNZr5aQZLWHQFoUZa4w3SSD5O7fEmDo/wxlafEr8mI0/iaNbdcYhMhadFPvHeFX4djrQpMri6V 4fhI2YtI0xit+szqZ/kBVCEada8Tq99t/d/1KPmnkD5462NlI8k/fykGUcJCRJdGnrxZp6IYODT4G FQf6BKew==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdTj5-00BGZ5-OE; Thu, 21 Oct 2021 08:47:03 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 41B3F300221; Thu, 21 Oct 2021 10:47:00 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 18CA52D4101EC; Thu, 21 Oct 2021 10:47:00 +0200 (CEST) Date: Thu, 21 Oct 2021 10:47:00 +0200 From: Peter Zijlstra To: Alexei Starovoitov Cc: x86@kernel.org, jpoimboe@redhat.com, andrew.cooper3@citrix.com, linux-kernel@vger.kernel.org, ndesaulniers@google.com, daniel@iogearbox.net, bpf@vger.kernel.org, andrii@kernel.org Subject: Re: [PATCH v2 14/14] bpf,x86: Respect X86_FEATURE_RETPOLINE* Message-ID: References: <20211020104442.021802560@infradead.org> <20211020105843.345016338@infradead.org> <20211021000502.ltn5o6ji6offwzeg@ast-mbp.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211021000502.ltn5o6ji6offwzeg@ast-mbp.dhcp.thefacebook.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 20, 2021 at 05:05:02PM -0700, Alexei Starovoitov wrote: > On Wed, Oct 20, 2021 at 01:09:51PM +0200, Peter Zijlstra wrote: > > @@ -446,25 +440,8 @@ static void emit_bpf_tail_call_indirect( > > { > > int tcc_off = -4 - round_up(stack_depth, 8); > > u8 *prog = *pprog, *start = *pprog; > > - int pop_bytes = 0; > > - int off1 = 42; > > - int off2 = 31; > > - int off3 = 9; > > - > > - /* count the additional bytes used for popping callee regs from stack > > - * that need to be taken into account for each of the offsets that > > - * are used for bailing out of the tail call > > - */ > > - pop_bytes = get_pop_bytes(callee_regs_used); > > - off1 += pop_bytes; > > - off2 += pop_bytes; > > - off3 += pop_bytes; > > - > > - if (stack_depth) { > > - off1 += 7; > > - off2 += 7; > > - off3 += 7; > > - } > > + static int out_label = -1; > > Interesting idea! I nicked it from emit_bpf_tail_call() in the 32bit jit :-) It seemed a lot more robust than the 64bit one and I couldn't figure out why the difference. > All insn emits trying to do the right thing from the start. > Here the logic assumes that there will be at least two passes over image. > I think that is correct, but we never had such assumption. That's not exactly true; I think image is NULL on every first run, so all insn that depend on it will be wrong to start with. Equally there's a number of insn that seem to depend on addrs[i], that also requires at least two passes. > A comment is certainly must have. I can certainly add one, although I think we'll disagree on the comment style :-) > The race is possible too. Not sure whether READ_ONCE/WRITE_ONCE > are really warranted though. Might be overkill. Is there concurrency on the jit? > Once you have a git branch with all the changes I can give it a go. Ok, I'll go polish this thing and stick it in the tree mentioned in the cover letter. > Also you can rely on our BPF CI. > Just cc your patchset to bpf@vger and add [PATCH bpf-next] to a subject. > In patchwork there will be "bpf/vmtest-bpf-next" link that > builds kernel, selftests and runs everything. What's a patchwork and where do I find it? > It's pretty much the same as selftests/bpf/vmtest.sh, but with the latest > clang nightly and other deps like pahole. nice.