From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3EC03A0C58; Wed, 8 Sep 2021 23:51:12 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 912E641125; Wed, 8 Sep 2021 23:51:01 +0200 (CEST) Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by mails.dpdk.org (Postfix) with ESMTP id 577BA40E25 for ; Wed, 8 Sep 2021 23:50:59 +0200 (CEST) Received: by mail-pj1-f46.google.com with SMTP id f11-20020a17090aa78b00b0018e98a7cddaso2522748pjq.4 for ; Wed, 08 Sep 2021 14:50:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=B2uAon4cvKoOj+QnKe/KWMgPSrjtWc91Ug3S5m+/n+k=; b=OHFCAxkbGVlm8vfc3vm01iBsW5kAIpdbZuPS7v53lt/FMelHR7XYW9WaRttiRFm50X bJx1/Yj6p1iuLoxr9NJ+M21J1Wo31/wfd17K4/3sILv/+L6qgsk2Sl8EkDlEEsqcPoxp BVdSLp1UX275RdwtyKsN1z0hxVMEbXo/Hj8sx3aobiSDSfFxAr47i5gD3D/Twmy/H+uh DKAyLSs+ZhsvAIj5Cw7odiSokEzW1VNbcOXgYv52NdrqNvcYqI7bVMfGpbFDzc4D5ODp mguIxFlWdi83fKnpbpS1BaSRRiwjuaOfyZjh+mzOCSDtLMmOK4zdSHfMIF/Spmf8r+HG b+og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=B2uAon4cvKoOj+QnKe/KWMgPSrjtWc91Ug3S5m+/n+k=; b=esZv/IYCNs3mVHBzZD0MNWTB36OExe+myOn+gSGETrsH6lR2FKhuEAmZkA5XHFv/aB p7cQKyGHzobLCCV16cjdqSUCQRCifAWKR8pw0gR8hG7pn9zbBoYFBeekMxpw+ZLDiAoG MO+uIkiYxOG9GGZeQ8gl5pjYeArqazXPzD8SgtYZ7uW2YPTC3y7cf2QAG6eG+KIuttGo VtLheKdEnUckslUJLtw9HHcJntFxGfWVTakI+TVQT7RXskhI9YmNZsDMQriZoaAoklaE mKzMqG3w72wDpwrJi8Dzw9dR0rCYyw2vgmyKTr+lcsIVrJHCn378vvCa7/4f1M6OkO6C QtRQ== X-Gm-Message-State: AOAM530+MHn6d/LPR+yvGeH1uN1o4tJXM19N4kSVCaLa2r1198UgHfqo k7iD7vb1YnWzNLCdu9adBBo6xe0I2PDq2Q== X-Google-Smtp-Source: ABdhPJy8U33yp4VXd5IlTyEByOukrd32gCZcwpnCy+0R87kLS0U6OZQM+p8ehHAkY2rC+bLGts4K5A== X-Received: by 2002:a17:902:7fc1:b0:138:f21a:4be3 with SMTP id t1-20020a1709027fc100b00138f21a4be3mr329136plb.27.1631137858112; Wed, 08 Sep 2021 14:50:58 -0700 (PDT) Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123]) by smtp.gmail.com with ESMTPSA id a80sm151923pfd.179.2021.09.08.14.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 14:50:57 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Wed, 8 Sep 2021 14:50:46 -0700 Message-Id: <20210908215053.74628-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210908215053.74628-1-stephen@networkplumber.org> References: <20210903004732.109023-1-stephen@networkplumber.org> <20210908215053.74628-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v5 2/9] bpf: allow self-xor operation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When doing BPF filter program conversion, a common way to zero a register in single instruction is: xor r7,r7 The BPF validator would not allow this because the value of r7 was undefined. But after this operation it always zero. Signed-off-by: Stephen Hemminger --- lib/bpf/bpf_validate.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/bpf/bpf_validate.c b/lib/bpf/bpf_validate.c index 7b1291b382e9..7647a7454dc2 100644 --- a/lib/bpf/bpf_validate.c +++ b/lib/bpf/bpf_validate.c @@ -661,8 +661,12 @@ eval_alu(struct bpf_verifier *bvf, const struct ebpf_insn *ins) op = BPF_OP(ins->code); - err = eval_defined((op != EBPF_MOV) ? rd : NULL, - (op != BPF_NEG) ? &rs : NULL); + /* Allow self-xor as way to zero register */ + if (op == BPF_XOR && ins->src_reg == ins->dst_reg) + err = NULL; + else + err = eval_defined((op != EBPF_MOV) ? rd : NULL, + (op != BPF_NEG) ? &rs : NULL); if (err != NULL) return err; -- 2.30.2