Re: [Bpf] [PATCH 1/1] bpf, docs: Describe stack contents of function calls

Alexei Starovoitov <alexei.starovoitov@gmail.com> Thu, 06 July 2023 23:32 UTC

Return-Path: <alexei.starovoitov@gmail.com>
X-Original-To: bpf@ietfa.amsl.com
Delivered-To: bpf@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 80389C151527 for <bpf@ietfa.amsl.com>; Thu, 6 Jul 2023 16:32:04 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.098
X-Spam-Level:
X-Spam-Status: No, score=-2.098 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ysSHtIB_utvr for <bpf@ietfa.amsl.com>; Thu, 6 Jul 2023 16:32:04 -0700 (PDT)
Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 16C81C15109F for <bpf@ietf.org>; Thu, 6 Jul 2023 16:32:04 -0700 (PDT)
Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2b63e5f94f1so15883081fa.1 for <bpf@ietf.org>; Thu, 06 Jul 2023 16:32:03 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688686322; x=1691278322; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=B6HGx3BBK3e6NncirqzjfehqKmV8RLD2m05P7jQfvq4=; b=T63ZYqhdM8qR/Vsyta6go+eAeIyr6N4yUrP30azBb7axy5Iusz6QvzS9GrcdoxidG9 BPqzPy7BPs4feaFwNEYhhJv04covUWpjlR/Vrz1h0D+NWjCYC3TkGF4e265jfF0TQImY NsZxGAlVSyPJZyGmJxSmTvCYK03pFljjHMqt7XqEAZpwtkCL37tIeV2vrq5Wfu6vqg7y a+NznAPFhsSmQiyi+K0P2IH9/WTaliBOeCMmkeU0K3QlS1StN+nNilqZkCRbIHYLcGQw Wmk5N3ldacWxAb6nDb5trXcp+1+jAh5QlA8Sr+pcTTmK2iKeP4pD/z+QVJNAkvY54pBU rXsw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688686322; x=1691278322; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B6HGx3BBK3e6NncirqzjfehqKmV8RLD2m05P7jQfvq4=; b=ONva1B5DM5CtYjTfMwRaIufW3DHIM+6wXXRiH+2BX+Xq6Rn95pHfAOMc9VZ9THd7MS vml0zAgDumjzvv7PBu3/sslmPMM+nLIJkGiF7hlYRnMk77YyxXEmSOc9Y0kmsMgRsqBB gvb10RtrZdfwigfAtsN4pdIR4vYTuYvu5EMSED44eZQsXxIGQFqrwnEKuVskZ8qbY/fi QkJliWAdDfpN6/m+ku4bL2RWSWNej+BXqCpWfzBwMK/QO1pW9NLc8WVhhy2wYcnm12va BBrrVGAVAvShneB/GlmhHl8vlHkfxlQ0GFpCE+IAPL0n/I5pvyZNUxsibVAyFqT0xHfc +ikQ==
X-Gm-Message-State: ABy/qLYwv7ymaq4kIy9v52n4cVeNFxOU6Gg0xXcqcvQgS4Wn0R/ZX/jp 7W3Cu+Ss9v8GHu3eVIkzwUT+9x5VddmuDWgn9Ag=
X-Google-Smtp-Source: APBJJlEFFF7M+y06+VP2GGB4Fq3B08az07f0fRoWhnGEqrWxhCs6cKkZl1kBcjsx1Nx50cvsRrjmslgeO26pG6LDSqs=
X-Received: by 2002:a2e:81c8:0:b0:2b7:118:a1bc with SMTP id s8-20020a2e81c8000000b002b70118a1bcmr1142457ljg.25.1688686321990; Thu, 06 Jul 2023 16:32:01 -0700 (PDT)
MIME-Version: 1.0
References: <20230706222020.268136-1-hawkinsw@obs.cr> <20230706222020.268136-2-hawkinsw@obs.cr>
In-Reply-To: <20230706222020.268136-2-hawkinsw@obs.cr>
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Date: Thu, 06 Jul 2023 16:31:50 -0700
Message-ID: <CAADnVQ+kfTPYE1kbUuxsaoEZBCHKG2SLDkcs62RXqEo8Jhi9+Q@mail.gmail.com>
To: Will Hawkins <hawkinsw@obs.cr>
Cc: bpf <bpf@vger.kernel.org>, bpf@ietf.org
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Archived-At: <https://mailarchive.ietf.org/arch/msg/bpf/F9lWtevv1hVKmf6cofVHa-7lFa4>
Subject: Re: [Bpf] [PATCH 1/1] bpf, docs: Describe stack contents of function calls
X-BeenThere: bpf@ietf.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: Discussion of BPF/eBPF standardization efforts within the IETF <bpf.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/bpf>, <mailto:bpf-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/bpf/>
List-Post: <mailto:bpf@ietf.org>
List-Help: <mailto:bpf-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/bpf>, <mailto:bpf-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 06 Jul 2023 23:32:04 -0000

On Thu, Jul 6, 2023 at 3:20 PM Will Hawkins <hawkinsw@obs.cr> wrote:
>
> The execution of every function proceeds as if it has access to its own
> stack space.
>
> Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
> ---
>  Documentation/bpf/instruction-set.rst | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/Documentation/bpf/instruction-set.rst b/Documentation/bpf/instruction-set.rst
> index 751e657973f0..717259767a41 100644
> --- a/Documentation/bpf/instruction-set.rst
> +++ b/Documentation/bpf/instruction-set.rst
> @@ -30,6 +30,11 @@ The eBPF calling convention is defined as:
>  R0 - R5 are scratch registers and eBPF programs needs to spill/fill them if
>  necessary across calls.
>
> +Every function invocation proceeds as if it has exclusive access to an
> +implementation-defined amount of stack space. R10 is a pointer to the byte of
> +memory with the highest address in that stack space. The contents
> +of a function invocation's stack space do not persist between invocations.

Such description belongs in a future psABI doc.
instruction-set.rst is not a place to describe how registers are used.
For example x86-64 JIT maps BPF R10 to RBP.
Yet there is -fomit-frame-pointer.
So we might very well do something like that in the future.