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 D16EEA0547; Fri, 10 Sep 2021 20:19:06 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0D85941148; Fri, 10 Sep 2021 20:18:53 +0200 (CEST) Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by mails.dpdk.org (Postfix) with ESMTP id 47505410EF for ; Fri, 10 Sep 2021 20:18:49 +0200 (CEST) Received: by mail-pj1-f48.google.com with SMTP id c13-20020a17090a558d00b00198e6497a4fso2092842pji.4 for ; Fri, 10 Sep 2021 11:18:49 -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=CTJWQNsk6pkPbpmUaZkWQ0ylrFBt9tMS0Avtx5HzwIp5E/ILTk7IroBXMEH0xODa/5 /4UjoqOe3qNTksz8a7pnxE53orHzu4WyopHSc3xJK69ktu3OyVsDKdars7cQSGJ18vFj D+EnQT+PB0bINBTwqbKRIst3FXyLlYwgUlJqtkAoS6EjxF9jZmXf/7Lt5T0WKrtomE0q Tq53mhOkoL0UrUsTFVK3P0SBHZazN7MCF8SIxKh/uY5VrvIthITPu/+9aT6oCPKy5+yL aW25r6V56hhkEj35lUV0Zb24Qat7iC5r++O1yPbZSNK+Q4Ml7Sf4vTOLmqowKGUy/U9r i9hA== 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=rZ1TC+8IeSTXDCp8DFkoJW1MGcoDssWH2B6F8W65OoN6mrEnQDOe6tGhTLK2ShvWrP C3xinlb/G7z6p3PPv1hFXegbYJJ8X+Hd1cP/e46y7NlJ6XoSvxUXTt52bSlrPKoWRNkt B40T2QzyxiMtZ9LV2KpUz1sEv4dQft4jotLU86zH8hlDwC+ddtjCs1+4x6DyxfqYOYP5 fokJCqzl8SC05TJHq5OJDMF4gTec/Ws6z1HMsncPhWIq56omKCusZAyuIc9kWVDiSkSa GIOp8ET5kz3v485Kljzmc0d9XBEQkpsho4QBNU4eiRr4STO9mpaXa7E6AjNZJ6+x0fCD rrbA== X-Gm-Message-State: AOAM531jTTagb6IJX796GQlx9+D32GRl41wBzElk5mQFwOka9h9GIUPx eE+gi1Fbi5JsXtFrPhvknEn83X+AuBLpFw== X-Google-Smtp-Source: ABdhPJzoqoj6kPDzk8mur3NBl5IRsKOWj02shPOZ4Qyha8jjP8Xv7h0CqEO16B6jjw6v+0G8l1LBUg== X-Received: by 2002:a17:90a:5886:: with SMTP id j6mr10981259pji.238.1631297928095; Fri, 10 Sep 2021 11:18:48 -0700 (PDT) Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123]) by smtp.gmail.com with ESMTPSA id p13sm5652857pjo.9.2021.09.10.11.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Sep 2021 11:18:47 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Fri, 10 Sep 2021 11:18:33 -0700 Message-Id: <20210910181841.530280-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210910181841.530280-1-stephen@networkplumber.org> References: <20210903004732.109023-1-stephen@networkplumber.org> <20210910181841.530280-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v7 03/11] 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