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 316BAA0C5C; Wed, 8 Sep 2021 19:17:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 105AE411E1; Wed, 8 Sep 2021 19:16:54 +0200 (CEST) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by mails.dpdk.org (Postfix) with ESMTP id B17BA41172 for ; Wed, 8 Sep 2021 19:16:51 +0200 (CEST) Received: by mail-pl1-f182.google.com with SMTP id n18so1730006plp.7 for ; Wed, 08 Sep 2021 10:16:51 -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=aBNogUR+hXz/k4RMrwiAOPj51ds1i7KQ+o3Pb8nqbTebgzpTGgKOoGykN3TmDviT7n Xk+3QcKSNk0HaoYCQ0MSRe+VZZBoQej7Y+AcFwDLGXszq2nCVyZTxRcy8D+pHSXyK511 wH1KNCBaeUCUDcQ9IYyAaM8FrvnlWYrVeRVttLuJgx8CwnU/JWAHrC5i3zK/T/dp+OBe uUNmny1ihXtxVAy24vcxyvd2nxkY79fxwARAbJtS8Fvw9NZm0cUCa5eitRGDloq64c4O cBvWzQJLLu1hcvn/HXJSXvXr0y0Za/Xm1NTh9Ge51dOOF/nhmTXDC2o3s42lc6h9/ZLZ lzDg== 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=LLkC/eoc1nv7hwaPpR5Lx7PUHWEU8IZ20TgpsZ48Kb1TIBIJ6vttBRpyccEfFekP/f xGdbQuigdNZCJgiM21zQtgu5lcX3WlppQpjC48bGPXOLRJsg74w9ihhxUg0gNShug745 mG1YxDSMV8bEyxK899599vjgXaBcnhplM7VKMmTAkis/sxL3ZwDqatGka+Q2+tlHyolA oKjuDDPMnqL2E4I51iuGArL1GPcuFTVkgkPENyLFEmQ+IZQWPYKixPn4q0w4P4hNkYyx s/MmaJ0sDNApqweBsvER0NmVwu0jO5uD1V5B3/0in/PZywxuON6lYbMMKjyoR8tffg3P KslQ== X-Gm-Message-State: AOAM532gWFCyBVByBVuijwfMZxNk02nuhjfijrULeP3JiGbEJRf6UdN5 uD9ljqurgI2TJW3J6ii2FJZD8nrRTzF+aQ== X-Google-Smtp-Source: ABdhPJyZIWFB9dzKDhn8IGoUooyDWAciTk4Ixm+0EElg0pUQPtVSHwmO7LL0zsiPtIKnCD7xWlrtag== X-Received: by 2002:a17:902:e550:b0:138:ed48:2e9a with SMTP id n16-20020a170902e55000b00138ed482e9amr4173195plf.46.1631121410529; Wed, 08 Sep 2021 10:16:50 -0700 (PDT) Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123]) by smtp.gmail.com with ESMTPSA id d5sm3194571pfd.142.2021.09.08.10.16.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Sep 2021 10:16:49 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Wed, 8 Sep 2021 10:16:38 -0700 Message-Id: <20210908171644.26571-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210908171644.26571-1-stephen@networkplumber.org> References: <20210903004732.109023-1-stephen@networkplumber.org> <20210908171644.26571-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 2/8] 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