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 9525BA0547; Fri, 10 Sep 2021 01:33:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AED96410F5; Fri, 10 Sep 2021 01:33:37 +0200 (CEST) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by mails.dpdk.org (Postfix) with ESMTP id 048E54003F for ; Fri, 10 Sep 2021 01:33:35 +0200 (CEST) Received: by mail-pj1-f45.google.com with SMTP id d5so151180pjx.2 for ; Thu, 09 Sep 2021 16:33:34 -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=iNXbHxmjsk1erJOGIgQnjj5gr8+rGsLlnrY+qTXWeJtVj959QqhH9f446dw4RPlKp1 ekMYGWyTpRJEitjSLUamMZGHT0asxdLxdvS0WfqAKcFL8JqoESpLchZaLub1KsEF3/7K 7/hJ4PAUDZjAn24CZ3eMOe2XQZh4nKoRRfj6TAold1qb+Dc6uYZsATV8gu9ViGz33B1o LjQdWubFonzId3LPWgi4K70hEJo0ALCKnaEWljNqPGal1xqzllTowP6Z+1NYwSzZfpFM kAmytomeOttIk8sb3FhmwOH8z+6LjwGcTkLYvdfYHxhLnHa8HIMdKcj8s5EZWkDPSMry Exzg== 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=Rdc8AocMzRQ7SMKLn+Mrvrk8utIhcydA1CBh5OWIORk9lril07WyfdUkqLWlbnOFpC M2/fdd+xWl2mjun+sKqeGPmsfzW06WObQS7gUlOEjevLXTPwGyoBBGKpSlY9e8NbhkvZ 9wtl+qPdT+yt/T7LL7TMq0Jlc6dWoNdRDiiiiZOhX0YETAsBEiIvGykGrQ1pU4LWpmJr 8VMdcJuqRd7KogfygXHiOvabc9UV4mFtcQtwkpq3p9aT3163MGw71PxJxW2W+eMddWjr 2uX7tFRKw948fa6ldrUFK2nh+WUALS4W6Qwd7BOaSVnoMVS7M8gmppfobj9AQC0W8Cle msAw== X-Gm-Message-State: AOAM530WLXPQHPtxgATA7IF6cZpwDeZPcoSAuuBX53KOU1K0cwNPGF+G A9NWuXM6kA8dQzVVV3den6X+7OazWwX06Q== X-Google-Smtp-Source: ABdhPJynDlyYmDQHlDxO9C6AVbKvKogFCkWR9pfjckXsBrycrxufMQlkbn9w1b/PtilD1dGDMAkVpg== X-Received: by 2002:a17:90a:da02:: with SMTP id e2mr6309710pjv.89.1631230413798; Thu, 09 Sep 2021 16:33:33 -0700 (PDT) Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123]) by smtp.gmail.com with ESMTPSA id z6sm3172255pjn.27.2021.09.09.16.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 16:33:33 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 9 Sep 2021 16:33:21 -0700 Message-Id: <20210909233329.190021-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909233329.190021-1-stephen@networkplumber.org> References: <20210903004732.109023-1-stephen@networkplumber.org> <20210909233329.190021-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v6 02/10] 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