浏览代码

btf: run ANDROID_KABI_USE fix on sublevel 43 and ungate xdp_buff/ELF_T_WORD

- Move the ANDROID_KABI_USE() rework patch (drops __UNIQUE_ID for
  deterministic ABI naming under thin/full LTO) from repo root into
  btf/patches/ and add a step applying it on android12-5.10 sublevel 43
  (2021-10 tree), where it is still needed.
- Ungate the xdp_buff BTF-emit fix and the resolve_btfids ELF_T_WORD
  endian fix so they also run on sublevel 43.
TheWildJames 1 月之前
父节点
当前提交
cde3fc0b67

+ 15 - 2
.github/actions/btf/action.yml

@@ -30,10 +30,23 @@ runs:
         set -euo pipefail
         patch -p1 -N < ${{ github.action_path }}/patches/0002-resolve_btfids-inherit-host-linker-flags.patch
 
+    - name: Apply ANDROID_KABI_USE macro fix (android12-5.10, sublevel 43)
+      shell: bash
+      working-directory: ${{ github.workspace }}/kernel/common
+      if: ${{ inputs.version == 'android12-5.10' && inputs.sublevel == '43' }}
+      run: |
+        set -euo pipefail
+        # Rework ANDROID_KABI_USE() to drop __UNIQUE_ID(android_kabi_hide).
+        # __UNIQUE_ID relies on __COUNTER__ which is non-deterministic across
+        # compiler runs (differs between thin vs full LTO), breaking the ABI
+        # symbol naming. Only needed on the oldest sublevel-43 (2021-10) tree;
+        # newer sublevels already carry this change in-tree.
+        patch -p1 -N < ${{ github.action_path }}/patches/0001-ANDROID-GKI-rework-the-ANDROID_KABI_USE-macro-to-not.patch
+
     - name: Apply xdp_buff BTF-emit fix (android12-5.10)
       shell: bash
       working-directory: ${{ github.workspace }}/kernel/common
-      if: ${{ inputs.version == 'android12-5.10' && (inputs.sublevel == 'X' || fromJSON(inputs.sublevel) > 43) }}
+      if: ${{ inputs.version == 'android12-5.10' }}
       run: |
         set -euo pipefail
         # bpf_types.h references struct xdp_buff via
@@ -51,7 +64,7 @@ runs:
     - name: Apply resolve_btfids ELF_T_WORD endian fix (android12-5.10)
       shell: bash
       working-directory: ${{ github.workspace }}/kernel/common
-      if: ${{ inputs.version == 'android12-5.10' && (inputs.sublevel == 'X' || fromJSON(inputs.sublevel) > 43) }}
+      if: ${{ inputs.version == 'android12-5.10' }}
       run: |
         set -euo pipefail
         # Backport of upstream 61e8aeda9398 ("bpf: Fix libelf endian handling

+ 43 - 0
.github/actions/btf/patches/0001-ANDROID-GKI-rework-the-ANDROID_KABI_USE-macro-to-not.patch

@@ -0,0 +1,43 @@
+From f8b361d17da5fa125a9e788d3088599216f33019 Mon Sep 17 00:00:00 2001
+From: Greg Kroah-Hartman <gregkh@google.com>
+Date: Tue, 28 Sep 2021 14:38:19 +0200
+Subject: [PATCH] ANDROID: GKI: rework the ANDROID_KABI_USE() macro to not use
+ __UNIQUE()
+
+The __UNIQUE_ID() macro causes problems as it turns out to not be
+deterministic across different compiler runs as it relies on the
+__COUNTER__ macro which could have been used on other .h files previous
+to this .h file being included.
+
+This shows up specifically when building with "LTO=thin" vs. "LTO=full"
+as different build paths seem to be triggered.
+
+As the structure name isn't really needed at all here, we were just
+including it for older compilers that could not handle anonymous
+structures in a union, just drop the whole thing which resolves the abi
+naming issue.
+
+Bug: 210255585
+Reported-by: Giuliano Procida <gprocida@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
+Change-Id: I6b9449fa9d26ffc5d66b2f0f3b41e2d5f3003f68
+---
+ include/linux/android_kabi.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/linux/android_kabi.h b/include/linux/android_kabi.h
+index efa52953fe35..9c7b6c035ad3 100644
+--- a/include/linux/android_kabi.h
++++ b/include/linux/android_kabi.h
+@@ -63,7 +63,7 @@
+ 		_new;						\
+ 		struct {					\
+ 			_orig;					\
+-		} __UNIQUE_ID(android_kabi_hide);		\
++		};						\
+ 		__ANDROID_KABI_CHECK_SIZE_ALIGN(_orig, _new);	\
+ 	}
+ 
+-- 
+2.55.0
+