mirror of
https://github.com/openharmony/kernel_linux_build.git
synced 2026-07-19 16:24:25 -04:00
@@ -48,5 +48,8 @@ group("linuxkerneltest") {
|
||||
":init_runtest",
|
||||
"fuzztest:fuzztest",
|
||||
]
|
||||
if ("$device_name" == "rk3568") {
|
||||
deps += [ "tracepointtest:tracepointtest" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
|
||||
action("tracepointtest") {
|
||||
script = "tracepoint.sh"
|
||||
outputs =
|
||||
[ "$root_build_dir/tests/kernel_shelltest/tracepointtest.timestamp" ]
|
||||
deps = [ "//device/board/hihope/rk3568/kernel:kernel" ]
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# Kconfig for tracepoint test
|
||||
#
|
||||
|
||||
menu "tracepoint test"
|
||||
|
||||
source "drivers/tracepointtest/vendordommap_test/Kconfig"
|
||||
|
||||
source "drivers/tracepointtest/vendordomprotectpkey_test/Kconfig"
|
||||
|
||||
source "drivers/tracepointtest/tracepoint_test/Kconfig"
|
||||
|
||||
source "drivers/tracepointtest/vendoramlemmcpartition_test/Kconfig"
|
||||
|
||||
source "drivers/tracepointtest/vendorfakebootpartition_test/Kconfig"
|
||||
|
||||
endmenu
|
||||
@@ -0,0 +1,10 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# Makefile for tracepoint test
|
||||
#
|
||||
|
||||
obj-$(CONFIG_TRACEPOINT_MMAP) += vendordommap_test/
|
||||
obj-$(CONFIG_TRACEPOINT_MPROTECT_PKEY) += vendordomprotectpkey_test/
|
||||
obj-$(CONFIG_TRACEPOINT_TEST) += tracepoint_test/
|
||||
obj-$(CONFIG_TRACEPOINT_AML_EMMC_PARTITION) += vendoramlemmcpartition_test/
|
||||
obj-$(CONFIG_TRACEPOINT_FAKE_BOOT_PARTITION) += vendorfakebootpartition_test/
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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.
|
||||
*/
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
|
||||
#undef TRACE_SYSTEM
|
||||
#define TRACE_SYSTEM emmc
|
||||
|
||||
#define TRACE_INCLUDE_PATH trace/hooks
|
||||
#if !defined(_TRACE_HOOKS_EMMC_H) || defined(TRACE_HEADER_MULTI_READ)
|
||||
#define _TRACE_HOOKS_EMMC_H
|
||||
|
||||
#include <trace/hooks/vendor_hooks.h>
|
||||
#include <linux/tracepoint.h>
|
||||
|
||||
DECLARE_HOOK(vendor_aml_emmc_partition,
|
||||
TP_PROTO(unsigned long prot, int *err),
|
||||
TP_ARGS(prot, err)
|
||||
);
|
||||
|
||||
DECLARE_HOOK(vendor_fake_boot_partition,
|
||||
TP_PROTO(unsigned long prot, int *err),
|
||||
TP_ARGS(prot, err)
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
/* This part must be outside protection */
|
||||
#include <trace/define_trace.h>
|
||||
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# Linux/arm64 5.10.79 Kernel Configuration
|
||||
#
|
||||
|
||||
CONFIG_VENDOR_HOOKS=y
|
||||
CONFIG_TRACEPOINT_MMAP=m
|
||||
CONFIG_TRACEPOINT_MPROTECT_PKEY=m
|
||||
CONFIG_TRACEPOINT_TEST=m
|
||||
CONFIG_TRACEPOINT_AML_EMMC_PARTITION=m
|
||||
CONFIG_TRACEPOINT_FAKE_BOOT_PARTITION=m
|
||||
@@ -0,0 +1,176 @@
|
||||
#!/bin/sh
|
||||
################################################################################
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# 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.
|
||||
#
|
||||
################################################################################
|
||||
# File: tracepoint.sh
|
||||
#
|
||||
# Description: test tracepoint
|
||||
#
|
||||
# Authors: yang ming di
|
||||
#
|
||||
# History: August 4 2022 - test tracepoint
|
||||
#
|
||||
################################################################################
|
||||
|
||||
CURRENT_DIR=$(pwd)
|
||||
ROOT_DIR=$(cd $CURRENT_DIR/../../ && pwd)
|
||||
ROOT_FILE_DIR=$ROOT_DIR/kernel/linux/build/test/tracepointtest
|
||||
#ROOT_TEST_DIR=$(cd $CURRENT_DIR/../../../../../ && pwd)
|
||||
COMPILE_DIR=$ROOT_DIR/out/kernel/src_tmp/linux-5.10
|
||||
OBJ_DIR=$ROOT_DIR/out/kernel/OBJ
|
||||
DRIVERS_DIR=${ROOT_DIR}/out/kernel/src_tmp/linux-5.10/drivers
|
||||
TRACEPOINT_INCLUDE_DIR=${ROOT_DIR}/out/kernel/src_tmp/linux-5.10/include/trace/hooks
|
||||
DRIVERS_TRACEPOINT_DIR=${ROOT_DIR}/out/kernel/src_tmp/linux-5.10/drivers/tracepointtest
|
||||
CONFIG_DIR=${ROOT_DIR}/out/kernel/src_tmp/linux-5.10/arch/arm64/configs
|
||||
|
||||
copy() {
|
||||
echo "copy $1 to $2"
|
||||
cp -rf $1 $2
|
||||
}
|
||||
|
||||
modify_config() {
|
||||
if [ -e $CONFIG_DIR/tmp ]; then
|
||||
rm -f $CONFIG_DIR/tmp
|
||||
fi
|
||||
|
||||
cp -f $CONFIG_DIR/$2 $CONFIG_DIR/$2_tmpfile
|
||||
|
||||
while read line; do
|
||||
echo "$line" >>$CONFIG_DIR/tmp
|
||||
done <$CONFIG_DIR/$2
|
||||
|
||||
while read line; do
|
||||
if [[ "$line" != "#"* ]]; then
|
||||
echo "$line" >>$CONFIG_DIR/tmp
|
||||
fi
|
||||
done <$1
|
||||
|
||||
mv $CONFIG_DIR/tmp $CONFIG_DIR/$2
|
||||
}
|
||||
|
||||
modify_files() {
|
||||
KCONFIG=$DRIVERS_DIR/Kconfig
|
||||
MAKEFILE=$DRIVERS_DIR/Makefile
|
||||
VENDOR_HOOKS=$DRIVERS_DIR/hooks/vendor_hooks.c
|
||||
TMPFILE=$DRIVERS_DIR/tmp
|
||||
|
||||
cp -f $KCONFIG ${KCONFIG}_tmpfile
|
||||
cp -f $MAKEFILE ${MAKEFILE}_tmpfile
|
||||
cp -f $VENDOR_HOOKS ${VENDOR_HOOKS}_tmpfile
|
||||
|
||||
if [ -e $TMPFILE ]; then
|
||||
rm -f $TMPFILE
|
||||
fi
|
||||
|
||||
while read line; do
|
||||
if [[ "$line" != "endmenu" ]]; then
|
||||
echo "$line" >>$TMPFILE
|
||||
fi
|
||||
done <$KCONFIG
|
||||
echo "source \"drivers/tracepointtest/Kconfig\"" >>$TMPFILE
|
||||
echo "endmenu" >>$TMPFILE
|
||||
mv $TMPFILE $KCONFIG
|
||||
|
||||
while read line; do
|
||||
echo "$line" >>$TMPFILE
|
||||
done <$MAKEFILE
|
||||
echo "obj-y += tracepointtest/" >>$TMPFILE
|
||||
mv $TMPFILE $MAKEFILE
|
||||
|
||||
while read line; do
|
||||
echo "$line" >>$TMPFILE
|
||||
done <$VENDOR_HOOKS
|
||||
echo "#include <trace/hooks/emmc.h>" >>$TMPFILE
|
||||
echo "EXPORT_TRACEPOINT_SYMBOL_GPL(vendor_aml_emmc_partition);" >>$TMPFILE
|
||||
echo "EXPORT_TRACEPOINT_SYMBOL_GPL(vendor_fake_boot_partition);" >>$TMPFILE
|
||||
mv $TMPFILE $VENDOR_HOOKS
|
||||
}
|
||||
|
||||
compile() {
|
||||
cd $COMPILE_DIR || exit
|
||||
export PRODUCT_COMPANY=hihope
|
||||
export DEVICE_NAME=rk3568
|
||||
export DEVICE_COMPANY=rockchip
|
||||
export PRODUCT_PATH=~/OpenHarmony/master/out/kernel/vendor/hihope/rk3568
|
||||
./make-ohos.sh TB-RK3568X0 >null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "compile failed"
|
||||
exit 1
|
||||
else
|
||||
echo "compile success"
|
||||
fi
|
||||
}
|
||||
|
||||
collectKO() {
|
||||
if [ -e $OBJ_DIR/kofiles ]; then
|
||||
rm -f $OBJ_DIR/kofiles
|
||||
mkdir -p $OBJ_DIR/kofiles
|
||||
else
|
||||
mkdir -p $OBJ_DIR/kofiles
|
||||
fi
|
||||
|
||||
find $DRIVERS_TRACEPOINT_DIR -name '*.ko' | xargs cp -t $OBJ_DIR/kofiles
|
||||
}
|
||||
|
||||
restore() {
|
||||
CONFIGNAME=rockchip_linux_defconfig
|
||||
KCONFIG=$DRIVERS_DIR/Kconfig
|
||||
MAKEFILE=$DRIVERS_DIR/Makefile
|
||||
VENDOR_HOOKS=$DRIVERS_DIR/hooks/vendor_hooks.c
|
||||
|
||||
rm -rf $DRIVERS_TRACEPOINT_DIR
|
||||
mv -f $CONFIG_DIR/${CONFIGNAME}_tmpfile $CONFIG_DIR/$CONFIGNAME
|
||||
mv -f ${KCONFIG}_tmpfile $KCONFIG
|
||||
mv -f ${MAKEFILE}_tmpfile $MAKEFILE
|
||||
mv -f ${VENDOR_HOOKS}_tmpfile $VENDOR_HOOKS
|
||||
rm -rf $COMPILE_DIR/.lock
|
||||
}
|
||||
|
||||
main() {
|
||||
if [ -e $COMPILE_DIR/.lock ]; then
|
||||
restore
|
||||
fi
|
||||
|
||||
echo "" >$COMPILE_DIR/.lock
|
||||
|
||||
if [ -d $DRIVERS_DIR/tracepointtest ]; then
|
||||
rm -rf $DRIVERS_DIR/tracepointtest
|
||||
mkdir -p $DRIVERS_DIR/tracepointtest
|
||||
else
|
||||
mkdir -p $DRIVERS_DIR/tracepointtest
|
||||
fi
|
||||
|
||||
for dir in $(ls $ROOT_FILE_DIR); do
|
||||
if [ -d $ROOT_FILE_DIR/$dir ]; then
|
||||
copy $ROOT_FILE_DIR/$dir $DRIVERS_TRACEPOINT_DIR/$dir
|
||||
elif [[ "$dir" == "Makefile" ]]; then
|
||||
copy $ROOT_FILE_DIR/$dir $DRIVERS_TRACEPOINT_DIR/$dir
|
||||
elif [[ "$dir" == "Kconfig" ]]; then
|
||||
copy $ROOT_FILE_DIR/$dir $DRIVERS_TRACEPOINT_DIR/$dir
|
||||
elif [[ $dir == *.h ]]; then
|
||||
copy $ROOT_FILE_DIR/$dir $TRACEPOINT_INCLUDE_DIR/$dir
|
||||
elif [[ "$dir" == "rockchip_linux_defconfig" ]]; then
|
||||
modify_config $ROOT_FILE_DIR/$dir $dir
|
||||
fi
|
||||
done
|
||||
|
||||
modify_files
|
||||
compile
|
||||
collectKO
|
||||
restore
|
||||
}
|
||||
|
||||
main
|
||||
@@ -0,0 +1,9 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
config TRACEPOINT_TEST
|
||||
tristate "Test Tracepoint For Vendor Hooks"
|
||||
default m
|
||||
help
|
||||
Enable test tracepoint for vendor hooks
|
||||
Allow vendor modules to attach driver hooks defined via
|
||||
DECLARE_HOOK or DECLARE_RESTRICTED_HOOK
|
||||
@@ -0,0 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# Makefile for test tracepoint
|
||||
#
|
||||
|
||||
obj-$(CONFIG_TRACEPOINT_TEST) += tracepoint_test.o
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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 <trace/hooks/mm.h>
|
||||
#include <trace/hooks/emmc.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
static int tracepoint_test_init_module(void)
|
||||
{
|
||||
pr_info("tracepoint test module init\n");
|
||||
trace_vendor_do_mmap(NULL, NULL);
|
||||
trace_vendor_do_mprotect_pkey(NULL, NULL);
|
||||
trace_vendor_aml_emmc_partition(NULL, NULL);
|
||||
trace_vendor_fake_boot_partition(NULL, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void tracepoint_test_exit_module(void)
|
||||
{
|
||||
pr_info("tracepoint test module exit\n");
|
||||
}
|
||||
|
||||
/* module entry points */
|
||||
module_init(tracepoint_test_init_module);
|
||||
module_exit(tracepoint_test_exit_module);
|
||||
MODULE_LICENSE ("GPL v2");
|
||||
@@ -0,0 +1,67 @@
|
||||
#!/bin/sh
|
||||
################################################################################
|
||||
#
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# 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.
|
||||
#
|
||||
################################################################################
|
||||
# File: tracepointtestko.sh
|
||||
#
|
||||
# Description: tracepoint ko test
|
||||
#
|
||||
# Authors: yang ming di
|
||||
#
|
||||
# History: August 4 2022 - tracepoint ko test
|
||||
#
|
||||
################################################################################
|
||||
|
||||
CURRENT_DIR=$(pwd)
|
||||
KO_DIR=$CURRENT_DIR/kofile
|
||||
|
||||
insmod_ko() {
|
||||
for dir in $(ls $KO_DIR); do
|
||||
if [[ "$dir" != "tracepoint_test.ko" ]]; then
|
||||
insmod $KO_DIR/$dir
|
||||
echo "$KO_DIR/$dir is loaded"
|
||||
fi
|
||||
done
|
||||
|
||||
insmod $KO_DIR/tracepoint_test.ko
|
||||
|
||||
arr=(vendor_do_mmap vendor_do_mprotect_pkey vendor_aml_emmc_partition vendor_fake_boot_partition)
|
||||
for i in ${arr[@]}; do
|
||||
dmesg | grep $i >/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "tracepoint $i succeed"
|
||||
else
|
||||
echo "tracepoint $i failed"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
rmmod_ko() {
|
||||
for dir in $(ls $KO_DIR); do
|
||||
rmmod $KO_DIR/$dir
|
||||
echo "$KO_DIR/$dir is removed"
|
||||
done
|
||||
}
|
||||
|
||||
main() {
|
||||
if [[ $1 == "rmmod_ko" ]]; then
|
||||
rmmod_ko
|
||||
else
|
||||
insmod_ko
|
||||
fi
|
||||
}
|
||||
|
||||
main $1
|
||||
@@ -0,0 +1,10 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
config TRACEPOINT_AML_EMMC_PARTITION
|
||||
tristate "AML_EMMC_PARTITION Tracepoint For Vendor Hooks"
|
||||
depends on VENDOR_HOOKS
|
||||
default m
|
||||
help
|
||||
Enable aml emmc partition tracepoint for vendor hooks
|
||||
Allow vendor modules to attach driver hooks defined via
|
||||
DECLARE_HOOK or DECLARE_RESTRICTED_HOOK
|
||||
@@ -0,0 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# Makefile for aml emmc partition tracepoint
|
||||
#
|
||||
|
||||
obj-$(CONFIG_TRACEPOINT_AML_EMMC_PARTITION) += vendoramlemmcpartition_test.o
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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 <trace/hooks/emmc.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
static void vendor_aml_emmc_partition(void *data, unsigned long prot, int *err)
|
||||
{
|
||||
pr_info("%s\n", __func__);
|
||||
}
|
||||
|
||||
static int aml_emmc_partition_test_init_module(void)
|
||||
{
|
||||
return register_trace_vendor_aml_emmc_partition(&vendor_aml_emmc_partition, NULL);
|
||||
}
|
||||
|
||||
static void aml_emmc_partition_test_exit_module(void)
|
||||
{
|
||||
unregister_trace_vendor_aml_emmc_partition(&vendor_aml_emmc_partition, NULL);
|
||||
}
|
||||
|
||||
/* module entry points */
|
||||
module_init(aml_emmc_partition_test_init_module);
|
||||
module_exit(aml_emmc_partition_test_exit_module);
|
||||
MODULE_LICENSE ("GPL v2");
|
||||
@@ -0,0 +1,10 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
config TRACEPOINT_MMAP
|
||||
tristate "MMAP Tracepoint For Vendor Hooks"
|
||||
depends on VENDOR_HOOKS
|
||||
default m
|
||||
help
|
||||
Enable mmap tracepoint for vendor hooks
|
||||
Allow vendor modules to attach driver hooks defined via
|
||||
DECLARE_HOOK or DECLARE_RESTRICTED_HOOK
|
||||
@@ -0,0 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# Makefile for mmap tracepoint
|
||||
#
|
||||
|
||||
obj-$(CONFIG_TRACEPOINT_MMAP) += vendordommap_test.o
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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 <trace/hooks/mm.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
static void vendor_do_mmap(void *data, vm_flags_t *vm_flags, int *err)
|
||||
{
|
||||
pr_info("%s\n", __func__);
|
||||
}
|
||||
|
||||
static int mmap_test_init_module(void)
|
||||
{
|
||||
return register_trace_vendor_do_mmap(&vendor_do_mmap, NULL);
|
||||
}
|
||||
|
||||
static void mmap_test_exit_module(void)
|
||||
{
|
||||
unregister_trace_vendor_do_mmap(&vendor_do_mmap, NULL);
|
||||
}
|
||||
|
||||
/* module entry points */
|
||||
module_init(mmap_test_init_module);
|
||||
module_exit(mmap_test_exit_module);
|
||||
MODULE_LICENSE ("GPL v2");
|
||||
@@ -0,0 +1,10 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
config TRACEPOINT_MPROTECT_PKEY
|
||||
tristate "MPROTECT_PKEY Tracepoint For Vendor Hooks"
|
||||
depends on VENDOR_HOOKS
|
||||
default m
|
||||
help
|
||||
Enable mprotect pkey tracepoint for vendor hooks
|
||||
Allow vendor modules to attach driver hooks defined via
|
||||
DECLARE_HOOK or DECLARE_RESTRICTED_HOOK
|
||||
@@ -0,0 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# Makefile for mprotect pkey tracepoint
|
||||
#
|
||||
|
||||
obj-$(CONFIG_TRACEPOINT_MPROTECT_PKEY) += vendordomprotectpkey_test.o
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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 <trace/hooks/mm.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
static void vendor_do_mprotect_pkey(void *data, unsigned long prot, int *err)
|
||||
{
|
||||
pr_info("%s\n", __func__);
|
||||
}
|
||||
|
||||
static int mprotect_pkey_test_init_module(void)
|
||||
{
|
||||
return register_trace_vendor_do_mprotect_pkey(&vendor_do_mprotect_pkey, NULL);
|
||||
}
|
||||
|
||||
static void mprotect_pkey_test_exit_module(void)
|
||||
{
|
||||
unregister_trace_vendor_do_mprotect_pkey(&vendor_do_mprotect_pkey, NULL);
|
||||
}
|
||||
|
||||
/* module entry points */
|
||||
module_init(mprotect_pkey_test_init_module);
|
||||
module_exit(mprotect_pkey_test_exit_module);
|
||||
MODULE_LICENSE ("GPL v2");
|
||||
@@ -0,0 +1,10 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
config TRACEPOINT_FAKE_BOOT_PARTITION
|
||||
tristate "FAKE_BOOT_PARTITION Tracepoint For Vendor Hooks"
|
||||
depends on VENDOR_HOOKS
|
||||
default m
|
||||
help
|
||||
Enable fake boot partition tracepoint for vendor hooks
|
||||
Allow vendor modules to attach driver hooks defined via
|
||||
DECLARE_HOOK or DECLARE_RESTRICTED_HOOK
|
||||
@@ -0,0 +1,6 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# Makefile for fake boot partition tracepoint
|
||||
#
|
||||
|
||||
obj-$(CONFIG_TRACEPOINT_FAKE_BOOT_PARTITION) += vendorfakebootpartition_test.o
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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 <trace/hooks/emmc.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/kernel.h>
|
||||
|
||||
static void vendor_fake_boot_partition(void *data, unsigned long prot, int *err)
|
||||
{
|
||||
pr_info("%s\n", __func__);
|
||||
}
|
||||
|
||||
static int fake_boot_partition_test_init_module(void)
|
||||
{
|
||||
return register_trace_vendor_fake_boot_partition(&vendor_fake_boot_partition, NULL);
|
||||
}
|
||||
|
||||
static void fake_boot_partition_test_exit_module(void)
|
||||
{
|
||||
unregister_trace_vendor_fake_boot_partition(&vendor_fake_boot_partition, NULL);
|
||||
}
|
||||
|
||||
/* module entry points */
|
||||
module_init(fake_boot_partition_test_init_module);
|
||||
module_exit(fake_boot_partition_test_exit_module);
|
||||
MODULE_LICENSE ("GPL v2");
|
||||
Reference in New Issue
Block a user