Merge "Create an arm64 kernel module to test arm64 KMI" am: f1f176fa45 am: 9f9be21a51 am: 07f00284ed am: 8ecad96fa6
Original change: https://android-review.googlesource.com/c/platform/development/+/1816780 Change-Id: Idf071c8d1919a727a081307369e164b9a4a0e2f4
This commit is contained in:
30
gki/kmi_abi_chk/Makefile
Normal file
30
gki/kmi_abi_chk/Makefile
Normal file
@@ -0,0 +1,30 @@
|
||||
# Copyright (C) 2021 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
kmi_sym-objs := kmi_sym_main.o kmi_sym_list.o
|
||||
obj-m += kmi_sym.o
|
||||
|
||||
GKI_VER ?= 5.10
|
||||
GKI_DIR ?= ${ANDROID_BUILD_TOP}/kernel
|
||||
KSRC=${GKI_DIR}/out/android12-${GKI_VER}/common
|
||||
|
||||
GKI_BID ?= 7618735
|
||||
CFLAGS_kmi_sym_main.o = -DGKI_BID=${GKI_BID}
|
||||
|
||||
all:
|
||||
make -C $(KSRC) M=$(PWD) modules
|
||||
mv kmi_sym.ko kmi_sym-a12-${GKI_VER}.ko
|
||||
|
||||
clean:
|
||||
make -C $(KSRC) M=$(PWD) clean
|
||||
59
gki/kmi_abi_chk/README
Normal file
59
gki/kmi_abi_chk/README
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
#
|
||||
# How to build the KMI ABI test kernel module, kmi_sym.ko
|
||||
#
|
||||
|
||||
1. Set up the GKI source.
|
||||
# Set up and export GKI_DIR to be used for kernel module building
|
||||
$ cd $GKI_DIR
|
||||
$ repo init -u https://android.googlesource.com/kernel/manifest \
|
||||
-b common-android12-5.10
|
||||
$ repo sync
|
||||
See "GKI Monthly Branch Handbook" for details.
|
||||
2. Build arm64 GKI under $GKI_DIR
|
||||
$ BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh -j16
|
||||
3. Download a supported kernel symbol file, vmlinux.symvers, from GKI AB:
|
||||
$ export GKI_BID=7618735
|
||||
https://ci.android.com/builds/submitted/$GKI_BID/kernel_aarch64/latest
|
||||
$ cp vmlinux.symvers $ANDROID_BUILD_TOP/development/gki/kmi_abi_chk/vmlinux.symvers-$GKI_BID
|
||||
4. Replace the Module.symvers just built with the supported kernel symbol file.
|
||||
$ cp vmlinux.symvers $GKI_DIR/out/android12-5.10/common/Module.symvers
|
||||
5. Create the KMI symbol list
|
||||
$ cd development/gki/kmi_abi_chk
|
||||
$ cp $GKI_DIR/out/android12-5.10/common/Module.symvers vmlinux.symvers-$GKI_BID
|
||||
$ awk '{printf("\t.xword\t%s\n",$2)}' vmlinux.symvers-$GKI_BID >> kmi_sym_list.inc
|
||||
Note that kmi_sym_list.inc included in the current directory is a version
|
||||
modified from the one based on vmlinux.symvers of build 7618735, the initial
|
||||
GKI 5.10 released in July, 2021. Search b/197035344 in it for details.
|
||||
6. Build the kernel module
|
||||
$ make ARCH=arm64 CROSS_COMPILE=aarch64 LLVM=1 LLVM_IAS=1 LTO=thin
|
||||
|
||||
A prebuilt test kernel module, kmi_sym-7618735.ko, for arm64 GKI 5.10
|
||||
2021-07 and later builds is included in the current directory.
|
||||
|
||||
#
|
||||
# How to use/run KMI test kernel module, kmi_sym.ko, on GKI
|
||||
#
|
||||
|
||||
1. Copy the test kernel module to the Android device
|
||||
$ adb push kmi_sym.ko /data/local/tmp
|
||||
2. "Root" the Android device we'd like to run the test
|
||||
$ adb root
|
||||
3. Check the kernel information on the device
|
||||
emulator64_arm64:/ # uname -a
|
||||
Linux localhost 5.10.43-android12-9-00005-g376ecc372342-ab7614753 #1 SMP PREEMPT Thu Aug 5 15:12:49 UTC 2021 aarch64
|
||||
4. Load the test kernel module
|
||||
emulator64_arm64:/ # lsmod | grep kmi_sym
|
||||
emulator64_arm64:/ # insmod /data/local/tmp/kmi_sym.ko; echo $?
|
||||
0
|
||||
5. Verify the test kernel module is loaded successfully
|
||||
emulator64_arm64:/ # lsmod | grep kmi_sym
|
||||
kmi_sym 57344 0
|
||||
emulator64_arm64:/ # dmesg | grep KMI
|
||||
[ 1669.833480] 5317 KMI ABI symbols at 00000000d34c59ea
|
||||
6. Unload the test kernel module
|
||||
emulator64_arm64:/ # rmmod kmi_sym; echo $?
|
||||
0
|
||||
emulator64_arm64:/ # dmesg | grep KMI
|
||||
[ 1669.833480] 5317 KMI ABI symbols at 00000000d34c59ea
|
||||
[ 1860.571944] Cleaning up KMI ABI.
|
||||
BIN
gki/kmi_abi_chk/kmi_sym-a12-5.10.ko
Normal file
BIN
gki/kmi_abi_chk/kmi_sym-a12-5.10.ko
Normal file
Binary file not shown.
29
gki/kmi_abi_chk/kmi_sym_list.S
Normal file
29
gki/kmi_abi_chk/kmi_sym_list.S
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
.text
|
||||
.file "kmi_sym_lst.S"
|
||||
.type kmi_sym_arr,@object // @kmi_sym_arr
|
||||
.section .rodata,"a",@progbits
|
||||
.globl kmi_sym_arr
|
||||
.p2align 3
|
||||
|
||||
kmi_sym_arr:
|
||||
|
||||
#include "kmi_sym_list.inc"
|
||||
|
||||
.xword 0
|
||||
.size kmi_sym_arr, . - kmi_sym_arr
|
||||
5323
gki/kmi_abi_chk/kmi_sym_list.inc
Normal file
5323
gki/kmi_abi_chk/kmi_sym_list.inc
Normal file
File diff suppressed because it is too large
Load Diff
46
gki/kmi_abi_chk/kmi_sym_main.c
Normal file
46
gki/kmi_abi_chk/kmi_sym_main.c
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <linux/module.h> // included for all kernel modules
|
||||
#include <linux/kernel.h> // included for KERN_INFO
|
||||
#include <linux/init.h> // included for __init and __exit macros
|
||||
#include <linux/stringify.h>
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("A kernel module using all GKI KMI symbols");
|
||||
MODULE_IMPORT_NS(CRYPTO_INTERNAL);
|
||||
|
||||
extern void *kmi_sym_arr[];
|
||||
|
||||
static int __init kmi_sym_init(void)
|
||||
{
|
||||
int cnt;
|
||||
|
||||
for (cnt = 0; kmi_sym_arr[cnt] != 0; ++cnt)
|
||||
;
|
||||
printk(KERN_INFO "GKI build: %s\n", __stringify(GKI_BID));
|
||||
printk(KERN_INFO "%d GKI KMI symbols at %p\n", cnt, kmi_sym_arr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit kmi_sym_cleanup(void)
|
||||
{
|
||||
printk(KERN_INFO "Cleaning up GKI KMI test.\n");
|
||||
}
|
||||
|
||||
module_init(kmi_sym_init);
|
||||
module_exit(kmi_sym_cleanup);
|
||||
Reference in New Issue
Block a user