summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-prod (mdb) <android-build-team-robot@google.com>2020-05-27 21:06:08 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-05-27 21:06:08 +0000
commitb0991eb0dcba10a87adb7426905c667dad76e116 (patch)
tree0a771f7b19ea60fe9869f702fd1be8b63867fc87
parent12f716a5719f8daa22c660227116a87b8d368d85 (diff)
parent8894685137c1185d76cdaf91daae11bd1df22ca1 (diff)
downloadextras-b0991eb0dcba10a87adb7426905c667dad76e116.tar.gz
Merge "Snap for 6533464 from 8279e6342e4a79b6579129f1ab05dddd27688c94 to sdk-release" into sdk-releaseplatform-tools-30.0.3platform-tools-30.0.2
-rw-r--r--METADATA3
-rw-r--r--libfscrypt/fscrypt.cpp17
-rw-r--r--libfscrypt/include/fscrypt/fscrypt.h6
-rw-r--r--libfscrypt/tests/fscrypt_test.cpp12
-rw-r--r--simpleperf/doc/android_platform_profiling.md45
-rwxr-xr-xsimpleperf/scripts/bin/android/arm/simpleperfbin2559164 -> 2534088 bytes
-rwxr-xr-xsimpleperf/scripts/bin/android/arm64/simpleperfbin3509208 -> 3494080 bytes
-rwxr-xr-xsimpleperf/scripts/bin/android/x86/simpleperfbin4244608 -> 4279924 bytes
-rwxr-xr-xsimpleperf/scripts/bin/android/x86_64/simpleperfbin4160264 -> 4178560 bytes
-rwxr-xr-xsimpleperf/scripts/bin/darwin/x86_64/libsimpleperf_report.dylibbin6271552 -> 5982028 bytes
-rwxr-xr-xsimpleperf/scripts/bin/darwin/x86_64/simpleperfbin7772852 -> 7618908 bytes
-rwxr-xr-xsimpleperf/scripts/bin/linux/x86_64/libsimpleperf_report.sobin4982240 -> 6579960 bytes
-rwxr-xr-xsimpleperf/scripts/bin/linux/x86_64/simpleperfbin6228000 -> 6559416 bytes
-rwxr-xr-xsimpleperf/scripts/bin/windows/x86/libsimpleperf_report.dllbin3947520 -> 4043776 bytes
-rwxr-xr-xsimpleperf/scripts/bin/windows/x86/libwinpthread-1.dllbin231082 -> 231594 bytes
-rwxr-xr-xsimpleperf/scripts/bin/windows/x86/simpleperf.exebin3883008 -> 4102656 bytes
-rwxr-xr-xsimpleperf/scripts/bin/windows/x86_64/libsimpleperf_report.dllbin4187648 -> 4375040 bytes
-rwxr-xr-xsimpleperf/scripts/bin/windows/x86_64/libwinpthread-1.dllbin570473 -> 572009 bytes
-rwxr-xr-xsimpleperf/scripts/bin/windows/x86_64/simpleperf.exebin4193280 -> 4518400 bytes
19 files changed, 83 insertions, 0 deletions
diff --git a/METADATA b/METADATA
new file mode 100644
index 00000000..d97975ca
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,3 @@
+third_party {
+ license_type: NOTICE
+}
diff --git a/libfscrypt/fscrypt.cpp b/libfscrypt/fscrypt.cpp
index 622b4cdb..a52ed90c 100644
--- a/libfscrypt/fscrypt.cpp
+++ b/libfscrypt/fscrypt.cpp
@@ -153,6 +153,9 @@ bool OptionsToStringForApiLevel(unsigned int first_api_level, const EncryptionOp
if ((options.flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64)) {
*options_string += "+inlinecrypt_optimized";
}
+ if ((options.flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32)) {
+ *options_string += "+emmc_optimized";
+ }
if (options.use_hw_wrapped_key) {
*options_string += "+wrappedkey_v0";
}
@@ -214,6 +217,8 @@ bool ParseOptionsForApiLevel(unsigned int first_api_level, const std::string& op
options->version = 2;
} else if (flag == "inlinecrypt_optimized") {
options->flags |= FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64;
+ } else if (flag == "emmc_optimized") {
+ options->flags |= FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32;
} else if (flag == "wrappedkey_v0") {
options->use_hw_wrapped_key = true;
} else {
@@ -248,6 +253,18 @@ bool ParseOptionsForApiLevel(unsigned int first_api_level, const std::string& op
LOG(ERROR) << "Adiantum must be both contents and filenames mode or neither, invalid options: " << options_string;
return false;
}
+
+ // IV generation methods are mutually exclusive
+ int iv_methods = 0;
+ iv_methods += !!(options->flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64);
+ iv_methods += !!(options->flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32);
+ iv_methods += !!(options->flags & FSCRYPT_POLICY_FLAG_DIRECT_KEY);
+ if (iv_methods > 1) {
+ LOG(ERROR) << "At most one IV generation method can be set, invalid options: "
+ << options_string;
+ return false;
+ }
+
return true;
}
diff --git a/libfscrypt/include/fscrypt/fscrypt.h b/libfscrypt/include/fscrypt/fscrypt.h
index 78b12560..b1ba1dfe 100644
--- a/libfscrypt/include/fscrypt/fscrypt.h
+++ b/libfscrypt/include/fscrypt/fscrypt.h
@@ -19,6 +19,12 @@
#include <string>
+#ifndef FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32
+// When FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32 is added to Bionic's linux/fscrypt.h
+// then this whole stanza should be removed.
+#define FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32 0x10
+#endif
+
bool fscrypt_is_native();
static const char* fscrypt_unencrypted_folder = "/unencrypted";
diff --git a/libfscrypt/tests/fscrypt_test.cpp b/libfscrypt/tests/fscrypt_test.cpp
index 457ac684..4fbd742c 100644
--- a/libfscrypt/tests/fscrypt_test.cpp
+++ b/libfscrypt/tests/fscrypt_test.cpp
@@ -156,6 +156,18 @@ TEST(fscrypt, ParseOptions) {
EXPECT_EQ(FSCRYPT_POLICY_FLAGS_PAD_16 | FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64, options.flags);
}
+ {
+ TEST_STRING(30, "::emmc_optimized", "aes-256-xts:aes-256-cts:v2+emmc_optimized");
+ EXPECT_EQ(2, options.version);
+ EXPECT_EQ(FSCRYPT_MODE_AES_256_XTS, options.contents_mode);
+ EXPECT_EQ(FSCRYPT_MODE_AES_256_CTS, options.filenames_mode);
+ EXPECT_EQ(FSCRYPT_POLICY_FLAGS_PAD_16 | FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32, options.flags);
+ }
+ EXPECT_FALSE(
+ ParseOptionsForApiLevel(30, "::inlinecrypt_optimized+emmc_optimized", &dummy_options));
+ EXPECT_FALSE(ParseOptionsForApiLevel(30, "adiantum::inlinecrypt_optimized", &dummy_options));
+ EXPECT_FALSE(ParseOptionsForApiLevel(30, "adiantum::emmc_optimized", &dummy_options));
+
EXPECT_FALSE(ParseOptionsForApiLevel(29, "aes-256-xts:aes-256-cts:v2:", &dummy_options));
EXPECT_FALSE(ParseOptionsForApiLevel(29, "aes-256-xts:aes-256-cts:v2:foo", &dummy_options));
EXPECT_FALSE(ParseOptionsForApiLevel(29, "aes-256-xts:aes-256-cts:blah", &dummy_options));
diff --git a/simpleperf/doc/android_platform_profiling.md b/simpleperf/doc/android_platform_profiling.md
index afa1927b..797d640a 100644
--- a/simpleperf/doc/android_platform_profiling.md
+++ b/simpleperf/doc/android_platform_profiling.md
@@ -1,5 +1,14 @@
# Android platform profiling
+## Table of Contents
+- [Android platform profiling](#android-platform-profiling)
+ - [Table of Contents](#table-of-contents)
+ - [General Tips](#general-tips)
+ - [Start simpleperf from system_server process](#start-simpleperf-from-systemserver-process)
+ - [Hardware PMU counter limit](#hardware-pmu-counter-limit)
+
+## General Tips
+
Here are some tips for Android platform developers, who build and flash system images on rooted
devices:
1. After running `adb root`, simpleperf can be used to profile any process or system wide.
@@ -34,3 +43,39 @@ $ python binary_cache_builder.py -lib $ANDROID_PRODUCT_OUT/symbols
$ python report_html.py --add_source_code --source_dirs $ANDROID_BUILD_TOP --add_disassembly \
--binary_filter surfaceflinger.so
```
+
+## Start simpleperf from system_server process
+
+Sometimes we want to profile a process/system-wide when a special situation happens. In this case,
+we can add code starting simpleperf at the point where the situation is detected.
+
+1. Disable selinux by `adb shell setenforce 0`. Because selinux only allows simpleperf running
+ in shell or debuggable/profileable apps.
+
+2. Add below code at the point where the special situation is detected.
+
+```java
+try {
+ // for capability check
+ Os.prctl(OsConstants.PR_CAP_AMBIENT, OsConstants.PR_CAP_AMBIENT_RAISE,
+ OsConstants.CAP_SYS_PTRACE, 0, 0);
+ // Write to /data instead of /data/local/tmp. Because /data can be written by system user.
+ Runtime.getRuntime().exec("/system/bin/simpleperf record -g -p " + String.valueOf(Process.myPid())
+ + " -o /data/perf.data --duration 30 --log-to-android-buffer --log verbose");
+} catch (Exception e) {
+ Slog.e(TAG, "error while running simpleperf");
+ e.printStackTrace();
+}
+```
+
+## Hardware PMU counter limit
+
+When monitoring instruction and cache related perf events (in hw/cache/raw/pmu category of list cmd),
+these events are mapped to PMU counters on each cpu core. But each core only has a limited number
+of PMU counters. If number of events > number of PMU counters, then the counters are multiplexed
+among events, which probably isn't what we want.
+
+On Pixel devices, the number of PMU counters on each core is usually 7, of which 4 of them are used
+by the kernel to monitor memory latency. So only 3 counters are available. It's fine to monitor up
+to 3 PMU events at the same time. To monitor more than 3 events, the `--use-devfreq-counters` option
+can be used to borrow from the counters used by the kernel.
diff --git a/simpleperf/scripts/bin/android/arm/simpleperf b/simpleperf/scripts/bin/android/arm/simpleperf
index 9a29c7f8..7379680d 100755
--- a/simpleperf/scripts/bin/android/arm/simpleperf
+++ b/simpleperf/scripts/bin/android/arm/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/android/arm64/simpleperf b/simpleperf/scripts/bin/android/arm64/simpleperf
index cbc1da5c..d4c58a17 100755
--- a/simpleperf/scripts/bin/android/arm64/simpleperf
+++ b/simpleperf/scripts/bin/android/arm64/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/android/x86/simpleperf b/simpleperf/scripts/bin/android/x86/simpleperf
index a6119599..ddbf3954 100755
--- a/simpleperf/scripts/bin/android/x86/simpleperf
+++ b/simpleperf/scripts/bin/android/x86/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/android/x86_64/simpleperf b/simpleperf/scripts/bin/android/x86_64/simpleperf
index 0470a5d5..af95c1a2 100755
--- a/simpleperf/scripts/bin/android/x86_64/simpleperf
+++ b/simpleperf/scripts/bin/android/x86_64/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/darwin/x86_64/libsimpleperf_report.dylib b/simpleperf/scripts/bin/darwin/x86_64/libsimpleperf_report.dylib
index cbe96228..2dfef2fd 100755
--- a/simpleperf/scripts/bin/darwin/x86_64/libsimpleperf_report.dylib
+++ b/simpleperf/scripts/bin/darwin/x86_64/libsimpleperf_report.dylib
Binary files differ
diff --git a/simpleperf/scripts/bin/darwin/x86_64/simpleperf b/simpleperf/scripts/bin/darwin/x86_64/simpleperf
index b056f29d..0dbdbb09 100755
--- a/simpleperf/scripts/bin/darwin/x86_64/simpleperf
+++ b/simpleperf/scripts/bin/darwin/x86_64/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/linux/x86_64/libsimpleperf_report.so b/simpleperf/scripts/bin/linux/x86_64/libsimpleperf_report.so
index 480d2890..5f2c5ba5 100755
--- a/simpleperf/scripts/bin/linux/x86_64/libsimpleperf_report.so
+++ b/simpleperf/scripts/bin/linux/x86_64/libsimpleperf_report.so
Binary files differ
diff --git a/simpleperf/scripts/bin/linux/x86_64/simpleperf b/simpleperf/scripts/bin/linux/x86_64/simpleperf
index 372d42e2..e9606ff6 100755
--- a/simpleperf/scripts/bin/linux/x86_64/simpleperf
+++ b/simpleperf/scripts/bin/linux/x86_64/simpleperf
Binary files differ
diff --git a/simpleperf/scripts/bin/windows/x86/libsimpleperf_report.dll b/simpleperf/scripts/bin/windows/x86/libsimpleperf_report.dll
index 33326d3e..330cad54 100755
--- a/simpleperf/scripts/bin/windows/x86/libsimpleperf_report.dll
+++ b/simpleperf/scripts/bin/windows/x86/libsimpleperf_report.dll
Binary files differ
diff --git a/simpleperf/scripts/bin/windows/x86/libwinpthread-1.dll b/simpleperf/scripts/bin/windows/x86/libwinpthread-1.dll
index a41127ab..202ec47b 100755
--- a/simpleperf/scripts/bin/windows/x86/libwinpthread-1.dll
+++ b/simpleperf/scripts/bin/windows/x86/libwinpthread-1.dll
Binary files differ
diff --git a/simpleperf/scripts/bin/windows/x86/simpleperf.exe b/simpleperf/scripts/bin/windows/x86/simpleperf.exe
index daee828f..9b263111 100755
--- a/simpleperf/scripts/bin/windows/x86/simpleperf.exe
+++ b/simpleperf/scripts/bin/windows/x86/simpleperf.exe
Binary files differ
diff --git a/simpleperf/scripts/bin/windows/x86_64/libsimpleperf_report.dll b/simpleperf/scripts/bin/windows/x86_64/libsimpleperf_report.dll
index 176e8b6a..cc0d878e 100755
--- a/simpleperf/scripts/bin/windows/x86_64/libsimpleperf_report.dll
+++ b/simpleperf/scripts/bin/windows/x86_64/libsimpleperf_report.dll
Binary files differ
diff --git a/simpleperf/scripts/bin/windows/x86_64/libwinpthread-1.dll b/simpleperf/scripts/bin/windows/x86_64/libwinpthread-1.dll
index 5a12ce3c..971ffb14 100755
--- a/simpleperf/scripts/bin/windows/x86_64/libwinpthread-1.dll
+++ b/simpleperf/scripts/bin/windows/x86_64/libwinpthread-1.dll
Binary files differ
diff --git a/simpleperf/scripts/bin/windows/x86_64/simpleperf.exe b/simpleperf/scripts/bin/windows/x86_64/simpleperf.exe
index 89dbc9b0..2176054f 100755
--- a/simpleperf/scripts/bin/windows/x86_64/simpleperf.exe
+++ b/simpleperf/scripts/bin/windows/x86_64/simpleperf.exe
Binary files differ