Commit graph

4339 commits

Author SHA1 Message Date
Douglas Anderson
9f760f8d41 init: Reorder GetBlockDeviceSymlinks() so FindDmDevice() is first
By moving FindDmDevice() it's easier to unify the code with the
IsBootDevice() function. In this case the order doesn't matter since
anything with the uevent path "/devices/virtual/block/dm-" (the only
devices FindDmDevice() looks at) won't match any of the other sections
of the if/then/else test.

Bug: 316324155
Test: Build & boot

Change-Id: I819eb60aa5077f0eb2c2f2783b152e43a52ba8b7
2024-11-05 15:55:26 -08:00
Douglas Anderson
e53e50e3fa init: Add partition_uuid to Uevent
As of commit upstream Linux kernel commit 74f4a8dc0dd8 ("block: add
partition uuid into uevent as "PARTUUID""), it's easy to include the
partition UUID in the Uevent structure. Add it in so that other parts
of the init code can make decisions based on the partition UUID.

If this code is run on older kernels we'll never see the partition
UUID and it will be left blank.

Bug: 316324155
Test: Run w/ a newer kernel and see partition_uuid populated.
Change-Id: I48a52aa006c05023f7f1cc5cc0ab5c1f1ec37455
2024-11-05 15:55:26 -08:00
Treehugger Robot
9be749fe98 Merge changes Ibd1a942d,Ie07cee76 into main
* changes:
  libmodprobe: add support for dynamic module options
  firmware_handler: extract part responsible for running ext program to lib
2024-10-31 23:09:40 +00:00
Bo Hu
c33584e2b2 Merge "Revert^3 "init: Look for super partition only on a boot device"" into main 2024-10-31 19:44:13 +00:00
Konrad Adamczyk
5cc1ca1762 Revert^3 "init: Look for super partition only on a boot device"
This reverts commit 5bfb93678f.

Reason for revert: b/376468452 and trusty boot up on arm64. This CL is causing a lot of troubles (now only on emulator, but may affect more devices in field) and shall be reverted. Desktop team will handle support for selecting single boot source (while having more than one) as part of boot_part_uuid support (at aosp/3318438).  

Change-Id: I2804c119631f592d0862f3472ffe18dbb23b17e5
2024-10-31 08:25:54 +00:00
Konrad Adamczyk
0508b53f0c Merge "Revert^2 "init: Look for super partition only on a boot device"" into main 2024-10-28 06:35:07 +00:00
Grzegorz Jaszczyk
ac474ff7a0 firmware_handler: extract part responsible for running ext program to lib
As a preparation for upcoming commit, extract part which is responsible
for external program execution to libmodprobe so it can be later
re-used not only for firmware handler but also for dynamic module
options handler within libmodprobe.

RunExternalHandler is moved entirely to separate library with two
changes:
- Setting env needed previously by firmware handler was made generic and
  now external handler can get envs_map containing pairs of env and its
  value which needs to be set.
- "Firmware" was removed from one of the log since now it can be used in
  different context (s/External Firmware Handler/External Handler/)

Bug: 335619610
Test: `atest CtsInitTestCases` passed, especially:
      [105/129] ueventd_parser#ExternalFirmwareHandlers: PASSED (0ms)
      [106/129] ueventd_parser#ExternalFirmwareHandlersDuplicate: PASSED (0ms)

Change-Id: Ie07cee763278f224bd3c0acfbe06c44eb36d0a81
2024-10-25 09:27:43 +00:00
Treehugger Robot
e4acb47ba9 Merge "init: filter .##rc with preview SDK version" into main 2024-10-24 08:02:49 +00:00
Konrad Adamczyk
5bfb93678f Revert^2 "init: Look for super partition only on a boot device"
This reverts commit 8d71220df2.

Reason for revert: Fix for gcar emulator (basically all QEMU-based emulators) landed at aosp/3315253 and aosp/3160116.

Change-Id: If4eddd3f7e224c31019ad3bd752e2375c7567780
2024-10-24 07:28:25 +00:00
Treehugger Robot
07e913e85e Merge "Remove dependencies on the 1-variant fallback" into main 2024-10-23 03:23:18 +00:00
Cole Faust
09c18c17fd Remove dependencies on the 1-variant fallback
When adding a dependencies, if the variants don't match, but the
dependency only has 1 variant anyways, soong will always use that
variant. This makes it hard to add new variants to soong, because the
1-variant fallback stops being used and you start getting missing
variant errors. Make changes to bp files such that all dependencies
correctly specify the variant to use.

Bug: 372091092
Flag: EXEMPT refactor
Test: m nothing
Change-Id: I35a5ac0e6b63080f692be6597edf5f213c4e7acb
2024-10-22 16:33:50 -07:00
T.J. Mercier
490b505a3f Merge changes from topic "reapply_no_cgroup.rc" into main
* changes:
  Reapply "libprocessgroup: Combine all 3 ActivateControllers imple..."
  Reapply "libprocessgroup: Remove ACgroupController_getMaxActivati..."
  Reapply "libprocessgroup: Remove dependency on libcgrouprc"
  Reapply "libprocessgroup: Remove cgroup.rc file"
2024-10-22 15:07:17 +00:00
David Anderson
097b607ac6 Merge "init: Issue a wipe on boot if trade-in mode was active." into main 2024-10-18 21:55:09 +00:00
Jooyung Han
a6af9bced3 init: filter .##rc with preview SDK version
On a preview device (where codename is not "REL"), filtering .##rc files
will choose the highest versions reglardless of ro.build.version.sdk.

Bug: n/a
Test: add .36rc to an apex and see if init reads it.
Change-Id: Icd63cf70e45cc14504f839ce9492e1766147a40e
2024-10-15 15:02:11 +09:00
Treehugger Robot
499643e456 Merge "init: Remove schedtune support" into main 2024-10-09 20:45:29 +00:00
T.J. Mercier
a09ee8ece6 Reapply "libprocessgroup: Remove cgroup.rc file"
This reverts commit 972a2d30f8.

Change-Id: Icdf2824675e515ea3656b1c58ac55160ecc337df
2024-10-08 23:42:49 +00:00
Priyanka Advani (xWF)
eb34156abe Merge changes from topic "revert-3212512-XCWURMYNFC" into main
* changes:
  Revert "libprocessgroup: Remove cgroup.rc file"
  Revert "libprocessgroup: Remove dependency on libcgrouprc"
  Revert "libprocessgroup: Remove ACgroupController_getMaxActivati..."
  Revert "libprocessgroup: Combine all 3 ActivateControllers imple..."
2024-10-08 20:35:53 +00:00
Priyanka Advani (xWF)
972a2d30f8 Revert "libprocessgroup: Remove cgroup.rc file"
Revert submission 3212512

Reason for revert: Droidmonitor created revert due to b/372273614. Will be verifying through ABTD before submission.

Reverted changes: /q/submissionid:3212512

Change-Id: I37568516e973cb940f1229d52f94b8dc801da2ab
2024-10-08 18:54:37 +00:00
T.J. Mercier
90dc57cea8 Merge changes from topic "No cgroup.rc" into main
* changes:
  libprocessgroup: Combine all 3 ActivateControllers implementations into one
  libprocessgroup: Remove ACgroupController_getMaxActivationDepth
  libprocessgroup: Remove dependency on libcgrouprc
  libprocessgroup: Remove cgroup.rc file
2024-10-08 17:36:42 +00:00
Treehugger Robot
7cc50a8c29 Merge "init/epoll: clean up reorder-init-list warning" into main 2024-10-04 17:33:25 +00:00
Treehugger Robot
f348909323 Merge "Revert "init: Wait for /dev/hvc1 during ARCVM first-stage mount"" into main 2024-10-04 17:28:04 +00:00
Neill Kapron
551c6018c8 init/epoll: clean up reorder-init-list warning
This change cleans up the following build warning:

warning: ISO C++ requires field designators to be specified in
declaration order; field 'events' will be initialized after field
'handler' [-Wreorder-init-list]

Bug: none
Test: TH
Change-Id: I9fe566b452438dc9f00f782fc4435905227a60c9
Signed-off-by: Neill Kapron <nkapron@google.com>
2024-10-04 15:57:35 +00:00
T.J. Mercier
50fd822149 init: Remove schedtune support
Schedtune was an out of tree cgroup controller present in Android
kernels up to 4.19. It was replaced with uclamp and the cpu controller.
Now that 4.19 is EOL and unsupported, and schedtune is not present in
any supported Android kernels, remove the userspace support for
schedtune.

Bug: 362504801
Change-Id: Iab7b7295d1fb443209d5868ac5c65dca0aabfbab
2024-10-04 14:53:27 +00:00
Jusik Chung
8d71220df2 Revert "init: Look for super partition only on a boot device"
This reverts commit 6f0ebcb526.

Reason for revert: b/371393845 boot up failure of gcar emulator

Change-Id: I15e5bea609938cf5a1e347666b9a2abb287cb086
2024-10-04 02:21:37 +00:00
Tiffany Yang
36ea62f1fd Revert "init: Wait for /dev/hvc1 during ARCVM first-stage mount"
This reverts commit b885e4ad53.

Reason for revert: No longer needed (using virtio-blk instead)

Change-Id: I667f0d4f58060e781a5e9b21c778cd568b92971a
2024-10-03 23:52:54 +00:00
T.J. Mercier
ae4ce8ccc5 libprocessgroup: Remove cgroup.rc file
The cgroup.rc file was introduced in 192aee782 ("libprocessgroup: Add
support for task profiles") back with the initial support for task
profiles. It was intended to optimize performance associated with cgroup
operations. However over time, supporting this file led to making
libprocessgroup code more complicated (such as the cgrouprc LLNDK
interface), and the file ended up getting mmaped into nearly every
process on Android even though only a handful of them actually use it.
Replacing this file with reading and parsing of cgroup information on
demand allows us to simplify and shrink libprocessgroup, and eliminates
thousands of unused mappings without negatively affecting boot time or
other performance metrics.

Bug: 349105928
Test: Verified with memcg v2 and MaxActivationDepth 1 on Cuttlefish, Raven, and Mokey
Change-Id: Ic3f01fdf7fda89a56ab80657e1cf4573156273e6
2024-10-03 17:01:34 +00:00
David Anderson
6f451a9c8c init: Issue a wipe on boot if trade-in mode was active.
This modifies first-stage init to check for /metadata/tradeinmode/wipe
as soon as /metadata is mounted. If the file exists, we issue a request
to the bootloader to reboot to recovery and wipe /data. Since this also
wipes /metadata, the wipe indicator will be removed too.

In case some kind of failure happens in recovery, this also implements a
quick-and-dirty counter mechanism to fallback to the recovery menu.

Bug: 307713521
Test: touch /metadata/tradeinmode/wipe && adb reboot
Change-Id: I2d05903cadcdadf9c05f6736454db790a9e6b5bb
2024-10-02 20:19:08 -07:00
Jan Dabros
6f0ebcb526 init: Look for super partition only on a boot device
Init code is bailing out as soon as `super` partition was
found in the system, ignoring rest of uevents.

In case given device contains multiple boot sources, `super`
partition as well as all other partitions shall be taken
from the same boot source, instead of relying on
`which uevent came first`.

Bug: 309244873, 349144493
Test: Plug secondary USB boot device to device that supports multiple
      boot sources. Select boot from USB. Device boots properly.

Signed-off-by: Jan Dabros <dabros@google.com>
Signed-off-by: Konrad Adamczyk <konrada@google.com>

Change-Id: I70eb7d4223258ec273faa523cb67ddab0b7c32a0
2024-09-27 06:43:00 +00:00
Priyanka Advani (xWF)
1350207265 Merge "Revert "Support vendor partition in non-debuggable pVMs"" into main 2024-09-24 21:21:38 +00:00
Pechetty Sravani (xWF)
16f94816db Revert "Support vendor partition in non-debuggable pVMs"
Revert submission 3236797-b/340506965

Reason for revert: DroidMonitor created revert due to b/366178299.

Reverted changes: /q/submissionid:3236797-b/340506965

Tracking bug: b/369390218

Change-Id: I0ec7fe89a7a0ca3a9981cd80222d03a785e9b28f
2024-09-24 18:31:49 +00:00
Maciej Żenczykowski
3e8f0b53e4 Merge "start netd earlier" into main 2024-09-23 21:16:05 +00:00
Maciej Żenczykowski
e60b760e74 start netd earlier
In this change we're moving the asynchronous netd startup ahead of
the async statd and *synchronous* update_verifier.

This is desirable as we want a netd failure (which could
happen due to some mainline incompatibility wrt. bpf
or mainline shipped shared libs: resolver or netd updatable)
to be considered a signal for a bad boot.

It's still asynchronous though, so it's not ideal.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib3e252f085f569864feddaf20ac80858a3bb969d
2024-09-23 21:15:01 +00:00
Treehugger Robot
23903e1655 Merge "Support vendor partition in non-debuggable pVMs" into main 2024-09-23 20:27:15 +00:00
Matt Gilbride
9ac82420cb Support vendor partition in non-debuggable pVMs
Use the existence of
/proc/device-tree/avf/vendor_hashtree_descriptor_root_digest (rather
than kernel param androidboot.microdroid.mount_vendor=1) to know if the
vendor partition is requested.

Bug: 340506965
Test: TH
Change-Id: I0ac1c773e44454fd9c52559d833dc8eca211889c
2024-09-11 08:30:10 +00:00
Terry Guan
b9f6c12b4d Merge "init: add a swapoff built-in command" into main 2024-09-10 16:59:46 +00:00
terryguan
4399754035 init: add a swapoff built-in command
Enables a method for swapping off certain block devices or files. This
will be used before hibernation occurs.

Bug: 339688542
Test: Manual, verified that calling swapoff from a init file swapsoff
location that is specified

Change-Id: I212a6f303a023c3e440b557caae82ad3904ac9c9
2024-09-06 08:49:04 -07:00
Ryan Prichard
4f13b13aac [fastboot+init] avoid std::allocator<const T>
std::vector<const T> uses std::allocator<const T>, which is an
undocumented libc++ extension to the C++ standard library. The extension
was removed in llvm.org/PR96319. Use an ordinary non-const T instead.

Bug: http://b/349681543
Test: m fuzzy_fastboot CtsInitTestCases
Test: m MODULES-IN-system-core
Flag: EXEMPT, refactor to fix build failure
Change-Id: Ia98a2f090e87541fd35a89bd75bf9638bc7dc711
2024-09-04 17:45:14 -07:00
Treehugger Robot
41db2810bc Merge "ueventd: fix other assorted style nits" into main 2024-08-30 21:31:21 +00:00
Eric Caruso
bb4a40955a ueventd: fix other assorted style nits
Indentation in this file is four spaces, remove an
unnecessary trailing semicolon, put a space between
a type declaration and its structured binding.

clang-format shuffled a line around as well.

Bug: None
Test: compile
Change-Id: Ib4cf17fecb1e54971020dc77b7903d2aac5dd9c1
2024-08-30 13:39:49 -04:00
Eric Caruso
23276f63af ueventd: fix confusing indentation
Bug: None
Test: compile
Change-Id: I8eb39792ed13ba61dd6a61e9771935ece33ae915
2024-08-30 11:31:35 -04:00
Treehugger Robot
8067bd819f Merge "Standardize page property." into main 2024-08-29 01:31:05 +00:00
Treehugger Robot
40f2bfd604 Merge "libsnapshot: Move snapshot metadata to super partition." into main 2024-08-28 17:39:29 +00:00
Jooyung Han
ad6ec1e35d Merge "libinit_host: clean up dependencies" into main 2024-08-28 07:14:45 +00:00
Akilesh Kailash
398203d1da libsnapshot: Move snapshot metadata to super partition.
snapshot metadata files are stored in /metadata. This means, we cannot
wipe after installing any update.

This patch does the following:

1: Create a scratch space in super partition. The scratch space for ota
   metadata is just about 1MB.

2: Create ext4 filesystem on top of scratch block device.

3: Mount the scratch on /mnt/scratch_super

4: When snapshot-manager instance is created, point the /mnt/scratch/ota
to metadata_dir_ so that all the snapshot files are stored in the new
path.

All the logic of OTA remains the same. This flow is enabled only on userdebug builds for now and the only consumer would be snapshotctl

$snapshotctl apply-update /data/nbd/ -w

During init, we would have to mount the scratch partition to detect
if there is any pending updates.

With this, we would now be able to wipe the device along with the update flow. This will help incremental flashing wherein we would end up saving ~35-40 seconds on Pixel devices.

With this flow, the end-to-end update for incremental builds takes
~20-30 seconds.

Bug: 330744468
Test: Pixel 6 incremental flashing with wipe, Full OTA, vts_libsnapshot
Change-Id: Iac6ce2cf37b70ea221cd18175c8962988d03d95b
Signed-off-by: Akilesh Kailash <akailash@google.com>
2024-08-27 23:48:03 -07:00
Terry Guan
adcba86848 Merge "Add resume from hibernation in first stage init" into main 2024-08-27 21:22:51 +00:00
terryguan
d96c6b8e88 Add resume from hibernation in first stage init
If bootconfig hibernation_resume_device is present in boot config, then
we write that value to /sys/power/resume

Bug: 339688542
Test: Check resume from hibernation/boots with/without config present
Change-Id: I1a9bf63af4dab07e494740722898c1aba33c00b5
2024-08-27 09:37:25 -07:00
Jooyung Han
9b4ad17bfb libinit_host: clean up dependencies
libinit_host doesn't need HIDL stuff. host_init_verifier does HIDL
interface checks.

Bug: 326827772
Test: mmma system/core
Change-Id: I59c1444649a62202abb54a2e0cceee38522c1259
2024-08-27 13:10:33 +09:00
Steven Moreland
b47e18a659 Standardize page property.
ro.boot.hardware.cpu.pagesize is used on some devices to
report the page size. However, we also know what value this
should be from the CPU. Rather than create a separate property
for this, standardize around this property.

This also allows us to test the value of this property on all
devices.

Bug: 358696947
Test: Vts16KPageSizeTest
Change-Id: I7f6260c68e17e7df8a789e9066a7171f3a56f4b0
2024-08-23 00:41:44 +00:00
Jooyung Han
d51fb54d56 init: remove interface checks from init
HIDL interface checks are done by host_init_verifier at build-time.

Bug: 326827772
Test: mmma system/core/init
Change-Id: I18e9590aba614bebfdbc6aa8bca7036821a6c4f3
2024-08-21 17:44:09 +09:00
Jooyung Han
95c4242cf6 host_init_verifier: check interface names directly
Previously, ServiceParser did the check, but only when it's invoked by
host_init_verifier. Host_init_verifier can do it directly, which removes
unnecessary runtime dependencies from init.

Bug: 326827772
Test: host_init_verifier detects wrong HIDL interface names.
Change-Id: I4c8bb0e89a5def7341c48c52af730795a6ee13c0
2024-08-21 17:42:05 +09:00