Merge changes from topic "remove-log_to"
* changes:
base: remove LOG_TO(), PLOG_TO() and LOG_STREAM_TO() macros
storaged: replace LOG_TO() macros with LOG()
diff --git a/adb/adb.h b/adb/adb.h
index e7fcc91..7f7dd0d 100644
--- a/adb/adb.h
+++ b/adb/adb.h
@@ -185,14 +185,7 @@
} while (0)
#endif
-#if ADB_HOST_ON_TARGET
-/* adb and adbd are coexisting on the target, so use 5038 for adb
- * to avoid conflicting with adbd's usage of 5037
- */
-#define DEFAULT_ADB_PORT 5038
-#else
#define DEFAULT_ADB_PORT 5037
-#endif
#define DEFAULT_ADB_LOCAL_TRANSPORT_PORT 5555
diff --git a/adb/apex/ld.config.txt b/adb/apex/ld.config.txt
index 13d66b6..d1858a4 100644
--- a/adb/apex/ld.config.txt
+++ b/adb/apex/ld.config.txt
@@ -10,6 +10,8 @@
namespace.default.isolated = true
namespace.default.search.paths = /apex/com.android.adbd/${LIB}
namespace.default.asan.search.paths = /apex/com.android.adbd/${LIB}
+namespace.default.permitted.paths = /system/${LIB}
+namespace.default.asan.permitted.paths = /system/${LIB}
namespace.default.links = art,platform
namespace.default.link.art.shared_libs = libadbconnection_server.so
namespace.default.link.platform.shared_libs = libc.so:libdl.so:libm.so:libclang_rt.hwasan-aarch64-android.so
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index 15c9dfb..03c7943 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -910,6 +910,10 @@
return true;
}
+static bool SupportsCheckpoint(FstabEntry* entry) {
+ return entry->fs_mgr_flags.checkpoint_blk || entry->fs_mgr_flags.checkpoint_fs;
+}
+
class CheckpointManager {
public:
CheckpointManager(int needs_checkpoint = -1) : needs_checkpoint_(needs_checkpoint) {}
@@ -926,7 +930,7 @@
}
bool Update(FstabEntry* entry, const std::string& block_device = std::string()) {
- if (!entry->fs_mgr_flags.checkpoint_blk && !entry->fs_mgr_flags.checkpoint_fs) {
+ if (!SupportsCheckpoint(entry)) {
return true;
}
@@ -947,7 +951,7 @@
}
bool Revert(FstabEntry* entry) {
- if (!entry->fs_mgr_flags.checkpoint_blk && !entry->fs_mgr_flags.checkpoint_fs) {
+ if (!SupportsCheckpoint(entry)) {
return true;
}
@@ -1362,6 +1366,7 @@
}
static bool fs_mgr_unmount_all_data_mounts(const std::string& block_device) {
+ LINFO << __FUNCTION__ << "(): about to umount everything on top of " << block_device;
Timer t;
// TODO(b/135984674): should be configured via a read-only property.
std::chrono::milliseconds timeout = 5s;
@@ -1369,22 +1374,34 @@
bool umount_done = true;
Fstab proc_mounts;
if (!ReadFstabFromFile("/proc/mounts", &proc_mounts)) {
- LERROR << "Can't read /proc/mounts";
+ LERROR << __FUNCTION__ << "(): Can't read /proc/mounts";
return false;
}
// Now proceed with other bind mounts on top of /data.
for (const auto& entry : proc_mounts) {
if (entry.blk_device == block_device) {
if (umount2(entry.mount_point.c_str(), 0) != 0) {
+ PERROR << __FUNCTION__ << "(): Failed to umount " << entry.mount_point;
umount_done = false;
}
}
}
if (umount_done) {
- LINFO << "Unmounting /data took " << t;
+ LINFO << __FUNCTION__ << "(): Unmounting /data took " << t;
return true;
}
if (t.duration() > timeout) {
+ LERROR << __FUNCTION__ << "(): Timed out unmounting all mounts on " << block_device;
+ Fstab remaining_mounts;
+ if (!ReadFstabFromFile("/proc/mounts", &remaining_mounts)) {
+ LERROR << __FUNCTION__ << "(): Can't read /proc/mounts";
+ } else {
+ LERROR << __FUNCTION__ << "(): Following mounts remaining";
+ for (const auto& e : remaining_mounts) {
+ LERROR << __FUNCTION__ << "(): mount point: " << e.mount_point
+ << " block device: " << e.blk_device;
+ }
+ }
return false;
}
std::this_thread::sleep_for(50ms);
@@ -1410,18 +1427,20 @@
LERROR << "Can't find /data in fstab";
return -1;
}
- if (!fstab_entry->fs_mgr_flags.checkpoint_blk && !fstab_entry->fs_mgr_flags.checkpoint_fs) {
+ bool force_umount = GetBoolProperty("sys.init.userdata_remount.force_umount", false);
+ if (force_umount) {
+ LINFO << "Will force an umount of userdata even if it's not required";
+ }
+ if (!force_umount && !SupportsCheckpoint(fstab_entry)) {
LINFO << "Userdata doesn't support checkpointing. Nothing to do";
return 0;
}
CheckpointManager checkpoint_manager;
- if (!checkpoint_manager.NeedsCheckpoint()) {
+ if (!force_umount && !checkpoint_manager.NeedsCheckpoint()) {
LINFO << "Checkpointing not needed. Don't remount";
return 0;
}
- bool force_umount_for_f2fs =
- GetBoolProperty("sys.init.userdata_remount.force_umount_f2fs", false);
- if (fstab_entry->fs_mgr_flags.checkpoint_fs && !force_umount_for_f2fs) {
+ if (!force_umount && fstab_entry->fs_mgr_flags.checkpoint_fs) {
// Userdata is f2fs, simply remount it.
if (!checkpoint_manager.Update(fstab_entry)) {
LERROR << "Failed to remount userdata in checkpointing mode";
diff --git a/fs_mgr/libfiemap/Android.bp b/fs_mgr/libfiemap/Android.bp
index e2df862..1bf457f 100644
--- a/fs_mgr/libfiemap/Android.bp
+++ b/fs_mgr/libfiemap/Android.bp
@@ -79,6 +79,11 @@
srcs: [
"fiemap_writer_test.cpp",
],
+
+ test_suites: ["vts-core", "device-tests"],
+ auto_gen_config: true,
+ test_min_api_level: 29,
+ require_root: true,
}
cc_test {
@@ -100,7 +105,3 @@
"image_test.cpp",
],
}
-
-vts_config {
- name: "VtsFiemapWriterTest",
-}
diff --git a/fs_mgr/libfiemap/AndroidTest.xml b/fs_mgr/libfiemap/AndroidTest.xml
deleted file mode 100644
index 44c80fc..0000000
--- a/fs_mgr/libfiemap/AndroidTest.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2019 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration description="Config for VTS VtsFiemapWriterTest">
- <option name="config-descriptor:metadata" key="plan" value="vts-kernel" />
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
- <option name="abort-on-push-failure" value="false"/>
- <option name="push-group" value="HostDrivenTest.push"/>
- </target_preparer>
- <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
- <option name="test-module-name" value="VtsFiemapWriterTest"/>
- <option name="binary-test-source" value="_32bit::DATA/nativetest/fiemap_writer_test/fiemap_writer_test" />
- <option name="binary-test-source" value="_64bit::DATA/nativetest64/fiemap_writer_test/fiemap_writer_test" />
- <option name="binary-test-type" value="gtest"/>
- <option name="precondition-first-api-level" value="29" />
- <option name="test-timeout" value="1m"/>
- </test>
-</configuration>
diff --git a/init/README.md b/init/README.md
index b8300fa..4f0a7ec 100644
--- a/init/README.md
+++ b/init/README.md
@@ -487,6 +487,25 @@
-f: force installation of the module even if the version of the running kernel
and the version of the kernel for which the module was compiled do not match.
+`interface_start <name>` \
+`interface_restart <name>` \
+`interface_stop <name>`
+> Find the service that provides the interface _name_ if it exists and run the `start`, `restart`,
+or `stop` commands on it respectively. _name_ may be either a fully qualified HIDL name, in which
+case it is specified as `<interface>/<instance>`, or an AIDL name, in which case it is specified as
+`aidl/<interface>` for example `android.hardware.secure_element@1.1::ISecureElement/eSE1` or
+`aidl/aidl_lazy_test_1`.
+
+> Note that these commands only act on interfaces specified by the `interface` service option, not
+on interfaces registered at runtime.
+
+> Example usage of these commands: \
+`interface_start android.hardware.secure_element@1.1::ISecureElement/eSE1`
+will start the HIDL Service that provides the `android.hardware.secure_element@1.1` and `eSI1`
+instance. \
+`interface_start aidl/aidl_lazy_test_1` will start the AIDL service that
+provides the `aidl_lazy_test_1` interface.
+
`load_system_props`
> (This action is deprecated and no-op.)
@@ -700,6 +719,26 @@
`/sys/fs/ext4/${dev.mnt.blk.<mount_point>}/` to tune the block device
characteristics in a device agnostic manner.
+Init responds to properties that begin with `ctl.`. These properties take the format of
+`ctl.<command>` and the _value_ of the system property is used as a parameter, for example:
+`SetProperty("ctl.start", "logd")` will run the `start` command on `logd`. Note that these
+properties are only settable; they will have no value when read.
+
+`ctl.start` \
+`ctl.restart` \
+`ctl.stop`
+> These are equivalent to using the `start`, `restart`, and `stop` commands on the service specified
+by the _value_ of the property.
+
+`ctl.interface_start` \
+`ctl.interface_restart` \
+`ctl.interface_stop`
+> These are equivalent to using the `interface_start`, `interface_restart`, and `interface_stop`
+commands on the interface specified by the _value_ of the property.
+
+`ctl.sigstop_on` and `ctl.sigstop_off` will turn on or off the _sigstop_ feature for the service
+specified by the _value_ of the property. See the _Debugging init_ section below for more details
+about this feature.
Boot timing
-----------
diff --git a/init/mount_namespace.cpp b/init/mount_namespace.cpp
index 93eb244..b811622 100644
--- a/init/mount_namespace.cpp
+++ b/init/mount_namespace.cpp
@@ -35,6 +35,19 @@
namespace init {
namespace {
+static bool BindMount(const std::string& source, const std::string& mount_point,
+ bool recursive = false) {
+ unsigned long mountflags = MS_BIND;
+ if (recursive) {
+ mountflags |= MS_REC;
+ }
+ if (mount(source.c_str(), mount_point.c_str(), nullptr, mountflags, nullptr) == -1) {
+ PLOG(ERROR) << "Failed to bind mount " << source;
+ return false;
+ }
+ return true;
+}
+
static bool MakeShared(const std::string& mount_point, bool recursive = false) {
unsigned long mountflags = MS_SHARED;
if (recursive) {
@@ -47,6 +60,18 @@
return true;
}
+static bool MakeSlave(const std::string& mount_point, bool recursive = false) {
+ unsigned long mountflags = MS_SLAVE;
+ if (recursive) {
+ mountflags |= MS_REC;
+ }
+ if (mount(nullptr, mount_point.c_str(), nullptr, mountflags, nullptr) == -1) {
+ PLOG(ERROR) << "Failed to change propagation type to slave";
+ return false;
+ }
+ return true;
+}
+
static bool MakePrivate(const std::string& mount_point, bool recursive = false) {
unsigned long mountflags = MS_PRIVATE;
if (recursive) {
@@ -191,6 +216,39 @@
// namespace
if (!(MakePrivate("/linkerconfig"))) return false;
+ // The two mount namespaces present challenges for scoped storage, because
+ // vold, which is responsible for most of the mounting, lives in the
+ // bootstrap mount namespace, whereas most other daemons and all apps live
+ // in the default namespace. Scoped storage has a need for a
+ // /mnt/installer view that is a slave bind mount of /mnt/user - in other
+ // words, all mounts under /mnt/user should automatically show up under
+ // /mnt/installer. However, additional mounts done under /mnt/installer
+ // should not propagate back to /mnt/user. In a single mount namespace
+ // this is easy to achieve, by simply marking the /mnt/installer a slave
+ // bind mount. Unfortunately, if /mnt/installer is only created and
+ // bind mounted after the two namespaces are created below, we end up
+ // with the following situation:
+ // /mnt/user and /mnt/installer share the same peer group in both the
+ // bootstrap and default namespaces. Marking /mnt/installer slave in either
+ // namespace means that it won't propagate events to the /mnt/installer in
+ // the other namespace, which is still something we require - vold is the
+ // one doing the mounting under /mnt/installer, and those mounts should
+ // show up in the default namespace as well.
+ //
+ // The simplest solution is to do the bind mount before the two namespaces
+ // are created: the effect is that in both namespaces, /mnt/installer is a
+ // slave to the /mnt/user mount, and at the same time /mnt/installer in the
+ // bootstrap namespace shares a peer group with /mnt/installer in the
+ // default namespace.
+ if (!mkdir_recursive("/mnt/user", 0755)) return false;
+ if (!mkdir_recursive("/mnt/installer", 0755)) return false;
+ if (!(BindMount("/mnt/user", "/mnt/installer", true))) return false;
+ // First, make /mnt/installer a slave bind mount
+ if (!(MakeSlave("/mnt/installer"))) return false;
+ // Then, make it shared again - effectively creating a new peer group, that
+ // will be inherited by new mount namespaces.
+ if (!(MakeShared("/mnt/installer"))) return false;
+
bootstrap_ns_fd.reset(OpenMountNamespace());
bootstrap_ns_id = GetMountNamespaceId();
diff --git a/libcutils/include/cutils/trace.h b/libcutils/include/cutils/trace.h
index 79b4b35..e12c32c 100644
--- a/libcutils/include/cutils/trace.h
+++ b/libcutils/include/cutils/trace.h
@@ -25,7 +25,6 @@
#include <sys/cdefs.h>
#include <sys/types.h>
#include <unistd.h>
-
#include <cutils/compiler.h>
__BEGIN_DECLS
@@ -89,6 +88,12 @@
#error ATRACE_TAG must be defined to be one of the tags defined in cutils/trace.h
#endif
+// Set this to 0 to revert to the old Binder-based atrace implementation.
+// This is only here in case rollbacks do not apply cleanly.
+// TODO(fmayer): Remove this once we are confident this won't need to be
+// rolled back, no later than 2020-03-01.
+#define ATRACE_SHMEM 1
+
/**
* Opens the trace file for writing and reads the property for initial tags.
* The atrace.tags.enableflags property sets the tags to trace.
@@ -116,11 +121,15 @@
* prevent tracing within the Zygote process.
*/
void atrace_set_tracing_enabled(bool enabled);
-
/**
- * Flag indicating whether setup has been completed, initialized to 0.
- * Nonzero indicates setup has completed.
- * Note: This does NOT indicate whether or not setup was successful.
+ * If !ATRACE_SHMEM:
+ * Flag indicating whether setup has been completed, initialized to 0.
+ * Nonzero indicates setup has completed.
+ * Note: This does NOT indicate whether or not setup was successful.
+ * If ATRACE_SHMEM:
+ * This is always set to false. This forces code that uses an old version
+ * of this header to always call into atrace_setup, in which we call
+ * atrace_init unconditionally.
*/
extern atomic_bool atrace_is_ready;
@@ -143,6 +152,12 @@
* This can be explicitly run to avoid setup delay on first trace function.
*/
#define ATRACE_INIT() atrace_init()
+#define ATRACE_GET_ENABLED_TAGS() atrace_get_enabled_tags()
+
+#if ATRACE_SHMEM
+void atrace_init();
+uint64_t atrace_get_enabled_tags();
+#else
static inline void atrace_init()
{
if (CC_UNLIKELY(!atomic_load_explicit(&atrace_is_ready, memory_order_acquire))) {
@@ -155,12 +170,12 @@
* It can be used as a guard condition around more expensive trace calculations.
* Every trace function calls this, which ensures atrace_init is run.
*/
-#define ATRACE_GET_ENABLED_TAGS() atrace_get_enabled_tags()
static inline uint64_t atrace_get_enabled_tags()
{
atrace_init();
return atrace_enabled_tags;
}
+#endif
/**
* Test if a given tag is currently enabled.
diff --git a/libcutils/trace-container.cpp b/libcutils/trace-container.cpp
index d981f8f..c23d5e2 100644
--- a/libcutils/trace-container.cpp
+++ b/libcutils/trace-container.cpp
@@ -39,6 +39,11 @@
static pthread_mutex_t atrace_enabling_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_rwlock_t atrace_container_sock_rwlock = PTHREAD_RWLOCK_INITIALIZER;
+static void atrace_seq_number_changed(uint32_t, uint32_t seq_no) {
+ pthread_once(&atrace_once_control, atrace_init_once);
+ atomic_store_explicit(&last_sequence_number, seq_no, memory_order_relaxed);
+}
+
static bool atrace_init_container_sock()
{
pthread_rwlock_wrlock(&atrace_container_sock_rwlock);
diff --git a/libcutils/trace-dev.cpp b/libcutils/trace-dev.cpp
index bff16c1..2ee39d3 100644
--- a/libcutils/trace-dev.cpp
+++ b/libcutils/trace-dev.cpp
@@ -37,12 +37,39 @@
} else {
atrace_enabled_tags = atrace_get_property();
}
+#if !ATRACE_SHMEM
atomic_store_explicit(&atrace_is_ready, true, memory_order_release);
+#endif
+}
+
+static void atrace_seq_number_changed(uint32_t prev_seq_no, uint32_t seq_no) {
+ if (!atomic_load_explicit(&atrace_is_enabled, memory_order_acquire)) {
+ return;
+ }
+
+ // Someone raced us.
+ if (!atomic_compare_exchange_strong(&last_sequence_number, &prev_seq_no, seq_no)) {
+ return;
+ }
+
+ if (CC_UNLIKELY(prev_seq_no == kSeqNoNotInit)) {
+#if defined(__BIONIC__)
+ const prop_info* new_pi = __system_property_find("debug.atrace.tags.enableflags");
+ if (new_pi) atrace_property_info = new_pi;
+#endif
+ pthread_once(&atrace_once_control, atrace_init_once);
+ }
+
+ atrace_update_tags();
}
void atrace_setup()
{
+#if ATRACE_SHMEM
+ atrace_init();
+#else
pthread_once(&atrace_once_control, atrace_init_once);
+#endif
}
void atrace_begin_body(const char* name)
diff --git a/libcutils/trace-dev.inc b/libcutils/trace-dev.inc
index e3da77b..a57a4c5 100644
--- a/libcutils/trace-dev.inc
+++ b/libcutils/trace-dev.inc
@@ -34,6 +34,11 @@
#include <log/log.h>
#include <log/log_properties.h>
+#if defined(__BIONIC__)
+#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
+#include <sys/_system_properties.h>
+#endif
+
/**
* Maximum size of a message that can be logged to the trace buffer.
* Note this message includes a tag, the pid, and the string given as the name.
@@ -41,12 +46,57 @@
*/
#define ATRACE_MESSAGE_LENGTH 1024
-atomic_bool atrace_is_ready = ATOMIC_VAR_INIT(false);
-int atrace_marker_fd = -1;
-uint64_t atrace_enabled_tags = ATRACE_TAG_NOT_READY;
-static bool atrace_is_debuggable = false;
-static atomic_bool atrace_is_enabled = ATOMIC_VAR_INIT(true);
-static pthread_mutex_t atrace_tags_mutex = PTHREAD_MUTEX_INITIALIZER;
+constexpr uint32_t kSeqNoNotInit = static_cast<uint32_t>(-1);
+
+atomic_bool atrace_is_ready = ATOMIC_VAR_INIT(false);
+int atrace_marker_fd = -1;
+uint64_t atrace_enabled_tags = ATRACE_TAG_NOT_READY;
+static bool atrace_is_debuggable = false;
+static atomic_bool atrace_is_enabled = ATOMIC_VAR_INIT(true);
+static pthread_mutex_t atrace_tags_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/**
+ * Sequence number of debug.atrace.tags.enableflags the last time the enabled
+ * tags were reloaded.
+ **/
+static _Atomic(uint32_t) last_sequence_number = ATOMIC_VAR_INIT(kSeqNoNotInit);
+
+#if defined(__BIONIC__)
+// All zero prop_info that has a sequence number of 0. This is easier than
+// depending on implementation details of the property implementation.
+//
+// prop_info is static_assert-ed to be 96 bytes, which cannot change due to
+// ABI compatibility.
+alignas(uint64_t) static char empty_pi[96];
+static const prop_info* atrace_property_info = reinterpret_cast<const prop_info*>(empty_pi);
+#endif
+
+#if ATRACE_SHMEM
+
+/**
+ * This is called when the sequence number of debug.atrace.tags.enableflags
+ * changes and we need to reload the enabled tags.
+ **/
+static void atrace_seq_number_changed(uint32_t prev_seq_no, uint32_t seq_no);
+
+void atrace_init() {
+#if defined(__BIONIC__)
+ uint32_t seq_no = __system_property_serial(atrace_property_info); // Acquire semantics.
+#else
+ uint32_t seq_no = 0;
+#endif
+ uint32_t prev_seq_no = atomic_load_explicit(&last_sequence_number, memory_order_relaxed);
+ if (CC_UNLIKELY(seq_no != prev_seq_no)) {
+ atrace_seq_number_changed(prev_seq_no, seq_no);
+ }
+}
+
+uint64_t atrace_get_enabled_tags()
+{
+ atrace_init();
+ return atrace_enabled_tags;
+}
+#endif
// Set whether this process is debuggable, which determines whether
// application-level tracing is allowed when the ro.debuggable system property
@@ -136,7 +186,7 @@
void atrace_update_tags()
{
uint64_t tags;
- if (CC_UNLIKELY(atomic_load_explicit(&atrace_is_ready, memory_order_acquire))) {
+ if (ATRACE_SHMEM || CC_UNLIKELY(atomic_load_explicit(&atrace_is_ready, memory_order_acquire))) {
if (atomic_load_explicit(&atrace_is_enabled, memory_order_acquire)) {
tags = atrace_get_property();
pthread_mutex_lock(&atrace_tags_mutex);
diff --git a/libcutils/trace-host.cpp b/libcutils/trace-host.cpp
index d47cc18..c21d0ee 100644
--- a/libcutils/trace-host.cpp
+++ b/libcutils/trace-host.cpp
@@ -30,3 +30,10 @@
void atrace_async_end_body(const char* /*name*/, int32_t /*cookie*/) {}
void atrace_int_body(const char* /*name*/, int32_t /*value*/) {}
void atrace_int64_body(const char* /*name*/, int64_t /*value*/) {}
+#if ATRACE_SHMEM
+void atrace_init() {}
+uint64_t atrace_get_enabled_tags()
+{
+ return ATRACE_TAG_NOT_READY;
+}
+#endif