1 2# 3# How to build the KMI ABI test kernel module, kmi_sym.ko 4# 5 61. Set up the GKI source. 7 # Set up and export GKI_DIR to be used for kernel module building 8 $ cd $GKI_DIR 9 $ repo init -u https://android.googlesource.com/kernel/manifest \ 10 -b common-android12-5.10 11 $ repo sync 12 See "GKI Monthly Branch Handbook" for details. 132. Build arm64 GKI under $GKI_DIR 14 $ BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh -j16 153. Download a supported kernel symbol file, vmlinux.symvers, from GKI AB: 16 $ export GKI_BID=7618735 17 https://ci.android.com/builds/submitted/$GKI_BID/kernel_aarch64/latest 18 $ cp vmlinux.symvers $ANDROID_BUILD_TOP/development/gki/kmi_abi_chk/vmlinux.symvers-$GKI_BID 194. Replace the Module.symvers just built with the supported kernel symbol file. 20 $ cp vmlinux.symvers $GKI_DIR/out/android12-5.10/common/Module.symvers 215. Create the KMI symbol list include file: 22 $ cd development/gki/kmi_abi_chk 23 $ cp $GKI_DIR/out/android12-5.10/common/Module.symvers vmlinux.symvers-$GKI_BID 24 $ awk '{printf("\t.xword\t%s\n",$2)}' vmlinux.symvers-$GKI_BID >> kmi_sym_list-$GKI_BID.inc 25 Note that kmi_sym_list-7618735.inc included in the current directory is a 26 version modified from the one based on vmlinux.symvers of build 7618735, the 27 initial GKI 5.10 released in July, 2021. Search b/197035344 for details. 286. Build the kernel module 29 $ make ARCH=arm64 CROSS_COMPILE=aarch64 LLVM=1 LLVM_IAS=1 LTO=thin 30 31A few prebuilt test kernel modules, kmi_sym-*.ko, for arm64 GKI 5.10 322021-07 and later builds is included under prebuilts/ directory. 33 34# 35# How to use/run KMI test kernel module, kmi_sym.ko, on GKI 36# 37 381. Copy the test kernel module to the Android device 39 $ adb push kmi_sym.ko /data/local/tmp 402. "Root" the Android device we'd like to run the test 41 $ adb root 423. Check the kernel information on the device 43 emulator64_arm64:/ # uname -a 44 Linux localhost 5.10.43-android12-9-00005-g376ecc372342-ab7614753 #1 SMP PREEMPT Thu Aug 5 15:12:49 UTC 2021 aarch64 454. Load the test kernel module 46 emulator64_arm64:/ # lsmod | grep kmi_sym 47 emulator64_arm64:/ # insmod /data/local/tmp/kmi_sym.ko; echo $? 48 0 495. Verify the test kernel module is loaded successfully 50 emulator64_arm64:/ # lsmod | grep kmi_sym 51 kmi_sym 57344 0 52 emulator64_arm64:/ # dmesg | grep KMI 53 [ 1669.833480] 5317 KMI ABI symbols at 00000000d34c59ea 546. Unload the test kernel module 55 emulator64_arm64:/ # rmmod kmi_sym; echo $? 56 0 57 emulator64_arm64:/ # dmesg | grep KMI 58 [ 1669.833480] 5317 KMI ABI symbols at 00000000d34c59ea 59 [ 1860.571944] Cleaning up KMI ABI. 60