No description
Find a file
Douglas Anderson e9de310061 init: Add the ability to find the boot device by partition UUID
The current mechanism for specifying boot devices on Android systems
involves passing a set of "boot_devices" though command line,
bootconfig, or device tree.

The bootdevices are specified as strings and, in general, need to
match a sysfs path but without the "/sys/devices" or
"/sys/devices/platform" prefix. The sysfs path is generally the path
to the closest parent of the block device that is a "platform" device.

As an example, if the sysfs path of the expected boot device is:
  /sys/devices/platform/soc@0/7c4000.mmc/mmc_host/mmc1/mmc1:0001/block/mmcblk1

The bootloader would specify it as "soc@0/7c4000.mmc" since:
* We strip off "/sys/devices/platform/"
* As we move up directories, we don't find one whose subsystem is
  "platform" until we get up to
  "/sys/devices/platform/soc@0/7c4000.mmc".

The current mechanism is a bit brittle. Specifically:
* The sysfs path isn't _really_ stable and can change across kernel
  upgrades. For instance, during one kernel upgrade the device tree
  for a product changed so that the root node changed from "soc" to
  "soc@0" and this changed all sysfs paths. In the past device tree
  folks have asserted that we shouldn't rely on dts node names to stay
  consistent, yet those node names are used to construct sysfs paths.
* For some devices, like USB, the path of the closest "platform"
  device tends to be the path of the USB controller. This means that
  if two USB disks are plugged in we can't guarantee which one will be
  identified as the boot device.

Add a new method of finding the boot device by passing the partition
UUID that we loaded the kernel from. Using the partition UUID to
identify the boot device is standard on Linux. You can see this
because when you're not using an initramfs you can use the syntax
"root=PARTUUID=<valid-uuid-id>[/PARTNROFF=n]" to specify the root.
Using the same idea for Android's boot code makes sense.

With this new method for finding the boot device, we can make the code
much more specific about matching sysfs paths. Once we find the sysfs
path for the kernel we can make sure that all of the other boot
partition share the same "scsi" or "mmc" parent instead of going all
the way to the closest platform device. In the above example, this
means that we'd make sure that all boot devices are found under this
sysfs node:
  /sys/devices/platform/soc@0/7c4000.mmc/mmc_host/mmc1/mmc1:0001/block/mmcblk1
...instead of just making sure they are under:
  /sys/devices/platform/soc@0/7c4000.mmc

There is the question of what we should do if the bootloader passes
_both_ an old style "boot_devices" and also a partition UUID. In this
case, we'll issue a warning and then ignore the old "boot_devices".
Considering it a warning rather than an error could allow switching to
the "boot_part_uuid" method even if an old bootloader is still
hardcoding some old "boot_devices".

NOTE: Using partition UUID won't cause any security problems even
though someone _could_ plug in an external device crafted to have the
same UUID as the normal boot device's kernel partition. We already
have "verity" in the system making sure our filesystems are not
tampered with and this would also protect us from booting a tampered
disk. That means that the worst someone could do in this case would be
to confuse the system and make the device non-bootable. Chromebooks
have been using the partition UUID to find the root filesystems for
years and this has never been a problem.

NOTE: this new method relies on the commit ("init: Add partition_uuid
to Uevent") which in turn relies upstream kernel commit 74f4a8dc0dd8
("block: add partition uuid into uevent as "PARTUUID"").

Bug: 316324155
Test: Use partition UUID to boot

Change-Id: If824cb700ca3696a442a28e6ad02d7c522c3b495
2024-11-06 13:03:15 -08:00
bootstat bootstat: avoid vector<const T> 2024-06-28 00:52:41 -07:00
cli-test [LSC] Add LOCAL_LICENSE_KINDS to system/core 2021-02-19 12:59:05 -08:00
code_coverage Disable code_coverage.other for riscv64 2022-10-13 13:49:10 -07:00
debuggerd Merge "Add support for tombstone symbolization to pbtombstone." into main 2024-10-31 21:16:01 +00:00
diagnose_usb Support building diagnose_usb against musl 2021-12-16 14:04:06 -08:00
fastboot Add support to update the DTB when flashing a vendor_boot ramdisk 2024-10-24 15:03:36 -07:00
fs_mgr Merge changes I819eb60a,I48a52aa0,Iab04742c into main 2024-11-06 16:40:33 +00:00
gatekeeperd Check AServiceManager_isDeclared before AServiceManager_getService 2023-06-14 02:43:54 +00:00
healthd charger: fix show qustion mark when start to draw UI 2024-07-22 20:06:25 +08:00
include Remove include/backtrace symlink. 2020-10-20 12:46:14 -07:00
init init: Add the ability to find the boot device by partition UUID 2024-11-06 13:03:15 -08:00
janitors Add maco to OWNERS. 2024-05-06 13:22:28 +00:00
libappfuse [LSC] Add LOCAL_LICENSE_KINDS to system/core 2021-02-19 12:59:05 -08:00
libasyncio Set min_sdk_version 2021-12-02 09:23:42 +09:00
libcrypto_utils Remove VNDK definition(s) 2024-03-15 08:19:44 +00:00
libcutils libcutils: Update libprocessgroup dependencies 2024-11-01 21:17:33 +00:00
libgrallocusage Make apex_available explicit 2022-02-09 11:37:19 -08:00
libkeyutils Make libfs_mgr dependencies vendor_ramdisk_available. 2021-07-23 16:50:06 -07:00
libmodprobe libmodprobe: add support for dynamic module options 2024-10-25 09:27:45 +00:00
libnetutils Remove VNDK definition(s) 2024-03-15 08:19:44 +00:00
libpackagelistparser parse_line: allow -1 for apexes and sdk libraries. 2024-04-26 15:30:30 +00:00
libprocessgroup libprocessgroup: Update libprocessgroup dependencies 2024-11-01 21:16:29 +00:00
libsparse Make simg2img host-only 2023-08-28 09:53:30 -07:00
libstats Merge "Remove libstats*_lazy tests from MTS" into main 2024-10-08 02:13:26 +00:00
libsuspend libsuspend: vendor_available. 2021-11-02 13:52:40 -07:00
libsync Remove NDK exports 2024-09-03 20:40:28 +00:00
libsystem Add COLOR_MODE_DISPLAY_BT2020 to graphics header. 2022-12-01 22:25:40 -08:00
libsysutils Merge "Remove VNDK definition(s)" into main 2024-05-23 00:38:19 +00:00
libusbhost Remove VNDK definition(s) 2024-03-15 08:19:44 +00:00
libutils RefBase: document leak memory case 2024-10-21 23:18:50 +00:00
libvendorsupport Use __ANDROID_VENDOR_API__ for vendor API surface 2024-10-07 16:56:06 +09:00
libvndksupport try llndk-deprecate 2023-12-21 02:09:14 +00:00
llkd llkd: Disable in userdebug builds by default 2021-11-04 16:21:46 -07:00
mini_keyctl Remove alanstokes@google.com from mini_keyctl/OWNERS 2024-07-09 21:12:32 +00:00
mkbootfs read() can return fewer bytes than requested 2024-10-30 10:35:52 -07:00
property_service Remove OEM_UNLOCK_PROP usage 2024-09-22 03:51:29 +00:00
reboot [LSC] Add LOCAL_LICENSE_KINDS to system/core 2021-02-19 12:59:05 -08:00
rootdir init: mount tracefs before apexd-bootstrap 2024-10-29 16:28:33 +09:00
run-as run-as: remove a special case. 2023-11-10 22:02:00 +00:00
sdcard [LSC] Add LOCAL_LICENSE_KINDS to system/core 2021-02-19 12:59:05 -08:00
shell_and_utilities Mark the phony shell_and_utilities_vendor as vendor: true 2024-10-21 22:04:20 +00:00
storaged Update storaged to use Health AIDL HAL V3. 2023-12-11 11:59:23 -08:00
toolbox toolbox/modprobe: Load modules from /lib/modules based on page size 2024-06-11 18:41:49 -07:00
trusty Rename KM VM related system properties 2024-10-30 09:44:27 +00:00
usbd usb: migration to USB gadget AIDL 2023-01-10 11:24:36 +08:00
watchdogd [LSC] Add LOCAL_LICENSE_KINDS to system/core 2021-02-19 12:59:05 -08:00
.clang-format Add a 2 width option of clang format. 2017-03-10 13:01:39 -08:00
.clang-format-2 Move clang-formats to build. 2019-01-18 14:26:33 -08:00
.clang-format-4 Move clang-formats to build. 2019-01-18 14:26:33 -08:00
.gitignore Ignore adb/*.pyc files 2015-08-11 12:59:58 -07:00
Android.bp Add dirgroup for trusty genrule 2024-10-10 18:21:29 +09:00
CleanSpec.mk snapshotctl don't auto-merge. 2020-03-03 13:19:49 -08:00
METADATA Add METADATA to system/core: Apache2+BSD=NOTICE 2020-04-29 13:16:41 -07:00
MODULE_LICENSE_APACHE2
OWNERS Add bug component to system/core 2023-07-26 07:57:58 -07:00
PREUPLOAD.cfg PREUPLOAD += bpfmt 2024-06-04 23:10:21 +00:00
rustfmt.toml Configure rustfmt for preupload hook 2022-04-06 21:11:09 +00:00