Commit graph

69554 commits

Author SHA1 Message Date
Elliot Berman
6eb234017a first_stage_init: Add SIGCHLD handler in first_stage_console
Add a simple SIGCHLD handler to reap zombie processes given to init.

Bug: 197662257
Change-Id: I6e7930cfd7c311c454b361b9a541369ece2eb744
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
2021-08-24 17:20:02 -07:00
Bart Van Assche
dba7e067dd Merge changes Ifa16084c,I3e3560f3,I63637811
* changes:
  Reduce the queue depth of loop devices used by the zram driver
  libdm: Export ExtractBlockDeviceName()
  libdm: Make ExtractBlockDeviceName() return its result
2021-08-13 17:43:17 +00:00
Bart Van Assche
0223cd89f7 Reduce the queue depth of loop devices used by the zram driver
Make the queue depth of loop devices identical to that of the underlying
storage device. This patch reduces latency by lowering the queue depth.
With this patch applied I see the following:

 # cat /sys/block/loop30/queue/nr_requests
32

Bug: 194450129
Test: Built Android images, installed these and verified that the queue depth of loop devices is 32 instead of 256.
Change-Id: Ifa16084c7df3a54d9559c2388abc4a8392ff88c6
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-08-12 15:42:51 -07:00
Bart Van Assche
c24f7b8224 libdm: Export ExtractBlockDeviceName()
Make this function available to libdm users. A caller outside libdm will
be added by a later patch.

Bug: 194450129
Test: mm libfs_mgr libdm_test
Change-Id: I3e3560f3cdef8978eac644d5b53cf3851209c0c2
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-08-12 15:11:48 -07:00
Bart Van Assche
6b296db8e3 libdm: Make ExtractBlockDeviceName() return its result
From https://engdoc.corp.google.com/eng/doc/devguide/cpp/styleguide.md:
"Prefer using return values over output parameters: they improve
readability, and often provide the same or better performance (see the C++
Primer)." Implement this advice for ExtractBlockDeviceName(). This patch
does not change any functionality.

Bug: 194450129
Test: mm libfs_mgr libdm_test
Change-Id: I6363781163eba08e6128507b403200f472f68a59
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-08-12 15:11:39 -07:00
Yabin Cui
c5c532fc31 Merge "debuggerd: add -fno-finite-loop to fix test." 2021-08-11 23:24:11 +00:00
Yabin Cui
e90a944c8a debuggerd: add -fno-finite-loop to fix test.
After compiler update, infinite side effect free loops are replaced with trap
instructions. So use -fno-finite-loop to disable this behavior.

Bug: 196162833
Test: run debuggerd_test.
Change-Id: I057263360a5df64af18c17a025fab48887d0b470
2021-08-11 13:21:11 -07:00
Christopher Ferris
4a9a79e3ff Merge "Remove jmgao from OWNERS files." 2021-08-11 17:28:27 +00:00
Yi-Yo Chiang
a50ffe6c7b Merge "Increase the minimal remount scratch size to 64MiB for F2FS scratch" 2021-08-11 07:42:51 +00:00
Christopher Ferris
0ef9b4d365 Remove jmgao from OWNERS files.
Josh no longer works on Android, so remove him from OWNERS files.

Test: NA
Change-Id: I676cd803b5e3167db1b5175a630d85d1edfcaaaf
2021-08-10 21:42:14 -07:00
Treehugger Robot
d82efe0bf0 Merge "fastboot: fix --disable-verifiation error message" 2021-08-11 04:09:46 +00:00
David Anderson
489f09abd4 Merge "fastbootd: Delete all VAB partitions during "flashall"." 2021-08-10 18:09:39 +00:00
Bowgo Tsai
671249a3d2 fastboot: fix --disable-verifiation error message
There is an unclear error message if we run
`fastboot --disable-verification flash boot boot.img` on a
AVB-disabled device without a /vbmeta partition.

Error message:
  terminating with uncaught exception of type std::out_of_range: basic_string
  Aborted

This is because the buf->fd of the loaded boot.img is not reset,
before returning from function copy_boot_avb_footer().

Also reset some changes in copy_boot_avb_footer() from commit
If83f785e235569ee8ef0de2b37f11dbd2a9a71f4, to prevent the
unnecessary read of the boot vbmeta if no need to copy the
boot image avb footer.

Bug: 191903922
Test: `fastboot --disable-verification flash boot boot.img` on a device
      without /vbmeta and without setting BOARD_AVB_ENABLE to true.
Change-Id: If84f08f1b2e12c4c6ded5cafda2bd1d30e75c662
2021-08-10 17:05:17 +08:00
David Anderson
1f670ef7a8 fastbootd: Delete all VAB partitions during "flashall".
With VAB we encourage a smaller super partition, so make sure we delete
"other" slot partitions during flashing. Otherwise, we may not have
enough space in super.

Bug: 195930130
Test: set_active, flashall, ensure other slot is deleted
Change-Id: Ic6a4f60e8f4c7abb8af7b38228753ad8ed85eedf
2021-08-09 12:36:13 -07:00
Yi-Yo Chiang
e6c21b9be1 Increase the minimal remount scratch size to 64MiB for F2FS scratch
F2FS requires a larger minimal size than the current value of 16MiB.

Bug: 171368484
Fixes: 171368484
Test: Presubmit
Change-Id: I085d91634ada673388b07a0f5c6b1847e261b7f8
2021-08-09 07:39:24 +00:00
Alexander Potapenko
6e3f64e7d8 Merge "Restrict creation of bootreceiver tracing instance to 64-bit systems." 2021-08-06 13:29:42 +00:00
Shikha Malhotra
f870b88e1b Merge "Move flattened APEX activation logic to apexd." 2021-08-06 08:15:23 +00:00
Tri Vo
2b52180603 Merge "trusty: storage: Allow starting without /data mounted" 2021-08-06 05:29:45 +00:00
Shikha Malhotra
720694dcca Move flattened APEX activation logic to apexd.
Also the check that linker configuration should not be updated if APEX
is in updatable state, is removed as now with refactoring of code and its
movement to apex project, that is also needed.

Resolves: https://b.corp.google.com/issues/192838499
Test: Run the AVD Device and check that it boots and run atest
ApexTestCases

Change-Id: I80a94fa0a4145d30546bb34a6d478a20a2881368
2021-08-05 19:57:21 +00:00
Alexander Potapenko
ec37ba8359 Restrict creation of bootreceiver tracing instance to 64-bit systems.
The main users of this instance are KFENCE and MTE-aided KASAN, which are only supported on arm64.
Skip creation of this tracing instance on 32-bit systems to save ~6Mb memory on low-end devices.

Bug: 195089948
Bug: 194719088
Bug: 194156700
Change-Id: Icaf762715fed7a282b1ad738c10bcb45dc848f4d
2021-08-05 18:46:43 +00:00
Bart Van Assche
155684c2bf Merge changes from topic "zram_loop"
* changes:
  Set the I/O scheduler of loop devices to 'none'
  Rename two local variables
2021-08-05 16:57:53 +00:00
Akilesh Kailash
e19f7be126 Merge "snapuserd: Read partition blocks to memory" 2021-08-05 03:02:07 +00:00
Bart Van Assche
ec5f635270 Set the I/O scheduler of loop devices to 'none'
The user interface of Android devices becomes very slow under memory
pressure. This is because Android uses the zram driver on top of the loop
driver for swapping, because under memory pressure the swap code alternates
reads and writes quickly, because mq-deadline is the default scheduler for
loop devices and because mq-deadline delays writes by five seconds for such
a workload with default settings. Fix this by selecting I/O scheduler 'none'
for loop devices.

Bug: 194450129
Test: Built Android images, installed these and verified that the I/O scheduler of all loop devices is 'none' instead of 'mq-deadline'.
Change-Id: Ia5f606504b663948ab56955cad5a71885a356430
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2021-08-04 08:57:32 -07:00
Bart Van Assche
06b95de973 Rename two local variables
Improve code readability by renaming 'device' into 'loop_device' and
'device_fd' into 'loop_fd'.

Bug: 194894000
Test: Built Android images and installed these on an Android device.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Change-Id: Ia9c2d7a525e727f8706e66631b97fc4678c6a4d9
2021-08-04 08:57:27 -07:00
Akilesh Kailash
a11a338e2b snapuserd: Read partition blocks to memory
When the device is rebooted after OTA is done,
daemon will read through all the dynamic partitions
to bring the blocks to memory. When update-verifier
runs, all the blocks would be in page-cache thereby
cutting down the boot time.

Boot time improvements on Pixel:

Full OTA:
===========

VABC (Without this patch): 37.308 seconds
VABC (With this patch): 28.604 seconds

Incremental OTA:
=================

VABC (Without this patch): 39.072 seconds
VABC (With this patch): 27.523 seconds

We read the blocks only during second stage transition. Thus,
it shouldn't impact when snapuserd is spin up during
post-install phase or during first-stage init.

Bug: 193863442
Test: Full and Incremental OTA on pixel
Signed-off-by: Akilesh Kailash <akailash@google.com>
Change-Id: Id654449238e22125f7d6288c7100fde512cc2ced
2021-08-04 08:38:10 +00:00
David Anderson
381c0fc07c Merge "Add a helper script for dumping snapshot protos." 2021-08-04 06:03:04 +00:00
David Anderson
6a2963e05a Merge "libsnapshot: Use std::unordered_set in DmSnapCowSizeCalculator." 2021-08-03 16:47:11 +00:00
Joel Galenson
0dd5dfed4a Merge "Migrate Rust libcutils bindings into librustutils." 2021-08-03 14:20:06 +00:00
Jiyong Park
5384f93751 Merge "Remove ndk_platform backend. Use the ndk backend." 2021-08-03 11:18:25 +00:00
Yi-Yo Chiang
215fde0fde Merge "fs_mgr: Add fs_mgr_flag overlayfs_remove_missing_lowerdir" 2021-08-03 08:46:57 +00:00
Daniel Rosenberg
c90b727301 Merge changes from topic "CowXorOp"
* changes:
  libsnapshot: Don't PrepMergeOps on resume
  snapuserd: Add support for Xor ops in snapuserd
  snapuserd: Rename Read Ahead Iterator
  snapuserd: Add XorSink
  libsnapshot: Clone worker readers from snapuserd
  libsnapshot: Add support for Xor ops in Cow Format
2021-08-03 03:15:49 +00:00
Tri Vo
91e475068d trusty: storage: Allow starting without /data mounted
Bug: 187105270
Test: m
Change-Id: I3735e0752a6e502536000bd3102abda30cbd58fe
2021-08-02 15:02:11 -07:00
Suren Baghdasaryan
9accb43a6a Merge "libprocessgroup: Activate controllers in cgroup v2 hierarchy at intermediate levels" 2021-08-02 21:27:37 +00:00
Suren Baghdasaryan
25ad3f9b86 libprocessgroup: Activate controllers in cgroup v2 hierarchy at intermediate levels
When creating uid/pid hierarchy, cgroup.subtree_control should be set at
every level of that hierarchy except for the leaf level.

Bug: 195149205
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Iedc2e859715b31db62158c85016708f252db2b70
2021-08-02 20:02:51 +00:00
Tom Cherry
18a9324e3f Merge "Allow mapping of raw block devices to partition names" 2021-08-02 18:59:25 +00:00
David Anderson
2a1603d07e Merge "snapuserd: Improve EnsureSnapuserdConnected logic." 2021-08-02 18:45:44 +00:00
Christopher Ferris
d874398501 Merge "Always use main thread pid for manual dumping." 2021-08-02 17:54:35 +00:00
Eric Biggers
392b9778e6 Merge "fs_mgr: Look for fstab file in /system/etc" 2021-08-02 17:07:03 +00:00
Yi-Yo Chiang
e7783a98af fs_mgr: Add fs_mgr_flag overlayfs_remove_missing_lowerdir
If this flag is given, then fs_mgr_mount_overlayfs_fstab_entry() shall
filter out missing directories in the lowerdir= list.

For example,

  test /mnt/vendor/overlay_test overlay \
    ro,lowerdir=/dir1:/dir2:/missing_dir3 \
    first_stage_mount,overlayfs_remove_missing_lowerdir

should mount the overlayfs device with "lowerdir=/dir1:/dir2".

Bug: 186342252
Test: Manual boot test with modified fstab on CF
Change-Id: Id06b37d0c236528cef981e495280b4f4e9c2b4bb
2021-08-03 01:02:31 +08:00
Eric Biggers
e98afa2687 fs_mgr: Look for fstab file in /system/etc
Look for the fstab file in /system/etc as an alternative to /, in order
to allow fstab files to be installed using the "prebuilt_etc" Soong
module.

This new path is meant to be used by the vendor ramdisk only. As before,
fstabs should *not* be placed in /system/etc on the system partition.

In more detail: sometimes, multiple nearly-identical fstabs need to be
installed to a device, with the correct one being selected at boot time
(b/191417025 as well as other cases that partners have run into).  To
avoid error-prone duplication of configuration files, these fstabs
should be generated from a template by the build system instead of being
duplicated in the source tree.  But if this is done, the usual way of
installing fstabs (PRODUCT_COPY_FILES) can't be used; they need to be
made into real build system modules instead.

Currently, the "prebuilt_etc" Soong module can't correctly install the
vendor_ramdisk copy of the fstab(s), since it will install it into the
/system/etc directory whereas Android currently requires that the
vendor_ramdisk copy of the fstab(s) be placed in the root directory.

Earlier I proposed adding a "prebuilt_fstab" module to handle this quirk
(https://r.android.com/1744033).  However, it was requested to instead
always look for the fstabs in /etc too, in order to allow "prebuilt_etc"
to be used and because /etc is the appropriate place for this file.
This change implements that suggestion (but actually using /system/etc,
since that is where "prebuilt_etc" actually installs it).

Bug: 191417025
Test: Tested that a device boots both with this, both before and after
      http://ag/15075136 which uses the new location.
Change-Id: Id083070e51ae85959167e4615cd96b31a0b1bd6a
2021-08-02 09:59:51 -07:00
Daniel Rosenberg
a7573c7b90 libsnapshot: Don't PrepMergeOps on resume
If we're reading up to a label, we're resuming setting up the file, and
there is no reason to expect the ops we require for sequence ops to be
present. In that case, skip prepping for merge, and return an empty
merge iterator if it is mistakenly requested.

Test: cow_api_test CowTest.ResumeSeqOp
Change-Id: Idd93bd4c4209197b9728fcb21a7191aae971b62d
2021-07-30 20:44:46 -07:00
Daniel Rosenberg
e278cee742 snapuserd: Add support for Xor ops in snapuserd
This adds the ability to read the blocks corresponding to xor operations
from snapuserd. Xor Operations should be treated the same as copy
operations during the merge, but before their data is written to disk,
it must be xor'ed against the operation's data. For the purposes of
readahead, this acts as a copy op. Post readahead, it acts more like a
replace op.

Change-Id: I7d74bbdd43bfc5277ef4c8aade57dd375be9180a
Bug: 177104308
Test: vts_libsnapshot_test and cow_snapuserd_test
2021-07-30 20:44:46 -07:00
Daniel Rosenberg
35bbf11ec1 snapuserd: Rename Read Ahead Iterator
Test: Builds
Change-Id: I1644da1e410141660f3d78447be1da590476505e
2021-07-30 20:44:46 -07:00
Daniel Rosenberg
edf7c667da snapuserd: Add XorSink
We can compute the xor while decompessing by computing it within a
buffer. This would allow us to use a smaller buffer than the full block
size if we wish to cut down on the extra memory required.

Bug: 177104308
Test: cow_snapuserd_test (Snapuserd_Test.xor_buffer)
Change-Id: Id18505841c77340760cea2d20e83454f1142b9b5
2021-07-30 20:44:46 -07:00
Daniel Rosenberg
d091522de9 libsnapshot: Clone worker readers from snapuserd
We'll need to have the Cow Files parsed to deal with xor ops, since
their data location is implicit from the format. Since the relevant data
is all stored in shared pointers, we can pass that data into the workers
without needing to reparse or copy.

Bug: 177104308
Test: builds
Change-Id: I96ac3da1ae620be48e5340c9f146c523b3ce74b6
2021-07-30 20:44:46 -07:00
Daniel Rosenberg
d83b2efb12 libsnapshot: Add support for Xor ops in Cow Format
This adds support for Xor Ops in the Cow Format. These represent store
possibly compressed data which must be xor'ed against the given section
of source data to be interpreted as a block in the new image. The cow
reader and writer do not have access to this data, so they assume the
provider and user of the data will handle the xor-ing.

Bug: 177104308
Test: cow_api_test (ReadWriteXor)
Change-Id: I7a313d2643773d6b81a878a3e5bc87e3bdfc387b
2021-07-30 20:44:46 -07:00
David Anderson
2ed67c9ca4 Add a helper script for dumping snapshot protos.
Bug: N/A
Test: manual test
Change-Id: Iba789cef899d8cbd2b5d623913d169a8258471c5
2021-07-30 16:48:16 -07:00
Christopher Ferris
a3e9a0b2e1 Always use main thread pid for manual dumping.
When running debuggerd from the command line, it's possible that
the signal will happen on a side thread. The original intercept
in tombstoned is set to only handle crashes from the main thread
pid, so in this case, the intercept doesn't occur. To fix this,
modify the code so that running debuggerd always sends the signal
to the main pid. In addition, modify the signal handler is entered
due to the BIONIC_SIGNAL_DEBUGGER signal, then the crashing tid is
set to the main thread pid instead of the current thread.

Add unit test to cover this case.

Bug: 194346289

Test: All unit tests pass.
Test: Verify the new unit test is getting the signal on the non-main
Test: thread and still properly handling the intercept.
Test: Modify the debuggerd code to send the signal to the non main pid
Test: and verify the dump still occurs correctly.

Change-Id: I2dd1bd11fc8ef4a6fe87f05ecc67ae349a101c82
2021-07-30 14:08:03 -07:00
David Anderson
8c1e93196b libsnapshot: Use std::unordered_set in DmSnapCowSizeCalculator.
There is a check here if vector resize fails. In practice, this would
throw bad_alloc or length_error and cause a runtime abort, so the check
is dead code.

To protect against bad chunk_ids we can switch to unordered_set instead.
The original memory concerns for std::set are less applicable since
unordered_set is bucketed.

Bug: 194431534
Test: apply OTA; run vts_libsnapshot_tests
Change-Id: I09c108b700d2f83acf80a9eaa5099b46aedcab89
2021-07-30 11:02:28 -07:00
Tom Cherry
96e5f9b5b8 Allow mapping of raw block devices to partition names
Allow mapping of raw block devices (those without a partition table)
to partition names for first stage mount and ueventd.  For example, a
block device `vdb` that contains only an ext4 metadata partition could
be mapped to `metadata` such that /dev/block/by-name/metadata is
created.

The mapping is provided by the `androidboot.partition_map` bootconfig
or kernel command line parameter.

Bug: 159943320
Test: boot with raw vdb,metadata;vdc,userdata partitions
Change-Id: Ib6a939d6fb88b85c46c81d613425a127627a734b
2021-07-30 10:35:58 -07:00