Commit graph

3430 commits

Author SHA1 Message Date
Christopher Ferris
758e52551f Merge "Update for new kernel headers." 2020-10-22 00:54:16 +00:00
Yifan Hong
634a3dc179 Merge "Always create ramdisk/first_stage_ramdisk." 2020-10-21 18:35:22 +00:00
Yifan Hong
42c55f5ce9 Always create ramdisk/first_stage_ramdisk.
Always create ramdisk/first_stage_ramdisk directory at build time.
Generic boot image always need this directory to work on devices
w/ and w/o a dedicated recovery partition. By default, the ramdisk is
mounted as readonly, unless on x86 platforms. If the ramdisk is mounted as
readonly, the directory cannot be created at runtime.

Note that devices with a dedicated recovery partition will never
switch root into the first_stage_ramdisk directory in first stage init.

Bug: 156098440
Test: manual by disabling init to mkdir first_stage_ramdisk

Change-Id: Ie272f4eedccc0b008fb538c1e0f3985ff70696cf
2020-10-20 13:44:09 -07:00
David Anderson
515a5bdde0 ueventd: Put dm-user devices in a folder
When a device-mapper table contains a "user" entry, a corresponding
dm-user misc control device is created. The devices are put into a
separate folder by default, which currently confuses ueventd, and we
wind up with paths like:

    /dev/dm-user!blah

Special case these devices so they wind up as:

    /dev/dm-user/blah

Test: dmctl create blah user 0 100 test-device
      /dev/dm-user/test-device exists
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
Change-Id: I313db07c3400f14f3ed0ffa20fdac2ac3e34b6d3
2020-10-20 12:13:51 -07:00
Christopher Ferris
9bbb841ee4 Update for new kernel headers.
A new capabality was added, so update.

Test: Builds.
Change-Id: I385f5d2443376e6a4dca98c34de265357a58460e
2020-10-19 11:55:12 -07:00
Treehugger Robot
ac46ab3c93 Merge "Load boot image props." 2020-10-16 19:23:08 +00:00
Yifan Hong
a68ee762f7 Load boot image props.
This change does the following:

- Create /second_stage_resources empty dir at root.
- At runtime:
  - At first stage init:
    - mount tmpfs to /second_stage_resources.
    - Copy /system/etc/ramdisk/build.prop to
      /second_stage_resources/system/etc/ramdisk/build.prop
  - At second stage init:
    - Load prop from the above path
    - umount /second_stage_resources

Test: getprop -Z
Test: getprop
Bug: 169169031

Change-Id: I18b16aa5fd42fa44686c858982a17791b2d43489
2020-10-15 13:12:52 -07:00
David Anderson
aca0beaf77 libsnapshot: Partially implement OpenSnapshotWriter.
This is a re-landing of the original CL, with a few changes:
 - The correct device is now returned in MapUpdateSnapshot.
 - The old API is used for tests, and the new API is only tested when
   used on a VABC device.
 - A sync() call has been added to ensure that writes to the base and
   target snapshot devices have been fully flushed. This makes
   IsPartitionUnchanged detect the MapUpdateSnapshot bug.

Implement OpenSnapshotWriter for non-compressed Virtual A/B. This is
done by adding an OnlineKernelSnapshotWriter class, which forwards all
writes to a dm-snapshot block device.

This also introduces a new ISnapshotWriter class which extends
ICowWriter, and adds features specific to libsnapshot (versus ICowWriter
which is intended only for the new COW format). The OpenSnapshotReader
call has been moved here since the writer retains all the information
needed to create the reader.

To test the new call, vts_libsnapshot_test has been modified to use
OpenSnapshotWriter.

As part of this change, all consumers of libsnapshot must now link to
libsnapshot_cow.

Bug: 168554689
Test: vts_libsnapshot_test
Test: full OTA with update_device.py
Test: incremental OTA with update_device.py
Change-Id: I90364a58902a4406a37cb14a816642c57a72bec2
2020-10-14 21:41:36 -07:00
Colin Cross
b519c71619 Use ro.build.version.release_or_codename to reconstruct fingerprint
The ro.build.version.release property was changed from being the
codename or final name of the current release to be the final name
of the most recent release.  Use ro.build.version.release_or_codename
to reconstruct the fingerprint to match what the build system does.

Bug: 158483506
Test: adb shell getprop | grep fingerprint
Change-Id: I3bd992b6f06ff90bb6024253339a2654afa069ee
2020-10-13 12:38:48 -07:00
Yo Chiang
165d9aee40 Call GetDsuMetadataKeyDir() for DSU metadata encryption dir
So DSU system don't use a hard-coded metadata key dir.

Bug: 168571434
Test: Install and boot a DSU system.
Change-Id: I096ef46a6f7b2d9fc42882288519fc5b93df1f41
2020-10-07 18:59:23 +08:00
Dan Shi
67b7dd570f Remove vts10 related configs
Bug: 169582597
Test: build
Change-Id: I38e1e0f8e32b86ab14b905d040c1c62245a1a9e3
2020-10-06 13:52:44 -07:00
Tianjie Xu
216ce0985f Merge changes from topic "revert-1433573-vab-libsnapshot-linkage-APIHERUSEB"
* changes:
  Revert "libsnapshot: Partially implement OpenSnapshotWriter."
  Revert "libsnapshot: Implement OnlineKernelSnapshotWriter::OpenReader."
2020-10-03 19:27:32 +00:00
Tianjie Xu
5aa52d91dd Revert "libsnapshot: Partially implement OpenSnapshotWriter."
Revert "Link to libsnapshot_cow everywhere libsnapshot is linked."

Revert submission 1433573-vab-libsnapshot-linkage

Reason for revert: b/169981170, update crash for droidfooders.
Reverted Changes:
Ie75bba98c:Link to libsnapshot_cow where libsnapshot is linke...
Ieedfadc55:libsnapshot: Partially implement OpenSnapshotWrite...
I28a5d4a88:Link to libsnapshot_cow everywhere libsnapshot is ...

Exempt-From-Owner-Approval: Revert to unblock dogfood
Change-Id: I0677df77672aca9fd54d94e009ac0be7c88a1a9d
2020-10-03 19:26:18 +00:00
Tom Cherry
7cfc944195 Merge "init: guarantee the ordering that actions are executed in" 2020-10-01 20:27:40 +00:00
Tom Cherry
34ee04762a init: guarantee the ordering that actions are executed in
The README.md states that this ordering is not guaranteed to give
flexibility for the future, however it's time to state that this
ordering is guaranteed, especially since:

1) We have a tests, EventTriggerOrder and
   EventTriggerOrderMultipleFiles, which have guaranteed this ordering
   since 2017.
2) We have users requesting and depending on this order

Also update some slightly out of date parts of the documentation:
1) We import /system/etc/init/hw/init.rc instead of /init.rc as the
   first import
2) We additionally import /system_ext/etc/init and /product/etc/init

Test: n/a
Change-Id: I6d7b8d9e52f0d52bee320d5074ebb74a537f9150
2020-10-01 11:07:43 -07:00
David Anderson
75b982ad30 libsnapshot: Partially implement OpenSnapshotWriter.
Implement OpenSnapshotWriter for non-compressed Virtual A/B. This is
done by adding an OnlineKernelSnapshotWriter class, which forwards all
writes to a dm-snapshot block device.

This also introduces a new ISnapshotWriter class which extends
ICowWriter, and adds features specific to libsnapshot (versus ICowWriter
which is intended only for the new COW format). The OpenSnapshotReader
call has been moved here since the writer retains all the information
needed to create the reader.

To test the new call, vts_libsnapshot_test has been modified to use
OpenSnapshotWriter.

As part of this change, all consumers of libsnapshot must now link to
libsnapshot_cow.

Bug: 168554689
Test: vts_libsnapshot_test
Change-Id: Ieedfadc557833c1e0540922aabc6e95c80266a64
2020-09-28 11:24:37 -07:00
Jooyung Han
2833e5d37d ueventd: change firmware location in apexes
To be consistent with other prebuilt modules within APEXes, the location
for firmware files is switched from /apex/*/firmware to
/apex/*/etc/firmware.

Bug: 167942098
Test: loading vibrator firmware from vibrator apex(sunfish)
Change-Id: Ia05735bf5a54482fded26525fa4a8f795dcfc029
2020-09-21 10:56:10 +09:00
Jooyung Han
21cad321db ueventd: scans /apex/*/firmware for firmwares
In addition to "firmware_directories", ueventd scans /apex/*/firmware/
directory as well to find firmware files.

Bug: 167942098
Test: loading firmware from vibrator apex successfully.
      (sunfish)
Change-Id: I90fc8f9ad843a08b1ca98a2be1b5d22c0c5954a3
2020-09-19 08:07:35 +09:00
Treehugger Robot
fd19ef40e8 Merge "Freeze com.android.sysprop.init API" 2020-09-15 02:02:25 +00:00
Jooyung Han
7bfe477b3d init: "init subcontext" in default mount namespace
"init subcontext" is responsible to handle a few commands in vendor
context. To support Vendor APEX, "init subcontext" is now started in
"default" mount namespace so that those commands can access /apex/*.

For example, insmod should see the contents of /apex to install kernel
modules in apexes.

Bug: 162701747
Test: adb shell ps -ef | grep init
      => check pid of <init subcontext>
      adb shell readlink /proc/<pid: init>/ns/mnt
      adb shell readlink /proc/<pid: init subcontext>/ns/mnt
      => check if these are equal
Change-Id: Icd5e862e52d78635e83824b267b6d32d8f3e9eea
2020-09-14 17:40:45 +09:00
Inseob Kim
2a8c714145 Freeze com.android.sysprop.init API
Bug: 145259948
Test: m com.android.sysprop.init-check-api
Change-Id: I5909c16390c35b5e5adf4c82eed191cc9ae82014
2020-09-14 13:51:27 +09:00
Tom Cherry
9481c67321 Merge "init: do not create dev.mnt. properties for emulated mounts" 2020-09-10 20:47:35 +00:00
Tom Cherry
e1bcd93326 init: do not create dev.mnt. properties for emulated mounts
dev.mnt. properties are primarily intended for tuning parameters for
mounts such as /system and /data but don't have much use for emulated
mounts.

There are additional emulated mounts created for each user on a
device, so if too many users are created, init would otherwise create
too many dev.mnt. properties, filling the property file that backs
these properties, and preventing more properties from being
generated.

Therefore, this change stops init from creating dev.mnt. properties
for emulated mounts.

Bug: 156721033
Test: user creation stress test doesn't create large numbers of
properties

Change-Id: I6475956719b7c938b8289189abfef661140d526d
2020-09-10 18:09:25 +00:00
Nikita Ioffe
4e311d69b5 Merge "Only store result of mount_all that mounted userdata" am: edc501d674
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1420053

Change-Id: I444f74692633b2bc4f5bcf03cd036b5c52b120aa
2020-09-08 23:10:11 +00:00
Nikita Ioffe
9ede7ec273 Only store result of mount_all that mounted userdata
During boot sequence there can be multiple calls to mount_all. For the
userspace reboot to correctly remount userdata, we need to store the
return code of the one that was responsible in mounting userdata.

Test: adb root
Test: adb shell setprop init.userspace_reboot.is_supported 1
Test: adb reboot userspace
Test: checked dmsg
Bug: 166353152
Change-Id: Id0ae15f3bcf65fa54e4e72b76f64716c053af7fb
2020-09-08 21:58:43 +01:00
Xin Li
0a112d52f8 Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507
Merged-In: Id18cb0e2d2f3e776a42b566c4a1af2e250890896
Change-Id: Iba7cab32ab3aa6f47952c840ff6dc8492e8d0704
2020-08-29 01:42:13 -07:00
Gavin Corkery
c0d11aa73a Merge "Store userspace reboot info in /metadata" 2020-08-26 21:47:19 +00:00
Gavin Corkery
8c92256df5 Store userspace reboot info in /metadata
Store pertinent information about userspace reboot events in the case
of failure. This information is any services which failed to stop
cleanly, the output of the default fstab and /proc/mounts, and
a list of mounts which failed to unmount. This information is only
stored as necessary (i.e. mount information will not be stored if
everything unmounted, even if some services failed to stop).

Added new /metadata/userspacereboot directory to persist this
information. Information older than 3 days will be deleted.

Test: adb reboot userspace with sigterm/sigkill timeouts set to
      very low values
Test: Manual test of storing all other information
Bug: 151820675
Change-Id: I6cfbfae92a7fc6f6c984475cad2c50c559924866
2020-08-21 17:32:34 +01:00
Treehugger Robot
d7cb6e1fd0 Merge "Revert "Fix non-existent module error"" 2020-08-18 07:41:01 +00:00
Paul Crowley
9acab5a4d6 Set ro.crypto.type even on failure
Move responsibility for setting ro.crypto.type into fs_mgr_mount_all,
so that even if setting up the filesystem fails, the type is set
correctly and so errors are appropriately handled.

Bug: 162289984
Test: simulate a failure and check that it's set.
Change-Id: Ib061a454e7e21d7206c3c1fa8e88e16618099581
2020-08-14 11:36:39 -07:00
Yo Chiang
4adce5fec3 Revert "Fix non-existent module error"
This reverts commit 78ee4c1005.

Reason for revert: revert bad fix

Change-Id: I45c2bc2414679d525677b0bc103167316e16b0c4
2020-08-13 04:54:18 +00:00
Yo Chiang
78ee4c1005 Fix non-existent module error
TARGET module init_vendor requires non-existent TARGET module: init_first_stage

Module `init_first_stage` is skipped (not defined) on ASAN builds.

Bug: 163802658
Test: TH
Change-Id: I5aa030dfaa59a21511a7112ff89f8a5d8b8dc735
2020-08-12 16:27:08 +00:00
Jooyung Han
f7c2585f6d Fix the order for boot scripts scanning
To support "override" services, we need to scan partitions from least
speicific to most specific.

Bug: 163021585
Test: m
Change-Id: I26a6de4f7fb571c60038e803137a4b1c237792fd
2020-08-07 10:44:14 +09:00
Treehugger Robot
30e542983a Merge "cts: Skip CtsInitTestCases over a native bridge." 2020-08-06 17:31:56 +00:00
Kazuhiro Inaba
c293c58660 cts: Skip CtsInitTestCases over a native bridge.
The set of linked binaries was making it difficult to run
the test over a native bridge. Since init won't usually
run over a native bridge, the test can be skipped.

Bug: 161081809, 142324733, 162288553
Test: Arm build of CtsInitTestCases skips rammus-arc-r Chromebook.
Change-Id: Icdd8b03111d0f3fd6658ee6d9a97fca27181db45
(cherry picked from commit 9cecf8422a)
2020-08-07 01:11:29 +09:00
Christopher Ferris
ab60ca583a Add new caps from kernel 5.8.
Test: Builds and boots on a bonito.
Change-Id: I8dff4818bb98be3d731256be100a1c4aed4d414c
2020-08-04 22:57:44 -07:00
Steven Moreland
fe8dec0447 Merge "perfboot: significant figures + units for summary" 2020-08-04 18:10:32 +00:00
Steven Moreland
18b73dd0b6 perfboot: significant figures + units for summary
This is correct significant figures/units based on the precision of our
measurements, but it does not reflect our actual certainty re the output
data, since in reality, confidence is diminished by temperature, device,
hardware revision, time of day/month/year, spurious activity, data
connectivity, app install list, inherent randomness of multiprogramming,
sensor activity, user interaction, /data caches, build-by-build
differences, charging state, data fragmentation, race-driven sleeps,
cosmic radiation, factory defects, local magnetic or gravitational field
differences, changes in device momentum, or other known and unknown
causes.

Bug: N/A
Test: run perfboot.py, and output has:
    mean: 10801 ms
    median: 10801 ms
    standard deviation: 18 ms
Change-Id: I796396acc203b29e9a14e4d6dffa58db7b8cd9fb
2020-08-04 00:58:40 +00:00
Elliott Hughes
e79b8c2092 Cleanup for #inclusivefixit.
Test: treehugger
Change-Id: I651689e2d59c017a9bde44251d95b57e594f0b5b
2020-07-28 11:09:03 -07:00
Tom Cherry
2d451663be Cleanup for #inclusivefixit.
Test: build
Change-Id: If11a32c130367560394eccf442de95d941918073
2020-07-27 11:37:19 -07:00
David Anderson
67665a4571 Merge changes I49495684,I0db2e0f4,I07bb811b
* changes:
  init: Initiate other misc devices from BlockDevInitializer.
  Allow snapuserd to be included in the initial ramdisk.
  Add experimental daemon for handling dm-user requests.
2020-07-24 19:18:45 +00:00
Hung-ying Tyan
d1bd5f20eb Merge "init: set $PATH in second stage init" 2020-07-24 03:01:33 +00:00
Tom Cherry
d36f4a36ed init: set $PATH in second stage init
If the system partition has been updated and _PATH_DEFPATH has a new
value, then we must set $PATH in second stage init to take on the new
value, as well as having set it in first stage init.

Bug: 160210288
Test: build
Change-Id: I18765709dc9bff9379b0ae39272199cf74a79d2f
2020-07-23 09:13:37 -07:00
Tom Cherry
e122701142 Merge "Ueventd: Fix a corner case in ReadUevent() that triggers duplicate firmware loading." 2020-07-21 21:14:52 +00:00
P.Adarsh Reddy
a86bf05a01 Ueventd: Fix a corner case in ReadUevent() that triggers duplicate firmware loading.
Presently, within ReadUevent(), true is returned for a successful case
as well as for the case where we read an invalid uevent (overflowed
buffer)where the Uevent object is not cleared, and the caller calls the
callback (with the earlier stored uevent object),leading to duplicate
firmware loading.

Uevent uevent;
while (ReadUevent(&uevent)) {
  if (callback(uevent) == ListenerAction::kStop) return;
}

Scenario:
1. Proper Uevent received and callback is called (firmware loading
   is triggered).
2. Overflowed uevent is received as part of the same ReadUevent session,
   ReadUevent() returns true, but the uevent object is not cleared and
   still has earlier event values.
3. Callback is called again, leading to duplicate firmware load.

Handle it by adding explicit return codes to let the caller know if the
uevent read is invalid, and the caller can ignore it and read
further pending uevents.

Bug: 161580785

Change-Id: I09e80052337fd1495b968dc02ecff5ceb683da18
2020-07-21 03:09:28 +05:30
Tom Cherry
939b41c79b ueventd: bump UEVENT_MSG_LEN to 8192
The previous size, 2048, is only the size of the 'environment' for the
uevent message, but doesn't include the <action>@<dev path> portion.
The <action> portion has a max length < 10, but the <dev path> portion
is unbounded.

8192 should be plenty to capture all of these parameters.

Bug: 161580785
Test: ueventd still works
Change-Id: I6de6fd3a444ac91b3b4df154097abde3696e21b3
2020-07-20 13:18:01 -07:00
Yifan Hong
30b52007e5 Merge changes from topic "odm_dlkm" am: 3e31ec8392 am: 8c3a7ca939
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1363939

Change-Id: I8cdd4583c894d7fb5168fce1df789f2973a57357
2020-07-17 22:52:14 +00:00
Yifan Hong
9258f2e423 Load sysprops from odm_dlkm.
Load sysprops from /odm_dlkm/etc/build.prop. Note that no
property contexts are loaded from odm_dlkm.

Test: getprop | grep odm_dlkm
Bug: 156020364
Change-Id: I90c3a54a110462736d9888101d4281100d586632
2020-07-15 17:15:49 -07:00
Yifan Hong
a8e5779e18 Merge changes from topic "vendor_dlkm" am: 7ca7680ec5 am: 0c1a242060
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1350785

Change-Id: I7db376a03c329023a626c1130b7a55dc74ae9ae1
2020-07-14 19:47:16 +00:00
Yifan Hong
7ca7680ec5 Merge changes from topic "vendor_dlkm"
* changes:
  load sysprops from vendor_dlkm.
  fastboot: Add vendor_dlkm
  rootdir: add vendor_dlkm symlinks
2020-07-14 19:15:12 +00:00
Treehugger Robot
b64af0cc2a Merge "init README: document AIDL service interface" am: 4d3c284605 am: e526b545cd
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1360957

Change-Id: Ib8b619145c77c42afe771755e3e2199bfa5c68dc
2020-07-10 20:03:59 +00:00
Steven Moreland
fa2457e1cd init README: document AIDL service interface
There is documentation for how AIDL works with ctl commands or
interface_start commands, however it seems we were missing documentation
on declaration of interfaces.

Bug: N/A
Test: N/A
Change-Id: I0e5d2350b6b847a870eafbc69828e75f1f6ca4f0
2020-07-10 17:53:18 +00:00
Yifan Hong
2ed3cdaa06 load sysprops from vendor_dlkm.
Load sysprops from /vendor_dlkm/build.prop. Note that
no property contexts are loaded from vendor_dlkm.

Test: getprop | grep vendor_dlkm
Bug: 156020364
Change-Id: Ib0e8ba1791e1d2c11d055ef496208993e11d9b0f
2020-07-09 15:06:44 -07:00
Tom Cherry
f18e009f97 Merge "init: skip RejectsCriticalAndOneshotService for devices launched before R" am: c8e4154d89 am: 9c590e4c97
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1359383

Change-Id: I8d77c402b55b1e460dd49c4a37fd00baada98d5d
2020-07-09 20:06:57 +00:00
Tom Cherry
c8e4154d89 Merge "init: skip RejectsCriticalAndOneshotService for devices launched before R" 2020-07-09 19:35:34 +00:00
Tom Cherry
0e40ba3183 init: skip RejectsCriticalAndOneshotService for devices launched before R
This restriction is only added for devices launching with R or later.

Bug: 160663765
Test: this test runs when appropriate
Change-Id: I2353bfa7f598bd19ba57498cc5bbad7a3ed34707
2020-07-09 08:49:29 -07:00
David Anderson
67cd9f09ca init: Initiate other misc devices from BlockDevInitializer.
This allows init to easily ensure misc devices other than device-mapper
are present.

Bug: 154536437
Test: manual test
Change-Id: I49495684edee322f9787ce7ab7f79d0e8060171d
2020-07-08 15:46:28 -07:00
Wei Wang
b35f076d7f Merge "Boost init priority before main loop" am: 4203129353 am: 7531866047
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1355811

Change-Id: I8ee40c5247f52e5d09ed0e9a04db0777612dfc05
2020-07-08 05:29:34 +00:00
Wei Wang
4203129353 Merge "Boost init priority before main loop" 2020-07-08 04:53:04 +00:00
Treehugger Robot
086b322d10 Merge "Move build.prop to ./etc subdir for some partitions" am: 90fe62e76e am: e47bb665c0
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1351307

Change-Id: Ib09d8413c20d24652f6188c1c4124f7a4c7a8187
2020-07-08 00:37:06 +00:00
Treehugger Robot
90fe62e76e Merge "Move build.prop to ./etc subdir for some partitions" 2020-07-08 00:03:30 +00:00
Wei Wang
30bbf7d0ad Boost init priority before main loop
Now we have more things e.g. loading kernel modules, initialize
selinux. And before all these, system cannot make further progress. It
should be beneficial to boost this critical peroid in init.

Benchmark on a Pixel device shows this saves 100+ms on early boot

ToT release + This CL (P15538587)
D/BaseBootTest: init_stage_second_START_TIME_avg : 1563.4
D/BaseBootTest: ueventd_Coldboot_avg : 219.0
D/BaseBootTest: action_init_/system/etc/init/hw/init.rc:114_START_TIME_avg : 2103.7

ToT release (6654154)
D/BaseBootTest: init_stage_second_START_TIME_avg : 1639.0
D/BaseBootTest: ueventd_Coldboot_avg : 238.2
D/BaseBootTest: action_init_/system/etc/init/hw/init.rc:114_START_TIME_avg : 2226.0

Bug: 143857500
Bug: 147997403
Bug: 160271169
Bug: 160696502
Test: Boottime
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I21c9e051f4ae3e953d991c031f151b2779702548
2020-07-07 15:50:58 -07:00
Jiyong Park
8178c5f0c9 Move build.prop to ./etc subdir for some partitions
build.prop files under system_ext, product, and odm partitions are moved
to the ./etc subdirectory. This is to be in-line with the established
practice of having all configuration files under ./etc subdir.
build.prop doesn't need to be an exception.

However, system/build.prop and vendor/build.prop were not moved because
there are a lot of apps and tools that depend on the path.

Bug: 158735147
Test: device has build.prop under ./etc and is bootable
Change-Id: I26300574c23c78cc4e5bc20f98fc9702838465e1
2020-07-08 02:18:16 +09:00
Tom Cherry
09100b7fbd Merge "Add AMBA bus support to platform devices" am: b88a97b41e am: 8edc5e449c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1353606

Change-Id: I7e3e0835a7066ff46c888ce801e027b314c5d674
2020-07-07 15:48:49 +00:00
Tom Cherry
b88a97b41e Merge "Add AMBA bus support to platform devices" 2020-07-07 15:14:14 +00:00
Jooyung Han
98768e7ba3 Merge "init: generate apex-info-list.xml" am: a657c799bf am: f7cb833300
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1354547

Change-Id: I28a1aa865ac8078f4cb4528af7622ed6a721e2d1
2020-07-06 21:59:05 +00:00
Jooyung Han
1d951b7700 init: generate apex-info-list.xml
If a device doesn't support unflattened APEXes, init activates flattened
APEXes instead of apexd.

Because apexd dumps apex-info-list.xml after it activates all APEXes,
init should do the same thing.

Bug: 159585065
Test: lunch aosp_cf_x86_phone_noapex & m & boot
      adb more /apex/apex-info-list.xml
      adb shell ls -lZ /apex/apex-info-list.xml
       -> -rw-rw-rw- 1 root root u:object_r:apex_info_file:s0 ..
Change-Id: I74a4d0ee363761564225097c5949e5ce335ac6dc
2020-07-05 00:12:04 +00:00
Usama Arif
d86300cc7e
Add AMBA bus support to platform devices
AMBA specification from Arm is a freely available open
standard for the connection and management of functional
blocks in a system-on-chip.
AMBA devices create a device kernel object in /sys/devices/platform
and a kernel object of the bus for the respective device in
/sys/bus/amba. For e.g. for pl180 mmc:
device: /sys/devices/platform/1c050000.mmci
bus: /sys/bus/amba/devices/1c050000.mmci

In first stage init, android creates a symlink from /sys/devices/platform/...
to /dev/block/platform/... for all partitions and then to
/dev/block/by-name for the boot_device used. However this is only done
for devices that "attach" to bus/platform. This patch adds support for
platform devices that attach to bus/amba.

Signed-off-by: Usama Arif <usama.arif@arm.com>
Change-Id: I9da7456407c4f62335c959502d8b2d16026fddfc
2020-07-01 11:47:49 +01:00
Nikita Ioffe
64697dcd89 Merge "Reboot sequence: Unmount active apexes before unmounting /data" am: b255195375 am: d60f0708c9
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1327913

Change-Id: Ie64a60f5a104ad22326e2d632b5cf30b2f489f42
2020-06-13 21:14:03 +00:00
Nikita Ioffe
91a9848775 Reboot sequence: Unmount active apexes before unmounting /data
Having mounted apexes with loop back devices backing files on /data
partition will prevent clean unmount of it. Unmounting them and tearing
down loop devices should minimize the risk of that.

Note that it won't fix the issue completely, as there are a few (~2-3)
processes that keep restarting even after SIGKILL is sent. Which means
that they can still hold references to apexes on /data partition. But
in practice probability of this is quite low.

Test: adb reboot
Test: put tzdata apex in /data/apex/active && adb reboot
Bug: 158152940
Change-Id: I4624567b3d0f304dba4c6e37b77abd89e57411de
2020-06-13 00:13:11 +01:00
Jooyung Han
971add2022 Merge "init: start ueventd in the default mount namespace" am: 7cc98e212b am: 9b07c52de0
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1325695

Change-Id: I8e29d81747b871f3e92c32c43d74f4fc6bdf8b85
2020-06-12 02:26:52 +00:00
Jooyung Han
7cc98e212b Merge "init: start ueventd in the default mount namespace" 2020-06-12 02:06:12 +00:00
Treehugger Robot
3a1b4a8731 Merge "Fix a misleading warning message about sysprop overriding" am: 6c7b75b421 am: 1adcea5c84
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1331393

Change-Id: If339409849da2088951a0379b7a9bb284b7d56b3
2020-06-11 15:20:44 +00:00
Jiyong Park
e714cde55d Fix a misleading warning message about sysprop overriding
Regardless of whether a system property is "ro." or not, it can be
overridden by build.prop from the more specific partition. i.e.
foo.bar=true in system/build.prop can be overridden by
foo.bar=false in vendor/build.prop. However, the warning message
was referring the overridden property as "ro." causing confusion
when reading the log. Fix it by not mentioning "ro.".

Bug: 117892318
Test: N/A
Change-Id: I13014522d0c6b507b30c8754e2087fd71cc39971
2020-06-11 19:45:14 +09:00
Jooyung Han
4f23d5a236 init: start ueventd in the default mount namespace
Init starts ueventd in the default mount namespace to support loading
firmware from APEXes.

Bug: 155023652
Test: devices boots
      adb$ nsenter -t (pid of ueventd) -m ls /apex
      => shows all APEXes
Change-Id: Ibb8b33a07eb014752275e3bca4541b8b694dc64b
2020-06-11 15:10:40 +09:00
Treehugger Robot
485f55a8eb Merge "Fix typo in android init language documentation." am: e4424ff422 am: a33a65c8e2
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1327897

Change-Id: Ib64abb1b8ebce2b72eb8cbdaf3accb716d6d59ee
2020-06-10 15:32:16 +00:00
Amos Bianchi
16bfe099f3 Fix typo in android init language documentation.
Test: N/A
Change-Id: I158294b59f120f5f1296f3c9e6e5357fb02ed6b8
2020-06-09 17:10:49 -07:00
Treehugger Robot
aa9b467a0c Merge "init: fix README.md about perform_apex_configs" am: 389d8885a8 am: a3238e04f7
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1325691

Change-Id: I462e2677956162aaff2215f9112fdcb5b23001e2
2020-06-09 15:33:49 +00:00
Treehugger Robot
389d8885a8 Merge "init: fix README.md about perform_apex_configs" 2020-06-09 15:06:54 +00:00
Alistair Delva
de28a8651f Respect ro.boot.fstab_suffix in swapon_all
While mount_all and umount_all were updated to use ro.boot.fstab_suffix,
I neglected to update swapon_all. Trivially copied from umount_all.

Bug: 142424832
Change-Id: Icd706fe7a1fe16c687cd2811b0a3158d7d2e224e
Merged-In: Icd706fe7a1fe16c687cd2811b0a3158d7d2e224e
2020-06-08 23:41:40 +00:00
Alistair Delva
aedd2879e6 Respect ro.boot.fstab_suffix in swapon_all am: afaa5fbccc
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11796125

Change-Id: Ifde3728da61a1a96286e6b92f07e3bcbea28ccbf
2020-06-08 23:23:27 +00:00
Alistair Delva
ca7e91e908 Add documentation for umount_all am: 46f25dee36
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11796124

Change-Id: Ie3ca432b221b477e34796f27a8b949a90a9c3123
2020-06-08 23:23:25 +00:00
Alistair Delva
afaa5fbccc Respect ro.boot.fstab_suffix in swapon_all
While mount_all and umount_all were updated to use ro.boot.fstab_suffix,
I neglected to update swapon_all. Trivially copied from umount_all.

Bug: 142424832
Change-Id: Icd706fe7a1fe16c687cd2811b0a3158d7d2e224e
2020-06-08 11:36:05 -07:00
Alistair Delva
46f25dee36 Add documentation for umount_all
The mount_all and swapon_all commands are documented, but umount_all
is not. Add some documentation.

Bug: 142424832
Change-Id: I7e4dcb4d222b787350a79c9e312062cac9eeb4d8
2020-06-08 11:29:13 -07:00
Alistair Delva
6c6a36fb31 Add documentation for umount_all
The mount_all and swapon_all commands are documented, but umount_all
is not. Add some documentation.

Bug: 142424832
Change-Id: I7e4dcb4d222b787350a79c9e312062cac9eeb4d8
2020-06-08 10:51:40 -07:00
Jooyung Han
ea138c8695 init: fix README.md about perform_apex_configs
parse_apex_configs was renamed with
13e51e7f0b.

Bug: n/a
Test: n/a
Change-Id: I6e60d64f915fa9ed47c5ec1195a9b371f68f1134
2020-06-08 18:22:15 +09:00
Treehugger Robot
2f724342ff Merge "first_stage_init: support kernel module directories" am: dc9acdd221 am: f517b00dce
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1319048

Change-Id: I8a3774e14d24c3559b8f50e9aea5f4c33cf86548
2020-06-03 19:34:23 +00:00
Steve Muckle
e35d217958 first_stage_init: support kernel module directories
Kernel modules may be located within directories in /lib/modules.
Attempt to load kernel modules from each directory that has a name starting with
the major and minor version of the currently running kernel. If a single
kernel module is successfully loaded from a directory, that directory is
treated as the correct kernel module directory for the system. No other
kernel module directories are searched and any kernel module load errors
in that directory are fatal. If the attempt to load the first kernel
module from a directory fails, or if there are no kernel modules in a
directory, then the search proceeds to the next directory.

If no kernel module is successfully loaded from any directory as above,
an attempt is made to load kernel modules from the top level at
/lib/modules/.

Bug: 157645635
Change-Id: I92eadd8617f03a645da460ccb776bc04fa541f00
Merged-In: I92eadd8617f03a645da460ccb776bc04fa541f00
2020-06-03 12:11:38 -07:00
Steve Muckle
d6d38c326e first_stage_init: support kernel module directories
Kernel modules may be located within directories in /lib/modules.
Attempt to load kernel modules from each directory that has a name starting with
the major and minor version of the currently running kernel. If a single
kernel module is successfully loaded from a directory, that directory is
treated as the correct kernel module directory for the system. No other
kernel module directories are searched and any kernel module load errors
in that directory are fatal. If the attempt to load the first kernel
module from a directory fails, or if there are no kernel modules in a
directory, then the search proceeds to the next directory.

If no kernel module is successfully loaded from any directory as above,
an attempt is made to load kernel modules from the top level at
/lib/modules/.

Bug: 157645635
Change-Id: I92eadd8617f03a645da460ccb776bc04fa541f00
2020-06-03 10:51:51 -07:00
Martijn Coenen
4ff6531bc5 Merge changes from topic "fusectl" into rvc-dev am: 6030f2f016
Change-Id: I4888400ae48f4061e938832f49c8d1e453798244
2020-05-29 14:54:54 +00:00
Martijn Coenen
6030f2f016 Merge changes from topic "fusectl" into rvc-dev
* changes:
  Abort FUSE filesystems during shutdown.
  Abort FUSE filesystem when Zygote restarts.
  Mount fusectl filesystem.
2020-05-29 14:41:20 +00:00
Martijn Coenen
860ba64393 Abort FUSE filesystems during shutdown.
To ensure we can shutdown cleanly, and don't hang an outstanding
requests to a FUSE host daemon that has already exited.

Bug: 153411204
Test: inspect logs during shutdown
Change-Id: I8e6479bd54dbc1fc85b087617aa6b16be9f15a3b
2020-05-28 19:11:07 +02:00
Alistair Delva
c631f94c77 Add ro.boot.fstab_suffix and modify mount_all to use it
Currently the ReadDefaultFstab function, which calls GetFstabPath,
makes some assumptions about what the fstab will be called and where
it is located. This is being used by vold to set up userdata encryption
and for gsid, and is even used in the default boot control HAL, so it
has become quite baked.

The original way for a board to specify things to mount was to use the
"mount_all /path/to/fstab" command in init.rc. However, due to the
above functionality, the path after mount_all is no longer very useful,
as it cannot differ from the inferred path, or userdata encryption and
other features will be broken.

On Cuttlefish, we have an interest in being able to test alternative
userdata configurations (ext4 vs f2fs, encryption on/off, etc.) and
currently the only way to achieve this is to either a) modify the
ro.hardware or ro.hardware.platform properties, which breaks a bunch
of things like default HAL filenames, or regenerate our odm.img or
vendor.img filesystems. We can't simply install another fstab and
point to it with "mount_all".

This change allows the fstab path to be omitted from "mount_all", and
adds another property which overrides the existing checks for
fstab.${ro.hardware} and fstab.${ro.hardware.platform}. Specifying
${ro.boot.fstab_suffix} will cause fstab.${ro.boot.fstab_suffix}
to be checked first.

Bug: 142424832
Test: booted cuttlefish with 'mount_all ${ro.hardware} --late'
Test: booted cuttlefish with 'mount_all --late'
Test: booted cuttlefish with 'mount_all --late' and fstab_suffix=f2fs
Test: partially booted cuttlefish with 'mount_all ${ro.hardware}'
Test: partially booted cuttlefish with 'mount_all'
Change-Id: I3e10f66aecfcd48bdb9ebf1d304b7aae745cbd3c
Merged-In: I3e10f66aecfcd48bdb9ebf1d304b7aae745cbd3c
2020-05-28 00:07:05 +00:00
Alistair Delva
a2cc1ebb72 Add ro.boot.fstab_suffix and modify mount_all to use it
Currently the ReadDefaultFstab function, which calls GetFstabPath,
makes some assumptions about what the fstab will be called and where
it is located. This is being used by vold to set up userdata encryption
and for gsid, and is even used in the default boot control HAL, so it
has become quite baked.

The original way for a board to specify things to mount was to use the
"mount_all /path/to/fstab" command in init.rc. However, due to the
above functionality, the path after mount_all is no longer very useful,
as it cannot differ from the inferred path, or userdata encryption and
other features will be broken.

On Cuttlefish, we have an interest in being able to test alternative
userdata configurations (ext4 vs f2fs, encryption on/off, etc.) and
currently the only way to achieve this is to either a) modify the
ro.hardware or ro.hardware.platform properties, which breaks a bunch
of things like default HAL filenames, or regenerate our odm.img or
vendor.img filesystems. We can't simply install another fstab and
point to it with "mount_all".

This change allows the fstab path to be omitted from "mount_all", and
adds another property which overrides the existing checks for
fstab.${ro.hardware} and fstab.${ro.hardware.platform}. Specifying
${ro.boot.fstab_suffix} will cause fstab.${ro.boot.fstab_suffix}
to be checked first.

Bug: 142424832
Test: booted cuttlefish with 'mount_all ${ro.hardware} --late'
Test: booted cuttlefish with 'mount_all --late'
Test: booted cuttlefish with 'mount_all --late' and fstab_suffix=f2fs
Test: partially booted cuttlefish with 'mount_all ${ro.hardware}'
Test: partially booted cuttlefish with 'mount_all'
Change-Id: I3e10f66aecfcd48bdb9ebf1d304b7aae745cbd3c
2020-05-21 16:38:40 -07:00
Mark Salyzyn
61de0d226d init: support wait timeout with more precision
A one second timeout is so coarse and can affect boot time when
the possibility that the file does not exist.  Switch to accepting
a floating point number for seconds for the wait for file command.

Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Bug: 151950334
Test: wait_for_file sleep 0.05 reports an appropriate delay
Change-Id: I8d8ed386519ab54270b05ce91663d0add30f12e7
2020-05-19 13:25:07 -07:00
Treehugger Robot
25a96e44ca Merge "init_kill_services_test: also reboot after" 2020-05-18 17:42:29 +00:00
Treehugger Robot
fba5028d56 Merge "init: support wait timeout with more precision" 2020-05-18 13:14:36 +00:00
Treehugger Robot
f464e6e0ac Merge "Remove /default.prop" 2020-05-16 08:39:56 +00:00
Treehugger Robot
a782da9b3e Merge changes from topic "remove_default_prop"
* changes:
  Remove /system/etc/prop.default
  /vendor/default.prop is removed.
2020-05-15 02:12:49 +00:00
Mark Salyzyn
ffa52e9c6f init: support wait timeout with more precision
A one second timeout is so coarse and can affect boot time when
the possibility that the file does not exist.  Switch to accepting
a floating point number for seconds for the wait for file command.

Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Bug: 151950334
Test: wait_for_file sleep 0.05 reports an appropriate delay
Change-Id: I8d8ed386519ab54270b05ce91663d0add30f12e7
2020-05-15 01:18:24 +00:00
Steven Moreland
d642fe4985 init_kill_services_test: also reboot after
See details in comment inside. This is to increase stability of the
device. There are some thing we might not detect (yet) but which cause
the test to fail.

Bug: 156380383
Test: run on walleye
Change-Id: Ic0189af7e818916665a2b709d440c517a04c587f
2020-05-15 01:14:04 +00:00
Mark Salyzyn
6fca594fc2 init: failed to set sys.usb.controller
With GKI we find in certain situations the timing of the drivers
loading is delayed as compared to a monolithic kernel.  This
introduces a race where during second stage init, the attributes
inside /sys/class/udc/ might not be set by the time
SetUsbController() is called.

To address this, we also call SetUsbController() until the property
sys.usb.controller is set at the bottom of the event loop.

Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Bug: 151950334
Test: make sure user space fastbootd comes up reliably for a GKI kernel
Change-Id: Iececd8ffa3e6641554d215d622d8dab72d85d34d
2020-05-14 13:05:42 -07:00
Jiyong Park
c688e8fcce Remove /default.prop
The file is removed. init no longer needs to read it.

Bug: 117892318
Test: TH passes on non-Treble devices.
Change-Id: Idc4127bad66db24c7033b47c41b9eb85a5e0a5cd
2020-05-14 17:09:26 +09:00
Jiyong Park
c068d0e0ef Remove /system/etc/prop.default
Contents that were in /system/etc/prop.default are now in
/system/build.prop.

The content is placed at the top of build.prop to keep the existing
order between the two files.

Caveat #1: /prop.default still remains for non-Treble devices.

Caveat #2: ReadFileSymbolicLink test was changed to read /system/bin/ps
because /prop.default is no longer guaranteed to exist.

Bug: 117892318
Test: TH passes
Test: inspect  /system/build.prop and check if it has contents from
the old /system/etc/prop.default file

Change-Id: I0d3f96c1656dfe02bfa0e801680f7fa887afd1d9
2020-05-14 16:19:33 +09:00
Jiyong Park
8569552ec2 /vendor/default.prop is removed.
It is merged to /vendor/build.prop. However, for backwards
compatibility, the old file is read on devices running R or earlier.

Bug: 117892318
Test: TH passes
Test: inspect  /vendor/build.prop and check if it has contents from
the old /vendor/default.prop file
Change-Id: I994cc85fc0765bc9233e9799bcb670a23180f068
2020-05-14 16:19:32 +09:00
Mark Salyzyn
150687b87d init: failed to set sys.usb.controller
With GKI we find in certain situations the timing of the drivers
loading is delayed as compared to a monolithic kernel.  This
introduces a race where during second stage init, the attributes
inside /sys/class/udc/ might not be set by the time
SetUsbController() is called.

To address this, we also call SetUsbController() until the property
sys.usb.controller is set at the bottom of the event loop.

Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Bug: 151950334
Test: make sure user space fastbootd comes up reliably for a GKI kernel
Change-Id: Iececd8ffa3e6641554d215d622d8dab72d85d34d
2020-05-13 17:56:31 -07:00
Woody Lin
8fb6e3fdaf InitFatalReboot: Trigger panic explicitly for init_fatal_panic
The exit of init panics the system *after* process context (mm, stack,
...etc.) are recycled, according to Linux kernel's 'do_exit'
implementation. To preserve most init process context for debugging,
triggers the panic via proc-sysrq explicitly.

Note: after this change, there will be no "Attempt to kill init" panic
when androidboot.init_fatal_panic is set.

Test: Insert data abort fault in init, the full process context is
      preserved in memory dump captured after panic.
Bug: 155940351
Change-Id: I3393bd00f99b8cb432cfa19a105b7d636b411764
(cherry picked from commit be1cf9006a)
2020-05-11 14:50:27 +00:00
Woody Lin
be1cf9006a InitFatalReboot: Trigger panic explicitly for init_fatal_panic
The exit of init panics the system *after* process context (mm, stack,
...etc.) are recycled, according to Linux kernel's 'do_exit'
implementation. To preserve most init process context for debugging,
triggers the panic via proc-sysrq explicitly.

Note: after this change, there will be no "Attempt to kill init" panic
when androidboot.init_fatal_panic is set.

Test: Insert data abort fault in init, the full process context is
      preserved in memory dump captured after panic.
Bug: 155940351
Change-Id: I3393bd00f99b8cb432cfa19a105b7d636b411764
2020-05-09 01:30:32 +08:00
Will McVicker
f3483ec6a0 first_stage_init: add support to skip module load failures
Extend androidboot.first_stage_console cmdline property to enable
skipping module load failures without stopping at a serial console. This
is useful for GKI development.

Set androidboot.first_stage_console=2 for this behavior.

Bug: 155296582
Test: verify behavior for values 0, 1, and 2
Merged-In: I068c631a22c848e45a421b297b1acae1b3deb3c1
Change-Id: I068c631a22c848e45a421b297b1acae1b3deb3c1
(cherry picked from commit 6c5f82642b)
2020-05-07 21:47:17 +00:00
Will McVicker
c8907427bc first_stage_init: add support to skip module load failures
Extend androidboot.first_stage_console cmdline property to enable
skipping module load failures without stopping at a serial console. This
is useful for GKI development.

Set androidboot.first_stage_console=2 for this behavior.

Bug: 155296582
Test: verify behavior for values 0, 1, and 2
Change-Id: I068c631a22c848e45a421b297b1acae1b3deb3c1
2020-05-01 16:47:12 -07:00
Suren Baghdasaryan
21ae541691 init: Add task_profiles init command
Introduce new command to allow setting task profiles from inside .rc
script. This is to replace usage of writepid when a service is trying
to join a cgroup. Usage example from a .rc file:

service surfaceflinger /system/bin/surfaceflinger
    task_profiles HighPerformance

Bug: 155419956
Test: change .rc file and confirm task profile is applied
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I0add9c3b363a7cb1ea89778780896cae1c8a303c
Merged-In: I0add9c3b363a7cb1ea89778780896cae1c8a303c
2020-05-01 22:20:57 +00:00
Nikita Ioffe
e874875570 Merge "Reject services that are both critical and oneshot" 2020-05-01 16:07:09 +00:00
Nikita Ioffe
51c251c74b Reject services that are both critical and oneshot
Test: atest CtsInitTestCases
Test: builds
Test: device boots
Bug: 155275196
Merged-In: I1bb9099371bd1a3f339396ef343c49b054fcef66
Change-Id: I1bb9099371bd1a3f339396ef343c49b054fcef66
(cherry picked from commit 6a3c94b3aa)
2020-05-01 15:10:25 +01:00
Nikita Ioffe
39d4553fee Add reason why userspace reboot shutdown sequence failed
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 154772075
Merged-In: I7e4674c474189b0185c020e3e066aea5678d7428
Change-Id: I7e4674c474189b0185c020e3e066aea5678d7428
(cherry picked from commit a4e83ad3d7)
2020-05-01 13:27:14 +01:00
Nikita Ioffe
eb3f92f1ba Merge "Add reason why userspace reboot shutdown sequence failed" into rvc-dev 2020-05-01 10:42:49 +00:00
Suren Baghdasaryan
c9c0bbac53 init: Add task_profiles init command
Introduce new command to allow setting task profiles from inside .rc
script. This is to replace usage of writepid when a service is trying
to join a cgroup. Usage example from a .rc file:

service surfaceflinger /system/bin/surfaceflinger
    task_profiles HighPerformance

Bug: 155419956
Test: change .rc file and confirm task profile is applied
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I0add9c3b363a7cb1ea89778780896cae1c8a303c
2020-04-30 22:24:21 +00:00
Nikita Ioffe
a4e83ad3d7 Add reason why userspace reboot shutdown sequence failed
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 154772075
Change-Id: I7e4674c474189b0185c020e3e066aea5678d7428
2020-04-30 22:37:15 +01:00
Nikita Ioffe
6a3c94b3aa Reject services that are both critical and oneshot
Test: atest CtsInitTestCases
Test: builds
Test: device boots
Bug: 155275196
Change-Id: I1bb9099371bd1a3f339396ef343c49b054fcef66
2020-04-30 19:52:43 +01:00
Tom Cherry
1c84135144 init: add even more debugging information for reboot
There are devices stuck waiting for vendor_init to finish a command,
without giving much more information.  Instead of setting aside the
last run command, it's more valuable to store and dump the last 30
logs seen.

Bug: 155203339
Test: these logs appear during hung reboots
Test: normal reboots have no difference.
Change-Id: I99cae248eb81eaf34ef66b910fa653a9fa135f68
2020-04-29 09:01:53 -07:00
Tom Cherry
e70c28bdad init: fix restarting of subcontext
When the subcontext code was redone to allow only one subcontext
(vendor_init), the code for restarting it and for terminating it
during shutdown was not updated, resulting in it not working.

Bug: 155203339
Test: kill subcontext init and notice it restart
Test: subcontext init stops during shutdown
Merged-In: Ib77f59d1e7be0ffcfd3f31c8450dc022c20bb322
Change-Id: Ib77f59d1e7be0ffcfd3f31c8450dc022c20bb322
(cherry picked from commit e3e77d382f)
2020-04-29 08:41:21 -07:00
Tom Cherry
e3e77d382f init: fix restarting of subcontext
When the subcontext code was redone to allow only one subcontext
(vendor_init), the code for restarting it and for terminating it
during shutdown was not updated, resulting in it not working.

Bug: 155203339
Test: kill subcontext init and notice it restart
Test: subcontext init stops during shutdown
Change-Id: Ib77f59d1e7be0ffcfd3f31c8450dc022c20bb322
2020-04-28 14:03:25 -07:00
Ricky Wai
a4c163d734 Add /mnt/androidwritable for MOUNT_EXTERNAL_ANDROID_WRITABLE apps
Bug: 153540919
Test: Able to boot without errors
Change-Id: If206e5e3d76a7919b7468bc2d9666b3aff296b3b
Merged-In: If206e5e3d76a7919b7468bc2d9666b3aff296b3b
2020-04-21 12:16:43 +01:00
TreeHugger Robot
af9240abc9 Merge "Add /mnt/androidwritable for MOUNT_EXTERNAL_ANDROID_WRITABLE apps" into rvc-dev 2020-04-21 11:08:07 +00:00
Nikita Ioffe
a3be996673 Cleanup logic in KillZramBackingDevice
Since this function is used in userspace reboot, we need to be more
diligent with error handling, e.g.:

* If init fails to read /sys/block/zram0/backing_dev, then fail and
fallback to hard reboot.
* Always call swapoff.
* Always reset zram.
* Tear down loop device only if zram is backed by a loop device.

Test: adb reboot userspace
Bug: 153917129
Change-Id: I4709da1d08cf427ad9c898cfb2506b6a29f1d680
Merged-In: I4709da1d08cf427ad9c898cfb2506b6a29f1d680
(cherry picked from commit a840d405eb)
2020-04-17 12:28:25 +01:00
Nikita Ioffe
a840d405eb Cleanup logic in KillZramBackingDevice
Since this function is used in userspace reboot, we need to be more
diligent with error handling, e.g.:

* If init fails to read /sys/block/zram0/backing_dev, then fail and
fallback to hard reboot.
* Always call swapoff.
* Always reset zram.
* Tear down loop device only if zram is backed by a loop device.

Test: adb reboot userspace
Bug: 153917129
Change-Id: I4709da1d08cf427ad9c898cfb2506b6a29f1d680
2020-04-16 21:37:03 +01:00
Yifan Hong
66f0115b05 libsnapshot clients: Add missing dep.
libsnapshot* uses update_metadata-protos. This
used to be optimized out, but now that SnapshotManager is
virtual, CreateUpdateSnapshots can no longer be optimized out.

Bug: 148956645
Test: compiles
Change-Id: Ib67cafd156308bf5a477996ec32eb786f8e896db
2020-04-16 13:12:41 -07:00
Steve Muckle
2980ba4b3d first_stage_init: add hook to exec a shell script
If the first stage console is being used, attempt to run /first_stage.sh
immediately before the console is created.

Bug: 154126020
Change-Id: I8b7431e7b8219afea295b120d7ea91751804bda6
Merged-In: I8b7431e7b8219afea295b120d7ea91751804bda6
2020-04-15 14:05:05 -07:00
Steve Muckle
a4bf2cee04 first_stage_init: add hook to exec a shell script
If the first stage console is being used, attempt to run /first_stage.sh
immediately before the console is created.

Bug: 154126020
Change-Id: I8b7431e7b8219afea295b120d7ea91751804bda6
2020-04-15 10:59:30 -07:00
Will McVicker
c4793572f3 first_stage_init: increase serial console tries to 50
tl,dr;
Increase the attempts to 50 to reduce the chances of failing
to load the serial console. This will only happen if the cmdline
parameter "androidboot.first_stage_console=1" is enabled.

Details:
10 attempts only amounts to about 1 second of trying to open the serial
console. I tested booting an ACK GKI image 5x with 20 vendor modules and
found the serial console loaded on attempt 17 for all five boot
tests.

Bug: 153354917
Test: boot ACK image 5x and verify serial console comes up
Change-Id: I161a4176b2c6cf7b0bc1eefe072ff38b894add5d
Merged-In: I161a4176b2c6cf7b0bc1eefe072ff38b894add5d
2020-04-15 10:57:46 -07:00
Nikita Ioffe
f3504ec58d Add RootTargetPreparer for CtsInitTestCases and CtsFsMgrTestCases
Some of the test cases in CtsInitTestCases and CtsFsMgrTestCases require
root. This CL makes it possible to run such tests cases on userdebug
builds, which in turn means that they will be run on presubmit.

New option was implemented in
https://android-review.googlesource.com/c/platform/tools/tradefederation/+/1283834

Test: atest CtsInitTestCases
Test: atest CtsFsMgrTestCases
Change-Id: I3d29789ddd7ac549e40ac193c58d986670c49285
2020-04-14 18:57:07 +01:00
Ricky Wai
7f72524f9f Add /mnt/androidwritable for MOUNT_EXTERNAL_ANDROID_WRITABLE apps
Bug: 153540919
Test: Able to boot without errors
Change-Id: If206e5e3d76a7919b7468bc2d9666b3aff296b3b
2020-04-14 12:31:50 +01:00
Nikita Ioffe
6236af3d0c Fallback to hard reboot if userspace reboot hasn't started in time
Similarly to other recovery mechanisms, timeout is controlled by a
read-only property that can be configured per-device.

Test: adb root
Test: adb shell setprop init.userspace_reboot.started.timeoutmillis 2
Test: adb reboot userspace
Bug: 152803929
Change-Id: Id70710b46da798945ac5422ef7d69265911ea5ef
Merged-In: Id70710b46da798945ac5422ef7d69265911ea5ef
(cherry picked from commit d05535485f)
2020-04-14 00:21:41 +01:00
Nikita Ioffe
1c14654732 Merge "Fallback to hard reboot if userspace reboot hasn't started in time" 2020-04-13 19:14:56 +00:00
Tom Cherry
ffe39ea541 Merge "Cleanup some trivial TODOs." 2020-04-13 15:39:49 +00:00
Nikita Ioffe
d05535485f Fallback to hard reboot if userspace reboot hasn't started in time
Similarly to other recovery mechanisms, timeout is controlled by a
read-only property that can be configured per-device.

Test: adb root
Test: adb shell setprop init.userspace_reboot.started.timeoutmillis 2
Test: adb reboot userspace
Bug: 152803929
Change-Id: Id70710b46da798945ac5422ef7d69265911ea5ef
2020-04-11 01:59:17 +01:00
Tom Cherry
85f2bc930a Cleanup some trivial TODOs.
1) There's no reason or way to support boot_clock for waiting for
   property changes, since the underlying futex_wait uses
   CLOCK_MONOTONIC.  We probably wouldn't want boot_clock even if it
   did, since it doesn't make sense to consider the time a device was
   suspending in the timeout for waiting for a property to change.
2) The init tokenizer has been essentially unchanged for a decade,
   there's no motivation to 'fix' it to not require a trailing
   newline.
3) The ueventd TODO regarding moving vendor specific ueventd.rc
   entries out of rootdir has been fixed.

Test: n/a
Change-Id: I3b68e3d2f25cbd539f9f8ff526669b8af04d833d
2020-04-10 10:15:30 -07:00
Tom Cherry
3f67fb8e45 init: fix todo in a test
Structured bindings with templated containers work now, so no need for
the workaround or TODO.

Test: init unit tests
Change-Id: I6a286de9859d8a97df480a7ac2862a3a10bd9fb3
2020-04-10 10:08:24 -07:00
Steven Moreland
90540ad53a Merge "Note selinux trans error happens in permissive." 2020-04-09 21:52:08 +00:00
Steven Moreland
9e987cbb1a Note selinux trans error happens in permissive.
There was an email thread about this recently, and I've been asked many
times.

For instance, if this error wasn't attributed, denials a service is
hitting would be attributed to init, and that's a recipe for disaster.
Secondarily, thinking about SELinux whenever you write a new service is
good.

Bug: N/A
Test: N/A
Change-Id: Ib9d2c5d8947375a0d4c33ecf3d075caef6b41f70
2020-04-09 12:48:46 -07:00
Steven Moreland
1ec8c39c3f Merge "init_kill_services_test: reboot device first." 2020-04-09 00:23:20 +00:00
Steven Moreland
32876f356d init_kill_services_test: reboot device first.
This test is killing critical device services, and if it runs
repeatedly or some of the critical services have already died, it'll
force the device to reboot again and potentially consider the test a
failure.

This forces the test to reboot first, so that it is in a fresh state and
we can avoid this type of flake on the device.

Bug: 153444614
Test: atest init_kill_services_test
Change-Id: Ia81a319af1d209f58e70f824bb8eb7f11973637c
2020-04-08 20:23:18 +00:00
Steve Muckle
ae317c716b first_stage_init: load modules in modules.load.recovery in recovery
In recovery mode, load modules from modules.load.recovery if it
exists. Otherwise load from modules.load as usual.

Bug: 150825361
Change-Id: I7636bb5958ed10ae9a66015f04f168129618272f
Merged-In: I7636bb5958ed10ae9a66015f04f168129618272f
2020-04-08 10:49:13 -07:00
Treehugger Robot
51abcc5633 Merge "first_stage_init: load modules in modules.load.recovery in recovery" 2020-04-08 17:41:09 +00:00
Will Mcvicker
51ae53fa1c Merge "first_stage_init: increase serial console tries to 50" into rvc-dev 2020-04-07 20:24:02 +00:00
Dan Shi
12c7aa8ace Remove vts10 tests from vts suite
The tests are only needed in vts10 suite, as they are part of CTS
package and no longer needed in vts 11.

Bug: 151896491
Test: local build
Exempt-From-Owner-Approval: This CL removes vts10 tests from vts suite.
It won't change test logic or behavior.

Change-Id: I4d468be075b54213b56c7e1aa94af94f2bdce9ff
Merged-In: I4d468be075b54213b56c7e1aa94af94f2bdce9ff
2020-04-06 14:25:10 -07:00
Dan Shi
45efd5a27b Merge "Remove vts10 tests from vts suite" 2020-04-06 21:24:46 +00:00
Will McVicker
283128f26a first_stage_init: increase serial console tries to 50
tl,dr;
Increase the attempts to 50 to reduce the chances of failing
to load the serial console. This will only happen if the cmdline
parameter "androidboot.first_stage_console=1" is enabled.

Details:
10 attempts only amounts to about 1 second of trying to open the serial
console. I tested booting an ACK GKI image 5x with 20 vendor modules and
found the serial console loaded on attempt 17 for all five boot
tests.

Bug: 153354917
Test: boot ACK image 5x and verify serial console comes up
Change-Id: I161a4176b2c6cf7b0bc1eefe072ff38b894add5d
2020-04-06 19:49:00 +00:00
Steve Muckle
4c59323dc6 first_stage_init: load modules in modules.load.recovery in recovery
In recovery mode, load modules from modules.load.recovery if it
exists. Otherwise load from modules.load as usual.

Change-Id: I7636bb5958ed10ae9a66015f04f168129618272f
2020-04-06 12:24:16 -07:00
Tom Cherry
79f3d26b25 Merge "Remove EXCLUDE_FS_CONFIG_STRUCTURES" 2020-04-03 14:36:58 +00:00
Tom Cherry
27311fd844 Merge "init: don't sync() before shutting down services" into rvc-dev 2020-04-03 02:40:17 +00:00
Tom Cherry
6288212ac3 init: don't sync() before shutting down services
Devices in the lab are hitting an issue where they're getting stuck
likely in the sync() call in DoReboot() before we start the reboot
monitor thread and before we shut down services.

It's possible that concurrent writing to RW file systems is causing
this sync() call to take essentially forever.  To protect against
this, we need to remove this sync().  Note that we will still call
sync() after shutting down services.

Note that the service shutdown code has a timeout and there is a
reboot monitor thread that will shutdown the device if more than 30
seconds pass above that timeout.  This change increases that timeout
to 300 seconds to give the final sync() calls explicitly more time to
finish.

Bug: 150863651
Test: reboot functions normally
Test: put an infinite loop in DoReboot and the the reboot monitor thread
      triggers and shuts down the device appropriately
Merged-In: I6fd7d3a25d3225081388e39a14c9fdab21b592ba
Change-Id: I6fd7d3a25d3225081388e39a14c9fdab21b592ba
(cherry picked from commit 10615eb397)
2020-04-02 12:51:36 -07:00
Nikita Ioffe
6bd3bc8d01 Properly fail userspace reboot if it's not supported
Previously, after `adb reboot userspace` is called on a device that
doesn't suppor it, init would've logged an error and quietly exit the
shutdown sequence. This was leaving adb handing forever.

With this approach, init will fail setprop
"sys.powerctl=reboot,userspace" in case userspace reboot is not
supported.

Test: adb root
Test: adb setprop init.userspace_reboot.is_supported 0
Test: adb reboot userspace
Test: atest CtsInitTestCases
Bug: 146639622
Change-Id: I1264078f53ed3ff54638c7f3b6846b7437f98ee5
Merged-In: I1264078f53ed3ff54638c7f3b6846b7437f98ee5
(cherry picked from commit 92116e4129)
2020-04-02 17:25:48 +01:00
Nikita Ioffe
2af5bd00b0 Merge "Properly fail userspace reboot if it's not supported" 2020-04-02 10:23:45 +00:00
Nikita Ioffe
9fd393f430 Make init.userspace_reboot.is_supported a rw property
General recommendation is to avoid read-only properties, and instead control
"read-onlines" by only allowing init/vendor_init to set the property.

Since ro.init.userspace_reboot.is_supported was added in this release, and
nobody outside of the platform is querying it directly, it should be fine to
simply rename it.

Test: adb shell getprop init.userspace_reboot.is_supported
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 152803929
Change-Id: I7552d5ccc6e9b750a6081947eef8fcb027be13e1
Merged-In: I7552d5ccc6e9b750a6081947eef8fcb027be13e1
(cherry picked from commit 663cd35030)
2020-04-01 18:24:57 +01:00
Tom Cherry
d54a4bf9a3 Merge "init: don't sync() before shutting down services" 2020-04-01 15:40:44 +00:00
Nikita Ioffe
92116e4129 Properly fail userspace reboot if it's not supported
Previously, after `adb reboot userspace` is called on a device that
doesn't suppor it, init would've logged an error and quietly exit the
shutdown sequence. This was leaving adb handing forever.

With this approach, init will fail setprop
"sys.powerctl=reboot,userspace" in case userspace reboot is not
supported.

Test: adb root
Test: adb setprop init.userspace_reboot.is_supported 0
Test: adb reboot userspace
Test: atest CtsInitTestCases
Bug: 146639622
Change-Id: I1264078f53ed3ff54638c7f3b6846b7437f98ee5
2020-04-01 14:34:54 +01:00
Nikita Ioffe
884b570100 Merge "Make init.userspace_reboot.is_supported a rw property" 2020-04-01 13:14:21 +00:00
Tom Cherry
10615eb397 init: don't sync() before shutting down services
Devices in the lab are hitting an issue where they're getting stuck
likely in the sync() call in DoReboot() before we start the reboot
monitor thread and before we shut down services.

It's possible that concurrent writing to RW file systems is causing
this sync() call to take essentially forever.  To protect against
this, we need to remove this sync().  Note that we will still call
sync() after shutting down services.

Note that the service shutdown code has a timeout and there is a
reboot monitor thread that will shutdown the device if more than 30
seconds pass above that timeout.  This change increases that timeout
to 300 seconds to give the final sync() calls explicitly more time to
finish.

Bug: 150863651
Test: reboot functions normally
Test: put an infinite loop in DoReboot and the the reboot monitor thread
      triggers and shuts down the device appropriately
Change-Id: I6fd7d3a25d3225081388e39a14c9fdab21b592ba
2020-03-31 18:59:23 -07:00
Tom Cherry
9174a9bff8 init: only print backtraces on subsequent reboots with a value
Userspace reboot resets sys.powerctl to an empty string once it
starts, which was inadvertently triggering the backtrace of the main
init thread.

Test: no more unexpected backtraces
Change-Id: I35d6f1b37aa31a46ae9266647f41a709f28b6099
2020-03-31 14:36:03 -07:00
TreeHugger Robot
d456db6d50 Merge "init: require root for oneshot_on test" into rvc-dev 2020-03-31 15:33:51 +00:00
Tom Cherry
5b1c316a1f init: require root for oneshot_on test
Bug: 152630580
Bug: 152637928
Bug: 152662041
Bug: 152662652
Test: this test is skipped when run as non-root
Merged-In: I7118025cc20081a200000bf484a08c9ed0b0d3ec
Change-Id: I7118025cc20081a200000bf484a08c9ed0b0d3ec
(cherry picked from commit 14f4afd2f2)
2020-03-30 18:52:44 -07:00
Nikita Ioffe
663cd35030 Make init.userspace_reboot.is_supported a rw property
General recommendation is to avoid read-only properties, and instead control
"read-onlines" by only allowing init/vendor_init to set the property.

Since ro.init.userspace_reboot.is_supported was added in this release, and
nobody outside of the platform is querying it directly, it should be fine to
simply rename it.

Test: adb shell getprop init.userspace_reboot.is_supported
Test: atest CtsUserspaceRebootHostSideTestCases
Bug: 152803929
Change-Id: I7552d5ccc6e9b750a6081947eef8fcb027be13e1
2020-03-30 23:40:45 +01:00
Tom Cherry
91537d30de Revert "init: disable oneshot_on test"
This reverts commit d30c51157e.

This test wasn't flaky, it was failing when not run as root, but that
has been fixed.

Bug: 152630580
Bug: 152637928
Test: this test is okay now
Change-Id: I3b20be2839dae90ffc6a8eeea68f36e532060af1
2020-03-30 09:37:05 -07:00
Tom Cherry
14f4afd2f2 init: require root for oneshot_on test
Bug: 152630580
Bug: 152637928
Bug: 152662041
Bug: 152662652
Test: this test is skipped when run as non-root
Change-Id: I7118025cc20081a200000bf484a08c9ed0b0d3ec
2020-03-30 09:12:31 -07:00
Treehugger Robot
56188cc1c2 Merge "init: disable oneshot_on test" 2020-03-28 19:49:26 +00:00
Tom Cherry
495a394fd3 init: do not handle control messages after shutdown
We already stop queue'ing new control messages, but we forgot to stop
handling those control messages that are already queued.  This CL
fixes that.

Bug: 150863651
Test: CF reboots appropriately
Merged-In: Ifea07a30b868de23eb735db10d8bae410e1b98bb
Change-Id: Ifea07a30b868de23eb735db10d8bae410e1b98bb
(cherry picked from commit 22d6348845)
2020-03-28 12:17:40 -07:00
Tom Cherry
43374ce9c1 init: fix StopSendingMessages()
A typo made this function a no-op.

Bug: 150863651
Test: CF responds to messages appropriately
Merged-In: Iaae0264fae3f2b899ceb5ba0364a4773df1f7ca3
Change-Id: Iaae0264fae3f2b899ceb5ba0364a4773df1f7ca3
(cherry picked from commit 68855276a1)
2020-03-28 12:17:30 -07:00
Tom Cherry
9c83185c1e init: use an eventfd instead of socketpair to wake the main loop
eventfd is a more suitable mechanism.

Bug: 150863651
Test: boot CF, ctl.start services, reboot CF
Merged-In: Ie5c3b0c048afdd7afa4bfc4cba26bec3225925e5
Change-Id: Ie5c3b0c048afdd7afa4bfc4cba26bec3225925e5
(cherry picked from commit 40463336a8)
2020-03-27 16:17:57 -07:00
Tom Cherry
080fa98815 init: even better logging around subsequent sys.powerctl messages
Bug: 150863651
Test: add delays during critical parts of shutdown and see the
      expected debug information
Change-Id: Ida586903fd3eefc32ca9ee34ea2db037896ed9f4
2020-03-27 14:39:16 -07:00
Tom Cherry
22d6348845 init: do not handle control messages after shutdown
We already stop queue'ing new control messages, but we forgot to stop
handling those control messages that are already queued.  This CL
fixes that.

Bug: 150863651
Test: CF reboots appropriately
Change-Id: Ifea07a30b868de23eb735db10d8bae410e1b98bb
2020-03-27 14:08:20 -07:00
Tom Cherry
68855276a1 init: fix StopSendingMessages()
A typo made this function a no-op.

Bug: 150863651
Test: CF responds to messages appropriately
Change-Id: Iaae0264fae3f2b899ceb5ba0364a4773df1f7ca3
2020-03-27 13:57:53 -07:00
Tom Cherry
d30c51157e init: disable oneshot_on test
Apparently relying on bootanim to restart or not is too flaky.

Bug: 152630580
Bug: 152637928
Test: this test no longer runs
Change-Id: If61b31bad276560a9f0db9811724bbc9efc51d28
2020-03-27 13:37:50 -07:00
Dan Shi
96f29ead9c Remove vts10 tests from vts suite
The tests are only needed in vts10 suite.

Bug: 151896491
Test: local build
Exempt-From-Owner-Approval: This CL removes vts10 tests from vts suite.
It won't change test logic or behavior.

Change-Id: I4d468be075b54213b56c7e1aa94af94f2bdce9ff
2020-03-27 10:07:44 -07:00
Tom Cherry
40463336a8 init: use an eventfd instead of socketpair to wake the main loop
eventfd is a more suitable mechanism.

Bug: 150863651
Test: boot CF, ctl.start services, reboot CF
Change-Id: Ie5c3b0c048afdd7afa4bfc4cba26bec3225925e5
2020-03-27 08:08:52 -07:00
David Anderson
b9123e5bce init: Forcefully mount system_ext on DAP devices if not present in fstab.
Bug: 150315914
Test: cuttlefish boots with system_ext missing from fstab
Change-Id: I99f292a070678b8a98500258af98129fbd81dfa7
Merged-In: I99f292a070678b8a98500258af98129fbd81dfa7
2020-03-26 17:25:54 -07:00
David Anderson
d8f032ee93 init: Factor out first-stage uevent handling into a separate class.
This will make it possible to re-use in second-stage init.

Bug: 150315914
Test: first-stage init boots
Change-Id: I6a0f13d5c71ab5529a76751f68ac0f15834323d1
Merged-In: I6a0f13d5c71ab5529a76751f68ac0f15834323d1
2020-03-26 17:25:49 -07:00
David Anderson
620e5d48db init: Remove special-case hacks for the super partition.
Rather than special-casing super in the uevent listener, call Realpath()
after we've generated its symlink. This allows us to generalize the
uevent listener code.

Also, rename "metadata partition" to "super partition" in a few places,
as this terminology is a bit dated.

Bug: 150315914
Test: first-stage init boots
Change-Id: I2bf3bebf3360f097582df7fba95f3c1753feb2e2
Merged-In: I2bf3bebf3360f097582df7fba95f3c1753feb2e2
2020-03-26 17:25:45 -07:00
Tom Cherry
975bfe1146 init: add missing TEMP_FAILURE_RETRY
Bug: 150863651
Test: boot
Merged-In: I09e86e08a716c2c2933e090d57818a9aad6486f8
Change-Id: I09e86e08a716c2c2933e090d57818a9aad6486f8
2020-03-26 20:50:35 +00:00
Nikita Ioffe
f0ab5b17f6 Use properties for various userspace reboot timeouts
Test: adb reboot userspace
Bug: 146560409
Change-Id: I435e4f93a8769ff7d30cf781e0b48fa3e96121ef
Merged-In: I435e4f93a8769ff7d30cf781e0b48fa3e96121ef
(cherry picked from commit 7b41a1558d)
2020-03-25 21:40:45 +00:00
TreeHugger Robot
5eb308766e Merge "Remove use of static libdexfile to avoid linking in ART internal code." into rvc-dev 2020-03-25 20:29:25 +00:00
Nikita Ioffe
fc51af215b Merge "Use properties for various userspace reboot timeouts" 2020-03-25 20:02:05 +00:00
Nikita Ioffe
7b41a1558d Use properties for various userspace reboot timeouts
Test: adb reboot userspace
Bug: 146560409
Change-Id: I435e4f93a8769ff7d30cf781e0b48fa3e96121ef
2020-03-25 17:46:13 +00:00
David Anderson
f12ea1ed1b Merge "init: Forcefully mount system_ext on DAP devices if not present in fstab." 2020-03-25 17:01:38 +00:00
Treehugger Robot
58f35246cf Merge "init: add more logging around reboots" 2020-03-25 15:48:24 +00:00
TreeHugger Robot
3553c5ea4c Merge "init: add missing TEMP_FAILURE_RETRY" into rvc-dev 2020-03-25 15:40:26 +00:00
David Anderson
d0ce5303e3 init: Forcefully mount system_ext on DAP devices if not present in fstab.
Bug: 150315914
Test: cuttlefish boots with system_ext missing from fstab
Change-Id: I99f292a070678b8a98500258af98129fbd81dfa7
2020-03-24 22:24:32 -07:00
Tom Cherry
494cffb26c init: add missing TEMP_FAILURE_RETRY
Bug: 150863651
Test: boot
Change-Id: I09e86e08a716c2c2933e090d57818a9aad6486f8
2020-03-24 18:17:53 -07:00
Tom Cherry
1c688365ac init: add more logging around reboots
Particularly in the case of the device failing to reboot.  Some test
devices are showing that they've received the reboot message but
without rebooting.

Bug: 150863651
Test: prevent init from handling reboot and see a stacktrace
Test: reboot works normally
Change-Id: Ide001dadbb9e9cd235ea509066e6ae6664bb429b
2020-03-24 18:01:50 -07:00
Treehugger Robot
2d90168f80 Merge "Add vts10 suite to existing vts tests" 2020-03-24 21:49:44 +00:00
Martin Stjernholm
ae695c9fad Remove use of static libdexfile to avoid linking in ART internal code.
- Create a static library libunwindstack_no_dex without DEX support.
- Use it in libdebuggerd_handler_fallback, whose only use is in the
  linker, which shouldn't need that support.
- Use it in init_first_stage, which doesn't need DEX support either.
- Also need a libbacktrace_no_dex since it's in the dependency chain
  from init_first_stage to libunwindstack_no_dex.

Also restrict the *_no_dex libs and libdebuggerd_handler_fallback as
much as possible to avoid inadvertent use of these reduced
functionality libs.

Test: m init_first_stage on Cuttlefish
  where BOARD_BUILD_SYSTEM_ROOT_IMAGE=false
Test: m system_image com.android.runtime
Test: Build & boot
Test: atest linker-unit-tests libunwindstack_unit_test debuggerd_test
Bug: 142944931
Bug: 151466650
Change-Id: Iaacb29bfe602f3ca12a00a712e2a64c45ff0118b
Merged-In: Iaacb29bfe602f3ca12a00a712e2a64c45ff0118b
2020-03-24 21:48:00 +00:00
Dan Shi
5d8d73c440 Add vts10 suite to existing vts tests
This is to prepare renaming vts to vts10.

Bug: 151896491
Test: local build
Exempt-From-Owner-Approval: This CL adds all tests in vts to a new
suite vts10. vts10 will be the new name of existing vts suite. This CL
won't change test logic or behavior.

Change-Id: I3c7ccef142de30f02a59046cecba121480f6e436
2020-03-24 13:04:53 -07:00
David Anderson
b80b654b1b Merge "init: Factor out first-stage uevent handling into a separate class." 2020-03-24 18:19:15 +00:00
David Anderson
4117559746 init: Factor out first-stage uevent handling into a separate class.
This will make it possible to re-use in second-stage init.

Bug: 150315914
Test: first-stage init boots
Change-Id: I6a0f13d5c71ab5529a76751f68ac0f15834323d1
2020-03-23 18:49:51 -07:00
Martin Stjernholm
6d4e47a165 Merge "Remove use of static libdexfile to avoid linking in ART internal code." 2020-03-23 20:15:14 +00:00
David Anderson
0053acd11c Merge "init: Remove special-case hacks for the super partition." 2020-03-23 19:19:22 +00:00
Tom Cherry
c297d6034d init: add ctl.oneshot_on/ctl.oneshot_off
Some services are lazy HALs on some platforms and not lazy HALs on
others; this is known at runtime by hwservicemanager, so this change
adds these properties to allow hwservicemanager to turn one oneshot
(for lazy HALs).  It may also be required to make a lazy HAL not lazy
anymore, and oneshot_off is provided for this.

Bug: 147841742
Test: new unit test that turn on and off oneshot on a service (bootanim)
      and observes that it follows the expected behavior
Merged-In: I79524e2c9a5008f90c8d3bc40920fde00602a439
Change-Id: I79524e2c9a5008f90c8d3bc40920fde00602a439
(cherry picked from commit bdbf5047c9)
2020-03-23 08:03:01 -07:00
David Anderson
b78a632ab7 init: Remove special-case hacks for the super partition.
Rather than special-casing super in the uevent listener, call Realpath()
after we've generated its symlink. This allows us to generalize the
uevent listener code.

Also, rename "metadata partition" to "super partition" in a few places,
as this terminology is a bit dated.

Bug: 150315914
Test: first-stage init boots
Change-Id: I2bf3bebf3360f097582df7fba95f3c1753feb2e2
2020-03-20 19:48:46 -07:00
Martin Stjernholm
a2cc893044 Remove use of static libdexfile to avoid linking in ART internal code.
- Create a static library libunwindstack_no_dex without DEX support.
- Use it in libdebuggerd_handler_fallback, whose only use is in the
  linker, which shouldn't need that support.
- Use it in init_first_stage, which doesn't need DEX support either.
- Also need a libbacktrace_no_dex since it's in the dependency chain
  from init_first_stage to libunwindstack_no_dex.

Also restrict the *_no_dex libs and libdebuggerd_handler_fallback as
much as possible to avoid inadvertent use of these reduced
functionality libs.

Test: m init_first_stage on Cuttlefish
  where BOARD_BUILD_SYSTEM_ROOT_IMAGE=false
Test: m system_image com.android.runtime
Test: Build & boot
Test: atest linker-unit-tests libunwindstack_unit_test debuggerd_test
Bug: 142944931
Bug: 151466650
Change-Id: Iaacb29bfe602f3ca12a00a712e2a64c45ff0118b
2020-03-19 22:23:54 +00:00
Tom Cherry
bdbf5047c9 init: add ctl.oneshot_on/ctl.oneshot_off
Some services are lazy HALs on some platforms and not lazy HALs on
others; this is known at runtime by hwservicemanager, so this change
adds these properties to allow hwservicemanager to turn one oneshot
(for lazy HALs).  It may also be required to make a lazy HAL not lazy
anymore, and oneshot_off is provided for this.

Bug: 147841742
Test: new unit test that turn on and off oneshot on a service (bootanim)
      and observes that it follows the expected behavior
Change-Id: I79524e2c9a5008f90c8d3bc40920fde00602a439
2020-03-19 12:54:25 -07:00
Tom Cherry
2bf886afc2 init: use a no-op signal handler instead of SIG_IGN for SIGPIPE
We want to ignore SIGPIPE within init, but if we use SIG_IGN, that
would be inherited by child processes through exec(), which we do not
want to have happen.  We instead set up a real signal handler with a
no-op handler function, that will ignore SIGPIPE within init, but will
not be inherited across exec().

This fixes c29c2baa69 ("init: Add support for native service
registration with lmkd"), when SIG_IGN was introduced.
Note that we caught this issue before shipping a release with that
change, so the major motivation here is to not cause a behavior change
in init.

Bug: 151581751
Test: children of init that don't explicitly block SIGPIPE exit when
      sent SIGPIPE
Test: children of init that do explicitly block SIGPIPE do not exit
      when sent SIGPIPE
Test: init does not exit when sent SIGPIPE
Test: init exits when sent SIGABRT
Merged-In: Ieda8555fd03836bcd672a422fe673a8369ad9beb
Change-Id: Ieda8555fd03836bcd672a422fe673a8369ad9beb
(cherry picked from commit fd470e87cc)
2020-03-18 09:42:56 -07:00