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 0CE33A0C45; Mon, 13 Sep 2021 20:15:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8E67F4014F; Mon, 13 Sep 2021 20:15:21 +0200 (CEST) Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) by mails.dpdk.org (Postfix) with ESMTP id 461D9410EC for ; Mon, 13 Sep 2021 20:15:17 +0200 (CEST) Received: by mail-pj1-f41.google.com with SMTP id lb1-20020a17090b4a4100b001993f863df2so655929pjb.5 for ; Mon, 13 Sep 2021 11:15:17 -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=Btx666vU6QKoEMBocsQm4RbSnFxqP00cUNtL1xIwzqhOPVXQFGy2WjylJ2/PeABnl6 YjMTIw6LlBtdjQ7cbxqmRrsHq8xsj7bYzF+fEhlD28r/m2U+exxJMsWIbsjjioMoJLHy RV3pZNpeb9Ta9wD5hziPq59dAT7RnVwfufVYy5ZTFeAiTCCopUBYCj88hsboBUDTe/WU W1si6RfV/yrK1QGRYi5GAahtjvfeGlSG9RWOXqp/CY+xFnoeGU3zQsHqVt5xyziWTXAC 8tUoYMSSr0gNh6ufRQ5Ipm3JRZl7OYYSeL/eWPiHtb3yIWYkUaB3D0aDqvuObGUQlwSi wm8w== 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=wXbDT3wULYDyyUBPohPZ9LLNMFU2cBiV9DHg9TaYaxmTj9TX4ELuiycTYTRfKK4Ae3 ytX/mihmZMw6iXHzdy5oz+QbQ7e4WHOLnv0JZSWdPEZ6qFRklLvHzQwPVNgWj1Nw/DKt auwr+/Uuve4upv87LDRf+Ja9XIkkmI1+91gIFnJOVpMPJx+SgrpkZ5l5Y3L93X+djCxC L6Weti7nRZspv3aWCmNTC3DgYQvzSAfw/Ej/z1fT47teIL+RWHg6Lq5Uhwdql1CALwOw Z2q8433B59wBPmhPIIhRauo6+JMDJvIbWZCa8w5A3B2gVHgV8LaLl1sshvn+d1gaS2gV ovkA== X-Gm-Message-State: AOAM532FqjmFGRBpfCdmeJGRXqu7BL+pBg7hjPW4GN8wwczJ523R7rcU e82/9uTfpbxxWyxEq0VQahBc6IlNe22j/Q== X-Google-Smtp-Source: ABdhPJzfXMlt9o4K1e/GTDZPd133hnKDJ8d7OAZxHrGYSnJlkQkmBnUNRWCLE58ZDKLT/MjmWkPLMQ== X-Received: by 2002:a17:903:102:b0:13a:66a8:f28 with SMTP id y2-20020a170903010200b0013a66a80f28mr11573775plc.62.1631556916102; Mon, 13 Sep 2021 11:15:16 -0700 (PDT) Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123]) by smtp.gmail.com with ESMTPSA id b10sm7616888pfl.220.2021.09.13.11.15.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Sep 2021 11:15:15 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 13 Sep 2021 11:15:01 -0700 Message-Id: <20210913181510.46058-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210913181510.46058-1-stephen@networkplumber.org> References: <20210903004732.109023-1-stephen@networkplumber.org> <20210913181510.46058-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v8 03/12] 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