diff --git a/kernel_patches_daemon/patchwork.py b/kernel_patches_daemon/patchwork.py index f648ad4..662b6ae 100644 --- a/kernel_patches_daemon/patchwork.py +++ b/kernel_patches_daemon/patchwork.py @@ -290,10 +290,10 @@ def __init__(self, subject: str, pw_client: "Patchwork") -> None: self.subject = subject async def branch(self) -> Optional[str]: - relevant_series = await self.relevant_series() - if len(relevant_series) == 0: + s = await self.latest_series() + if s is None: return None - return f"series{SERIES_ID_SEPARATOR}{relevant_series[0].id}" + return f"series{SERIES_ID_SEPARATOR}{s.id}" async def latest_series(self) -> Optional["Series"]: relevant_series = await self.relevant_series() diff --git a/tests/data/test_github_sync.test_sync_patches_pr_summary_success/relevant-subjects-20250610.json b/tests/data/test_github_sync.test_sync_patches_pr_summary_success/relevant-subjects-20250610.json deleted file mode 100644 index b8bea12..0000000 --- a/tests/data/test_github_sync.test_sync_patches_pr_summary_success/relevant-subjects-20250610.json +++ /dev/null @@ -1,164 +0,0 @@ -[ - { - "id": 14114605, - "url": "https://patchwork.test/api/1.1/patches/14114605/", - "web_url": "https://patchwork.test/project/netdevbpf/patch/20250611154859.259682-1-chen.dylane@linux.dev/", - "project": { - "id": 399, - "url": "https://patchwork.test/api/1.1/projects/399/", - "name": "Netdev + BPF", - "link_name": "netdevbpf", - "list_id": "bpf.vger.kernel.org", - "list_email": "bpf@vger.kernel.org", - "web_url": "", - "scm_url": "", - "webscm_url": "" - }, - "msgid": "<20250611154859.259682-1-chen.dylane@linux.dev>", - "date": "2025-06-11T15:48:58", - "name": "[bpf-next] bpf: clear user buf when bpf_d_path failed", - "commit_ref": null, - "pull_url": null, - "state": "new", - "archived": false, - "hash": "ecb10e6ecea01d3f770e4d08eb251179b0f9a98b", - "submitter": { - "id": 216065, - "url": "https://patchwork.test/api/1.1/people/216065/", - "name": "Tao Chen", - "email": "chen.dylane@linux.dev" - }, - "delegate": { - "id": 121173, - "url": "https://patchwork.test/api/1.1/users/121173/", - "username": "bpf", - "first_name": "BPF", - "last_name": "", - "email": "bpf@iogearbox.net" - }, - "mbox": "https://patchwork.test/project/netdevbpf/patch/20250611154859.259682-1-chen.dylane@linux.dev/mbox/", - "series": [ - { - "id": 970926, - "url": "https://patchwork.test/api/1.1/series/970926/", - "web_url": "https://patchwork.test/project/netdevbpf/list/?series=970926", - "date": "2025-06-11T15:48:58", - "name": "[bpf-next] bpf: clear user buf when bpf_d_path failed", - "version": 1, - "mbox": "https://patchwork.test/series/970926/mbox/" - } - ], - "comments": "https://patchwork.test/api/patches/14114605/comments/", - "check": "success", - "checks": "https://patchwork.test/api/patches/14114605/checks/", - "tags": {} - }, - { - "id": 14114774, - "url": "https://patchwork.test/api/1.1/patches/14114774/", - "web_url": "https://patchwork.test/project/netdevbpf/patch/20250611171529.2034330-1-yonghong.song@linux.dev/", - "project": { - "id": 399, - "url": "https://patchwork.test/api/1.1/projects/399/", - "name": "Netdev + BPF", - "link_name": "netdevbpf", - "list_id": "bpf.vger.kernel.org", - "list_email": "bpf@vger.kernel.org", - "web_url": "", - "scm_url": "", - "webscm_url": "" - }, - "msgid": "<20250611171529.2034330-1-yonghong.song@linux.dev>", - "date": "2025-06-11T17:15:29", - "name": "[bpf-next,v2,2/3] selftests/bpf: Fix two net related test failures with 64K page size", - "commit_ref": null, - "pull_url": null, - "state": "new", - "archived": false, - "hash": "3734274f90b6282e0c574a9ac2c9bda37ef5d6a0", - "submitter": { - "id": 210263, - "url": "https://patchwork.test/api/1.1/people/210263/", - "name": "Yonghong Song", - "email": "yonghong.song@linux.dev" - }, - "delegate": { - "id": 121173, - "url": "https://patchwork.test/api/1.1/users/121173/", - "username": "bpf", - "first_name": "BPF", - "last_name": "", - "email": "bpf@iogearbox.net" - }, - "mbox": "https://patchwork.test/project/netdevbpf/patch/20250611171529.2034330-1-yonghong.song@linux.dev/mbox/", - "series": [ - { - "id": 970968, - "url": "https://patchwork.test/api/1.1/series/970968/", - "web_url": "https://patchwork.test/project/netdevbpf/list/?series=970968", - "date": "2025-06-11T17:15:19", - "name": "bpf: Fix a few test failures with 64K page size", - "version": 2, - "mbox": "https://patchwork.test/series/970968/mbox/" - } - ], - "comments": "https://patchwork.test/api/patches/14114774/comments/", - "check": "warning", - "checks": "https://patchwork.test/api/patches/14114774/checks/", - "tags": {} - }, - { - "id": 14114777, - "url": "https://patchwork.test/api/1.1/patches/14114777/", - "web_url": "https://patchwork.test/project/netdevbpf/patch/20250611-rcu-fix-task_cls_state-v3-1-3d30e1de753f@posteo.net/", - "project": { - "id": 399, - "url": "https://patchwork.test/api/1.1/projects/399/", - "name": "Netdev + BPF", - "link_name": "netdevbpf", - "list_id": "bpf.vger.kernel.org", - "list_email": "bpf@vger.kernel.org", - "web_url": "", - "scm_url": "", - "webscm_url": "" - }, - "msgid": "<20250611-rcu-fix-task_cls_state-v3-1-3d30e1de753f@posteo.net>", - "date": "2025-06-11T17:20:43", - "name": "[bpf-next,v3] net: Fix RCU usage in task_cls_state() for BPF programs", - "commit_ref": null, - "pull_url": null, - "state": "new", - "archived": false, - "hash": "fb8bc5714a26b9ad4011597046c855b5a4857807", - "submitter": { - "id": 211324, - "url": "https://patchwork.test/api/1.1/people/211324/", - "name": "Charalampos Mitrodimas", - "email": "charmitro@posteo.net" - }, - "delegate": { - "id": 121173, - "url": "https://patchwork.test/api/1.1/users/121173/", - "username": "bpf", - "first_name": "BPF", - "last_name": "", - "email": "bpf@iogearbox.net" - }, - "mbox": "https://patchwork.test/project/netdevbpf/patch/20250611-rcu-fix-task_cls_state-v3-1-3d30e1de753f@posteo.net/mbox/", - "series": [ - { - "id": 970970, - "url": "https://patchwork.test/api/1.1/series/970970/", - "web_url": "https://patchwork.test/project/netdevbpf/list/?series=970970", - "date": "2025-06-11T17:20:43", - "name": "[bpf-next,v3] net: Fix RCU usage in task_cls_state() for BPF programs", - "version": 3, - "mbox": "https://patchwork.test/series/970970/mbox/" - } - ], - "comments": "https://patchwork.test/api/patches/14114777/comments/", - "check": "warning", - "checks": "https://patchwork.test/api/patches/14114777/checks/", - "tags": {} - } -] diff --git a/tests/data/test_latest_series_real_sample/patch-13574002.json b/tests/data/test_latest_series_real_sample/patch-13574002.json new file mode 100644 index 0000000..9169bdb --- /dev/null +++ b/tests/data/test_latest_series_real_sample/patch-13574002.json @@ -0,0 +1,99 @@ +{ + "id": 13574002, + "url": "https://patchwork.kernel.org/api/1.1/patches/13574002/", + "web_url": "https://patchwork.kernel.org/project/netdevbpf/patch/20240227151115.4623-2-puranjay12@gmail.com/", + "project": { + "id": 399, + "url": "https://patchwork.kernel.org/api/1.1/projects/399/", + "name": "Netdev + BPF", + "link_name": "netdevbpf", + "list_id": "bpf.vger.kernel.org", + "list_email": "bpf@vger.kernel.org", + "web_url": "", + "scm_url": "", + "webscm_url": "" + }, + "msgid": "<20240227151115.4623-2-puranjay12@gmail.com>", + "date": "2024-02-27T15:11:15", + "name": "[bpf-next,1/1] arm64/cfi,bpf: Support kCFI + BPF on arm64", + "commit_ref": null, + "pull_url": null, + "state": "superseded", + "archived": false, + "hash": "e0f4a64cdbc1bc9ac631930b3388c9e9537ab20c", + "submitter": { + "id": 186869, + "url": "https://patchwork.kernel.org/api/1.1/people/186869/", + "name": "Puranjay Mohan", + "email": "puranjay12@gmail.com" + }, + "delegate": { + "id": 121173, + "url": "https://patchwork.kernel.org/api/1.1/users/121173/", + "username": "bpf", + "first_name": "BPF", + "last_name": "", + "email": "bpf@iogearbox.net" + }, + "mbox": "https://patchwork.kernel.org/project/netdevbpf/patch/20240227151115.4623-2-puranjay12@gmail.com/mbox/", + "series": [ + { + "id": 830310, + "url": "https://patchwork.kernel.org/api/1.1/series/830310/", + "web_url": "https://patchwork.kernel.org/project/netdevbpf/list/?series=830310", + "date": "2024-02-27T15:11:14", + "name": "Support kCFI + BPF on arm64", + "version": 1, + "mbox": "https://patchwork.kernel.org/series/830310/mbox/" + } + ], + "comments": "https://patchwork.kernel.org/api/patches/13574002/comments/", + "check": "fail", + "checks": "https://patchwork.kernel.org/api/patches/13574002/checks/", + "tags": {}, + "headers": { + "Received": [ + "from mail-wr1-f50.google.com (mail-wr1-f50.google.com\n [209.85.221.50])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id B53C4145FF4;\n\tTue, 27 Feb 2024 15:11:46 +0000 (UTC)", + "by mail-wr1-f50.google.com with SMTP id\n ffacd0b85a97d-33d6fe64a9bso3348660f8f.0;\n Tue, 27 Feb 2024 07:11:46 -0800 (PST)", + "from localhost (54-240-197-231.amazon.com. [54.240.197.231])\n by smtp.gmail.com with ESMTPSA id\n bq7-20020a5d5a07000000b0033cddadde6esm11917259wrb.80.2024.02.27.07.11.44\n (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);\n Tue, 27 Feb 2024 07:11:44 -0800 (PST)" + ], + "Authentication-Results": [ + "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.221.50", + "smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com", + "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=gmail.com", + "smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=\"laO9OWYA\"" + ], + "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1709046708; cv=none;\n b=V7r+1+Gfxr03h8R8tns+I40GekcCY+I6dee3v94YJxMA5iHo2c6gg/Ovcd/5dJMJjIQL1L67IAhhx5wESoNITQ37mViTzjIw1B/stJ5I+xh9aKDGlCl2ebuN+t2ywqnAWRruZEdErYvCTo4eDp59gs46L9QuCWDfVxetd7dJjCY=", + "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1709046708; c=relaxed/simple;\n\tbh=uXkdZ+nGgZ8dBlwogGYG/znpIjVGxCyU2Z1+CR/AVIE=;\n\th=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:\n\t MIME-Version;\n b=Lm9uZ0h4p4qYHPsEw/XJsRFpfbgq8y5QxXVeXGS1drvRNylfHV0ZaMDW9yVox+aO4HbdyvK05mQyUMsS7z5oKc1zt2SSOkhZRuz4oFwcV+pIzS7H77ilii4MTv0GYXiI8dDPAijqOFtA95M7+GRwyHxxC0hHjKjmW/dMv+67r9I=", + "ARC-Authentication-Results": "i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com;\n spf=pass smtp.mailfrom=gmail.com;\n dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=laO9OWYA; arc=none smtp.client-ip=209.85.221.50", + "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20230601; t=1709046705; x=1709651505;\n darn=vger.kernel.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=YgUZYYEewWOr0eZgCM/D+yRszpCU2Zn6RVKpSWiScZI=;\n b=laO9OWYAnLP2pdH5x5Zu8gfMadrLUJjXCkBtFFrZ3pqPReFmMLF1KCBY43p5dOeRX6\n QhknXVyz2Q7vj2ZaE4qzvMCuZEujGunbiLWxD/qe5Rtkl18+yPgyMhd0htdz/c87drOb\n /Yy+y5VqYHaVRxa79zH3ugUCHDqjfUqFO4l1Y+9NS8m9KjV+V18yhg8PDiuAihJqZ30X\n qLuUi0nmuflyF3owGI2Z4/+CiHUJ13sV+OA/OMlki1ecikJ4ItxxwkOvuaTi0GIPKEpv\n SMz6ZVTeQ68vXfKEgOsa+SA9Z5DChMAVnuAd6P0zvMyABtF0Hv54gCgOnG1F2iuOZl+m\n qDVQ==", + "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1709046705; x=1709651505;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=YgUZYYEewWOr0eZgCM/D+yRszpCU2Zn6RVKpSWiScZI=;\n b=XQKIauqn9BOol4IUuy9PTtROBuJzPsOmmy8w9jo+GcK6sltBSBgz+jGVh1MXLBXt/N\n lbhDiBYTIezGG7yLxbIDWuqo9pKKWxiO2PMt4cgtAKtXIP2HGmQ1wI/+nCja0c22PUHT\n RqYKJKy983GASpXQ3kEu9mgocAka1LToSLv65lV/Al+9OfzCwnZgCqc+BCAkBHQrHV7G\n mjezjJ+2a2mbOWP5/Uxw20q125Co8F36n+C+TsrzeCvigRbkC0MUxXBoPQAhROkUUBcr\n oBLEyp27wCEJZuvvhdseYCeSHNcBBHgZlVYVI7RpNaW8E6I2zwkzkjlY6+BzOs844XAR\n iC3Q==", + "X-Forwarded-Encrypted": "i=1;\n AJvYcCVffLIVKjI9Mk77Nc8IV7iGKXyk8oVJLSjTa8dUGYZWygREkgJXvBBUtzws+GC6+U40+IEABIv9te4YncEembAKeQq2aOE2Oso7FYccxmRz22QUE8h+mYoicDKcZuHeSUmD", + "X-Gm-Message-State": "AOJu0YzZrNfLxYXEhHjR+5G/PuENFXuZm9y+JJEjy8XUzNe4tgTIHJhN\n\te7HPMYB6MunUx3c2xl0l+F5wNy+k5dTPANs7kJtIcGOdl2VYEkwN", + "X-Google-Smtp-Source": "\n AGHT+IGLirqfah9d4iGWTMCqewDLhnmBg8hi2Iy2nBqKNPhbA3EjAa6SiYGrHFnWv/yqvMG7UwDjxA==", + "X-Received": "by 2002:a5d:58cd:0:b0:33d:b872:1c1b with SMTP id\n o13-20020a5d58cd000000b0033db8721c1bmr7385349wrf.23.1709046704756;\n Tue, 27 Feb 2024 07:11:44 -0800 (PST)", + "From": "Puranjay Mohan ", + "To": "Catalin Marinas ,\n\tWill Deacon ,\n\tAlexei Starovoitov ,\n\tDaniel Borkmann ,\n\tAndrii Nakryiko ,\n\tMartin KaFai Lau ,\n\tEduard Zingerman ,\n\tSong Liu ,\n\tYonghong Song ,\n\tJohn Fastabend ,\n\tKP Singh ,\n\tStanislav Fomichev ,\n\tHao Luo ,\n\tJiri Olsa ,\n\tZi Shen Lim ,\n\tMark Rutland ,\n\tSuzuki K Poulose ,\n\tMark Brown ,\n\tlinux-arm-kernel@lists.infradead.org,\n\tlinux-kernel@vger.kernel.org (open list),\n\tbpf@vger.kernel.org (open list:BPF [GENERAL] (Safe Dynamic Programs and\n Tools)),\n\tJosh Poimboeuf ", + "Cc": "puranjay12@gmail.com", + "Subject": "[PATCH bpf-next 1/1] arm64/cfi,bpf: Support kCFI + BPF on arm64", + "Date": "Tue, 27 Feb 2024 15:11:15 +0000", + "Message-Id": "<20240227151115.4623-2-puranjay12@gmail.com>", + "X-Mailer": "git-send-email 2.40.1", + "In-Reply-To": "<20240227151115.4623-1-puranjay12@gmail.com>", + "References": "<20240227151115.4623-1-puranjay12@gmail.com>", + "Precedence": "bulk", + "X-Mailing-List": "bpf@vger.kernel.org", + "List-Id": "", + "List-Subscribe": "", + "List-Unsubscribe": "", + "MIME-Version": "1.0", + "Content-Transfer-Encoding": "8bit", + "X-Patchwork-Delegate": "bpf@iogearbox.net" + }, + "content": "Currently, bpf_dispatcher_*_func() is marked with `__nocfi` therefore\ncalling BPF programs from this interface doesn't cause CFI warnings.\n\nWhen BPF programs are called directly from C: from BPF helpers or\nstruct_ops, CFI warnings are generated.\n\nImplement proper CFI prologues for the BPF programs and callbacks and\ndrop __nocfi for arm64. Fix the trampoline generation code to emit kCFI\nprologue when a struct_ops trampoline is being prepared.\n\nSigned-off-by: Puranjay Mohan \n---\n arch/arm64/include/asm/cfi.h | 23 ++++++++++++++\n arch/arm64/kernel/alternative.c | 54 +++++++++++++++++++++++++++++++++\n arch/arm64/net/bpf_jit_comp.c | 26 ++++++++++++----\n 3 files changed, 97 insertions(+), 6 deletions(-)\n create mode 100644 arch/arm64/include/asm/cfi.h", + "diff": "diff --git a/arch/arm64/include/asm/cfi.h b/arch/arm64/include/asm/cfi.h\nnew file mode 100644\nindex 000000000000..670e191f8628\n--- /dev/null\n+++ b/arch/arm64/include/asm/cfi.h\n@@ -0,0 +1,23 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+#ifndef _ASM_ARM64_CFI_H\n+#define _ASM_ARM64_CFI_H\n+\n+#ifdef CONFIG_CFI_CLANG\n+#define __bpfcall\n+static inline int cfi_get_offset(void)\n+{\n+\treturn 4;\n+}\n+#define cfi_get_offset cfi_get_offset\n+extern u32 cfi_bpf_hash;\n+extern u32 cfi_bpf_subprog_hash;\n+extern u32 cfi_get_func_hash(void *func);\n+#else\n+#define cfi_bpf_hash 0U\n+#define cfi_bpf_subprog_hash 0U\n+static inline u32 cfi_get_func_hash(void *func)\n+{\n+\treturn 0;\n+}\n+#endif /* CONFIG_CFI_CLANG */\n+#endif /* _ASM_ARM64_CFI_H */\ndiff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c\nindex 8ff6610af496..350057a28abe 100644\n--- a/arch/arm64/kernel/alternative.c\n+++ b/arch/arm64/kernel/alternative.c\n@@ -13,6 +13,7 @@\n #include \n #include \n #include \n+#include \n #include \n #include \n #include \n@@ -298,3 +299,56 @@ noinstr void alt_cb_patch_nops(struct alt_instr *alt, __le32 *origptr,\n \t\tupdptr[i] = cpu_to_le32(aarch64_insn_gen_nop());\n }\n EXPORT_SYMBOL(alt_cb_patch_nops);\n+\n+#ifdef CONFIG_CFI_CLANG\n+struct bpf_insn;\n+\n+/* Must match bpf_func_t / DEFINE_BPF_PROG_RUN() */\n+extern unsigned int __bpf_prog_runX(const void *ctx,\n+\t\t\t\t const struct bpf_insn *insn);\n+\n+/*\n+ * Force a reference to the external symbol so the compiler generates\n+ * __kcfi_typid.\n+ */\n+__ADDRESSABLE(__bpf_prog_runX);\n+\n+/* u32 __ro_after_init cfi_bpf_hash = __kcfi_typeid___bpf_prog_runX; */\n+asm (\n+\"\t.pushsection\t.data..ro_after_init,\\\"aw\\\",@progbits\t\\n\"\n+\"\t.type\tcfi_bpf_hash,@object\t\t\t\t\\n\"\n+\"\t.globl\tcfi_bpf_hash\t\t\t\t\t\\n\"\n+\"\t.p2align\t2, 0x0\t\t\t\t\t\\n\"\n+\"cfi_bpf_hash:\t\t\t\t\t\t\t\\n\"\n+\"\t.long\t__kcfi_typeid___bpf_prog_runX\t\t\t\\n\"\n+\"\t.size\tcfi_bpf_hash, 4\t\t\t\t\t\\n\"\n+\"\t.popsection\t\t\t\t\t\t\\n\"\n+);\n+\n+/* Must match bpf_callback_t */\n+extern u64 __bpf_callback_fn(u64, u64, u64, u64, u64);\n+\n+__ADDRESSABLE(__bpf_callback_fn);\n+\n+/* u32 __ro_after_init cfi_bpf_subprog_hash = __kcfi_typeid___bpf_callback_fn; */\n+asm (\n+\"\t.pushsection\t.data..ro_after_init,\\\"aw\\\",@progbits\t\\n\"\n+\"\t.type\tcfi_bpf_subprog_hash,@object\t\t\t\\n\"\n+\"\t.globl\tcfi_bpf_subprog_hash\t\t\t\t\\n\"\n+\"\t.p2align\t2, 0x0\t\t\t\t\t\\n\"\n+\"cfi_bpf_subprog_hash:\t\t\t\t\t\t\\n\"\n+\"\t.word\t__kcfi_typeid___bpf_callback_fn\t\t\t\\n\"\n+\"\t.size\tcfi_bpf_subprog_hash, 4\t\t\t\t\\n\"\n+\"\t.popsection\t\t\t\t\t\t\\n\"\n+);\n+\n+u32 cfi_get_func_hash(void *func)\n+{\n+\tu32 hash;\n+\n+\tif (get_kernel_nofault(hash, func - cfi_get_offset()))\n+\t\treturn 0;\n+\n+\treturn hash;\n+}\n+#endif\ndiff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c\nindex cfd5434de483..fb02862e1a3a 100644\n--- a/arch/arm64/net/bpf_jit_comp.c\n+++ b/arch/arm64/net/bpf_jit_comp.c\n@@ -17,6 +17,7 @@\n #include \n #include \n #include \n+#include \n #include \n #include \n #include \n@@ -157,6 +158,12 @@ static inline void emit_bti(u32 insn, struct jit_ctx *ctx)\n \t\temit(insn, ctx);\n }\n \n+static inline void emit_kcfi(u32 hash, struct jit_ctx *ctx)\n+{\n+\tif (IS_ENABLED(CONFIG_CFI_CLANG))\n+\t\temit(hash, ctx);\n+}\n+\n /*\n * Kernel addresses in the vmalloc space use at most 48 bits, and the\n * remaining bits are guaranteed to be 0x1. So we can compose the address\n@@ -285,7 +292,7 @@ static bool is_lsi_offset(int offset, int scale)\n /* Tail call offset to jump into */\n #define PROLOGUE_OFFSET (BTI_INSNS + 2 + PAC_INSNS + 8)\n \n-static int build_prologue(struct jit_ctx *ctx, bool ebpf_from_cbpf)\n+static int build_prologue(struct jit_ctx *ctx, bool ebpf_from_cbpf, bool is_subprog)\n {\n \tconst struct bpf_prog *prog = ctx->prog;\n \tconst bool is_main_prog = !bpf_is_subprog(prog);\n@@ -296,7 +303,6 @@ static int build_prologue(struct jit_ctx *ctx, bool ebpf_from_cbpf)\n \tconst u8 fp = bpf2a64[BPF_REG_FP];\n \tconst u8 tcc = bpf2a64[TCALL_CNT];\n \tconst u8 fpb = bpf2a64[FP_BOTTOM];\n-\tconst int idx0 = ctx->idx;\n \tint cur_offset;\n \n \t/*\n@@ -322,6 +328,8 @@ static int build_prologue(struct jit_ctx *ctx, bool ebpf_from_cbpf)\n \t *\n \t */\n \n+\temit_kcfi(is_subprog ? cfi_bpf_subprog_hash : cfi_bpf_hash, ctx);\n+\tconst int idx0 = ctx->idx;\n \t/* bpf function may be invoked by 3 instruction types:\n \t * 1. bl, attached via freplace to bpf prog via short jump\n \t * 2. br, attached via freplace to bpf prog via long jump\n@@ -1575,7 +1583,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)\n \t * BPF line info needs ctx->offset[i] to be the offset of\n \t * instruction[i] in jited image, so build prologue first.\n \t */\n-\tif (build_prologue(&ctx, was_classic)) {\n+\tif (build_prologue(&ctx, was_classic, bpf_is_subprog(prog))) {\n \t\tprog = orig_prog;\n \t\tgoto out_off;\n \t}\n@@ -1614,7 +1622,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)\n \tctx.idx = 0;\n \tctx.exentry_idx = 0;\n \n-\tbuild_prologue(&ctx, was_classic);\n+\tbuild_prologue(&ctx, was_classic, bpf_is_subprog(prog));\n \n \tif (build_body(&ctx, extra_pass)) {\n \t\tbpf_jit_binary_free(header);\n@@ -1654,9 +1662,9 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)\n \t\tjit_data->image = image_ptr;\n \t\tjit_data->header = header;\n \t}\n-\tprog->bpf_func = (void *)ctx.image;\n+\tprog->bpf_func = (void *)ctx.image + cfi_get_offset();\n \tprog->jited = 1;\n-\tprog->jited_len = prog_size;\n+\tprog->jited_len = prog_size - cfi_get_offset();\n \n \tif (!prog->is_func || extra_pass) {\n \t\tint i;\n@@ -1905,6 +1913,12 @@ static int prepare_trampoline(struct jit_ctx *ctx, struct bpf_tramp_image *im,\n \t/* return address locates above FP */\n \tretaddr_off = stack_size + 8;\n \n+\tif (flags & BPF_TRAMP_F_INDIRECT) {\n+\t\t/*\n+\t\t * Indirect call for bpf_struct_ops\n+\t\t */\n+\t\temit_kcfi(cfi_get_func_hash(func_addr), ctx);\n+\t}\n \t/* bpf trampoline may be invoked by 3 instruction types:\n \t * 1. bl, attached to bpf prog or kernel function via short jump\n \t * 2. br, attached to bpf prog or kernel function via long jump\n", + "prefixes": [ + "bpf-next", + "1/1" + ] +} diff --git a/tests/data/test_latest_series_real_sample/patch-14165572.json b/tests/data/test_latest_series_real_sample/patch-14165572.json new file mode 100644 index 0000000..371dfe8 --- /dev/null +++ b/tests/data/test_latest_series_real_sample/patch-14165572.json @@ -0,0 +1,100 @@ +{ + "id": 14165572, + "url": "https://patchwork.kernel.org/api/1.1/patches/14165572/", + "web_url": "https://patchwork.kernel.org/project/netdevbpf/patch/20250722205357.3347626-6-samitolvanen@google.com/", + "project": { + "id": 399, + "url": "https://patchwork.kernel.org/api/1.1/projects/399/", + "name": "Netdev + BPF", + "link_name": "netdevbpf", + "list_id": "bpf.vger.kernel.org", + "list_email": "bpf@vger.kernel.org", + "web_url": "", + "scm_url": "", + "webscm_url": "" + }, + "msgid": "<20250722205357.3347626-6-samitolvanen@google.com>", + "date": "2025-07-22T20:53:59", + "name": "[bpf-next,v13,1/3] cfi: add C CFI type macro", + "commit_ref": null, + "pull_url": null, + "state": "new", + "archived": false, + "hash": "7c2f280f9792ec91d1175c9d3364e04d6342d650", + "submitter": { + "id": 126311, + "url": "https://patchwork.kernel.org/api/1.1/people/126311/", + "name": "Sami Tolvanen", + "email": "samitolvanen@google.com" + }, + "delegate": { + "id": 121173, + "url": "https://patchwork.kernel.org/api/1.1/users/121173/", + "username": "bpf", + "first_name": "BPF", + "last_name": "", + "email": "bpf@iogearbox.net" + }, + "mbox": "https://patchwork.kernel.org/project/netdevbpf/patch/20250722205357.3347626-6-samitolvanen@google.com/mbox/", + "series": [ + { + "id": 984880, + "url": "https://patchwork.kernel.org/api/1.1/series/984880/", + "web_url": "https://patchwork.kernel.org/project/netdevbpf/list/?series=984880", + "date": "2025-07-22T20:53:58", + "name": "Support kCFI + BPF on arm64", + "version": 13, + "mbox": "https://patchwork.kernel.org/series/984880/mbox/" + } + ], + "comments": "https://patchwork.kernel.org/api/patches/14165572/comments/", + "check": "warning", + "checks": "https://patchwork.kernel.org/api/patches/14165572/checks/", + "tags": {}, + "headers": { + "Received": [ + "from mail-pf1-f202.google.com (mail-pf1-f202.google.com\n [209.85.210.202])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D092285040\n\tfor ; Tue, 22 Jul 2025 20:54:04 +0000 (UTC)", + "by mail-pf1-f202.google.com with SMTP id\n d2e1a72fcca58-74913385dd8so8428932b3a.0\n for ; Tue, 22 Jul 2025 13:54:04 -0700 (PDT)" + ], + "Authentication-Results": [ + "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.210.202", + "smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=google.com", + "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=flex--samitolvanen.bounces.google.com", + "smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=google.com header.i=@google.com\n header.b=\"t1m50MBX\"" + ], + "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1753217646; cv=none;\n b=GAfN6AqBc5SV2z3trXgVD+9efiAGevy6lNcw6pKISIu58e9fqwJFXMANZOzEzN9mJA0vDvAh8OiJ3DdtC8Grwf6D+uMBL9v44x7hKGkf8yxv/lNeZVYDiIgYO01yOlgl0r6dJf1YGIMUBYArVEVAAZEqwsb0cYRIPMQXYWsTsdw=", + "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1753217646; c=relaxed/simple;\n\tbh=zd5DznBVI4sVvso/l/68ScJA/RSIQeiYIJRJ5CEjGgY=;\n\th=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From:\n\t To:Cc:Content-Type;\n b=KLLy/QdYDw/j6+ekJfUrUdbOvcjCF0agDSR+t/eE1sfSOzzB97FkrjBDI1wE4x4ylykHGv9C90xWcVu4eezjl4YKxhJkOR89xqahyYbiPkoiX1jQTADnVrdi4xt0oEFlh64Unrrft/QUT92iRt/ieKdRkIcC9Ewxod34pcD6/a8=", + "ARC-Authentication-Results": "i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=google.com;\n spf=pass smtp.mailfrom=flex--samitolvanen.bounces.google.com;\n dkim=pass (2048-bit key) header.d=google.com header.i=@google.com\n header.b=t1m50MBX; arc=none smtp.client-ip=209.85.210.202", + "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=google.com; s=20230601; t=1753217644; x=1753822444;\n darn=vger.kernel.org;\n h=cc:to:from:subject:message-id:references:mime-version:in-reply-to\n :date:from:to:cc:subject:date:message-id:reply-to;\n bh=ATtT7J3eGVlX0DAsIWIni7wioYwQuHnqhrVZz3llpO4=;\n b=t1m50MBXZZaal5IVGJPr1t0vSbd5dNShxxt06B3FoyuXs6zdkCdof3r9sAl3WN/Oxx\n yZkHUfCAWmDg+Uz2QO93PDRT47gB/DAiXqZQoWGbhiIKqdTu/W2IyzBet+UlpsJL8h2t\n 3r6qtnMaCbpdgluyfy27Gr6Upm4Q979JeJO+MkhtFwk2vLk6yYRwuewZ0MrKWAEGZAoW\n C9iPPDRLQGbpoEOMaRhrJuRYIpUpBNwd1CEZo1VboLkZcrpZkDMhrZTtGXlcKiTb2SqO\n 1w7VpahmcbGkQYR2SXc4SzWPMah6uNCesyJck9jO7UbI4UEAgEKuZW7q4IKO3dyfmJIA\n zEJw==", + "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1753217644; x=1753822444;\n h=cc:to:from:subject:message-id:references:mime-version:in-reply-to\n :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n bh=ATtT7J3eGVlX0DAsIWIni7wioYwQuHnqhrVZz3llpO4=;\n b=aFHgnNtc8gSSHwOq/sW5GIy+MOvx/THzqn7ZjEeMjcLH7mG81gCZcg1W4yCt7CgEot\n KYPNuCL6ZEWXqzdISrCqMXeYWpGoxA8mLrliGC7OH5AYAah5FfUZxhlG5dNbFz+Q5PtW\n LERO82v7cyWvILot7+MjvtqBFdSHv5dbUld14HtPIApQ+jWhoeNfcBYleMONYBglnjU8\n fVsSOzwrMA1p9foN8rWdjusFoiGPpjrRXR/zKprYp6Ou+Nhb3IAHM4KRWfCu1A8MU4cR\n d0xXNPoYyIXbzXaevYYpSSyZtxEPB+QFgkX+CJwPIWIfadEdDr5NJ0gRu8uyPAeVtqUa\n imJA==", + "X-Gm-Message-State": "AOJu0Yzcz1E03Fv2ZsfugKhcN8v8LbGqDtA+WQq2ix1faOw3mZNuNKfU\n\tJx+ciqG6it5B2HRc8wm77OpaDF/KbBe4gdULG3OS5y+WbePhwJ2IhnuGA64iIW9w5Oo5hHCiAMh\n\thhuxSuUpn5fFCX0Lb1LidO8LaUwO2Y0yJ7esjJq5burkrOVduaenW/eLa8wn7631sYYuSXkehlX\n\tFu2g9dK0pfD+SMYu19mCtU6sV6kUpq6a7mAYaz4mpTxRyo33j+6fJ7Z6bytY7ryYSn", + "X-Google-Smtp-Source": "\n AGHT+IGcJ1yJH0fRzYxlDDUqZBhJPeXzC6DrCDd4ckApy9RMyQ4dsnkHLjAoOoLgwzZvQEvUMtYym8FpF7QRiypohqI=", + "X-Received": "from pfbbe3.prod.google.com\n ([2002:a05:6a00:1f03:b0:748:e071:298a])\n (user=samitolvanen job=prod-delivery.src-stubby-dispatcher) by\n 2002:a05:6a21:b95:b0:220:94b1:f1b8 with SMTP id\n adf61e73a8af0-23d48e6859amr495572637.0.1753217643988;\n Tue, 22 Jul 2025 13:54:03 -0700 (PDT)", + "Date": "Tue, 22 Jul 2025 20:53:59 +0000", + "In-Reply-To": "<20250722205357.3347626-5-samitolvanen@google.com>", + "Precedence": "bulk", + "X-Mailing-List": "bpf@vger.kernel.org", + "List-Id": "", + "List-Subscribe": "", + "List-Unsubscribe": "", + "Mime-Version": "1.0", + "References": "<20250722205357.3347626-5-samitolvanen@google.com>", + "X-Developer-Key": "i=samitolvanen@google.com; a=openpgp;\n fpr=35CCFB63B283D6D3AEB783944CB5F6848BBC56EE", + "X-Developer-Signature": "v=1; a=openpgp-sha256; l=5301;\n i=samitolvanen@google.com;\n h=from:subject; bh=Dmv7MBdL2t4YlIN+ZApIs9QGn/40RNGjIGDoX876EIY=;\n b=owGbwMvMwCUWxa662nLh8irG02pJDBn1v9LqNh54s6quo15jb5tZrkxbpfL6Jv22VLWgfzd6F\n GTfOOzoKGVhEONikBVTZGn5unrr7u9Oqa8+F0nAzGFlAhnCwMUpABOZcoLhn80avWDtm/9ExOK3\n JJcwrNkVbJq/Snrm8S09a9+8MG0wZWNk+CabYXP+em13pVXuzycBPey/Km8+XfDejO2F1Ak+b8+\n F3AA=", + "X-Mailer": "git-send-email 2.50.0.727.gbf7dc18ff4-goog", + "Message-ID": "<20250722205357.3347626-6-samitolvanen@google.com>", + "Subject": "[PATCH bpf-next v13 1/3] cfi: add C CFI type macro", + "From": "Sami Tolvanen ", + "To": "bpf@vger.kernel.org, Puranjay Mohan ,\n\tAlexei Starovoitov , Daniel Borkmann ", + "Cc": "Catalin Marinas , Will Deacon ,\n\tAndrii Nakryiko , Mark Rutland ,\n\tlinux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org,\n\tMaxwell Bland , Sami Tolvanen ,\n\tDao Huang ", + "Content-Type": "text/plain; charset=\"UTF-8\"", + "X-Patchwork-Delegate": "bpf@iogearbox.net" + }, + "content": "From: Mark Rutland \n\nCurrently x86 and riscv open-code 4 instances of the same logic to\ndefine a u32 variable with the KCFI typeid of a given function.\n\nReplace the duplicate logic with a common macro.\n\nSigned-off-by: Mark Rutland \nCo-developed-by: Maxwell Bland \nSigned-off-by: Maxwell Bland \nCo-developed-by: Sami Tolvanen \nSigned-off-by: Sami Tolvanen \nTested-by: Dao Huang \nAcked-by: Will Deacon \n---\n arch/riscv/kernel/cfi.c | 35 +++--------------------------------\n arch/x86/kernel/alternative.c | 31 +++----------------------------\n include/linux/cfi_types.h | 23 +++++++++++++++++++++++\n 3 files changed, 29 insertions(+), 60 deletions(-)", + "diff": "diff --git a/arch/riscv/kernel/cfi.c b/arch/riscv/kernel/cfi.c\nindex 64bdd3e1ab8c..e7aec5f36dd5 100644\n--- a/arch/riscv/kernel/cfi.c\n+++ b/arch/riscv/kernel/cfi.c\n@@ -4,6 +4,7 @@\n *\n * Copyright (C) 2023 Google LLC\n */\n+#include \n #include \n #include \n \n@@ -82,41 +83,11 @@ struct bpf_insn;\n /* Must match bpf_func_t / DEFINE_BPF_PROG_RUN() */\n extern unsigned int __bpf_prog_runX(const void *ctx,\n \t\t\t\t const struct bpf_insn *insn);\n-\n-/*\n- * Force a reference to the external symbol so the compiler generates\n- * __kcfi_typid.\n- */\n-__ADDRESSABLE(__bpf_prog_runX);\n-\n-/* u32 __ro_after_init cfi_bpf_hash = __kcfi_typeid___bpf_prog_runX; */\n-asm (\n-\"\t.pushsection\t.data..ro_after_init,\\\"aw\\\",@progbits\t\\n\"\n-\"\t.type\tcfi_bpf_hash,@object\t\t\t\t\\n\"\n-\"\t.globl\tcfi_bpf_hash\t\t\t\t\t\\n\"\n-\"\t.p2align\t2, 0x0\t\t\t\t\t\\n\"\n-\"cfi_bpf_hash:\t\t\t\t\t\t\t\\n\"\n-\"\t.word\t__kcfi_typeid___bpf_prog_runX\t\t\t\\n\"\n-\"\t.size\tcfi_bpf_hash, 4\t\t\t\t\t\\n\"\n-\"\t.popsection\t\t\t\t\t\t\\n\"\n-);\n+DEFINE_CFI_TYPE(cfi_bpf_hash, __bpf_prog_runX);\n \n /* Must match bpf_callback_t */\n extern u64 __bpf_callback_fn(u64, u64, u64, u64, u64);\n-\n-__ADDRESSABLE(__bpf_callback_fn);\n-\n-/* u32 __ro_after_init cfi_bpf_subprog_hash = __kcfi_typeid___bpf_callback_fn; */\n-asm (\n-\"\t.pushsection\t.data..ro_after_init,\\\"aw\\\",@progbits\t\\n\"\n-\"\t.type\tcfi_bpf_subprog_hash,@object\t\t\t\\n\"\n-\"\t.globl\tcfi_bpf_subprog_hash\t\t\t\t\\n\"\n-\"\t.p2align\t2, 0x0\t\t\t\t\t\\n\"\n-\"cfi_bpf_subprog_hash:\t\t\t\t\t\t\\n\"\n-\"\t.word\t__kcfi_typeid___bpf_callback_fn\t\t\t\\n\"\n-\"\t.size\tcfi_bpf_subprog_hash, 4\t\t\t\t\\n\"\n-\"\t.popsection\t\t\t\t\t\t\\n\"\n-);\n+DEFINE_CFI_TYPE(cfi_bpf_subprog_hash, __bpf_callback_fn);\n \n u32 cfi_get_func_hash(void *func)\n {\ndiff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c\nindex ea1d984166cd..a555665b4d9c 100644\n--- a/arch/x86/kernel/alternative.c\n+++ b/arch/x86/kernel/alternative.c\n@@ -2,6 +2,7 @@\n #define pr_fmt(fmt) \"SMP alternatives: \" fmt\n \n #include \n+#include \n #include \n #include \n #include \n@@ -1189,37 +1190,11 @@ struct bpf_insn;\n /* Must match bpf_func_t / DEFINE_BPF_PROG_RUN() */\n extern unsigned int __bpf_prog_runX(const void *ctx,\n \t\t\t\t const struct bpf_insn *insn);\n-\n-KCFI_REFERENCE(__bpf_prog_runX);\n-\n-/* u32 __ro_after_init cfi_bpf_hash = __kcfi_typeid___bpf_prog_runX; */\n-asm (\n-\"\t.pushsection\t.data..ro_after_init,\\\"aw\\\",@progbits\t\\n\"\n-\"\t.type\tcfi_bpf_hash,@object\t\t\t\t\\n\"\n-\"\t.globl\tcfi_bpf_hash\t\t\t\t\t\\n\"\n-\"\t.p2align\t2, 0x0\t\t\t\t\t\\n\"\n-\"cfi_bpf_hash:\t\t\t\t\t\t\t\\n\"\n-\"\t.long\t__kcfi_typeid___bpf_prog_runX\t\t\t\\n\"\n-\"\t.size\tcfi_bpf_hash, 4\t\t\t\t\t\\n\"\n-\"\t.popsection\t\t\t\t\t\t\\n\"\n-);\n+DEFINE_CFI_TYPE(cfi_bpf_hash, __bpf_prog_runX);\n \n /* Must match bpf_callback_t */\n extern u64 __bpf_callback_fn(u64, u64, u64, u64, u64);\n-\n-KCFI_REFERENCE(__bpf_callback_fn);\n-\n-/* u32 __ro_after_init cfi_bpf_subprog_hash = __kcfi_typeid___bpf_callback_fn; */\n-asm (\n-\"\t.pushsection\t.data..ro_after_init,\\\"aw\\\",@progbits\t\\n\"\n-\"\t.type\tcfi_bpf_subprog_hash,@object\t\t\t\\n\"\n-\"\t.globl\tcfi_bpf_subprog_hash\t\t\t\t\\n\"\n-\"\t.p2align\t2, 0x0\t\t\t\t\t\\n\"\n-\"cfi_bpf_subprog_hash:\t\t\t\t\t\t\\n\"\n-\"\t.long\t__kcfi_typeid___bpf_callback_fn\t\t\t\\n\"\n-\"\t.size\tcfi_bpf_subprog_hash, 4\t\t\t\t\\n\"\n-\"\t.popsection\t\t\t\t\t\t\\n\"\n-);\n+DEFINE_CFI_TYPE(cfi_bpf_subprog_hash, __bpf_callback_fn);\n \n u32 cfi_get_func_hash(void *func)\n {\ndiff --git a/include/linux/cfi_types.h b/include/linux/cfi_types.h\nindex 6b8713675765..685f7181780f 100644\n--- a/include/linux/cfi_types.h\n+++ b/include/linux/cfi_types.h\n@@ -41,5 +41,28 @@\n \tSYM_TYPED_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)\n #endif\n \n+#else /* __ASSEMBLY__ */\n+\n+#ifdef CONFIG_CFI_CLANG\n+#define DEFINE_CFI_TYPE(name, func)\t\t\t\t\t\t\\\n+\t/*\t\t\t\t\t\t\t\t\t\\\n+\t * Force a reference to the function so the compiler generates\t\t\\\n+\t * __kcfi_typeid_.\t\t\t\t\t\t\\\n+\t */\t\t\t\t\t\t\t\t\t\\\n+\t__ADDRESSABLE(func);\t\t\t\t\t\t\t\\\n+\t/* u32 name __ro_after_init = __kcfi_typeid_ */\t\t\t\\\n+\textern u32 name;\t\t\t\t\t\t\t\\\n+\tasm (\t\t\t\t\t\t\t\t\t\\\n+\t\"\t.pushsection\t.data..ro_after_init,\\\"aw\\\",\\%progbits\t\\n\"\t\\\n+\t\"\t.type\t\" #name \",\\%object\t\t\t\t\\n\"\t\\\n+\t\"\t.globl\t\" #name \"\t\t\t\t\t\\n\"\t\\\n+\t\"\t.p2align\t2, 0x0\t\t\t\t\t\\n\"\t\\\n+\t#name \":\t\t\t\t\t\t\t\\n\"\t\\\n+\t\"\t.4byte\t__kcfi_typeid_\" #func \"\t\t\t\t\\n\"\t\\\n+\t\"\t.size\t\" #name \", 4\t\t\t\t\t\\n\"\t\\\n+\t\"\t.popsection\t\t\t\t\t\t\\n\"\t\\\n+\t);\n+#endif\n+\n #endif /* __ASSEMBLY__ */\n #endif /* _LINUX_CFI_TYPES_H */\n", + "prefixes": [ + "bpf-next", + "v13", + "1/3" + ] +} diff --git a/tests/data/test_latest_series_real_sample/patch-14165573.json b/tests/data/test_latest_series_real_sample/patch-14165573.json new file mode 100644 index 0000000..7dc2a5c --- /dev/null +++ b/tests/data/test_latest_series_real_sample/patch-14165573.json @@ -0,0 +1,100 @@ +{ + "id": 14165573, + "url": "https://patchwork.kernel.org/api/1.1/patches/14165573/", + "web_url": "https://patchwork.kernel.org/project/netdevbpf/patch/20250722205357.3347626-7-samitolvanen@google.com/", + "project": { + "id": 399, + "url": "https://patchwork.kernel.org/api/1.1/projects/399/", + "name": "Netdev + BPF", + "link_name": "netdevbpf", + "list_id": "bpf.vger.kernel.org", + "list_email": "bpf@vger.kernel.org", + "web_url": "", + "scm_url": "", + "webscm_url": "" + }, + "msgid": "<20250722205357.3347626-7-samitolvanen@google.com>", + "date": "2025-07-22T20:54:00", + "name": "[bpf-next,v13,2/3] cfi: Move BPF CFI types and helpers to generic code", + "commit_ref": null, + "pull_url": null, + "state": "new", + "archived": false, + "hash": "272ba9b28a13c06828be302debc3c426e63309b0", + "submitter": { + "id": 126311, + "url": "https://patchwork.kernel.org/api/1.1/people/126311/", + "name": "Sami Tolvanen", + "email": "samitolvanen@google.com" + }, + "delegate": { + "id": 121173, + "url": "https://patchwork.kernel.org/api/1.1/users/121173/", + "username": "bpf", + "first_name": "BPF", + "last_name": "", + "email": "bpf@iogearbox.net" + }, + "mbox": "https://patchwork.kernel.org/project/netdevbpf/patch/20250722205357.3347626-7-samitolvanen@google.com/mbox/", + "series": [ + { + "id": 984880, + "url": "https://patchwork.kernel.org/api/1.1/series/984880/", + "web_url": "https://patchwork.kernel.org/project/netdevbpf/list/?series=984880", + "date": "2025-07-22T20:53:58", + "name": "Support kCFI + BPF on arm64", + "version": 13, + "mbox": "https://patchwork.kernel.org/series/984880/mbox/" + } + ], + "comments": "https://patchwork.kernel.org/api/patches/14165573/comments/", + "check": "warning", + "checks": "https://patchwork.kernel.org/api/patches/14165573/checks/", + "tags": {}, + "headers": { + "Received": [ + "from mail-pf1-f201.google.com (mail-pf1-f201.google.com\n [209.85.210.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 5495D285CB5\n\tfor ; Tue, 22 Jul 2025 20:54:06 +0000 (UTC)", + "by mail-pf1-f201.google.com with SMTP id\n d2e1a72fcca58-748d96b974cso5564540b3a.2\n for ; Tue, 22 Jul 2025 13:54:06 -0700 (PDT)" + ], + "Authentication-Results": [ + "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.210.201", + "smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=google.com", + "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=flex--samitolvanen.bounces.google.com", + "smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=google.com header.i=@google.com\n header.b=\"v5rGBMRX\"" + ], + "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1753217647; cv=none;\n b=GdFAUAqvs0ZHySVEQLy9WKnSzH9whcq6zjsnhrnX4YERQIByWzsChaogWWdJGFDPdkCqyHF0LqCCKxFCZQvDo+wlao54qC7cSmw8SpxV20FIW7cuRRF8T7RdzXR3zK3dN9AE3uuGnmV55nkORjeFoqBzOTXWJ14FLXk/bouENnA=", + "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1753217647; c=relaxed/simple;\n\tbh=8sqyVESEJUMNiJl/uCjzhPfl9OVRxgVUJjpXrAl5Bgs=;\n\th=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From:\n\t To:Cc:Content-Type;\n b=VBI6ipqCsI7Ozh0BVZ1cAKVWwoAoOKslgtmgBRTpYOPfR6virx4lbirwhkjbWTgDJJLKD097VejgskHVBHVbOde2j1ZhHKNahTUuHqHjGZdFvlAbMOsYiB5OV9wk3LLwIz2crZetZuM0+jSP2BhduIMiMdHd3K0vXvitwu8cP2g=", + "ARC-Authentication-Results": "i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=google.com;\n spf=pass smtp.mailfrom=flex--samitolvanen.bounces.google.com;\n dkim=pass (2048-bit key) header.d=google.com header.i=@google.com\n header.b=v5rGBMRX; arc=none smtp.client-ip=209.85.210.201", + "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=google.com; s=20230601; t=1753217646; x=1753822446;\n darn=vger.kernel.org;\n h=cc:to:from:subject:message-id:references:mime-version:in-reply-to\n :date:from:to:cc:subject:date:message-id:reply-to;\n bh=FfCLGywMG5rCOsx3g823MlhxRQ/vXUvg0nXF69NJcN8=;\n b=v5rGBMRXhel4f5/79ABzyrmm8d3Tj9TZk8DuqrN/XNTNYyEOGqhN1kF1go3jSmu8qM\n gUuUApIwi8FY3PEJwzpq5TyUTRQOLQ03eJiDCvVGmE19Hl0BAvqLuYq6lIMGn0pVPOfU\n QuOHWgssT8kDDy+kgTFJvjxrQ6vd/r1TVYKuOsVzqlLPLQzGIoKKGW+zGbXxUERqrd7Z\n 8Ieaj6N+FIY2v5S1aZD3IRoajH6PGSPMgc2d8OOLJC9/1lMZ6K+SUVDhGISDzM/fYjb8\n a+J7B00B0zPQRL4LPK70cxfxcQuRRgJTTf88qs0D1PkxUZpCwSPeXRc6BHmmuJxAJTQX\n fu5w==", + "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1753217646; x=1753822446;\n h=cc:to:from:subject:message-id:references:mime-version:in-reply-to\n :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n bh=FfCLGywMG5rCOsx3g823MlhxRQ/vXUvg0nXF69NJcN8=;\n b=rEQMHkru3xO32I63uSCWxalhhiyMgoU9+0uyJ9Xr2yls2Bh4XDoOVT5cwL7g+H1l5g\n VWV2ClxRyuarkPy4QHfzKdgQqxAvqwLTkmX5Z6XYXi7MR1QPftEdZaWksA44mpNrMMK7\n CVmIae+1ImP35WHXya7wVnlAJnQk9f8puY41eh1TNR3Vu8q9PhspNrFtUP54KZg3FIRo\n fbAmIuSHIYHHiQNjt/WwK2F6Q2sDOo0POQkC9C9J+s/QRJai4cN0iuqmX42ckRE2SjNQ\n JuOIWFcV3IVQVKDQLJijKsXJJZ7JrikOfR8DwuZs73BEVmyC6yuveLjKvWCatrrMJUpK\n Wx3w==", + "X-Gm-Message-State": "AOJu0YzzWpx5Ec/PrH5vmawX/oqUMvSurM82LbkVLmIYiFYut1ktdr24\n\tSWCkiqmdnK+4C2/n+KVVMBBMchu59Itx0jYMklBxfyQGgIEGqqvavJvNXzXbK4q47Wf3Ha6DbCF\n\tReZUaLG6BhMFCrNP+IJEA+qsqAi4J6gOgODl3OIfV9NHmaY/50b42Y9HkyvBK9qh8eGVyS85d1k\n\tIh6gRHMNWTsUeKUyTiR6YqiCxANtbrfCqdTxQZkBIHq19WUrgBMRwUmXYDJWSbm12j", + "X-Google-Smtp-Source": "\n AGHT+IGj2mYJDItRw3m2soeh8qmNL3HkKmMm41UrOhWIIYH3X5YCpMlu0vttpjV7e4JBGv0PmXpCRcx9gMgupcUb7yo=", + "X-Received": "from pfbce15.prod.google.com\n ([2002:a05:6a00:2a0f:b0:749:937:54c8])\n (user=samitolvanen job=prod-delivery.src-stubby-dispatcher) by\n 2002:a05:6a21:112:b0:234:4b39:182c with SMTP id\n adf61e73a8af0-23d49143ad9mr423743637.38.1753217645576;\n Tue, 22 Jul 2025 13:54:05 -0700 (PDT)", + "Date": "Tue, 22 Jul 2025 20:54:00 +0000", + "In-Reply-To": "<20250722205357.3347626-5-samitolvanen@google.com>", + "Precedence": "bulk", + "X-Mailing-List": "bpf@vger.kernel.org", + "List-Id": "", + "List-Subscribe": "", + "List-Unsubscribe": "", + "Mime-Version": "1.0", + "References": "<20250722205357.3347626-5-samitolvanen@google.com>", + "X-Developer-Key": "i=samitolvanen@google.com; a=openpgp;\n fpr=35CCFB63B283D6D3AEB783944CB5F6848BBC56EE", + "X-Developer-Signature": "v=1; a=openpgp-sha256; l=7400;\n i=samitolvanen@google.com;\n h=from:subject; bh=8sqyVESEJUMNiJl/uCjzhPfl9OVRxgVUJjpXrAl5Bgs=;\n b=owGbwMvMwCUWxa662nLh8irG02pJDBn1v9LubhOs9bG86TVvvUGxxO87f2/x30p4zuy/IZlJf\n ENdZCxLRykLgxgXg6yYIkvL19Vbd393Sn31uUgCZg4rE8gQBi5OAZjIOkdGhvMK0/mtvrC8dNX8\n KlhQzRtbFsHivCigU+/XVQOXY2deKjMyvGANl2vkbW697vV5pemOmT0/rxlq21S3B9gIsd0rK/X\n hAwA=", + "X-Mailer": "git-send-email 2.50.0.727.gbf7dc18ff4-goog", + "Message-ID": "<20250722205357.3347626-7-samitolvanen@google.com>", + "Subject": "[PATCH bpf-next v13 2/3] cfi: Move BPF CFI types and helpers to\n generic code", + "From": "Sami Tolvanen ", + "To": "bpf@vger.kernel.org, Puranjay Mohan ,\n\tAlexei Starovoitov , Daniel Borkmann ", + "Cc": "Catalin Marinas , Will Deacon ,\n\tAndrii Nakryiko , Mark Rutland ,\n\tlinux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org,\n\tMaxwell Bland , Sami Tolvanen ", + "Content-Type": "text/plain; charset=\"UTF-8\"", + "X-Patchwork-Delegate": "bpf@iogearbox.net" + }, + "content": "Instead of duplicating the same code for each architecture, move\nthe CFI type hash variables for BPF function types and related\nhelper functions to generic CFI code, and allow architectures to\noverride the function definitions if needed.\n\nSigned-off-by: Sami Tolvanen \n---\n arch/riscv/include/asm/cfi.h | 16 ------------\n arch/riscv/kernel/cfi.c | 24 ------------------\n arch/x86/include/asm/cfi.h | 10 ++------\n arch/x86/kernel/alternative.c | 12 ---------\n include/linux/cfi.h | 47 +++++++++++++++++++++++++++++------\n kernel/cfi.c | 15 +++++++++++\n 6 files changed, 56 insertions(+), 68 deletions(-)", + "diff": "diff --git a/arch/riscv/include/asm/cfi.h b/arch/riscv/include/asm/cfi.h\nindex fb9696d7a3f2..4508aaa7a2fd 100644\n--- a/arch/riscv/include/asm/cfi.h\n+++ b/arch/riscv/include/asm/cfi.h\n@@ -14,27 +14,11 @@ struct pt_regs;\n #ifdef CONFIG_CFI_CLANG\n enum bug_trap_type handle_cfi_failure(struct pt_regs *regs);\n #define __bpfcall\n-static inline int cfi_get_offset(void)\n-{\n-\treturn 4;\n-}\n-\n-#define cfi_get_offset cfi_get_offset\n-extern u32 cfi_bpf_hash;\n-extern u32 cfi_bpf_subprog_hash;\n-extern u32 cfi_get_func_hash(void *func);\n #else\n static inline enum bug_trap_type handle_cfi_failure(struct pt_regs *regs)\n {\n \treturn BUG_TRAP_TYPE_NONE;\n }\n-\n-#define cfi_bpf_hash 0U\n-#define cfi_bpf_subprog_hash 0U\n-static inline u32 cfi_get_func_hash(void *func)\n-{\n-\treturn 0;\n-}\n #endif /* CONFIG_CFI_CLANG */\n \n #endif /* _ASM_RISCV_CFI_H */\ndiff --git a/arch/riscv/kernel/cfi.c b/arch/riscv/kernel/cfi.c\nindex e7aec5f36dd5..6ec9dbd7292e 100644\n--- a/arch/riscv/kernel/cfi.c\n+++ b/arch/riscv/kernel/cfi.c\n@@ -4,7 +4,6 @@\n *\n * Copyright (C) 2023 Google LLC\n */\n-#include \n #include \n #include \n \n@@ -76,26 +75,3 @@ enum bug_trap_type handle_cfi_failure(struct pt_regs *regs)\n \n \treturn report_cfi_failure(regs, regs->epc, &target, type);\n }\n-\n-#ifdef CONFIG_CFI_CLANG\n-struct bpf_insn;\n-\n-/* Must match bpf_func_t / DEFINE_BPF_PROG_RUN() */\n-extern unsigned int __bpf_prog_runX(const void *ctx,\n-\t\t\t\t const struct bpf_insn *insn);\n-DEFINE_CFI_TYPE(cfi_bpf_hash, __bpf_prog_runX);\n-\n-/* Must match bpf_callback_t */\n-extern u64 __bpf_callback_fn(u64, u64, u64, u64, u64);\n-DEFINE_CFI_TYPE(cfi_bpf_subprog_hash, __bpf_callback_fn);\n-\n-u32 cfi_get_func_hash(void *func)\n-{\n-\tu32 hash;\n-\n-\tif (get_kernel_nofault(hash, func - cfi_get_offset()))\n-\t\treturn 0;\n-\n-\treturn hash;\n-}\n-#endif\ndiff --git a/arch/x86/include/asm/cfi.h b/arch/x86/include/asm/cfi.h\nindex 3e51ba459154..1751f1eb95ef 100644\n--- a/arch/x86/include/asm/cfi.h\n+++ b/arch/x86/include/asm/cfi.h\n@@ -116,8 +116,6 @@ struct pt_regs;\n #ifdef CONFIG_CFI_CLANG\n enum bug_trap_type handle_cfi_failure(struct pt_regs *regs);\n #define __bpfcall\n-extern u32 cfi_bpf_hash;\n-extern u32 cfi_bpf_subprog_hash;\n \n static inline int cfi_get_offset(void)\n {\n@@ -135,6 +133,8 @@ static inline int cfi_get_offset(void)\n #define cfi_get_offset cfi_get_offset\n \n extern u32 cfi_get_func_hash(void *func);\n+#define cfi_get_func_hash cfi_get_func_hash\n+\n extern int cfi_get_func_arity(void *func);\n \n #ifdef CONFIG_FINEIBT\n@@ -153,12 +153,6 @@ static inline enum bug_trap_type handle_cfi_failure(struct pt_regs *regs)\n {\n \treturn BUG_TRAP_TYPE_NONE;\n }\n-#define cfi_bpf_hash 0U\n-#define cfi_bpf_subprog_hash 0U\n-static inline u32 cfi_get_func_hash(void *func)\n-{\n-\treturn 0;\n-}\n static inline int cfi_get_func_arity(void *func)\n {\n \treturn 0;\ndiff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c\nindex a555665b4d9c..9f6b7dab2d9a 100644\n--- a/arch/x86/kernel/alternative.c\n+++ b/arch/x86/kernel/alternative.c\n@@ -2,7 +2,6 @@\n #define pr_fmt(fmt) \"SMP alternatives: \" fmt\n \n #include \n-#include \n #include \n #include \n #include \n@@ -1185,17 +1184,6 @@ bool cfi_bhi __ro_after_init = false;\n #endif\n \n #ifdef CONFIG_CFI_CLANG\n-struct bpf_insn;\n-\n-/* Must match bpf_func_t / DEFINE_BPF_PROG_RUN() */\n-extern unsigned int __bpf_prog_runX(const void *ctx,\n-\t\t\t\t const struct bpf_insn *insn);\n-DEFINE_CFI_TYPE(cfi_bpf_hash, __bpf_prog_runX);\n-\n-/* Must match bpf_callback_t */\n-extern u64 __bpf_callback_fn(u64, u64, u64, u64, u64);\n-DEFINE_CFI_TYPE(cfi_bpf_subprog_hash, __bpf_callback_fn);\n-\n u32 cfi_get_func_hash(void *func)\n {\n \tu32 hash;\ndiff --git a/include/linux/cfi.h b/include/linux/cfi.h\nindex 1db17ecbb86c..52a98886a455 100644\n--- a/include/linux/cfi.h\n+++ b/include/linux/cfi.h\n@@ -11,16 +11,9 @@\n #include \n #include \n \n+#ifdef CONFIG_CFI_CLANG\n extern bool cfi_warn;\n \n-#ifndef cfi_get_offset\n-static inline int cfi_get_offset(void)\n-{\n-\treturn 0;\n-}\n-#endif\n-\n-#ifdef CONFIG_CFI_CLANG\n enum bug_trap_type report_cfi_failure(struct pt_regs *regs, unsigned long addr,\n \t\t\t\t unsigned long *target, u32 type);\n \n@@ -29,6 +22,44 @@ static inline enum bug_trap_type report_cfi_failure_noaddr(struct pt_regs *regs,\n {\n \treturn report_cfi_failure(regs, addr, NULL, 0);\n }\n+\n+#ifndef cfi_get_offset\n+/*\n+ * Returns the CFI prefix offset. By default, the compiler emits only\n+ * a 4-byte CFI type hash before the function. If an architecture\n+ * uses -fpatchable-function-entry=N,M where M>0 to change the prefix\n+ * offset, they must override this function.\n+ */\n+static inline int cfi_get_offset(void)\n+{\n+\treturn 4;\n+}\n+#endif\n+\n+#ifndef cfi_get_func_hash\n+static inline u32 cfi_get_func_hash(void *func)\n+{\n+\tu32 hash;\n+\n+\tif (get_kernel_nofault(hash, func - cfi_get_offset()))\n+\t\treturn 0;\n+\n+\treturn hash;\n+}\n+#endif\n+\n+/* CFI type hashes for BPF function types */\n+extern u32 cfi_bpf_hash;\n+extern u32 cfi_bpf_subprog_hash;\n+\n+#else /* CONFIG_CFI_CLANG */\n+\n+static inline int cfi_get_offset(void) { return 0; }\n+static inline u32 cfi_get_func_hash(void *func) { return 0; }\n+\n+#define cfi_bpf_hash 0U\n+#define cfi_bpf_subprog_hash 0U\n+\n #endif /* CONFIG_CFI_CLANG */\n \n #ifdef CONFIG_ARCH_USES_CFI_TRAPS\ndiff --git a/kernel/cfi.c b/kernel/cfi.c\nindex 422fa4f958ae..4dad04ead06c 100644\n--- a/kernel/cfi.c\n+++ b/kernel/cfi.c\n@@ -5,6 +5,8 @@\n * Copyright (C) 2022 Google LLC\n */\n \n+#include \n+#include \n #include \n \n bool cfi_warn __ro_after_init = IS_ENABLED(CONFIG_CFI_PERMISSIVE);\n@@ -27,6 +29,19 @@ enum bug_trap_type report_cfi_failure(struct pt_regs *regs, unsigned long addr,\n \treturn BUG_TRAP_TYPE_BUG;\n }\n \n+/*\n+ * Declare two non-existent functions with types that match bpf_func_t and\n+ * bpf_callback_t pointers, and use DEFINE_CFI_TYPE to define type hash\n+ * variables for each function type. The cfi_bpf_* variables are used by\n+ * arch-specific BPF JIT implementations to ensure indirectly callable JIT\n+ * code has matching CFI type hashes.\n+ */\n+extern typeof(*(bpf_func_t)0) __bpf_prog_runX;\n+DEFINE_CFI_TYPE(cfi_bpf_hash, __bpf_prog_runX);\n+\n+extern typeof(*(bpf_callback_t)0) __bpf_callback_fn;\n+DEFINE_CFI_TYPE(cfi_bpf_subprog_hash, __bpf_callback_fn);\n+\n #ifdef CONFIG_ARCH_USES_CFI_TRAPS\n static inline unsigned long trap_address(s32 *p)\n {\n", + "prefixes": [ + "bpf-next", + "v13", + "2/3" + ] +} diff --git a/tests/data/test_latest_series_real_sample/patch-14165574.json b/tests/data/test_latest_series_real_sample/patch-14165574.json new file mode 100644 index 0000000..dceaca1 --- /dev/null +++ b/tests/data/test_latest_series_real_sample/patch-14165574.json @@ -0,0 +1,100 @@ +{ + "id": 14165574, + "url": "https://patchwork.kernel.org/api/1.1/patches/14165574/", + "web_url": "https://patchwork.kernel.org/project/netdevbpf/patch/20250722205357.3347626-8-samitolvanen@google.com/", + "project": { + "id": 399, + "url": "https://patchwork.kernel.org/api/1.1/projects/399/", + "name": "Netdev + BPF", + "link_name": "netdevbpf", + "list_id": "bpf.vger.kernel.org", + "list_email": "bpf@vger.kernel.org", + "web_url": "", + "scm_url": "", + "webscm_url": "" + }, + "msgid": "<20250722205357.3347626-8-samitolvanen@google.com>", + "date": "2025-07-22T20:54:01", + "name": "[bpf-next,v13,3/3] arm64/cfi,bpf: Support kCFI + BPF on arm64", + "commit_ref": null, + "pull_url": null, + "state": "new", + "archived": false, + "hash": "1c08b445466fa8ecdd4c3415617170d588ad971c", + "submitter": { + "id": 126311, + "url": "https://patchwork.kernel.org/api/1.1/people/126311/", + "name": "Sami Tolvanen", + "email": "samitolvanen@google.com" + }, + "delegate": { + "id": 121173, + "url": "https://patchwork.kernel.org/api/1.1/users/121173/", + "username": "bpf", + "first_name": "BPF", + "last_name": "", + "email": "bpf@iogearbox.net" + }, + "mbox": "https://patchwork.kernel.org/project/netdevbpf/patch/20250722205357.3347626-8-samitolvanen@google.com/mbox/", + "series": [ + { + "id": 984880, + "url": "https://patchwork.kernel.org/api/1.1/series/984880/", + "web_url": "https://patchwork.kernel.org/project/netdevbpf/list/?series=984880", + "date": "2025-07-22T20:53:58", + "name": "Support kCFI + BPF on arm64", + "version": 13, + "mbox": "https://patchwork.kernel.org/series/984880/mbox/" + } + ], + "comments": "https://patchwork.kernel.org/api/patches/14165574/comments/", + "check": "fail", + "checks": "https://patchwork.kernel.org/api/patches/14165574/checks/", + "tags": {}, + "headers": { + "Received": [ + "from mail-pf1-f202.google.com (mail-pf1-f202.google.com\n [209.85.210.202])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id D4008286439\n\tfor ; Tue, 22 Jul 2025 20:54:07 +0000 (UTC)", + "by mail-pf1-f202.google.com with SMTP id\n d2e1a72fcca58-740774348f6so5721779b3a.1\n for ; Tue, 22 Jul 2025 13:54:07 -0700 (PDT)" + ], + "Authentication-Results": [ + "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.210.202", + "smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=google.com", + "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=flex--samitolvanen.bounces.google.com", + "smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=google.com header.i=@google.com\n header.b=\"xN5WF5sX\"" + ], + "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1753217649; cv=none;\n b=HimP0GEkkwo6rfazSt+stErif8d/1n4zcCMQ8cVtLhW4eYzxVMXTwXUgdstzdruLrHj7dgvkSuKlYCFJLLnWbPnkJas4ImkQsGW/ci6ir3UmyQUn0yMR4AKn1kxqUdbBOHJq5fqvIP+ZsfccQ/YMVesWkW+gzKaKgS8mrPw+JkU=", + "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1753217649; c=relaxed/simple;\n\tbh=66hctsnDvcPeo4bcqizkbbYExehSgXT0Gg3yUrHXPfc=;\n\th=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From:\n\t To:Cc:Content-Type;\n b=OsGB20kCq+tGjeyzFyeH5ELTOnnpKYOTq2cfEWsfdtWdrQnGgc8a6mo4+yi2ilSCzcrFDSK+HiStEWWQb4kAHrMDGYHCCfu8fc2bgNiWPeqVCBJD3OzeEHlyYUHC4vDLzM9KsArZDjWQgShCSjvWRn/voDTnj8zR1s8h4jSPIC4=", + "ARC-Authentication-Results": "i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=google.com;\n spf=pass smtp.mailfrom=flex--samitolvanen.bounces.google.com;\n dkim=pass (2048-bit key) header.d=google.com header.i=@google.com\n header.b=xN5WF5sX; arc=none smtp.client-ip=209.85.210.202", + "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=google.com; s=20230601; t=1753217647; x=1753822447;\n darn=vger.kernel.org;\n h=cc:to:from:subject:message-id:references:mime-version:in-reply-to\n :date:from:to:cc:subject:date:message-id:reply-to;\n bh=v0xky3Tz++dR8wOWXy0XI+fGsD8WnNLUtoliWtDdioM=;\n b=xN5WF5sXn6P7AA42S3lTILffuA9N4fySl2C2qry0n7o/Qo/m11eLOOpTKgvG+mL6kL\n H9WeQhfNjcpnpcHsIx5/ewVB9GQ6HEs8oaU3kqAs/sV/h7NVnphJxuMeKJVnK0znamuA\n rCUmwq/nvO6BCsVde6aDeIFuOYxXoRGq26TaEsRBXhCLoRuVI1jYZw8N/BTO8ELBpoCn\n CI/104+7orPlKfoHJomIaQPF6PnzTnYLsFWYsY2Y9YaC5xe8qhCxFzlWx9sEJKwct+fX\n BSnlJwZCKDMPZ3y+qh78ZuhpGYX4w2kGnwLQ9ysy5vg7to0wqd8hXfPN6V7gBBaXh7kZ\n 51ig==", + "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1753217647; x=1753822447;\n h=cc:to:from:subject:message-id:references:mime-version:in-reply-to\n :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;\n bh=v0xky3Tz++dR8wOWXy0XI+fGsD8WnNLUtoliWtDdioM=;\n b=Rj03hfd7XNUSx8ytP7nj35GJeI5J8djqvE5qzyU+hYHF27oaEHIlIIbWNsF8mKi4hK\n EZQm4ebuvSM8wF34Z3akw8TFY75JHpX7m436KVyYFcT1O6Bd7yFhPA5TrDU7MyKCcZRK\n eDPv7AUXhGQxCPjL/r/nSDJMGatK/7i1Psf83MWX3M9NG46vkDTeuE89Mjz9XKYMcjJn\n PHRzRN2qI8Vcgl9Q9IQXJc9NXFn907DL/j4BiBpaGPCg31F0ek/x6oA5iQaZCBIg5F/q\n t7x4Yy1+mb7pRidL+NR0rpVGdNRnd5XQWiRSKgkTsxh7lWUIc+WW7+G31i3tELU2ZbbJ\n sUcQ==", + "X-Gm-Message-State": "AOJu0YxOyKwI8L4sTztQdYYj2OIOIQoDwIi2tV6pm/xl07NqzeNmAJc/\n\tLgRk76Ga8D8M6kSt68VXlCdNtb3Gev8bnSdVjjHSSLmw+eIRRN1R4um3hdloZ2UmlWFUar4C55r\n\tskTv+FsG/MEgcJNzDn8+sOjtvMhCLE2Zt+ERsdTtF3P7FYnv5nBB7ozoZJ9jc2J4IYskvxXy/R2\n\tNXEXS7mPqq6yAn7Rv795/9aKkfqCzuje3xiHi8RDwE1l2Gm+M8j95MmASCQq2XqojL", + "X-Google-Smtp-Source": "\n AGHT+IH6x4q5kLczvA9H+m286fHAokh7HU92JRe53jNpVYETLy7h6qxVO9bNE0XMECCrfd5TA/Z0QoAyJ5vJf8ucB2k=", + "X-Received": "from pfbha4.prod.google.com\n ([2002:a05:6a00:8504:b0:746:2897:67e3])\n (user=samitolvanen job=prod-delivery.src-stubby-dispatcher) by\n 2002:a05:6a21:1fc3:b0:23d:35f2:4e69 with SMTP id\n adf61e73a8af0-23d490f6100mr432417637.23.1753217647145;\n Tue, 22 Jul 2025 13:54:07 -0700 (PDT)", + "Date": "Tue, 22 Jul 2025 20:54:01 +0000", + "In-Reply-To": "<20250722205357.3347626-5-samitolvanen@google.com>", + "Precedence": "bulk", + "X-Mailing-List": "bpf@vger.kernel.org", + "List-Id": "", + "List-Subscribe": "", + "List-Unsubscribe": "", + "Mime-Version": "1.0", + "References": "<20250722205357.3347626-5-samitolvanen@google.com>", + "X-Developer-Key": "i=samitolvanen@google.com; a=openpgp;\n fpr=35CCFB63B283D6D3AEB783944CB5F6848BBC56EE", + "X-Developer-Signature": "v=1; a=openpgp-sha256; l=4527;\n i=samitolvanen@google.com;\n h=from:subject; bh=V2hbK6L5Ngvs6CaLj1XnAp6J1iiarTYTez80LhYwsI4=;\n b=owGbwMvMwCUWxa662nLh8irG02pJDBn1v9I5n4RtPnZpu4LCIsOEhytmr2wSm7Bl7r4PE5YcN\n AzVFpxh3VHKwiDGxSArpsjS8nX11t3fnVJffS6SgJnDygQyhIGLUwAmwhzCyHA8ZdFRGXGj7H3m\n hcF8nw+xrJNYb3aRyVxu/b1fSybV9aYw/Pe4pPziyteDP3gibqY7T+XMu1ZoJl5VMkO3/+uVq9t\n uHmIHAA==", + "X-Mailer": "git-send-email 2.50.0.727.gbf7dc18ff4-goog", + "Message-ID": "<20250722205357.3347626-8-samitolvanen@google.com>", + "Subject": "[PATCH bpf-next v13 3/3] arm64/cfi,bpf: Support kCFI + BPF on arm64", + "From": "Sami Tolvanen ", + "To": "bpf@vger.kernel.org, Puranjay Mohan ,\n\tAlexei Starovoitov , Daniel Borkmann ", + "Cc": "Catalin Marinas , Will Deacon ,\n\tAndrii Nakryiko , Mark Rutland ,\n\tlinux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org,\n\tMaxwell Bland , Puranjay Mohan ,\n\tSami Tolvanen , Dao Huang ", + "Content-Type": "text/plain; charset=\"UTF-8\"", + "X-Patchwork-Delegate": "bpf@iogearbox.net" + }, + "content": "From: Puranjay Mohan \n\nCurrently, bpf_dispatcher_*_func() is marked with `__nocfi` therefore\ncalling BPF programs from this interface doesn't cause CFI warnings.\n\nWhen BPF programs are called directly from C: from BPF helpers or\nstruct_ops, CFI warnings are generated.\n\nImplement proper CFI prologues for the BPF programs and callbacks and\ndrop __nocfi for arm64. Fix the trampoline generation code to emit kCFI\nprologue when a struct_ops trampoline is being prepared.\n\nSigned-off-by: Puranjay Mohan \nCo-developed-by: Maxwell Bland \nSigned-off-by: Maxwell Bland \nCo-developed-by: Sami Tolvanen \nSigned-off-by: Sami Tolvanen \nTested-by: Dao Huang \nAcked-by: Will Deacon \n---\n arch/arm64/include/asm/cfi.h | 7 +++++++\n arch/arm64/net/bpf_jit_comp.c | 30 +++++++++++++++++++++++++++---\n 2 files changed, 34 insertions(+), 3 deletions(-)\n create mode 100644 arch/arm64/include/asm/cfi.h", + "diff": "diff --git a/arch/arm64/include/asm/cfi.h b/arch/arm64/include/asm/cfi.h\nnew file mode 100644\nindex 000000000000..ab90f0351b7a\n--- /dev/null\n+++ b/arch/arm64/include/asm/cfi.h\n@@ -0,0 +1,7 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+#ifndef _ASM_ARM64_CFI_H\n+#define _ASM_ARM64_CFI_H\n+\n+#define __bpfcall\n+\n+#endif /* _ASM_ARM64_CFI_H */\ndiff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c\nindex 89b1b8c248c6..993b5d6e1525 100644\n--- a/arch/arm64/net/bpf_jit_comp.c\n+++ b/arch/arm64/net/bpf_jit_comp.c\n@@ -10,6 +10,7 @@\n #include \n #include \n #include \n+#include \n #include \n #include \n #include \n@@ -106,6 +107,14 @@ static inline void emit(const u32 insn, struct jit_ctx *ctx)\n \tctx->idx++;\n }\n \n+static inline void emit_u32_data(const u32 data, struct jit_ctx *ctx)\n+{\n+\tif (ctx->image != NULL && ctx->write)\n+\t\tctx->image[ctx->idx] = data;\n+\n+\tctx->idx++;\n+}\n+\n static inline void emit_a64_mov_i(const int is64, const int reg,\n \t\t\t\t const s32 val, struct jit_ctx *ctx)\n {\n@@ -166,6 +175,12 @@ static inline void emit_bti(u32 insn, struct jit_ctx *ctx)\n \t\temit(insn, ctx);\n }\n \n+static inline void emit_kcfi(u32 hash, struct jit_ctx *ctx)\n+{\n+\tif (IS_ENABLED(CONFIG_CFI_CLANG))\n+\t\temit_u32_data(hash, ctx);\n+}\n+\n /*\n * Kernel addresses in the vmalloc space use at most 48 bits, and the\n * remaining bits are guaranteed to be 0x1. So we can compose the address\n@@ -476,7 +491,6 @@ static int build_prologue(struct jit_ctx *ctx, bool ebpf_from_cbpf)\n \tconst bool is_main_prog = !bpf_is_subprog(prog);\n \tconst u8 fp = bpf2a64[BPF_REG_FP];\n \tconst u8 arena_vm_base = bpf2a64[ARENA_VM_START];\n-\tconst int idx0 = ctx->idx;\n \tint cur_offset;\n \n \t/*\n@@ -502,6 +516,9 @@ static int build_prologue(struct jit_ctx *ctx, bool ebpf_from_cbpf)\n \t *\n \t */\n \n+\temit_kcfi(is_main_prog ? cfi_bpf_hash : cfi_bpf_subprog_hash, ctx);\n+\tconst int idx0 = ctx->idx;\n+\n \t/* bpf function may be invoked by 3 instruction types:\n \t * 1. bl, attached via freplace to bpf prog via short jump\n \t * 2. br, attached via freplace to bpf prog via long jump\n@@ -2055,9 +2072,9 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)\n \t\tjit_data->ro_header = ro_header;\n \t}\n \n-\tprog->bpf_func = (void *)ctx.ro_image;\n+\tprog->bpf_func = (void *)ctx.ro_image + cfi_get_offset();\n \tprog->jited = 1;\n-\tprog->jited_len = prog_size;\n+\tprog->jited_len = prog_size - cfi_get_offset();\n \n \tif (!prog->is_func || extra_pass) {\n \t\tint i;\n@@ -2426,6 +2443,12 @@ static int prepare_trampoline(struct jit_ctx *ctx, struct bpf_tramp_image *im,\n \t/* return address locates above FP */\n \tretaddr_off = stack_size + 8;\n \n+\tif (flags & BPF_TRAMP_F_INDIRECT) {\n+\t\t/*\n+\t\t * Indirect call for bpf_struct_ops\n+\t\t */\n+\t\temit_kcfi(cfi_get_func_hash(func_addr), ctx);\n+\t}\n \t/* bpf trampoline may be invoked by 3 instruction types:\n \t * 1. bl, attached to bpf prog or kernel function via short jump\n \t * 2. br, attached to bpf prog or kernel function via long jump\n@@ -2942,6 +2965,7 @@ void bpf_jit_free(struct bpf_prog *prog)\n \t\t\t\t\t sizeof(jit_data->header->size));\n \t\t\tkfree(jit_data);\n \t\t}\n+\t\tprog->bpf_func -= cfi_get_offset();\n \t\thdr = bpf_jit_binary_pack_hdr(prog);\n \t\tbpf_jit_binary_pack_free(hdr, NULL);\n \t\tWARN_ON_ONCE(!bpf_prog_kallsyms_verify_off(prog));\n", + "prefixes": [ + "bpf-next", + "v13", + "3/3" + ] +} diff --git a/tests/data/test_latest_series_real_sample/responses.json b/tests/data/test_latest_series_real_sample/responses.json new file mode 100644 index 0000000..781050f --- /dev/null +++ b/tests/data/test_latest_series_real_sample/responses.json @@ -0,0 +1,18 @@ +{ + "https://patchwork.test/api/1.1/series/830310/": "series-830310.json", + "https://patchwork.test/api/1.1/series/984880/": "series-984880.json", + "https://patchwork.test/api/1.1/patches/13574002/": "patch-13574002.json", + "https://patchwork.test/api/1.1/patches/14165572/": "patch-14165572.json", + "https://patchwork.test/api/1.1/patches/14165573/": "patch-14165573.json", + "https://patchwork.test/api/1.1/patches/14165574/": "patch-14165574.json", + "https://patchwork.test/api/1.1/patches/?archived=False&delegate=121173&project=399&since=2025-07-20T00%253A00%253A00&state=1&state=13&state=15&state=2&state=5&state=7": [ + "patch-13574002.json", + "patch-14165572.json", + "patch-14165573.json", + "patch-14165574.json" + ], + "https://patchwork.test/api/1.1/series/?q=Support+kCFI+%252B+BPF+on+arm64": [ + "series-830310.json", + "series-984880.json" + ] +} diff --git a/tests/data/test_latest_series_real_sample/series-830310.json b/tests/data/test_latest_series_real_sample/series-830310.json new file mode 100644 index 0000000..8f6b92b --- /dev/null +++ b/tests/data/test_latest_series_real_sample/series-830310.json @@ -0,0 +1,49 @@ +{ + "id": 830310, + "url": "https://patchwork.kernel.org/api/1.1/series/830310/", + "web_url": "https://patchwork.kernel.org/project/netdevbpf/list/?series=830310", + "project": { + "id": 399, + "url": "https://patchwork.kernel.org/api/1.1/projects/399/", + "name": "Netdev + BPF", + "link_name": "netdevbpf", + "list_id": "bpf.vger.kernel.org", + "list_email": "bpf@vger.kernel.org", + "web_url": "", + "scm_url": "", + "webscm_url": "" + }, + "name": "Support kCFI + BPF on arm64", + "date": "2024-02-27T15:11:14", + "submitter": { + "id": 186869, + "url": "https://patchwork.kernel.org/api/1.1/people/186869/", + "name": "Puranjay Mohan", + "email": "puranjay12@gmail.com" + }, + "version": 1, + "total": 1, + "received_total": 1, + "received_all": true, + "mbox": "https://patchwork.kernel.org/series/830310/mbox/", + "cover_letter": { + "id": 13574001, + "url": "https://patchwork.kernel.org/api/1.1/covers/13574001/", + "web_url": "https://patchwork.kernel.org/project/netdevbpf/cover/20240227151115.4623-1-puranjay12@gmail.com/", + "msgid": "<20240227151115.4623-1-puranjay12@gmail.com>", + "date": "2024-02-27T15:11:14", + "name": "[bpf-next,0/1] Support kCFI + BPF on arm64", + "mbox": "https://patchwork.kernel.org/project/netdevbpf/cover/20240227151115.4623-1-puranjay12@gmail.com/mbox/" + }, + "patches": [ + { + "id": 13574002, + "url": "https://patchwork.kernel.org/api/1.1/patches/13574002/", + "web_url": "https://patchwork.kernel.org/project/netdevbpf/patch/20240227151115.4623-2-puranjay12@gmail.com/", + "msgid": "<20240227151115.4623-2-puranjay12@gmail.com>", + "date": "2024-02-27T15:11:15", + "name": "[bpf-next,1/1] arm64/cfi,bpf: Support kCFI + BPF on arm64", + "mbox": "https://patchwork.kernel.org/project/netdevbpf/patch/20240227151115.4623-2-puranjay12@gmail.com/mbox/" + } + ] +} diff --git a/tests/data/test_latest_series_real_sample/series-984880.json b/tests/data/test_latest_series_real_sample/series-984880.json new file mode 100644 index 0000000..a3c2105 --- /dev/null +++ b/tests/data/test_latest_series_real_sample/series-984880.json @@ -0,0 +1,67 @@ +{ + "id": 984880, + "url": "https://patchwork.kernel.org/api/1.1/series/984880/", + "web_url": "https://patchwork.kernel.org/project/netdevbpf/list/?series=984880", + "project": { + "id": 399, + "url": "https://patchwork.kernel.org/api/1.1/projects/399/", + "name": "Netdev + BPF", + "link_name": "netdevbpf", + "list_id": "bpf.vger.kernel.org", + "list_email": "bpf@vger.kernel.org", + "web_url": "", + "scm_url": "", + "webscm_url": "" + }, + "name": "Support kCFI + BPF on arm64", + "date": "2025-07-22T20:53:58", + "submitter": { + "id": 126311, + "url": "https://patchwork.kernel.org/api/1.1/people/126311/", + "name": "Sami Tolvanen", + "email": "samitolvanen@google.com" + }, + "version": 13, + "total": 3, + "received_total": 3, + "received_all": true, + "mbox": "https://patchwork.kernel.org/series/984880/mbox/", + "cover_letter": { + "id": 14070911, + "url": "https://patchwork.kernel.org/api/1.1/covers/14070911/", + "web_url": "https://patchwork.kernel.org/project/netdevbpf/cover/20250722205357.3347626-5-samitolvanen@google.com/", + "msgid": "<20250722205357.3347626-5-samitolvanen@google.com>", + "date": "2025-07-22T20:53:58", + "name": "[bpf-next,v13,0/3] Support kCFI + BPF on arm64", + "mbox": "https://patchwork.kernel.org/project/netdevbpf/cover/20250722205357.3347626-5-samitolvanen@google.com/mbox/" + }, + "patches": [ + { + "id": 14165572, + "url": "https://patchwork.kernel.org/api/1.1/patches/14165572/", + "web_url": "https://patchwork.kernel.org/project/netdevbpf/patch/20250722205357.3347626-6-samitolvanen@google.com/", + "msgid": "<20250722205357.3347626-6-samitolvanen@google.com>", + "date": "2025-07-22T20:53:59", + "name": "[bpf-next,v13,1/3] cfi: add C CFI type macro", + "mbox": "https://patchwork.kernel.org/project/netdevbpf/patch/20250722205357.3347626-6-samitolvanen@google.com/mbox/" + }, + { + "id": 14165573, + "url": "https://patchwork.kernel.org/api/1.1/patches/14165573/", + "web_url": "https://patchwork.kernel.org/project/netdevbpf/patch/20250722205357.3347626-7-samitolvanen@google.com/", + "msgid": "<20250722205357.3347626-7-samitolvanen@google.com>", + "date": "2025-07-22T20:54:00", + "name": "[bpf-next,v13,2/3] cfi: Move BPF CFI types and helpers to generic code", + "mbox": "https://patchwork.kernel.org/project/netdevbpf/patch/20250722205357.3347626-7-samitolvanen@google.com/mbox/" + }, + { + "id": 14165574, + "url": "https://patchwork.kernel.org/api/1.1/patches/14165574/", + "web_url": "https://patchwork.kernel.org/project/netdevbpf/patch/20250722205357.3347626-8-samitolvanen@google.com/", + "msgid": "<20250722205357.3347626-8-samitolvanen@google.com>", + "date": "2025-07-22T20:54:01", + "name": "[bpf-next,v13,3/3] arm64/cfi,bpf: Support kCFI + BPF on arm64", + "mbox": "https://patchwork.kernel.org/project/netdevbpf/patch/20250722205357.3347626-8-samitolvanen@google.com/mbox/" + } + ] +} diff --git a/tests/data/test_github_sync.test_sync_patches_pr_summary_success/patch-14114605.json b/tests/data/test_sync_patches_pr_summary_success/patch-14114605.json similarity index 100% rename from tests/data/test_github_sync.test_sync_patches_pr_summary_success/patch-14114605.json rename to tests/data/test_sync_patches_pr_summary_success/patch-14114605.json diff --git a/tests/data/test_github_sync.test_sync_patches_pr_summary_success/patch-14114773.json b/tests/data/test_sync_patches_pr_summary_success/patch-14114773.json similarity index 100% rename from tests/data/test_github_sync.test_sync_patches_pr_summary_success/patch-14114773.json rename to tests/data/test_sync_patches_pr_summary_success/patch-14114773.json diff --git a/tests/data/test_github_sync.test_sync_patches_pr_summary_success/patch-14114774.json b/tests/data/test_sync_patches_pr_summary_success/patch-14114774.json similarity index 100% rename from tests/data/test_github_sync.test_sync_patches_pr_summary_success/patch-14114774.json rename to tests/data/test_sync_patches_pr_summary_success/patch-14114774.json diff --git a/tests/data/test_github_sync.test_sync_patches_pr_summary_success/patch-14114775.json b/tests/data/test_sync_patches_pr_summary_success/patch-14114775.json similarity index 100% rename from tests/data/test_github_sync.test_sync_patches_pr_summary_success/patch-14114775.json rename to tests/data/test_sync_patches_pr_summary_success/patch-14114775.json diff --git a/tests/data/test_github_sync.test_sync_patches_pr_summary_success/patch-14114777.json b/tests/data/test_sync_patches_pr_summary_success/patch-14114777.json similarity index 100% rename from tests/data/test_github_sync.test_sync_patches_pr_summary_success/patch-14114777.json rename to tests/data/test_sync_patches_pr_summary_success/patch-14114777.json diff --git a/tests/data/test_github_sync.test_sync_patches_pr_summary_success/responses.json b/tests/data/test_sync_patches_pr_summary_success/responses.json similarity index 90% rename from tests/data/test_github_sync.test_sync_patches_pr_summary_success/responses.json rename to tests/data/test_sync_patches_pr_summary_success/responses.json index f01e440..657ad30 100644 --- a/tests/data/test_github_sync.test_sync_patches_pr_summary_success/responses.json +++ b/tests/data/test_sync_patches_pr_summary_success/responses.json @@ -11,5 +11,9 @@ "https://patchwork.test/api/1.1/series/?q=bpf%253A+clear+user+buf+when+bpf_d_path+failed": ["series-970926.json"], "https://patchwork.test/api/1.1/series/?q=bpf%253A+Fix+a+few+test+failures+with+64K+page+size": ["series-970968.json"], "https://patchwork.test/api/1.1/series/?q=net%253A+Fix+RCU+usage+in+task_cls_state%2528%2529+for+BPF+programs": ["series-970970.json"], - "https://patchwork.test/api/1.1/patches/?archived=False&delegate=121173&project=399&since=2025-06-11T00:00:00&state=1&state=13&state=15&state=2&state=5&state=7": "relevant-subjects-20250610.json" + "https://patchwork.test/api/1.1/patches/?archived=False&delegate=121173&project=399&since=2025-06-11T00:00:00&state=1&state=13&state=15&state=2&state=5&state=7": [ + "patch-14114605.json", + "patch-14114774.json", + "patch-14114777.json" + ] } diff --git a/tests/data/test_github_sync.test_sync_patches_pr_summary_success/series-970926.json b/tests/data/test_sync_patches_pr_summary_success/series-970926.json similarity index 100% rename from tests/data/test_github_sync.test_sync_patches_pr_summary_success/series-970926.json rename to tests/data/test_sync_patches_pr_summary_success/series-970926.json diff --git a/tests/data/test_github_sync.test_sync_patches_pr_summary_success/series-970926.mbox b/tests/data/test_sync_patches_pr_summary_success/series-970926.mbox similarity index 100% rename from tests/data/test_github_sync.test_sync_patches_pr_summary_success/series-970926.mbox rename to tests/data/test_sync_patches_pr_summary_success/series-970926.mbox diff --git a/tests/data/test_github_sync.test_sync_patches_pr_summary_success/series-970968.json b/tests/data/test_sync_patches_pr_summary_success/series-970968.json similarity index 100% rename from tests/data/test_github_sync.test_sync_patches_pr_summary_success/series-970968.json rename to tests/data/test_sync_patches_pr_summary_success/series-970968.json diff --git a/tests/data/test_github_sync.test_sync_patches_pr_summary_success/series-970970.json b/tests/data/test_sync_patches_pr_summary_success/series-970970.json similarity index 100% rename from tests/data/test_github_sync.test_sync_patches_pr_summary_success/series-970970.json rename to tests/data/test_sync_patches_pr_summary_success/series-970970.json diff --git a/tests/test_branch_worker.py b/tests/test_branch_worker.py index f4c7396..1b1ef86 100644 --- a/tests/test_branch_worker.py +++ b/tests/test_branch_worker.py @@ -800,8 +800,8 @@ async def test_guess_pr_not_in_cache_no_specified_branch_is_remote_branch_v2_mul self._bw.patchwork = self._pw # Replace our BranchWorker repo instance by our gh_mock self._bw.repo = self._gh_mock - # DEFAULT_TEST_RESPONSES will return series 6 and 9, 6 being the first one - mybranch = f"series/6=>{TEST_REPO_BRANCH}" + # DEFAULT_TEST_RESPONSES will return series 6 and 9, 9 being the latest one + mybranch = f"series/9=>{TEST_REPO_BRANCH}" mymunch = munchify( { "head": {"ref": mybranch}, diff --git a/tests/test_github_sync.py b/tests/test_github_sync.py index 789dbf4..6056bc6 100644 --- a/tests/test_github_sync.py +++ b/tests/test_github_sync.py @@ -337,7 +337,7 @@ async def test_sync_patches_pr_summary_success(self, m: aioresponses) -> None: data_path = os.path.join( os.path.dirname(__file__), - "data/test_github_sync.test_sync_patches_pr_summary_success", + "data/test_sync_patches_pr_summary_success", ) test_data = load_test_data(data_path) init_pw_responses(m, test_data) diff --git a/tests/test_patchwork.py b/tests/test_patchwork.py index f876536..366351f 100644 --- a/tests/test_patchwork.py +++ b/tests/test_patchwork.py @@ -8,6 +8,7 @@ import copy import datetime +import os import re import unittest from dataclasses import dataclass @@ -31,6 +32,8 @@ get_default_pw_client, get_dict_key, init_pw_responses, + load_test_data, + PatchworkMock, ) @@ -698,4 +701,27 @@ async def test_branch_name(self, m: aioresponses) -> None: s = Subject("foo", self._pw) branch = await s.branch() # It is Series with ID 4 - self.assertEqual(branch, f"series/{FOO_SERIES_FIRST}") + self.assertEqual(branch, f"series/{FOO_SERIES_LAST}") + + @aioresponses() + async def test_latest_series_real_sample(self, m: aioresponses) -> None: + data_path = os.path.join( + os.path.dirname(__file__), + "data/test_latest_series_real_sample", + ) + test_data = load_test_data(data_path) + init_pw_responses(m, test_data) + + patchwork = PatchworkMock( + server="patchwork.test", + api_version="1.1", + search_patterns=[{"archived": False, "project": 399, "delegate": 121173}], + auth_token="mocktoken", + ) + s = Subject("Support kCFI + BPF on arm64", patchwork) + + latest_series = none_throws(await s.latest_series()) + branch = none_throws(await s.branch()) + + self.assertEqual(latest_series.id, 984880) + self.assertEqual(branch, "series/984880")