Commit graph

81774 commits

Author SHA1 Message Date
Nikita Ioffe
55dd32538f Introduce microdroid variants of init_first_stage and init_second_stage
These variants will compile with -DMICRODROID flag, which will allow us
to exclude init features that are not needed for Microdroid, and
introduce features that only work in Microdroid.

Bug: 287206497
Test: build com.android.virt APEX
Change-Id: Ib9af0cfcdf06c70fc39e6e6ac8ef07bb69982969
2023-06-21 16:44:40 +01:00
Jiyong Park
e09de2a5ca libdm: don't expect uevent for devices that have never been activated
Previously, libdm ensured that uevent will be generated when a dm device
is deleted. However, there actually are cases where uevent can't be
expected; for example, if an empty dm device is created, but then gets
deleted without being activated, then there should be no uevent upon
deleting because there actually is nothing to remove from /dev. (dm
device gets added to /dev only if it is activated).

Actually such a case exists in apexd. As a performance optimization, it
proactively creates empty dm devices for all APEXes it scanns. But
some of them don't ever get activated if the APEX is already in a
dm-verity protected block device (i.e. the pre-instaled APEX is the
latest one). In that cases, the empty dm devices are deleted at the end
of the boot process as a clean up.

The libdm triggered error during the clean up, because there was no
uevent generated for the empty dm devices. This has triggered a lot of
false alarms to the apex team.

This CL fixes this by ensuring uevent only for activate dm devices. If
the dm device doesn't show up in /dev, we just delete the in-kernel
object and don't expect it to generate uevent for it - which actually is
the kernel's behavior.

Bug: 286176029
Test: build and run aosp_cf_x86_64_phone. observe dmesg.

Before the change:
I apexd   : Deleting unused dm device com.android.hardware.core_permissions
E apexd   : Didn't generate uevent for [com.android.hardware.core_permissions] removal
W apexd   : Failed to delete dm-device com.android.hardware.core_permissions

After the change:
I apexd   : Deleting unused dm device com.android.hardware.core_permissions
<no error or warning logs>

Change-Id: I52042de7d4d9ab62e6a13428c32a67e13395d1b5
2023-06-22 00:43:32 +09:00
Roy Luo
d1d5f5ab69 fastboot: remove retries on invalid IO iterator in OSX
When IOServiceGetMatchingServices returns an invalid
iterator, IOIteratorReset doesn't help. Break the loop
to prevent being stuck in the reset loop forever.
This should be fine as the open_device() call in the
upper layer is already doing retries.

Bug: 286495045
Test: fastboot update
Change-Id: Ia58fa9285640be34aa22cd77e4f58cc9092679a4
2023-06-20 21:44:53 +00:00
Eric Biggers
c7f7743f4f Merge "Remove write permission from file mode of top-level user dirs" am: 46477f1d82
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2620458

Change-Id: Idc00da3c1d5ce7f5ffc8a3f7942b947fe1b59833
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-20 17:54:45 +00:00
Eric Biggers
46477f1d82 Merge "Remove write permission from file mode of top-level user dirs" 2023-06-20 17:15:24 +00:00
David Anderson
17421a93ba inspect_cow: Add --show_raw_ops.
This bypasses CowReader and shows ops directly from CowParserV2. This
will come in handy once CowOperation is versioned and CowReader will be
translating from older versions to new versions.

Bug: 280529365
Test: inspect_cow
Change-Id: Icaeba86105c31c4dfe2812309a4028dd1d0248c0
2023-06-15 11:18:25 -07:00
David Anderson
691b78a0fd inspect_cow: Switch to gflags.
gflags is a lot cleaner to use than getopt, and we don't really need any
advanced argument parsing.

Test: inspect_cow
Bug: N/A
Change-Id: I19007a787a2e5cd3a67486c7949b34ba76f762e4
2023-06-15 11:01:56 -07:00
Treehugger Robot
614857c782 Merge "Fix LruCache, allow std:string caching" am: 1477714262
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2627034

Change-Id: I633542894afa2dd1a8a6f84c222097bd41a4e68e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-15 15:05:17 +00:00
Treehugger Robot
1477714262 Merge "Fix LruCache, allow std:string caching" 2023-06-15 14:31:47 +00:00
Nikita Ioffe
dfd57251fe Merge "Reland "Treat Microdroid as OS with monolithic sepolicy"" am: 448b70a268
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2627370

Change-Id: I7c795df5084cbd34fd66757222a0a54941609dc9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-15 11:45:32 +00:00
Nikita Ioffe
448b70a268 Merge "Reland "Treat Microdroid as OS with monolithic sepolicy"" 2023-06-15 10:27:39 +00:00
Treehugger Robot
6929fc9f1a Merge "Check AServiceManager_isDeclared before AServiceManager_getService" am: fa58ead2cb
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2623413

Change-Id: I651a15fbffdd1a13d92b66cc374397cd9d705a88
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-15 06:57:29 +00:00
Treehugger Robot
fa58ead2cb Merge "Check AServiceManager_isDeclared before AServiceManager_getService" 2023-06-15 06:00:10 +00:00
Treehugger Robot
0afb83f595 Merge "init_kill_services_test: binder logs on apexd fail" am: 642929f8f8
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2627030

Change-Id: I269f2df5c4ab3654a2e006a2e64a03020dcd505f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-15 03:55:45 +00:00
Treehugger Robot
642929f8f8 Merge "init_kill_services_test: binder logs on apexd fail" 2023-06-15 01:57:30 +00:00
David Anderson
dda9de4ed9 Merge changes I380bf705,I888b8792 am: ba3bddd153
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2625177

Change-Id: I72c87ea55ad595eac84830952f1ff6cc744587ae
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-15 01:41:15 +00:00
Steven Moreland
1501b0c344 init_kill_services_test: binder logs on apexd fail
Print logs necessary to understand why apexd isn't shutting
down when this test fails, due to a rare flake.

Bug: 285458033
Test: init_kill_services_test (and cause this error to be hit)
Change-Id: Ic9cbf7b2b9fa89504e4a53597065e94c32233e12
2023-06-15 00:44:31 +00:00
Fabien Sanglard
2aba0a2283 Fix LruCache, allow std:string caching
The default initalization for mNullValue uses 0 which is in the case of
a std::string TValue will invoke the contructor with undefined behavior
parameter.

Using an empty uniform initialization {} addresses the problem.

Test: Already tested in lrucache_test.cpp
Bug: 257127748
Change-Id: I37420ce8a16c99f3014538a0208d7e113870b1c7
2023-06-15 00:37:52 +00:00
David Anderson
ba3bddd153 Merge changes I380bf705,I888b8792
* changes:
  snapuserd: Create snapuserd_verify.h.
  snapuserd: Create snapuserd_readahead.h.
2023-06-15 00:26:25 +00:00
Nikita Ioffe
fa33f85f52 Reland "Treat Microdroid as OS with monolithic sepolicy"
Bug: 285855150
Test: presubmit
Change-Id: I477e1ef7268ac8e7d0fdae7ffcc611a69bb9d4fe
2023-06-14 20:31:17 +00:00
David Anderson
76622d444d libsnapshot: Remove dependence between CowWriterV2 and CowReader.
The plan of record for the new CowOperation layout is to automatically
translate from CowOperationV2. However, CowWriterV2 currently imports
directly from CowReader, which means we'd need two translation steps.

Luckily we now have CowParserV2, which means we can directly import into
CowWriterV2.

Bug: 280529365
Test: vts_libsnapshot_test
Test: cow_api_test
Change-Id: I11863dcb483f0448686d6c492d8eb128840ce18c
2023-06-14 12:03:59 -07:00
David Anderson
5eae2cb450 libsnapshot: Remove ISnapshotWriter.
This only added one real method to ICowWriter, so let's just fold it
into ICowWriter. CompressedSnapshotWriter goes away as well.
CompressedSnapshotReader is now part of libsnapshot_cow.

Bug: 280529365
Test: m otapackage
      apply ota
Change-Id: I55358c3c9be111d5aee1a0c22c29cb1539d05494
2023-06-14 12:03:58 -07:00
Pawan Wagh
421bb89a0d Merge "Revert "Treat Microdroid as OS with monolithic sepolicy"" am: 61b9935e50
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2626910

Change-Id: I3705bac0af860013dab32680eeee24bd280e31a8
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-14 18:57:22 +00:00
Pawan Wagh
61b9935e50 Merge "Revert "Treat Microdroid as OS with monolithic sepolicy"" 2023-06-14 18:40:59 +00:00
Pawan Wagh
85f52dd1ac Revert "Treat Microdroid as OS with monolithic sepolicy"
Revert submission 2625691

Reason for revert: b/287283650

Reverted changes: /q/submissionid:2625691

Change-Id: Ie62bbb4d4f1af528f42aafde79407b151bab46f9
2023-06-14 18:28:19 +00:00
David Anderson
4ac7d0e82e snapuserd: Create snapuserd_verify.h.
Bug: N/A
Test: builds
Change-Id: I380bf705520858dbec8053432c0a7c3fa8bed26d
2023-06-14 08:43:49 -07:00
David Anderson
1779dcca32 snapuserd: Create snapuserd_readahead.h.
This moves ReadAhead out of snapuserd_core.h so it's easier to find.

Bug: N/A
Test: builds
Change-Id: I888b87921950f2f7582b94c078e9e136f8fdd09e
2023-06-14 08:43:49 -07:00
Nikita Ioffe
4aeb74b76c Merge "Treat Microdroid as OS with monolithic sepolicy" am: 121e3b8320
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2617775

Change-Id: Ic92490103ef484154ebdebe3d3d1cd4636388a13
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-14 15:30:48 +00:00
Nikita Ioffe
121e3b8320 Merge "Treat Microdroid as OS with monolithic sepolicy" 2023-06-14 15:20:18 +00:00
Nikita Ioffe
94ef7122d6 Treat Microdroid as OS with monolithic sepolicy
Bug: 285855150
Test: atest MicrodroidTestApp
Change-Id: Idfda3044716a021888017adef801ef67775a3eda
2023-06-14 13:28:05 +01:00
Subrahmanya Manikanta Venkateswarlu Bhamidipati Kameswara Sri
32e1c70f27 Check AServiceManager_isDeclared before AServiceManager_getService
Call AServiceManager_isDeclared before calling AServiceManager_getService
to avoid the waiting time when aidl service is not available.

Bug: 286969060
Test: run VtsHalGatekeeperTarget
Change-Id: I7d652a546cb810a601338a68950f01d065aea7a5
2023-06-14 02:43:54 +00:00
Treehugger Robot
29e1ccd5cc Merge "Removing duplicate CollectImages()" am: 18c531984c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2625181

Change-Id: I5fbf5df4c160c89ee5b96cffe962efed9d86bee6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-13 23:45:48 +00:00
Treehugger Robot
18c531984c Merge "Removing duplicate CollectImages()" 2023-06-13 23:18:50 +00:00
Daniel Zheng
3dc7fcc0b6 Removing duplicate CollectImages()
images are being flashed twice, because of an additional collectImages.
This is resulting in a ~50% increase in flashing time

Test: fastboot flashall -w
Change-Id: I6c271e1e1456cd789f37ebd67cefd221cabc6e7a
2023-06-13 14:57:25 -07:00
David Anderson
f78a62e9bd Merge "libsnapshot: Add CowWriterBase, clean up CowWriter." am: 812aaa9620
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2583491

Change-Id: If51e8c92a73663c7243695083926738dcfb50a96
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-13 20:30:36 +00:00
David Anderson
812aaa9620 Merge "libsnapshot: Add CowWriterBase, clean up CowWriter." 2023-06-13 19:59:14 +00:00
David Anderson
6d20df582b Merge "fastboot: Include header for ostream_iterator and istream_iterator" am: 1347d3407e
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2623149

Change-Id: I0e3efad29e3b73eeec5cdee22b25be6319349409
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-12 22:47:17 +00:00
Treehugger Robot
a5d6d55042 Merge "fastboot: Introduce FASTBOOT_DEVICE alias for ANDROID_SERIAL environment variable" am: 929a665f02
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2621310

Change-Id: I4b88af8a45aa86464c5eb435148233320f5a5665
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-12 22:46:03 +00:00
David Anderson
1347d3407e Merge "fastboot: Include header for ostream_iterator and istream_iterator" 2023-06-12 22:26:44 +00:00
Treehugger Robot
929a665f02 Merge "fastboot: Introduce FASTBOOT_DEVICE alias for ANDROID_SERIAL environment variable" 2023-06-12 22:01:54 +00:00
Biswapriyo Nath
816480b56e fastboot: Include header for ostream_iterator and istream_iterator
This fixes the following compiler errors with gcc

storage.cpp:45:20: error: 'ostream_iterator' is not a member of 'std'
storage.cpp:50:10: error: 'istream_iterator' is not a member of 'std'

Change-Id: I570e332d100bb18e445644a9d57dc14d80f104b5
2023-06-13 00:28:24 +05:30
David Anderson
6f18eddc11 Merge "fastboot: Add header that declares std::function" am: 1f876a81dd
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2620235

Change-Id: Ie2454f2d45b6cba525dc0b65176e6f154149e2ec
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-12 18:54:10 +00:00
David Anderson
1f876a81dd Merge "fastboot: Add header that declares std::function" 2023-06-12 18:09:59 +00:00
Jiyong Park
01ff043231 Merge "init: non-crashing service can restart immediately" am: acfc93f924
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2618493

Change-Id: I2f89eb33a9b8cc0b2ccdbd26bdb882f709d71429
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-12 01:40:57 +00:00
Jiyong Park
acfc93f924 Merge "init: non-crashing service can restart immediately" 2023-06-12 01:02:34 +00:00
Biswapriyo Nath
214f37c249 fastboot: Add header that declares std::function
This fixes the following compiler error with gcc
fastboot_driver.h:51:10: error: ‘function’ in namespace ‘std’ does not name a template type

Change-Id: I3a4d9b48bfdc2c76e443e2efe1761ec9503c6dc5
2023-06-10 20:08:29 +05:30
John Stultz
9d2fb9ca3c fastboot: Introduce FASTBOOT_DEVICE alias for ANDROID_SERIAL environment variable
The ANDROID_SERIAL env is useful for managing multiple
directly connected devices at one time.

Unfortunately for network connected devices, its harder to use.

This is because both adb and fastboot use the same ANDROID_SERIAL
environment value to identify the device to use, and while that
one value works for directly connected devices, when using
network connected devices, the fastboot and adb port numbers may
differ for the same device.

So if I set: `ANDROID_SERIAL="tcp:127.0.0.1:44403"`
fastboot will work, but when I type `adb shell`, I'll get:
 adb: device 'tcp:127.0.0.1:44403' not found

As `adb devices` outputs:
List of devices attached
localhost:36697 device

To resolve this, we need separate environment variables,
so introduce a FASTBOOT_DEVICE variable for fastboot.

If FASTBOOT_DEVICE is set, it will use that, and if not
it will fall back to the ANDROID_SERIAL if it is set.

Using an explicit -s argument will still override both.

Change-Id: Icd7db6f29e51ed2decd219e35537f6ed98d698b8
Signed-off-by: John Stultz <jstultz@google.com>
2023-06-09 22:54:09 +00:00
William McVicker
5611a87aac Merge "Revert "Revert "libmodprobe: LPM: Load all modules in *.load with *.dep satisfied""" am: bb8637b399
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2462636

Change-Id: Iad82312538a908cbc12b6a3d2c0be558cc192e1d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2023-06-09 19:41:21 +00:00
William McVicker
bb8637b399 Merge "Revert "Revert "libmodprobe: LPM: Load all modules in *.load with *.dep satisfied""" 2023-06-09 18:54:42 +00:00
Jiyong Park
0d277d777f init: non-crashing service can restart immediately
This CL allows restart_period to be set to a value shorter than 5s.
Previously this was prohibited to rate limit crashing services. That
behavior is considered to be a bit too conservative because some
services don't crash, but exit deliverately.

adbd is the motivating example. When adb root or adb unroot is
requested, it changes its mode of operation (via sysprop), exits itself,
and restarts (by init) to enter into the mode. However, due to the 5s
delay, the mode change can complete no earlier than 5 seconds after adbd
was started last time. This can slow the mode change when it is
requested right after the boot.

With this CL, restart_period can be set to a value smaller than 5. And
services like adbd can make use of it. However, in ordef to rate limit
crashing service, the default is enforced if the service was crashed
last time. In addition, such intended restart is not counted as crashes
when monitoring successive crashes during booting.

Bug: 286061817
Test: /packages/modules/Virtualization/vm/vm_shell.sh start-microdroid \
 --auto-connect -- --protected
* with this change: within 2s
* without this change: over 6s

Change-Id: I1b3f0c92d349e8c8760821cf50fb69997b67b242
2023-06-09 13:06:06 +09:00