Commit graph

82140 commits

Author SHA1 Message Date
Daniel Zheng
3e9b88d504 Removing is_retrofit code path
This code path was never invoked. is_logical will return false on
secondary partitions in retrofit devices, so nothing actually is ever
deleted. If we manage to call the delete, the device side code will
fail with "cannot open the super partition"

Test: fastboot flashall on sargo device
Change-Id: I20b430c5c30bf992506190ea4e00b0b69c7b1005
2023-10-05 12:37:57 -07:00
Daniel Zheng
adad3dbefe Merge "Refactor off V2 Cow Ops" into main 2023-10-05 19:12:56 +00:00
Arun Sharma
608e33f736 Merge "FastbootDevice::boot1_1 null pointer dereference" into main 2023-10-05 17:33:34 +00:00
Daniel Zheng
4b3b6e2ff5 Merge "Adding test for reader compatibility" into main 2023-10-05 17:04:17 +00:00
Arun Sharma
1a3456f0bc FastbootDevice::boot1_1 null pointer dereference
FastbootDevice::boot1_1 attempts to dereference a null pointer when the
boot_control_hal_ is not set. It needs a guard statement to prevent
that.

Test: Manually tested on device without BootControl.
Bug: 301682120
Change-Id: Id86bcb915c8e2857bda26f64738dd5b643048e98
2023-10-05 16:35:24 +00:00
Elliott Hughes
b533f531df Merge "s/master/main/" into main 2023-10-05 16:09:46 +00:00
Akilesh Kailash
743c4cdb1c Merge "snapuserd: I/O request on overlapping blocks during snapshot-merge." into main 2023-10-05 13:42:30 +00:00
Akilesh Kailash
cffa413de4 snapuserd: I/O request on overlapping blocks during snapshot-merge.
This fixes the case when all the following conditions are true:

1: Incremental OTA
2: When there are sequence of overlapping COPY operations within one merge-window
   (510 blocks)
3: Device is rebooted when snapshot-merge is in-progress of this
   merge-window. When device reboots, the state of merge-window (of 510 blocks) was
   merge-in-progress (aka - only partial set of blocks were merged in
   this window thereby the state of the base device is in-complete for
   this window)
4: During the next boot, if there any I/O request from the filesystem
   which maps to the merge-window in (3):
   	a: The data has to be retrieved from the scratch space of the
	COW until the snapshot-merge for that window is completed.

	b: Once the snapshot-merge is complete for that window, data
	has to be retrieved from base device.

The bug was in step 4(a) wherein I/O request was getting routed to base
device.

This patch addresses the above flow by fixing step 4(a).

A new vts test has been added to explicitly track this issue.

Additionally, there is no need to re-scan the partition if partition is in merge resume path. This should cut down the overhead of the scan.

Bug: 275296365
Test: 1: 100 iterations of ./vts_snapuserd_test --gtest_filter=SnapuserdTest.Snapshot_COPY_Overlap_Merge_Resume_IO_Validate_TEST
2: Incremental OTA on Pixel 6 Pro with multiple iterations of device
   reboot when merge is in progress

Change-Id: Ib53be7f07ff192a84ec7f7049b2c6be01dad1041
Signed-off-by: Akilesh Kailash <akailash@google.com>
2023-10-05 05:32:31 +00:00
Kiyoung Kim
7cf712ab3b Merge "Remove libbinder_rpc_unstable from system required libs" into main 2023-10-05 03:54:36 +00:00
Daniel Zheng
c9770b29b9 Refactor off V2 Cow Ops
Refactor writer, reader + parser to work off v2 version of
CowOperations.

Test: m libsnapshot. ota on cuttlefish
Change-Id: Iec59be91e5f54782272b37702d645942df38c771
2023-10-04 18:09:35 -07:00
Daniel Zheng
a16436d5d7 Adding test for reader compatibility
Reader + Parser v3 should be able to read V2 cow format written to disk.
This test reads in a small cow file written by basic_v2_cow_writer and
parses it to ensure this compatibility checks out.

Test: cow_api_test
Change-Id: I46ebf4e3f12cdb3e4716ca5b624aab5836086733
2023-10-04 17:37:26 -07:00
Treehugger Robot
310e7ae496 Merge changes Ib7509508,I7e256e8d into main
* changes:
  snapuserd: Add an extractor tool.
  inspect_cow: Add an --extract-to argument.
2023-10-05 00:25:50 +00:00
Christopher Ferris
e9f4feaf7e Merge "Change source to be a unique_ptr." into main 2023-10-05 00:13:19 +00:00
Elliott Hughes
716ff7b55a s/master/main/
Test: treehugger
Change-Id: Iabb23436d92686b934f2f2609217714b64ae75de
2023-10-04 23:31:09 +00:00
David Anderson
c942daf179 snapuserd: Add an extractor tool.
This is similar to inspect_cow --extract-to, except it uses snapuserd.
It is a diagnostic host tool and uses the tooling added for host
testing.

Usage: snapuserd_extractor -cow COW_FILE -base BASE_FILE -out OUT_FILE
                           -num_sectors NUM_SECTORS

Unlike inspect_cow, this supports xor/copy operations.

The extractor code is separated into a utility file so we can use it for
additional tests later on.

Bug: N/A
Test: manual test
Change-Id: Ib7509508cba45e6c3a0db8c75454e33c2a503e03
2023-10-03 19:54:28 -07:00
David Anderson
8a28163d33 inspect_cow: Add an --extract-to argument.
This adds an --extract-to argument to inspect_cow to verify that full
OTA snapshots contain correct data. It does not yet work for ordered
ops.

Test: inspect_cow
Bug: N/A
Change-Id: I9014da3e83fd4fb5ea54ac1d36e527b3e3e6c9d5

Change-Id: I7e256e8ddec626980cdcf8680bbeac3c2e9d8de1
2023-10-03 16:02:26 -07:00
Christopher Ferris
9dabc9ef32 Change source to be a unique_ptr.
The current code keeps a pointer to a local variable which doesn't
work too well. Change this to a unique_ptr and allocate the source
object that will be used instead.

Test: All unit tests pass.
Test: fastboot -w flashall on a mokey which crashed without this change.
Change-Id: Ief5437374181e514928c45dd540b42898901a137
2023-10-02 17:02:51 -07:00
Treehugger Robot
e877885533 Merge "Log the CowOperation when decompression failed" into main 2023-10-02 20:45:38 +00:00
Kelvin Zhang
ab4c9621d4 Log the CowOperation when decompression failed
Test: th
Bug: 302992208
Change-Id: I617062d75a79ae73dfdff13c2e9d2a62c5dfcfc0
2023-10-02 11:08:18 -07:00
Elliott Hughes
b0bff22429 Merge "Remove obsolete <linux/capabilities.h> workarounds." into main 2023-10-02 15:09:26 +00:00
Treehugger Robot
b90cd3b5ab Merge "Adjust unit tests for supporting chain partition with no ab" into main 2023-10-02 03:28:37 +00:00
Elliott Hughes
7d46c3fd7a Remove obsolete <linux/capabilities.h> workarounds.
We've updated the glibc header (and musl will just use the bionic uapi
headers), so this is obsolete (and getting in the way of someone trying
to use the PERFMON capability).

Test: treehugger
Change-Id: Ife7ee076179e1db6246738aa41c2b82bd8546265
2023-09-29 22:45:59 +00:00
Treehugger Robot
aadb2046fd Merge "Add the missing copyright headers to the .S files." into main 2023-09-28 20:13:37 +00:00
Elliott Hughes
041afb2883 Add the missing copyright headers to the .S files.
Dates taken from `git log --follow`.

Test: treehugger
Change-Id: I80e9ea6aa01f8e0553295453749afcbc3af827f9
2023-09-28 10:41:21 -07:00
Treehugger Robot
ec74e27a61 Merge "Keep fs_mgr_vendor_overlay_test in internal cf." into main 2023-09-28 17:13:01 +00:00
wuhaitao3
250aa5ed72 Adjust unit tests for supporting chain partition with no ab
Test: libfs_avb_internal_test
      libfs_avb_test
Signed-off-by: wuhaitao3 <wuhaitao3@xiaomi.corp-partner.google.com>
Change-Id: I5f91510e72776ed2ed53756ae94a87b1417ae1a5
2023-09-28 11:19:55 +00:00
Dan Shi
69f57f98c5 Keep fs_mgr_vendor_overlay_test in internal cf.
Bug: 302382476
Change-Id: I369927033b407660d2c0e7bdb85494c826c0b406
Test: presubmit
2023-09-28 06:32:31 +00:00
Treehugger Robot
cfec879ad6 Merge "disable sync_on_suspend when flag is set" into main 2023-09-28 00:03:50 +00:00
Daniel Zheng
26bed5fc09 Merge "Add copyright to libsnapshot/tools" into main 2023-09-27 18:39:00 +00:00
Daniel Zheng
0fc7feeafb Merge "Add binary to write basic COW" into main 2023-09-27 18:38:55 +00:00
Steve Muckle
5ebc657386 disable sync_on_suspend when flag is set
Bug: 285395636
Test: suspend/resume testing
Change-Id: I2d97d8366b864ab3e72d7ae38a0f4906dc74ec6f
2023-09-27 16:36:26 +00:00
Snehal Koukuntla
321f0989e5 Merge "Remove ambgiuity in format specifier" into main 2023-09-27 16:06:58 +00:00
Tomasz Wasilczyk
8c9c7d076f Merge "Revert "Revert "Lock down String8|16.string() usage""" into main 2023-09-27 15:06:23 +00:00
Snehal
6a12d23eab Remove ambgiuity in format specifier
Bug: 302163991

Test: m trusty-coverage-controller

Change-Id: I26318eeb4a6770bd01d3c677ca3cf5c76ce33fa0
2023-09-27 12:29:07 +00:00
Kiyoung Kim
566f1371e4 Remove libbinder_rpc_unstable from system required libs
libbinder_rpc_unstable is in the list of system required libs, but the
library is already located in the system/{LIB}, and this creates link to
the self namespace. Remove libbinder_rpc_unstable from system required
libs as it doesn't make sense to have require and provide same library
in a single image.

Bug: 298333253
Test: Cuttlefish build and boot succeded
Change-Id: Idb40e1dbc1053d4882093c188a36b2cc8d86e918
2023-09-27 10:26:41 +09:00
Daniel Zheng
ac758f2ccc Merge "should_flash_in_userspace signature change" into main 2023-09-26 23:55:25 +00:00
Daniel Zheng
7a8f82acbd should_flash_in_userspace signature change
We should change should_flash_in_userspace to work without
$ANDROID_PRODUCT_OUT being set and fall back on $OUT directory when
source isn't specified

This also fixes the flashing issue of flashing retrofit devices without
$ANDROID_PRODUCT_OUT set. If we
call fastboot update on a retrofit device, copy_avb_footer will resize
buf->sz of secondary partitions to the partition size, causing us to
send the unsparsed payload to the device -> "Invalid Size" issue.

This is because secondary partitions are considered physical partitions
on retrofit devices && should_flash_in_userspace wouldn't work if
$ANDROID_PRODUCT_OUT is set, so our first return clause in
copy_avb_footer doesn't catch this edge case causing us to resize the
buf-> sz incorrectly.

Did some testing, and also observed a case where flashing is able to
succeed despite $ANDROID_PRODUCT_OUT not being set before, so there
might still be some other edge case that we are still missing.

Test: fastboot update on sargo without $ANDROID_PRODUCT_OUT

Change-Id: I0e4781d96709b712f7d71657ec0d16d99b90214d
2023-09-26 16:55:06 -07:00
Daniel Zheng
301acae35b Add copyright to libsnapshot/tools
Adding copyright to cow_benchmark + basic_v2_cow_writer

Test: th
Change-Id: Ic6c32b68bbeaa3c0c365f146ef4342356e13706a
2023-09-26 16:51:53 -07:00
Daniel Zheng
d7c5511095 Add binary to write basic COW
Adding small binary to write a simple COW for version 2. We will then
use updated reader to make sure we can read this version 2 cow. Think it
would be a good idea to keep the binary here to see how exactly we
generated the cow (useful for debugging and if we ever need to recreate
this cow)

Test: m basic_v2_cow_writer
Change-Id: I28435025b7a8280fc5c4574876cc9110b391cb0e
2023-09-26 16:51:48 -07:00
Elliott Hughes
8d983ee878 Merge "Stop duplicating <linux/capabilities.h>." into main 2023-09-26 17:59:53 +00:00
Elliott Hughes
94ccdc06d0 Stop duplicating <linux/capabilities.h>.
This doesn't help the person who wants CAP_BPF, but we can fix that
better by adding it to our stale glibc (and our future switch to musl
will mean we'll never have similar problems again).

I think this just dates from when we still supported building the OS on
darwin, but those days are long gone, and I think this hack can be put
to rest now...

Test: treehugger
Change-Id: I3c2e56c68a5b00c1ad0aed422c6ce60886063f50
2023-09-25 20:33:02 +00:00
Daniel Zheng
d774be9b05 Merge "is_retrofit_device to work in bootloader" into main 2023-09-25 18:21:36 +00:00
Thiébaud Weksteen
911d309224 Merge "Skip /metadata/sepolicy creation" into main 2023-09-25 07:40:02 +00:00
Thiébaud Weksteen
a6b5f94687 Skip /metadata/sepolicy creation
Bug: 297794885
Test: presubmit
Change-Id: I93f94f319d0f86e1cad6f2a4912b5df3aae09cec
2023-09-25 16:07:47 +10:00
Treehugger Robot
a2cd2202f0 Merge "Create_cow: Hash of target blocks should not be stored." into main 2023-09-24 00:46:55 +00:00
Treehugger Robot
6d01651ab9 Merge "Do not check with vendor vndk version" into main 2023-09-23 13:06:15 +00:00
Kiyoung Kim
45d88d496e Do not check with vendor vndk version
Current libcutils checks if memfd is supported with vendor VNDK version,
but this is no longer valid if VNDK is deprecated. As we can assume that
any vendor using this code is supported as long as it is treblelized,
simplify logic to check if memfd is valid to vendor only with
'ro.treble.enabled' property.

Bug: 290159430
Test: Cuttlefish with VNDK deprecated worked without error from
libcutils

Change-Id: I351f0798da99cb4827bc3e424b63a2eaee5c7461
2023-09-23 21:06:57 +09:00
Akilesh Kailash
810274071d Create_cow: Hash of target blocks should not be stored.
Target block hash was in-correctly getting added to map thereby
overriding the source-hash.

Bug: 299011882
Test: Flash Pixel 6 Pro from A->B and from B->A
Change-Id: Ib3887c29cd6b8f2abd50e932273a5cfc2a096bd5
Signed-off-by: Akilesh Kailash <akailash@google.com>
2023-09-23 01:07:47 -07:00
Elliott Hughes
d091aa44b3 Merge "Remove Windows workaround in file not built for Windows." into main 2023-09-22 22:56:38 +00:00
Treehugger Robot
73fcd754ee Merge "Only skip _16k/_64k kernel modules dirs on 4K builds" into main 2023-09-22 21:55:11 +00:00