Introduce interrupts module for debug and trace
Interrupts module has following functions to perform: 1. Apply boot time configuration - Create a new trace instance - Enable required irq and irq_gia events in the instance - Apply required filters on the high frequency events - Set instance's trace buffer size - Enable tracing 2. Sepolicy for every required access 3. Copy interrupts trace buffer to dumpsys whenever triggered AVC denials: avc: denied { search } for comm="dump_interrupts" name="radio" dev="dm-53" ino=373 scontext=u:r:dump_interrupts_traces:s0 tcontext=u:object_r:radio_vendor_data_file:s0 tclass=dir permissive=1 avc: denied { write } for comm="dump_interrupts" name="all_logs" dev="dm-53" ino=7808 scontext=u:r:dump_interrupts_traces:s0 tcontext=u:object_r:radio_vendor_data_file:s0 tclass=dir permissive=1 avc: denied { add_name } for comm="dump_interrupts" name="interrupts" scontext=u:r:dump_interrupts_traces:s0 tcontext=u:object_r:radio_vendor_data_file:s0 tclass=dir permissive=1 avc: denied { create } for comm="dump_interrupts" name="interrupts" scontext=u:r:dump_interrupts_traces:s0 tcontext=u:object_r:radio_vendor_data_file:s0 tclass=dir permissive=1 avc: denied { search } for comm="dump_interrupts" name="instances" dev="tracefs" ino=2151 scontext=u:r:dump_interrupts_traces:s0 tcontext=u:object_r:debugfs_tracing_instances:s0 tclass=dir permissive=1 avc: denied { search } for comm="dump_interrupts" name="radio" dev="dm-53" ino=373 scontext=u:r:dump_interrupts_traces:s0 tcontext=u:object_r:radio_vendor_data_file:s0 tclass=dir permissive=1 avc: denied { read } for comm="dump_interrupts" name="trace" dev="tracefs" ino=143409 scontext=u:r:dump_interrupts_traces:s0 tcontext=u:object_r:tracefs_instances_interrupts:s0 tclass=file permissive=1 avc: denied { open } for comm="dump_interrupts" path="/sys/kernel/tracing/instances/irq_gia_google/trace" dev="tracefs" ino=143409 scontext=u:r:dump_interrupts_traces:s0 tcontext=u:object_r:tracefs_instances_interrupts:s0 tclass=file permissive=1 avc: denied { create } for comm="dump_interrupts" name="interrupts_trace" scontext=u:r:dump_interrupts_traces:s0 tcontext=u:object_r:radio_vendor_data_file:s0 tclass=file permissive=1 avc: denied { write open } for comm="dump_interrupts" path="/data/vendor/radio/logs/always-on/all_logs/interrupts/interrupts_trace" dev="dm-53" ino=8102 scontext=u:r:dump_interrupts_traces:s0 tcontext=u:object_r:radio_vendor_data_file:s0 tclass=file permissive=1 avc: denied { getattr } for comm="dump_interrupts" path="/sys/kernel/tracing/instances/irq_gia_google/trace" dev="tracefs" ino=141578 scontext=u:r:dump_interrupts_traces:s0 tcontext=u:object_r:tracefs_instances_interrupts:s0 tclass=file permissive=1 avc: denied { getattr } for comm="dump_interrupts" path="/data/vendor/radio/logs/always-on/all_logs/interrupts/interrupts_trace" dev="dm-53" ino=7965 scontext=u:r:dump_interrupts_traces:s0 tcontext=u:object_r:radio_vendor_data_file:s0 tclass=file permissive=1 Flag: EXEMPT, add interrupts traces dump program to bugreport Bug: 376124648 Test: Manually checked boot time trace configuration. Collected `adb bugreport`. And checked interrupt traces are dumped into and extracted out from the bugreport. More details in the bug. Change-Id: I08872a321fa9726b50a54aeb0a91ed63c0652a3a
This commit is contained in:
parent
fa76c993b7
commit
d6b9cc46bf
8 changed files with 88 additions and 0 deletions
21
interrupts/Android.bp
Normal file
21
interrupts/Android.bp
Normal file
|
@ -0,0 +1,21 @@
|
|||
package {
|
||||
default_applicable_licenses: ["Android-Apache-2.0"],
|
||||
}
|
||||
|
||||
cc_binary {
|
||||
name: "dump_interrupts_traces",
|
||||
srcs: ["traces/dump_interrupts_traces.cpp"],
|
||||
init_rc: ["init.interrupts.rc"],
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Werror",
|
||||
],
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libdump",
|
||||
"liblog",
|
||||
],
|
||||
vendor: true,
|
||||
relative_install_path: "dump",
|
||||
}
|
23
interrupts/init.interrupts.rc
Normal file
23
interrupts/init.interrupts.rc
Normal file
|
@ -0,0 +1,23 @@
|
|||
on init
|
||||
# Create the directory for the trace instance during early init
|
||||
mkdir /sys/kernel/tracing/instances/irq_gia_google 0755 root root
|
||||
chown system system /sys/kernel/tracing/instances/irq_gia_google
|
||||
chown system system /sys/kernel/tracing/instances/irq_gia_google/trace
|
||||
|
||||
# Enable gia events
|
||||
write /sys/kernel/tracing/instances/irq_gia_google/events/irq_gia/enable 1
|
||||
|
||||
# There are some very high frequency IRQ events happening all the time. Tracing
|
||||
# them is not absolute necessity, but a flood of them is noise for more interesting
|
||||
# events that we want to capture. All these high frequency IRQs have virq < 11.
|
||||
write /sys/kernel/tracing/instances/irq_gia_google/events/irq/filter "irq > 11"
|
||||
write /sys/kernel/tracing/instances/irq_gia_google/events/irq/irq_handler_entry/enable 1
|
||||
write /sys/kernel/tracing/instances/irq_gia_google/events/irq/irq_handler_exit/enable 1
|
||||
|
||||
# Keep the buffer size small. This size is practically enough for debug purpose.
|
||||
# Having low size helps because this entire buffer gets dumped in bugreport.
|
||||
# Having a large size can impact bugreport size and time it takes to pack/unpack.
|
||||
write /sys/kernel/tracing/instances/irq_gia_google/buffer_size_kb 512
|
||||
|
||||
# Go!
|
||||
write /sys/kernel/tracing/instances/irq_gia_google/tracing_on 1
|
3
interrupts/interrupts.mk
Normal file
3
interrupts/interrupts.mk
Normal file
|
@ -0,0 +1,3 @@
|
|||
BOARD_VENDOR_SEPOLICY_DIRS += device/google/gs-common/interrupts/traces/sepolicy
|
||||
|
||||
PRODUCT_PACKAGES += dump_interrupts_traces
|
30
interrupts/traces/dump_interrupts_traces.cpp
Normal file
30
interrupts/traces/dump_interrupts_traces.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright 2024 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 <dump/pixel_dump.h>
|
||||
#include <android-base/file.h>
|
||||
|
||||
int main() {
|
||||
std::string outputDir = concatenatePath(BUGREPORT_PACKING_DIR, "interrupts");
|
||||
if (mkdir(outputDir.c_str(), 0777) == -1) {
|
||||
printf("Unable to create folder: %s\n", outputDir.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
copyFile("/sys/kernel/tracing/instances/irq_gia_google/trace",
|
||||
concatenatePath(outputDir.c_str(), "interrupts_trace").c_str());
|
||||
|
||||
return 0;
|
||||
}
|
7
interrupts/traces/sepolicy/dump_interrupts_traces.te
Normal file
7
interrupts/traces/sepolicy/dump_interrupts_traces.te
Normal file
|
@ -0,0 +1,7 @@
|
|||
#
|
||||
pixel_bugreport(dump_interrupts_traces)
|
||||
|
||||
allow dump_interrupts_traces radio_vendor_data_file:dir { search add_name create write };
|
||||
allow dump_interrupts_traces radio_vendor_data_file:file { getattr create write open };
|
||||
allow dump_interrupts_traces debugfs_tracing_instances:dir search;
|
||||
allow dump_interrupts_traces tracefs_instances_interrupts:file { getattr read open };
|
2
interrupts/traces/sepolicy/file.te
Normal file
2
interrupts/traces/sepolicy/file.te
Normal file
|
@ -0,0 +1,2 @@
|
|||
#
|
||||
type tracefs_instances_interrupts, sysfs_type, fs_type;
|
1
interrupts/traces/sepolicy/file_contexts
Normal file
1
interrupts/traces/sepolicy/file_contexts
Normal file
|
@ -0,0 +1 @@
|
|||
/vendor/bin/dump/dump_interrupts_traces u:object_r:dump_interrupts_traces_exec:s0
|
1
interrupts/traces/sepolicy/genfs_contexts
Normal file
1
interrupts/traces/sepolicy/genfs_contexts
Normal file
|
@ -0,0 +1 @@
|
|||
genfscon tracefs /instances/irq_gia_google/trace u:object_r:tracefs_instances_interrupts:s0
|
Loading…
Add table
Add a link
Reference in a new issue