From patchwork Fri Mar 10 23:38:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Thaler X-Patchwork-Id: 13170452 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52D40C6FD19 for ; Fri, 10 Mar 2023 23:38:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230203AbjCJXiY (ORCPT ); Fri, 10 Mar 2023 18:38:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231910AbjCJXiW (ORCPT ); Fri, 10 Mar 2023 18:38:22 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0951C1B57B for ; Fri, 10 Mar 2023 15:38:17 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id p3-20020a17090ad30300b0023a1cd5065fso6652483pju.0 for ; Fri, 10 Mar 2023 15:38:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; t=1678491497; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=xBc0RjkmAJoUMHV1ZGJ9wJmJAFimaZ97KsvLEgWqlXQ=; b=bZOT4A/ZExCTmxknvCmYdWyLZAoJ8poIwSmfNEiVLdVlCFzmFkG2OxXxGXI3w6DOFy nirmHFyau7cjKBwviG8P2pN/pQnNTScjSZux8e/2zzQHMDzOl4iFD9k09NJ1ABbKkwKY PMnqKyOBAujCv5x7OsixmacC3QWMj+aGabXt00N9+8liP4N2xItTBPYegj4XO0HtK5Cp aDWiPFlB/PWjxBXnAdFsvX9gE3EUzU8IFhWrfS8iFhiJ3o7HvzlmcCFfLBzRcALMpcrW LlqJTJoQ8gdpvTgGQxPmPtX4HBxDYJnY+T/Gh2I5zu0Tf2vTiay7WOJ+UUHqXtHFtrX6 Ch7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678491497; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=xBc0RjkmAJoUMHV1ZGJ9wJmJAFimaZ97KsvLEgWqlXQ=; b=77+9BdYTueel2xxS5/DL0qlF7WNa3JNNghV+jQhCpbYTyWUocc1UEuYVfcE0qZHI0Y JJlzzCumCt2fjWHEzWmRujpRsLQpav2699LISxyldE8QNRITHyUh9HaCRbA8HHkDedDC T7M8Gaj2WWDSPEXn55mL2Vcs7ZRdYrmDL44ffol/ZGj6HR46+RIJ/qLGVLM3D2graGu6 uagkGRbaWE7/GAlBZ440XzDRPZZnSw2cMwkSvRaLGP/zdbQHheO7XqYZsW8hZLe3nLu8 fUDXGDuPQrat2rRg6jzyEqixNwz1W64YevymgjQu0YBb6lbHdNYAkIe09GnW6ZoCM6yv gOcg== X-Gm-Message-State: AO0yUKVllaSavAA4c0T7nrBwctkdTZvkX/Qg1tJ4tjUmivIDQSJxeEMt Q6WklHObVrZ2YyF2ie7z/9bvLzljkWw= X-Google-Smtp-Source: AK7set/uY7qVTl4b3W7RHMfqcVaguCEgGeGVIb6bKM4Zuj7ChTX/j44S55hzBIvBaPRinvG5I4c3aA== X-Received: by 2002:a17:902:eccb:b0:19f:2503:a201 with SMTP id a11-20020a170902eccb00b0019f2503a201mr246781plh.29.1678491497036; Fri, 10 Mar 2023 15:38:17 -0800 (PST) Received: from mariner-vm.. ([131.107.1.213]) by smtp.gmail.com with ESMTPSA id b7-20020a170902a9c700b0019cd1ee1523sm154231plr.30.2023.03.10.15.38.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 15:38:16 -0800 (PST) From: Dave Thaler To: bpf@vger.kernel.org Cc: bpf@ietf.org, Dave Thaler Subject: [PATCH bpf-next] bpf, docs: Add signed comparison example Date: Fri, 10 Mar 2023 23:38:14 +0000 Message-Id: <20230310233814.4641-1-dthaler1968@googlemail.com> X-Mailer: git-send-email 2.33.4 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: Dave Thaler Improve clarity by adding an example of a signed comparison instruction Signed-off-by: Dave Thaler Acked-by: David Vernet Acked-by: John Fastabend --- Documentation/bpf/instruction-set.rst | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Documentation/bpf/instruction-set.rst b/Documentation/bpf/instruction-set.rst index 5e43e14abe8..b4464058905 100644 --- a/Documentation/bpf/instruction-set.rst +++ b/Documentation/bpf/instruction-set.rst @@ -11,7 +11,8 @@ Documentation conventions ========================= For brevity, this document uses the type notion "u64", "u32", etc. -to mean an unsigned integer whose width is the specified number of bits. +to mean an unsigned integer whose width is the specified number of bits, +and "s32", etc. to mean a signed integer of the specified number of bits. Registers and calling convention ================================ @@ -264,6 +265,14 @@ BPF_JSLE 0xd0 PC += off if dst <= src signed The eBPF program needs to store the return value into register R0 before doing a BPF_EXIT. +Example: + +``BPF_JSGE | BPF_X | BPF_JMP32`` (0x7e) means:: + + if (s32)dst s>= (s32)src goto +offset + +where 's>=' indicates a signed '>=' comparison. + Helper functions ~~~~~~~~~~~~~~~~