File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727#include < sys/mount.h>
2828#include < sys/signalfd.h>
2929#include < sys/types.h>
30+ #include < sys/utsname.h>
3031#include < unistd.h>
3132
3233#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
@@ -554,6 +555,19 @@ static void SetUsbController() {
554555 }
555556}
556557
558+ // / Set ro.kernel.version property to contain the major.minor pair as returned
559+ // / by uname(2).
560+ static void SetKernelVersion () {
561+ struct utsname uts;
562+ unsigned int major, minor;
563+
564+ if ((uname (&uts) != 0 ) || (sscanf (uts.release , " %u.%u" , &major, &minor) != 2 )) {
565+ LOG (ERROR ) << " Could not parse the kernel version from uname" ;
566+ return ;
567+ }
568+ SetProperty (" ro.kernel.version" , android::base::StringPrintf (" %u.%u" , major, minor));
569+ }
570+
557571static void HandleSigtermSignal (const signalfd_siginfo& siginfo) {
558572 if (siginfo.ssi_pid != 0 ) {
559573 // Drop any userspace SIGTERM requests.
@@ -824,6 +838,7 @@ int SecondStageMain(int argc, char** argv) {
824838 export_oem_lock_status ();
825839 MountHandler mount_handler (&epoll);
826840 SetUsbController ();
841+ SetKernelVersion ();
827842
828843 const BuiltinFunctionMap& function_map = GetBuiltinFunctionMap ();
829844 Action::set_function_map (&function_map);
Original file line number Diff line number Diff line change @@ -590,9 +590,23 @@ on late-fs
590590 # Load trusted keys from dm-verity protected partitions
591591 exec -- /system/bin/fsverity_init --load-verified-keys
592592
593+ # Only enable the bootreceiver tracing instance for kernels 5.10 and above.
594+ on late-fs && property:ro.kernel.version=4.9
595+ setprop bootreceiver.enable 0
596+ on late-fs && property:ro.kernel.version=4.14
597+ setprop bootreceiver.enable 0
598+ on late-fs && property:ro.kernel.version=4.19
599+ setprop bootreceiver.enable 0
600+ on late-fs && property:ro.kernel.version=5.4
601+ setprop bootreceiver.enable 0
602+ on late-fs
603+ # Bootreceiver tracing instance is enabled by default.
604+ setprop bootreceiver.enable ${bootreceiver.enable:-1}
605+
606+ on property:ro.product.cpu.abilist64=* && property:bootreceiver.enable=1
593607 # Set up a tracing instance for system_server to monitor error_report_end events.
594608 # These are sent by kernel tools like KASAN and KFENCE when a memory corruption
595- # is detected.
609+ # is detected. This is only needed for 64-bit systems.
596610 mkdir /sys/kernel/tracing/instances/bootreceiver 0700 system system
597611 restorecon_recursive /sys/kernel/tracing/instances/bootreceiver
598612 write /sys/kernel/tracing/instances/bootreceiver/buffer_size_kb 1
You can’t perform that action at this time.
0 commit comments