Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp560916imn; Fri, 29 Jul 2022 15:56:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR4a7n47NUWE+ieNJb9XUQ0tDj5fPgrYD4d6Pml2dpQ9eIcsULeg4YA1Hl53vBFtAclYVB6A X-Received: by 2002:a17:902:f542:b0:16d:5a3d:a529 with SMTP id h2-20020a170902f54200b0016d5a3da529mr6094802plf.170.1659135408644; Fri, 29 Jul 2022 15:56:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659135408; cv=none; d=google.com; s=arc-20160816; b=MUNKkopVpMiVL+L6GH6VYF9NOi0f95pnIHGCy1fOFxWUb6AC5koAgb3cmoRNW0eQSH k8+WhLS40Ni6/y66GjgpUP0MGf5QQH3dFw82QkbJfk3BluRX5h6mp4vA9uA6Pgxtb0aT qx6B1Wz7SQP3d8tkk15Yh8mVo8/ZiV2JBvPTgHOfyhK3+PvmhmX/anu1+5Glu1e1gcQh N78Eil9xOzJivyuoC9PK3UakZAnJiJA3D+6zYYFSqdt7ioD891JwumTe4VsQz+FCQwK1 i2RmbShAx2rtii8aBUpMUjUM85fliQUMIeKcNMqnJnC93F9TS+ZBsxsojIRiViA4F/8b xwxA== 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=9PHjNC5/MEnwibKTgt66y4B8QHXUMZZ8F7xsD/e5vT8=; b=XzlmQntIEM7u0nI6Ub4NQZb6soLn9agOr2HAKIGM5AHGSh6qZVloSdjBz4d/EyruPE iJXO4g0LOzwvqWJJeY13Qq5gqwR0we0oHvLBHM8guTk2u8Q0dRlBUh1jN6xJOldZBBh1 PRPQWS7xXZQS2itYsH/N0Y2LYc+Q5odv+5vj87NJgMKOErbdUixWruL0MJRndcW7p8d8 N645+A9GzFxivK4I38g5z9q4E5+F9jNpRtITUxZmKCGMNpU+gErwl/Ly1PL7oJiBZ0uc tgEFdFyd9S4ofxomH/FSPbEpwjD/gdk/AOVQ14TinjjHIERhPyf4b+T0eA7sDBikQTTY QJWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=h5vuR3bE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i6-20020a170902cf0600b0016d2d5c251dsi5263303plg.329.2022.07.29.15.56.24; Fri, 29 Jul 2022 15:56:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=h5vuR3bE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S239532AbiG2WtL (ORCPT + 99 others); Fri, 29 Jul 2022 18:49:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239510AbiG2WtH (ORCPT ); Fri, 29 Jul 2022 18:49:07 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30E4D85F84 for ; Fri, 29 Jul 2022 15:49:06 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id m7so4676388qkk.6 for ; Fri, 29 Jul 2022 15:49:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9PHjNC5/MEnwibKTgt66y4B8QHXUMZZ8F7xsD/e5vT8=; b=h5vuR3bE9y86uyovtmo+yMSm360p7Vfl+m/49LSoNn6riovGoQldvmVXCT7DMuEA+M IxaHvlgpbrKuzx2KC81SJNf6wnUn5SDvFoEVVZT+mYB5ZvGliFP4XHH3cVBpAOFOrFrD +HlGmxArwenxwq3vCI6EkqRmtcu2JHfggoQLhMQ02F5fv3eM0WUfr+OfmUW1HqKpsrEW u47RbtzG0G/WyvxcmydCuApqYXvYxUxf5TSTMstpcA5rC6TrJdpHCoTL0AWFsqU2NE4N cH2+YQIN6Zw7OPF2QJ+/zrQj2UvKU33Fw8i1un0LliOyo9O6HWW/q8wJcqATrNPgKyrY JcCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9PHjNC5/MEnwibKTgt66y4B8QHXUMZZ8F7xsD/e5vT8=; b=wxqn/rXRvCpYtxvcjqDgJGwvVCaaobOg1X3dOn8SE9l60M8CsF2ErWk8vP9qJvNgsS oRbIoXMMdDcze0R999WgTHdV/K5vvSRrWqEMJ6MnTd+3u4nggZ5JS1H7HitIl6ifGJao qU2rZVshA/eXj89I3xRw74cbEF8Nujk278D4ZRFWBNdkxEf+FUSr8tNZmWxVj+YzWjSO NpehasHE1wMrl1rCLI0vDvi2nxc1+x336AyhK81SooQ64oBtWNv7CNtP5LoibQ0jt+T1 GECGUpRhm8ZL31jexSlnfEX+esnko34I2npl3i8OS+iaCCE3F0Mnwam+aZ7sYWo+aYnc M3kw== X-Gm-Message-State: AJIora/prDhixVodIRSiNyQ/gnHWcPB27UGPDkbQjcgKfiVmOIhKDTlv +n74gwZZWTxaxK/Fbo9p/lvGZCGzXos6+3XX+iPbCA== X-Received: by 2002:a05:620a:f0e:b0:6b5:48f6:91da with SMTP id v14-20020a05620a0f0e00b006b548f691damr4443449qkl.446.1659134945084; Fri, 29 Jul 2022 15:49:05 -0700 (PDT) MIME-Version: 1.0 References: <20220729224254.1798-1-liulin063@gmail.com> In-Reply-To: <20220729224254.1798-1-liulin063@gmail.com> From: Hao Luo Date: Fri, 29 Jul 2022 15:48:54 -0700 Message-ID: Subject: Re: [PATCH bpf] bpf: Do more tight ALU bounds tracking To: Youlin Li Cc: ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, kpsingh@kernel.org, sdf@google.com, jolsa@kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 29, 2022 at 3:43 PM Youlin Li wrote: > > In adjust_scalar_min_max_vals(), let 32bit bounds learn from 64bit bounds > to get more tight bounds tracking. Similar operation can be found in > reg_set_min_max(). > > Also, we can now fold reg_bounds_sync() into zext_32_to_64(). > > Before: > > func#0 @0 > 0: R1=ctx(off=0,imm=0) R10=fp0 > 0: (b7) r0 = 0 ; R0_w=0 > 1: (b7) r1 = 0 ; R1_w=0 > 2: (87) r1 = -r1 ; R1_w=scalar() > 3: (87) r1 = -r1 ; R1_w=scalar() > 4: (c7) r1 s>>= 63 ; R1_w=scalar(smin=-1,smax=0) > 5: (07) r1 += 2 ; R1_w=scalar(umin=1,umax=2,var_off=(0x0; 0xffffffff)) <--- [*] > 6: (95) exit > > It can be seen that even if the 64bit bounds is clear here, the 32bit > bounds is still in the state of 'UNKNOWN'. > > After: > > func#0 @0 > 0: R1=ctx(off=0,imm=0) R10=fp0 > 0: (b7) r0 = 0 ; R0_w=0 > 1: (b7) r1 = 0 ; R1_w=0 > 2: (87) r1 = -r1 ; R1_w=scalar() > 3: (87) r1 = -r1 ; R1_w=scalar() > 4: (c7) r1 s>>= 63 ; R1_w=scalar(smin=-1,smax=0) > 5: (07) r1 += 2 ; R1_w=scalar(umin=1,umax=2,var_off=(0x0; 0x3)) <--- [*] > 6: (95) exit > > Signed-off-by: Youlin Li Looks good to me. Thanks Youlin. Acked-by: Hao Luo Hao