Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2515244pxu; Sat, 28 Nov 2020 17:17:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrcdRaFTaDKg3zul9MqmgGlBYt+MVX6JbQwH3krl87wxxqOomzm5xmjMNOr+rUUpM/2sJ7 X-Received: by 2002:a17:906:2b06:: with SMTP id a6mr14799384ejg.283.1606612627760; Sat, 28 Nov 2020 17:17:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606612627; cv=none; d=google.com; s=arc-20160816; b=s06bbIIH5Vv8fYPP5aOHUN94oaECL2tPs+XePAPOwT9dxwZCo5wNM4gvkuF2rDWdXh 4uABbZo5FCC5tvo0BSQRS8D7pXPcdMFHHd6+p9MATuxhyhchhTU+/4/RpR8zIdqA4XuL KViyqYx+u9wDhVZ9hSUEfAyeuc2eYXf55C7yaE42denWCVOsbWVkijHOMWSCjlMmODk8 SInqXuVGyuI8UBpA6G812/dY1/OGZ/4WdwArGr48wxBN1wqVigNEjevV4w0B3MGhyXz6 0mgnLDC2nBDYsjGQyFQk/2XrUWVnBIzEqTnlM/ooHU8EVnOAWsA5noCUw4IeLwAYLRWQ AXAg== 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=7Vdc2IIjLuJX89GJ0THfSs30PM6I9wmP3XLI+A572XE=; b=RMlKv3iTLH2AM1ZanTWkbRKzw0XMB4ewSd90uXLEJkDuj1w6seCxNiGqZVffvmxeqU QVqIYWVdRn2HDeQ5LZXlelJK/PswGK6vyo9wVEwNu4nLgJZC+k8oK8k9cTUsYhMKmN0D 1caxnBUexlrwAVD/GoI43BC/wqi0WWRgL6x5VKU1goZE9A0nGQG61vG/UPU8FBZqQfnj IldAJDJoSv3P6e1CweK9uMGAmtPjPWT/9XW+9xgy2m4qhhUYqKrko1vqAWgwWFOy+FkE vbfjysfxuCXKODBxD2GEQGeBmiUMbSa6NR9SOhAQQBLaiEWXZuyU7w/BWVVxTlSRGykI dZtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iSRE5RRo; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q6si7886706eju.361.2020.11.28.17.16.44; Sat, 28 Nov 2020 17:17:07 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=iSRE5RRo; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728727AbgK2BOz (ORCPT + 99 others); Sat, 28 Nov 2020 20:14:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbgK2BOy (ORCPT ); Sat, 28 Nov 2020 20:14:54 -0500 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5648C0613D1; Sat, 28 Nov 2020 17:14:08 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id s2so4504304plr.9; Sat, 28 Nov 2020 17:14:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=7Vdc2IIjLuJX89GJ0THfSs30PM6I9wmP3XLI+A572XE=; b=iSRE5RRozVE0f7VVMTLVYqaEiIHzerZCbN2ogjnFS39fxGsLj2JcNHlZk812i090oN v5lQRCWuc/Jap3tICWNtHI+2Db5tBfGzatAtY7KVSAzdYV9K6ev9TuEKi1EHMJHiki8B wh229CzCH6qGVqhpZHjJ8itTsPCRBrrnjACK6IX6Ta2r0Hzz75RxPhwpo/JSfqBZJmFu JcOtzLJOZgyVhbBblP0JiIJXLoRqVA4SgokWZLUXDIY2Ept38NKiSBDrlkXVj+28j+Hl 3SHuyDuvHs0rrs0mQzoen4OoX8OtF28TB7ltfeAvDdt8ScB93OCJrCzgcV7l5u8f/2hj G9sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7Vdc2IIjLuJX89GJ0THfSs30PM6I9wmP3XLI+A572XE=; b=Troublc+xsy1uRaukGfOLwdT6UwOTbiTlyjwpi1tEQs4apRJH6p/xsdQRlKPKuJ9Ry fD40m4c5/2fq7zutrprxT5PMMo3I6xhdbydAnZM/ZElcjo3nPZ7Daldy0Tqg/YlWEMnw h3REsgJQ+AKz0/22WSjnWV8GicckcT39XL5fHH2zKcdkwJmfc/pDjzblwzZ8v8o8AzCi mM903BkMtcOof+6bTtfMjTjtk1rZT9NzMECu/zFvjO9r6man9hB9QDIIzFt1arcQvmqV AtHer7/Fd9QxwD8AupbAyFvyZt6nDo9VeCM0CR/TPVN806VQCLBX//WUiTk8Ryh6KPCj R8fA== X-Gm-Message-State: AOAM533d+O/0XGdpM2IcZ/ShoqnOZ0GbCanIcHHsNHEszjMGopi89zEt RYQi/yXQapF8h6izKsoSxmc= X-Received: by 2002:a17:902:8f82:b029:da:23e0:17d7 with SMTP id z2-20020a1709028f82b02900da23e017d7mr13111355plo.37.1606612448067; Sat, 28 Nov 2020 17:14:08 -0800 (PST) Received: from ast-mbp ([2620:10d:c090:400::5:5925]) by smtp.gmail.com with ESMTPSA id r68sm12030337pfr.113.2020.11.28.17.14.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Nov 2020 17:14:06 -0800 (PST) Date: Sat, 28 Nov 2020 17:14:05 -0800 From: Alexei Starovoitov To: Brendan Jackman Cc: bpf@vger.kernel.org, Alexei Starovoitov , Yonghong Song , Daniel Borkmann , KP Singh , Florent Revest , linux-kernel@vger.kernel.org, Jann Horn Subject: Re: [PATCH v2 bpf-next 02/13] bpf: x86: Factor out emission of REX byte Message-ID: <20201129011405.vai66tyexpphpacb@ast-mbp> References: <20201127175738.1085417-1-jackmanb@google.com> <20201127175738.1085417-3-jackmanb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201127175738.1085417-3-jackmanb@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 27, 2020 at 05:57:27PM +0000, Brendan Jackman wrote: > The JIT case for encoding atomic ops is about to get more > complicated. In order to make the review & resulting code easier, > let's factor out some shared helpers. > > Signed-off-by: Brendan Jackman > --- > arch/x86/net/bpf_jit_comp.c | 39 ++++++++++++++++++++++--------------- > 1 file changed, 23 insertions(+), 16 deletions(-) > > diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c > index 94b17bd30e00..a839c1a54276 100644 > --- a/arch/x86/net/bpf_jit_comp.c > +++ b/arch/x86/net/bpf_jit_comp.c > @@ -702,6 +702,21 @@ static void emit_modrm_dstoff(u8 **pprog, u32 r1, u32 r2, int off) > *pprog = prog; > } > > +/* > + * Emit a REX byte if it will be necessary to address these registers What is "REX byte" ? May be rename it to maybe_emit_mod() ? > + */ > +static void maybe_emit_rex(u8 **pprog, u32 reg_rm, u32 reg_reg, bool wide) could you please keep original names as dst_reg/src_reg instead of reg_rm/reg_reg ? reg_reg reads really odd and reg_rm is equally puzzling unless the reader studied intel's manual. I didn't. All these new abbreviations are challenging for me. > +{ > + u8 *prog = *pprog; > + int cnt = 0; > + > + if (wide) what is 'wide' ? Why not to call it 'bool is_alu64' ? > + EMIT1(add_2mod(0x48, reg_rm, reg_reg)); > + else if (is_ereg(reg_rm) || is_ereg(reg_reg)) > + EMIT1(add_2mod(0x40, reg_rm, reg_reg)); > + *pprog = prog; > +}