From patchwork Tue Feb 6 22:04:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexei Starovoitov X-Patchwork-Id: 13547848 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 951FCC48297 for ; Tue, 6 Feb 2024 22:05:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 287336B00A1; Tue, 6 Feb 2024 17:05:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 236A26B00A2; Tue, 6 Feb 2024 17:05:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B1666B00A3; Tue, 6 Feb 2024 17:05:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E71936B00A1 for ; Tue, 6 Feb 2024 17:05:39 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C859512011E for ; Tue, 6 Feb 2024 22:05:39 +0000 (UTC) X-FDA: 81762761598.07.58275F8 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf07.hostedemail.com (Postfix) with ESMTP id EDB6940019 for ; Tue, 6 Feb 2024 22:05:37 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=VCfs+39g; spf=pass (imf07.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707257138; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mCIDfn6Q/Sj02IoZMnsUeC+cwQq+R0K4Vy6avN3EcgA=; b=SsodAz+ajZrOlyaFRgRYYZxhvj1WSwBr5ixIQ4LpAwenrpbMWW9Ilq1f/mJq4PkRD9Ui3Q dI83QAc9R7S0OttSccgS3RCwUhxx7zvvIgNMP2515PSXFE43JgpOD0xKByAfY24h9u/t7G pxFC6xi96chEJ5pTbV+Lv3drpaUyje4= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=VCfs+39g; spf=pass (imf07.hostedemail.com: domain of alexei.starovoitov@gmail.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=alexei.starovoitov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707257138; a=rsa-sha256; cv=none; b=kB650Q1osjucBuhktN5SaANgbMLu3yu9pdnnOUGDYlM1FVrTYHrEQAoVPI0tUiQundOYm6 e39BOdjotCa8ydVAo5JhZuPnGkgGG4Gug/g/6V+Xc279XXt4k8oaihJeFYj6wHyBIvDvs6 Te3pIo/+Ov2hNn2bQX1k8v9vlfD3ubk= Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1d934c8f8f7so42785ad.2 for ; Tue, 06 Feb 2024 14:05:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707257137; x=1707861937; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mCIDfn6Q/Sj02IoZMnsUeC+cwQq+R0K4Vy6avN3EcgA=; b=VCfs+39gtXZv7paXd8uS5F2YNdABMnVkNiXjYchCREKl8dLNc/Kj6FzM3Su5hFCVFs No588FJgYYOuQVN7HPvDfCp/4NhNLmG2y59NzkYS8bwtSon64s0xoFPydX6qg5ifW9dB aCj/w3VihXKl4abNMDncivD+XY4p9Mvd3HcjwhL97UtSyVQitAByC0ukNM5c2qUgIj+b pDfY87kZJeqpR0du1/VBGObiftmr7UusvyL3Czru7v+ZDFliqTv76vTcXL2fC9JEX41/ MAb7Pr1S1AS7Bl4pItUDV+zA55iJCIrtbsC44nYQJXOIAgKYkob0+9itEKrecrc8FHJS I+WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707257137; x=1707861937; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mCIDfn6Q/Sj02IoZMnsUeC+cwQq+R0K4Vy6avN3EcgA=; b=RCK2S0kt/31t9Wj3AGcjT+kuY6ZnBQOZw5AhidVB3ffZBIetLN3F0r1uIMZALCM4zR /udq+x4xXXy4HLjbA0gQFl9kKycQGlA9iW4CLG4ip/u5n7paf/VkXVVULkqKKulyLvJ5 p1XPJwLNFGIFtcvZra2p+G0dL5y4P+6RQqM5R63M1+h0p4mwIjhy7PfcPqyb+SSEML8+ pwdshPFJfRTXbHs+Cvtk1xYbySn9ufmAWMOob0ofLhniz+jnA3zj4xYYMPvB+LFeg4vy ycpaxuYJOgJnRupZqL9QSQioPjwAjVVXr/YPC63x4F5Medgx3AXY1Gukk58DIZ7zSUf1 fJ8g== X-Forwarded-Encrypted: i=1; AJvYcCXgGbRaA62pCS2AySS0ysOQ7LtIJS/Jii0GCR1IBzD16dvOoPEPLSTKCZaU12I+TBZmSYp1bRYCaQowGKpU7/R8a8Y= X-Gm-Message-State: AOJu0YwoagoL0nJClbq12cNWstaOz99Ymmoa4dh2ejvsvot6XxAcL+eR TUZivNA/pavAUgSpbOGmGll0hoV6rLXcA/oNlQ5nBb3AafxkTJ8t X-Google-Smtp-Source: AGHT+IFC/8gaSn2ezfySvQY9fE+LjbzC6tGU3b69/lMAgjDuoKzugaxeFxuGwhXQP6FF6XydFy7cZQ== X-Received: by 2002:a17:902:d505:b0:1d9:1322:5b0d with SMTP id b5-20020a170902d50500b001d913225b0dmr3444099plg.65.1707257136843; Tue, 06 Feb 2024 14:05:36 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCV0x5GbXUCf5LB0OoOZH0U0NIvJ4KFVm6E2YVqM7e7OdGPW+05tZ5DAXSvvES4yBjccZ+t5IUAp2y3ibsYajhe4yp9SVObP53SFLmqQJAkx7FyJme2n9iRr5USNt4OJlJqM8O2xXtKU+496radnUUCnB5P/KQPT6zgteLeYt5oGrVMYnpbH4/Dh7vDvJGTDyB8HeVf+n7M4FLc534D7uDs7Skwll/6R5u6HMOZl0XgdXeTx12OGxEAN58tNuRpgmiZPbXSDoBOkb+iBJSRun85q1Mu9578UYxyZ Received: from localhost.localdomain ([2620:10d:c090:400::4:27bf]) by smtp.gmail.com with ESMTPSA id y11-20020a170902e18b00b001d6f29c12f7sm4613pla.135.2024.02.06.14.05.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 06 Feb 2024 14:05:36 -0800 (PST) From: Alexei Starovoitov To: bpf@vger.kernel.org Cc: daniel@iogearbox.net, andrii@kernel.org, martin.lau@kernel.org, memxor@gmail.com, eddyz87@gmail.com, tj@kernel.org, brho@google.com, hannes@cmpxchg.org, linux-mm@kvack.org, kernel-team@fb.com Subject: [PATCH bpf-next 13/16] bpf: Tell bpf programs kernel's PAGE_SIZE Date: Tue, 6 Feb 2024 14:04:38 -0800 Message-Id: <20240206220441.38311-14-alexei.starovoitov@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20240206220441.38311-1-alexei.starovoitov@gmail.com> References: <20240206220441.38311-1-alexei.starovoitov@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: EDB6940019 X-Rspam-User: X-Stat-Signature: ngozfkafcfa867rnppodknns3fusts6z X-Rspamd-Server: rspam01 X-HE-Tag: 1707257137-39049 X-HE-Meta: U2FsdGVkX19oGKqNjlRuif96WdHiruIJPDY3zXnGOGYIxCJf98gX8Ao5V2eXPYDMN5XjpdzyFDfUIXx6pud24JrY4ntjoeXB3o74Lx6yCk2yLq/qoALCJVh3HVU3dJmHlQmFAL2YmwmsBWlzbauVBFo6goKMM8IPVgT0Vyie8bIKGiKRiGBGEoY/gcqc1RtYoiXRX4nsXPo/Wgh83mP6ZYk0QSx5YNeyxqkHqlNE6AJx/Mws/eK2JgUZcb5gNBdop78EV2ga7FB/xxAJ9RvbFFtyg0nXkPda85461hS7buqnTsHcSw16ePu9TnV0o0ih5DjmHU2xJX9/v3NWRDbCU0S9nPmTR8hLb1agsvWa+Ii7XmZBc/NTE0H7wfwZrRs9vkgUdTela0qwl85Bg6Bua2G1n4y/I2BTF7tEw+CzlLyBVh6dGVd/cY6oYMrPhh2vHHz/2oONnBCIS7MUMfIHAtOSkqGyPXlcUb7ybqgC5iWdcl/1bPrUmbmWEBdeVg79PDsFqpDcIOddaz2aNB1ZWl349lQmFUqUDT+ksUBTkydpjG2IWBJ52ocLPHjbe6yyU41KVLuVbT6tgLrBCL+3DeTONijOR+79t6oBLU8n3CrgUTdv6fnqX49O8WVtYlHFVhhZEabKYPI+uy/2uiNCFxjDpBz2Hlni5ek7G86imcwRv91zxVW2AcL70C3OJqFvLRVPxvkrm0CBoPanM/tTxRraE+cSDIHNVRHqTxVyO+RNimjJdlCgfPlSZgXc43xDTXu8BPt3Hkop0roQIfR5pJ2eohnl551DPUcNLonCADS8KskNMjpDaeAIhP/eXbzqo4438WC/NrDLCW2Ae3DsCRtARl7eG+ezGS/0f3FAwolQte/98SLtIrMqv6Mm3hngT9WcYczpUdoO4LEueop7n+kuJOMHyFDDm/rLFa5cYkxqBxoOPlyxB68m0ParYbIMvFugpHQj4TgyAjpTOLW KGq7zJFE yPfCoj+pOc2LV7oJdMsgqPGW456ySAlpKeIjKiw5GJhR5wD0DCGOw0mA7nChtFFOzw1OWg6/M8Ij0aYu5l6EC2FPeaEk/JWJNiXV8hRUS2jnXYvbv6461gDFiEVFy2xkxTKjEqAIp0icv1jwbDx0GpVH1XcEYxDruO/VCJprBYcFiE10ayo5VH87yviSg0k8wOL2KKGtWFJAUEExnPZCW13rL//hLULe8mieDhU/wxsfnnY6drWu0FEBWn2sS8N8DfRvkuMeVV3M3n2KS52GA/5iLf0xVilymyR11EKLh9NbEj8YdhJ9YerKx1RHvtGc6gl8JqlwXPAM9VkkepZ1x5eC58RXcmmx8Ac0pZMQmXm+kgRCyAPnXoIhEVDZ/ONpXFB3adZO7iGxFrKyMy+gmJNH9oS2/JorqEv5JE8BCNysbn5fZpKXluFwVnltsSNEr2a+Vw89nvrUti9oyK4MkSiS8fOO7tANj8PQZhLuQRf465GJKt1vv5ko2vmXQq9g32cOAXq5eSrCEs/l8PeWHFpE8nP2992EfoNF3TXokHpkFNp2sfZSUry+nHElCo1XSg+oRRxG1mYUQ0zZ7XbfUtHeCZbuPBROcYCekTWucIv5wrW9OWsw0cvT6Nw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000023, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Alexei Starovoitov vmlinux BTF includes all kernel enums. Add __PAGE_SIZE = PAGE_SIZE enum, so that bpf programs that include vmlinux.h can easily access it. Signed-off-by: Alexei Starovoitov --- kernel/bpf/core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 2829077f0461..3aa3f56a4310 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -88,13 +88,18 @@ void *bpf_internal_load_pointer_neg_helper(const struct sk_buff *skb, int k, uns return NULL; } +/* tell bpf programs that include vmlinux.h kernel's PAGE_SIZE */ +enum page_size_enum { + __PAGE_SIZE = PAGE_SIZE +}; + struct bpf_prog *bpf_prog_alloc_no_stats(unsigned int size, gfp_t gfp_extra_flags) { gfp_t gfp_flags = bpf_memcg_flags(GFP_KERNEL | __GFP_ZERO | gfp_extra_flags); struct bpf_prog_aux *aux; struct bpf_prog *fp; - size = round_up(size, PAGE_SIZE); + size = round_up(size, __PAGE_SIZE); fp = __vmalloc(size, gfp_flags); if (fp == NULL) return NULL;