diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index ae6e379fb487..742862fc5134 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -1,4 +1,13 @@ /* SPDX-License-Identifier: GPL-2.0 */ +#ifdef PROTECT_TRACE_INCLUDE_PATH +#undef PROTECT_TRACE_INCLUDE_PATH + +#include +#include +#include + +#else /* PROTECT_TRACE_INCLUDE_PATH */ + #undef TRACE_SYSTEM #define TRACE_SYSTEM mm @@ -230,3 +239,5 @@ DECLARE_HOOK(android_vh_set_shmem_page_flag, /* This part must be outside protection */ #include + +#endif /* PROTECT_TRACE_INCLUDE_PATH */ diff --git a/include/trace/hooks/restore_incpath.h b/include/trace/hooks/restore_incpath.h new file mode 100644 index 000000000000..3a97e4572007 --- /dev/null +++ b/include/trace/hooks/restore_incpath.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Include this file from a header declaring vendor hooks to preserve and later + * restore TRACE_INCLUDE_PATH value. Typical usage: + * + * #ifdef PROTECT_TRACE_INCLUDE_PATH + * #undef PROTECT_TRACE_INCLUDE_PATH + * + * #include + * #include + * #include + * + * #else + * + * + * + * #endif + * + * The header that includes vendor hooks header file should define + * PROTECT_TRACE_INCLUDE_PATH before including the vendor hook file like this: + * + * #define PROTECT_TRACE_INCLUDE_PATH + * #include + */ +#ifdef STORED_TRACE_INCLUDE_PATH +# undef TRACE_INCLUDE_PATH +# define TRACE_INCLUDE_PATH STORED_TRACE_INCLUDE_PATH +# undef STORED_TRACE_INCLUDE_PATH +#else +# undef TRACE_INCLUDE_PATH +#endif + diff --git a/include/trace/hooks/save_incpath.h b/include/trace/hooks/save_incpath.h new file mode 100644 index 000000000000..3b4621a47275 --- /dev/null +++ b/include/trace/hooks/save_incpath.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Include this file from a header declaring vendor hooks to preserve and later + * restore TRACE_INCLUDE_PATH value. Typical usage: + * + * #ifdef PROTECT_TRACE_INCLUDE_PATH + * #undef PROTECT_TRACE_INCLUDE_PATH + * + * #include + * #include + * #include + * + * #else + * + * + * + * #endif + * + * The header that includes vendor hooks header file should define + * PROTECT_TRACE_INCLUDE_PATH before including the vendor hook file like this: + * + * #define PROTECT_TRACE_INCLUDE_PATH + * #include + */ +#ifdef TRACE_INCLUDE_PATH +#define STORED_TRACE_INCLUDE_PATH TRACE_INCLUDE_PATH +#undef TRACE_INCLUDE_PATH +#endif +