Commit Graph

783796 Commits

Author SHA1 Message Date
Paul Lawrence
0ce3eb37e9 ANDROID: dm-bow: Add dm-bow feature
Based on https://www.redhat.com/archives/dm-devel/2019-March/msg00025.html

Third version of dm-bow. Key changes:

Free list added
Support for block sizes other than 4k
Handles writes during trim phase, and overlapping trims
Integer overflow error
Support trims even if underlying device doesn't
Numerous small bug fixes

bow == backup on write

USE CASE:

dm-bow takes a snapshot of an existing file system before mounting.
The user may, before removing the device, commit the snapshot.
Alternatively the user may remove the device and then run a command
line utility to restore the device to its original state.

dm-bow does not require an external device

dm-bow efficiently uses all the available free space on the file system.

IMPLEMENTATION:

dm-bow can be in one of three states.

In state one, the free blocks on the device are identified by issuing
an FSTRIM to the filesystem.

In state two, any writes cause the overwritten data to be backup up
to the available free space. While in this state, the device can be
restored by unmounting the filesystem, removing the dm-bow device
and running a usermode tool over the underlying device.

In state three, the changes are committed, dm-bow is in pass-through
mode and the drive can no longer be restored.

It is planned to use this driver to enable restoration of a failed
update attempt on Android devices using ext4.

Test: Can boot Android with userdata mounted on this device. Can commit
userdata after SUW has run. Can then reboot, make changes and roll back.

Known issues:

Mutex is held around entire flush operation, including lengthy I/O. Plan
is to convert to state machine with pending queues.

Interaction with block encryption is unknown, especially with respect
to sector 0.

Bug: 119769411
Bug: 129280212
Test: Dogfooded on Wahoo.
      Ran under Cuttlefish, running VtsKernelBowTest &
      VtsKernelCheckpointTest tests against 4.19, 4.14 & 4.9 kernels
Change-Id: Id70988bbd797ebe3e76fc175094388b423c8da8c
Signed-off-by: Paul Lawrence <paullawrence@google.com>
2019-05-03 10:44:54 -07:00
Alistair Strachan
f346147376 ANDROID: cuttlefish_defconfig: Enable CONFIG_INPUT_MOUSEDEV
Bug: 120439617
Bug: 128633328
Change-Id: I2186d8070f7885937925a25e85ce7b5722a73d57
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:44:54 -07:00
Alistair Strachan
64ca087c27 ANDROID: cuttlefish_defconfig: Enable CONFIG_PSI
Bug: 120439617
Bug: 127712811
Change-Id: Id3531e3573ccea1720047d502288f60ee151cbff
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:44:53 -07:00
Maciej Żenczykowski
59407309cd ANDROID: cuttlefish: enable CONFIG_INET_UDP_DIAG=y
This is to mirror:
  https://android-review.googlesource.com/c/kernel/configs/+/721208
  android-base.cfg: enable CONFIG_INET_UDP_DIAG

Generated via:
  echo 'CONFIG_INET_UDP_DIAG=y' >> arch/x86/configs/x86_64_cuttlefish_defconfig
  echo 'CONFIG_INET_UDP_DIAG=y' >> arch/arm64/configs/cuttlefish_defconfig
  make ARCH=x86_64 x86_64_cuttlefish_defconfig
  make ARCH=x86_64 savedefconfig
  cat defconfig > arch/x86/configs/x86_64_cuttlefish_defconfig
  make ARCH=arm64 cuttlefish_defconfig
  make ARCH=arm64 savedefconfig
  cat defconfig > arch/arm64/configs/cuttlefish_defconfig
  rm defconfig

Bug: 127981801
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5d4533b7c3b9a11e45e96b0346a70b3f93d4a812
2019-05-03 10:44:53 -07:00
Maciej Żenczykowski
f1ed05843b ANDROID: cuttlefish: enable CONFIG_USB_RTL8152=y
This is to mirror:
  https://android-review.googlesource.com/c/kernel/configs/+/920741
  Require CONFIG_USB_RTL8152 != n if we have host usb support.

Generated via:
  echo 'CONFIG_USB_RTL8152=y' >> arch/x86/configs/x86_64_cuttlefish_defconfig
  echo 'CONFIG_USB_RTL8152=y' >> arch/arm64/configs/cuttlefish_defconfig
  make ARCH=x86_64 x86_64_cuttlefish_defconfig
  make ARCH=x86_64 savedefconfig
  cat defconfig > arch/x86/configs/x86_64_cuttlefish_defconfig
  make ARCH=arm64 cuttlefish_defconfig
  make ARCH=arm64 savedefconfig
  cat defconfig > arch/arm64/configs/cuttlefish_defconfig
  rm defconfig

Bug: 110755806
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iadca2a11b76296532aa42dde999ee73f58e0bd97
2019-05-03 10:44:53 -07:00
Alistair Strachan
de14450d06 ANDROID: cuttlefish_defconfig: Add support for AC97 audio
Enable driver support for the ac97 emulation provided by QEMU and
crosvm. This is for the older 'ac97' soundhw, not 'hda'.

Bug: 120439617
Bug: 126955561
Test: local build and test of sound from cuttlefish
Change-Id: I6c29e352e0be161e2a1dc35fde50b888b7dbf86e
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:44:52 -07:00
Connor O'Brien
fcecefc007 ANDROID: cpufreq: times: optimize proc files
The majority of the time spent reading /proc/uid_time_in_state is due
to seq_printf calls. Use the faster seq_put_* variations instead.

Also skip empty hash buckets in uid_seq_next for a further performance
improvement.

Bug: 111216804
Bug: 127641090
Test: Read /proc/uid_time_in_state and confirm output is sane
Test: Compare read times to confirm performance improvement
Change-Id: If8783b498ed73d2ddb186a49438af41ac5ab9957
Signed-off-by: Connor O'Brien <connoro@google.com>
2019-05-03 10:44:52 -07:00
Connor O'Brien
0d084d72df ANDROID: cpufreq: times: record fast switch frequency transitions
cpufreq_times_record_transition() is not called when fast switch is
enabled, leading /proc/uid_time_in_state to attribute all time on a
cluster to a single frequency. To fix this, add a call to
cpufreq_times_record_transition() in the fast switch path.

Also revise cpufreq_times_record_transition() to simplify the new call
and more closely align with cpufreq_stats_record_transition().

Bug: 121287027
Bug: 127641090
Test: /proc/uid_time_in_state shows times for more than one freq per
cluster
Change-Id: Ib63d19006878fafb88475e401ef243bdd8b11979
Signed-off-by: Connor O'Brien <connoro@google.com>
2019-05-03 10:44:51 -07:00
Connor O'Brien
4242998e5b ANDROID: cpufreq: times: add /proc/uid_concurrent_{active,policy}_time
In order to model the energy used by the cpu, we need to expose cpu
time information to userspace.  We can use this information to blame
uids for the energy they are using.

This patch adds 2 files:

/proc/uid_concurrent_active_time outputs the time each uid spent
running with 1 to num_possible_cpus online and not idle.

For instance, if 4 cores are online and active for 50ms and the uid is
running on one of the cores, the uid should be blamed for 1/4 of the
base energy used by the cpu when 1 or more cores is active.

/proc/uid_concurrent_policy_time outputs the time each uid spent
running on group of cpu's with the same policy with 1 to
num_related_cpus online and not idle.

For instance, if 2 cores that are a part of the same policy are online
and active for 50ms and the uid is running on one of the cores, the
uid should be blamed for 1/2 of the energy that is used everytime one
or more cpus in the same policy is active.

This patch is based on commit c89e69136fec ("ANDROID: cpufreq:
uid_concurrent_active_time") and commit 989212536842 ("ANDROID:
cpufreq: uid_concurrent_policy_time") in the android-msm-wahoo-4.4
kernel by Marissa Wall.

Bug: 111216804
Bug: 127641090
Test: cat files on hikey960 and confirm output is reasonable
Change-Id: I1a342361af5c04ecee58d1ab667c91c1bce42445
Signed-off-by: Connor O'Brien <connoro@google.com>
2019-05-03 10:44:51 -07:00
Alistair Strachan
0deaa99578 ANDROID: cuttlefish_defconfig: Enable CONFIG_CPU_FREQ_TIMES
Bug: 118439987
Bug: 127641090
Change-Id: If2a7c773f74dd9351815daa5a935eacc40fa5b84
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:44:51 -07:00
Connor O'Brien
ce765ecd8d ANDROID: cpufreq: Add time_in_state to /proc/uid directories
Add per-uid files that report the data in binary format rather than
text, to allow faster reading & parsing by userspace.

Signed-off-by: Connor O'Brien <connoro@google.com>
Bug: 72339335
Bug: 127641090
Test: compare values to those reported in /proc/uid_time_in_state
Change-Id: I463039ea7f17b842be4c70024fe772539fe2ce02
2019-05-03 10:44:50 -07:00
Connor O'Brien
864b400f49 ANDROID: proc: Add /proc/uid directory
Add support for reporting per-uid information through procfs, roughly
following the approach used for per-tid and per-tgid directories in
fs/proc/base.c.
This also entails some new tracking of which uids have been used, to
avoid losing information when the last task with a given uid exits.

Bug: 72339335
Bug: 127641090
Test: ls /proc/uid/; compare with UIDs in /proc/uid_time_in_state
Change-Id: I0908f0c04438b11ceb673d860e58441bf503d478
Signed-off-by: Connor O'Brien <connoro@google.com>
[AmitP: Fix proc_fill_cache() now that upstream commit
        0168b9e38c ("procfs: switch instantiate_t to d_splice_alias()"),
        switched instantiate() callback to d_splice_alias()]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
[astrachan: Folded 97b7790f505e ("ANDROID: proc: fix undefined behavior
            in proc_uid_base_readdir") into this change]
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:44:50 -07:00
Connor O'Brien
c408992c71 ANDROID: cpufreq: times: track per-uid time in state
Add /proc/uid_time_in_state showing per uid/frequency/cluster
times. Allow uid removal through /proc/uid_cputime/remove_uid_range.

Signed-off-by: Connor O'Brien <connoro@google.com>
Bug: 72339335
Bug: 127641090
Test: Read /proc/uid_time_in_state
Change-Id: I20ba3546a27c25b7e7991e2a86986e158aafa58c
2019-05-03 10:44:50 -07:00
Connor O'Brien
8bea10e033 ANDROID: cpufreq: track per-task time in state
Add time in state data to task structs, and create
/proc/<pid>/time_in_state files to show how long each individual task
has run at each frequency.
Create a CONFIG_CPU_FREQ_TIMES option to enable/disable this tracking.

Bug: 72339335
Bug: 127641090
Test: Read /proc/<pid>/time_in_state
Change-Id: Ia6456754f4cb1e83b2bc35efa8fbe9f8696febc8
Signed-off-by: Connor O'Brien <connoro@google.com>
[astrachan: Folded the following changes into this patch:
            a6d3de6a7fba ("ANDROID: Reduce use of #ifdef CONFIG_CPU_FREQ_TIMES")
            b89ada5d9c09 ("ANDROID: Fix massive cpufreq_times memory leaks")]
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:44:49 -07:00
Maciej Żenczykowski
3aae57372e ANDROID: cuttlefish: enable CONFIG_NETFILTER_XT_TARGET_CT=y
This is to mirror:
  https://android-review.googlesource.com/c/kernel/configs/+/919855
  android-4.9+: add CONFIG_NETFILTER_XT_TARGET_CT=y to base config

Generated via:
  echo 'CONFIG_NETFILTER_XT_TARGET_CT=y' >> arch/x86/configs/x86_64_cuttlefish_defconfig
  echo 'CONFIG_NETFILTER_XT_TARGET_CT=y' >> arch/arm64/configs/cuttlefish_defconfig
  make ARCH=x86_64 x86_64_cuttlefish_defconfig
  make ARCH=x86_64 savedefconfig
  cat defconfig > arch/x86/configs/x86_64_cuttlefish_defconfig
  make ARCH=arm64 cuttlefish_defconfig
  make ARCH=arm64 savedefconfig
  cat defconfig > arch/arm64/configs/cuttlefish_defconfig
  rm defconfig

Bug: 124361845
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I6035ef8e75f9daada706a9233999368a22904c4e
2019-05-03 10:44:49 -07:00
Maciej Żenczykowski
c12ab9fbac ANDROID: cuttlefish: enable CONFIG_NET_SCH_NETEM=y
This is to mirror:
  https://android-review.googlesource.com/c/kernel/configs/+/906713
  android-4.9+: add CONFIG_NET_SCH_NETEM=y to recommended config

Generated via:
  echo 'CONFIG_NET_SCH_NETEM=y' >> arch/x86/configs/x86_64_cuttlefish_defconfig
  echo 'CONFIG_NET_SCH_NETEM=y' >> arch/arm64/configs/cuttlefish_defconfig
  make ARCH=x86_64 x86_64_cuttlefish_defconfig
  make ARCH=x86_64 savedefconfig
  cat defconfig > arch/x86/configs/x86_64_cuttlefish_defconfig
  make ARCH=arm64 cuttlefish_defconfig
  make ARCH=arm64 savedefconfig
  cat defconfig > arch/arm64/configs/cuttlefish_defconfig
  rm defconfig

Bug: 124467469
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If06da8f0e77d5523c56fea5d520131e456f9b529
2019-05-03 10:44:48 -07:00
Alistair Strachan
3181189328 ANDROID: Move from clang r346389b to r349610.
Bug: 123635022
Test: make ARCH=arm64 cuttlefish_defconfig && make ARCH=arm64
Test: make ARCH=x86_64 x86_64_cuttlefish_defconfig && make ARCH=x86_64
Change-Id: Icc02ea92c13435fa5a6ecd33d8878629762fd2f7
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:44:48 -07:00
Chenbo Feng
6548078271 ANDROID: Turn xt_owner module on
Once xt_qtaguid module is deprecated, the netd strictController which
uses owner match to filter egress traffic will not work because
xt_qtaguid masquerades as (and implements/extends) the "owner" module on
android devices. It can be resolved by turning upstream xt_owner module
back on since strictController only targets egress traffic and the
upstream xt_owner module works fine in this case.

Signed-off-by: Chenbo Feng <fengc@google.com>
Bug: 79938294
Test: manual cherry-pick and compile
Change-Id: Ia099db025f17f6042384c9f0caf7b941a40b8b84
2019-05-03 10:44:48 -07:00
Matthias Maennich
f9df80a9ae ANDROID: cuttlefish_defconfig: Enable CONFIG_RTC_HCTOSYS
This configuration is required for the VTS test
VtsKernelApiSysfsTest#testRtcHctosys to pass.

Bug: 123860857
Test: run vts-kernel -m VtsKernelApiSysfsTest
Signed-off-by: Matthias Maennich <maennich@google.com>
Change-Id: Icae17c74460bcd2aef4cf4e3ec5381de9ea0a66c
2019-05-03 10:44:47 -07:00
Cody Schuffelen
59c8f5da34 ANDROID: cuttlefish_defconfig: Enable vsock options
Bug: 121166534
Test: Ran cuttlefish with common kernel + vsock adb tunnel
Signed-off-by: Cody Schuffelen <schuffelen@google.com>
Change-Id: I8168a710052c7daada306a915c56230c961accd4
2019-05-03 10:44:47 -07:00
Maciej Żenczykowski
9f4318ee37 ANDROID: cuttlefish: enable CONFIG_NET_CLS_BPF=y
This is to mirror
  https://android-review.googlesource.com/c/kernel/configs/+/870517
  android-4.9+: add CONFIG_NET_CLS_BPF to base

Generated via:
  echo 'CONFIG_NET_CLS_BPF=y' >> arch/x86/configs/x86_64_cuttlefish_defconfig
  echo 'CONFIG_NET_CLS_BPF=y' >> arch/arm64/configs/cuttlefish_defconfig
  make ARCH=x86_64 x86_64_cuttlefish_defconfig
  make ARCH=x86_64 savedefconfig
  cat defconfig > arch/x86/configs/x86_64_cuttlefish_defconfig
  make ARCH=arm64 cuttlefish_defconfig
  make ARCH=arm64 savedefconfig
  cat defconfig > arch/arm64/configs/cuttlefish_defconfig

Bug: 65674744
Change-Id: I8e4dfe7a99d38fd5942001a1aab83b7ac9df30dd
Signed-off-by: Maciej Żenczykowski <maze@google.com>
2019-05-03 10:42:49 -07:00
Alistair Strachan
0d6b9aaa28 ANDROID: cuttlefish_defconfig: Enable VIRTIO_INPUT
Bug: 120439617
Change-Id: I83fdb2088f17e71f377e5864d217655b47839267
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:42:48 -07:00
Alistair Strachan
e7a97880b2 ANDROID: cuttlefish_defconfig: Enable VIRT_WIFI
Bug: 120439617
Bug: 120682817
Change-Id: Ia1b66528bd9cb1e6e95bd75ac60f393978caa582
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:42:48 -07:00
Alistair Strachan
c049e6435b ANDROID: cuttlefish_defconfig: Enable CONFIG_ARM64_LSE_ATOMICS
Enabling this was previously blocked by a lack of support for this
feature in clang, but that problem has been resolved in a newer version
of the compiler.

Bug: 120439617
Change-Id: I0f5fd2439c5a71ee0988648970576b46b2c4d20b
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:42:48 -07:00
Alistair Strachan
bcd1bb76bc ANDROID: Move from clang r328903 to r346389b.
Bug: 120439617
Bug: 120503084
Change-Id: I21bb183cac03753d1ba719a69305e2199c3f3227
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:42:47 -07:00
Alistair Strachan
769359d188 ANDROID: cuttlefish_defconfig: Enable CONFIG_CRYPTO_ADIANTUM
Bug: 118439987
Bug: 120439617
Change-Id: I0a192256b4bbf101221a3bb31c4f288581bbddc5
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:42:47 -07:00
Martijn Coenen
e00eb41c0c ANDROID: binder: add support for RT prio inheritance.
Adds support for SCHED_BATCH/SCHED_FIFO/SCHED_RR
priority inheritance.

Bug: 34461621
Bug: 37293077
Bug: 120446518
Change-Id: I71f356e476be2933713a0ecfa2cc31aa141e2dc6
Signed-off-by: Martijn Coenen <maco@google.com>
[AmitP: Include <uapi/linux/sched/types.h> for struct sched_param]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
[astrachan: Folded the following changes into this patch:
            69308b3b07dd ("ANDROID: binder: add min sched_policy to node.")
            7a6edeb62d86 ("ANDROID: binder: improve priority inheritance.")
            22b061b17679 ("ANDROID: binder: don't check prio permissions on restore.")
            67cf97141d81 ("ANDROID: binder: Add tracing for binder priority inheritance.")
            fb92c34f7ba3 ("ANDROID: binder: add RT inheritance flag to node.")
            c847b48f8cda ("ANDROID: binder: init desired_prio.sched_policy before use it")]
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:42:47 -07:00
Lorenzo Colitti
20599bae2f ANDROID: net: ipv6: autoconf routes into per-device tables
Currently, IPv6 router discovery always puts routes into
RT6_TABLE_MAIN. This causes problems for connection managers
that want to support multiple simultaneous network connections
and want control over which one is used by default (e.g., wifi
and wired).

To work around this connection managers typically take the routes
they prefer and copy them to static routes with low metrics in
the main table. This puts the burden on the connection manager
to watch netlink to see if the routes have changed, delete the
routes when their lifetime expires, etc.

Instead, this patch adds a per-interface sysctl to have the
kernel put autoconf routes into different tables. This allows
each interface to have its own autoconf table, and choosing the
default interface (or using different interfaces at the same
time for different types of traffic) can be done using
appropriate ip rules.

The sysctl behaves as follows:

- = 0: default. Put routes into RT6_TABLE_MAIN as before.
- > 0: manual. Put routes into the specified table.
- < 0: automatic. Add the absolute value of the sysctl to the
       device's ifindex, and use that table.

The automatic mode is most useful in conjunction with
net.ipv6.conf.default.accept_ra_rt_table. A connection manager
or distribution could set it to, say, -100 on boot, and
thereafter just use IP rules.

Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
[AmitP: Refactored original changes to align with
        the changes introduced by upstream commits
        830218c1ad ("net: ipv6: Fix processing of RAs in presence of VRF"),
        8d1c802b28 ("net/ipv6: Flip FIB entries to fib6_info").

        Also folded following android-4.9 commit changes into this patch
        be65fb01da ("ANDROID: net: ipv6: remove unused variable ifindex in")]
Bug: 120445791
Change-Id: I82d16e3737d9cdfa6489e649e247894d0d60cbb1
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2019-05-03 10:42:46 -07:00
Alistair Strachan
a773a88f2f ANDROID: cuttlefish_defconfig: Enable SECURITY_PERF_EVENTS_RESTRICT
Bug: 118439987
Bug: 120439617
Change-Id: Ic7dd653292a565a2d4323d68692318e8d881aaeb
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:42:46 -07:00
Jeff Vander Stoep
5dbd8df7b3 ANDROID: security,perf: Allow further restriction of perf_event_open
When kernel.perf_event_open is set to 3 (or greater), disallow all
access to performance events by users without CAP_SYS_ADMIN.
Add a Kconfig symbol CONFIG_SECURITY_PERF_EVENTS_RESTRICT that
makes this value the default.

This is based on a similar feature in grsecurity
(CONFIG_GRKERNSEC_PERF_HARDEN).  This version doesn't include making
the variable read-only.  It also allows enabling further restriction
at run-time regardless of whether the default is changed.

https://lkml.org/lkml/2016/1/11/587

Bug: 29054680
Bug: 120445712
Change-Id: Iff5bff4fc1042e85866df9faa01bce8d04335ab8
[jeffv: Upstream doesn't want it https://lkml.org/lkml/2016/6/17/101]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2019-05-03 10:42:45 -07:00
JP Abgrall
f0c2df2b12 ANDROID: netfilter: xt_IDLETIMER: Add new netlink msg type
Send notifications when the label becomes active after an idle period.
Send netlink message notifications in addition to sysfs notifications.
Using a uevent with
  subsystem=xt_idletimer
  INTERFACE=...
  STATE={active,inactive}

This is backport from common android-3.0
commit: beb914e987
with uevent support instead of a new netlink message type.

Bug: 120445672
Change-Id: I31677ef00c94b5f82c8457e5bf9e5e584c23c523
Signed-off-by: Ashish Sharma <ashishsharma@google.com>
Signed-off-by: JP Abgrall <jpa@google.com>
[astrachan: Folded the following changes into this patch:
            ee0b238fada5 ("netfilter: xt_IDLETIMER: time-stamp and suspend/resume handling.")
            728c058a495e ("netfilter: xt_IDLETIMER: Adds the uid field in the msg")
            5ebea489d44c ("netfilter: xt_IDLETIMER: Fix use after free condition during work")
            5ab69d7ba2c5 ("netfilter: xt_IDLETIMER: Use fullsock when querying uid")]
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:42:45 -07:00
Alistair Strachan
cd1677614b ANDROID: cuttlefish_defconfig: Enable CONFIG_NETFILTER_XT_MATCH_QUOTA2
Bug: 118439987
Bug: 120439617
Change-Id: I88fad3590ef2f37daedfd4fe005bd196649f2384
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:42:45 -07:00
JP Abgrall
10cda83af9 ANDROID: netfilter: xt_quota2: adding the original quota2 from xtables-addons
The original xt_quota in the kernel is plain broken:
  - counts quota at a per CPU level
    (was written back when ubiquitous SMP was just a dream)
  - provides no way to count across IPV4/IPV6.

This patch is the original unaltered code from:
  http://sourceforge.net/projects/xtables-addons

  at commit e84391ce665cef046967f796dd91026851d6bbf3

Bug: 120445421
Change-Id: I19d49858840effee9ecf6cff03c23b45a97efdeb
Signed-off-by: JP Abgrall <jpa@google.com>
[astrachan: Folded 4d33aa305871 ("netfilter: xt_quota2: fixup the quota2,
            and enable.") into this patch]
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:42:44 -07:00
Ruchi Kandoi
bc17c02a85 ANDROID: power: wakeup_reason: add an API to log wakeup reasons
Add API log_wakeup_reason() and expose it to userspace via sysfs path
/sys/kernel/wakeup_reasons/last_resume_reason

Bug: 120445600
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
[AmitP: Folded following android-4.9 commit changes into this patch
        1135122a19 ("ANDROID: POWER: fix compile warnings in log_wakeup_reason")
        b4e6247778 ("ANDROID: Power: Changes the permission to read only for sysfs file /sys/kernel/wakeup_reasons/last_resume_reason")
        e13dbc7c69 ("ANDROID: power: wakeup_reason: rename irq_count to irqcount")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
[astrachan: Folded the following changes into this patch:
            39d7c7fe91c0 ("ANDROID: power: wakeup_reason: Add guard condition for maximum wakeup reasons")
            0730434bdf49 ("ANDROID: power: wakeup_reason: Avoids bogus error messages for the suspend aborts.")
            4e42dceae54e ("ANDROID: power: wakeup_reason: Adds functionality to log the last suspend abort reason.")
            f21313b70ac7 ("ANDROID: power: wakeup_reason: Report suspend times from last_suspend_time")
            f97ec34442ac ("ANDROID: power: wakeup_reason: fix suspend time reporting")
            cd92df73e504 ("ANDROID: power: wakeup: Add last wake up source logging for suspend abort reason.")
            546b6ae3c087 ("ANDROID: power: wakeup: Add the guard condition for len in pm_get_active_wakeup_sources")
            1453d9ffcdbe ("ANDROID: power: wakeup_reason: make logging work in an interrupt context.")]
Change-Id: I81addaf420f1338255c5d0638b0d244a99d777d1
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:42:37 -07:00
Rik van Riel
92501cb670 ANDROID: add extra free kbytes tunable
Add a userspace visible knob to tell the VM to keep an extra amount
of memory free, by increasing the gap between each zone's min and
low watermarks.

This is useful for realtime applications that call system
calls and have a bound on the number of allocations that happen
in any short time period.  In this application, extra_free_kbytes
would be left at an amount equal to or larger than than the
maximum number of allocations that happen in any burst.

It may also be useful to reduce the memory use of virtual
machines (temporarily?), in a way that does not cause memory
fragmentation like ballooning does.

[ccross]
Revived for use on old kernels where no other solution exists.
The tunable will be removed on kernels that do better at avoiding
direct reclaim.

[surenb]
Will be reverted as soon as Android framework is reworked to
use upstream-supported watermark_scale_factor instead of
extra_free_kbytes.

Bug: 86445363
Bug: 109664768
Bug: 120445732
Change-Id: I765a42be8e964bfd3e2886d1ca85a29d60c3bb3e
Signed-off-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-05-03 10:40:06 -07:00
Thierry Strudel
e6120dd58d ANDROID: cpu: send KOBJ_ONLINE event when enabling cpus
In case some sysfs nodes needs to be labeled with a different label than
sysfs then user needs to be notified when a core is brought back online.

Bug: 29359497
Bug: 120444461
Change-Id: I0395c86e01cd49c348fda8f93087d26f88557c91
Signed-off-by: Thierry Strudel <tstrudel@google.com>
2019-05-03 10:40:06 -07:00
Mohan Srinivasan
f2fe7bac26 ANDROID: fs: FS tracepoints to track IO.
Adds tracepoints in ext4/f2fs/mpage to track readpages/buffered
write()s. This allows us to track files that are being read/written
to PIDs.

Bug: 120445624
Change-Id: I44476230324e9397e292328463f846af4befbd6d
[joelaf: Needed for storaged fsync accounting ("storaged --uid" and
         "storaged --task".)]
Signed-off-by: Mohan Srinivasan <srmohan@google.com>
[AmitP: Folded following android-4.9 commit changes into this patch
        a5c4dbb05a ("ANDROID: Replace spaces by '_' for some
        android filesystem tracepoints.")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
[astrachan: Folded 63066f4acf92 ("ANDROID: fs: Refactor FS
            readpage/write tracepoints.") into this patch
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:40:05 -07:00
Alistair Strachan
27579ec9a7 ANDROID: cuttlefish_defconfig: Enable CONFIG_DM_VERITY_AVB
Bug: 118439987
Bug: 120439617
Change-Id: If92a3c2f23f211ab9b73ea2b41ee339727ad1018
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:40:05 -07:00
David Zeuthen
6115619831 ANDROID: AVB error handler to invalidate vbmeta partition.
If androidboot.vbmeta.invalidate_on_error is 'yes' and
androidboot.vbmeta.device is set and points to a device with vbmeta
magic, this header will be overwritten upon an irrecoverable dm-verity
error. The side-effect of this is that the slot will fail to verify on
next reboot, effectively triggering the boot loader to fallback to
another slot. This work both if the vbmeta struct is at the start of a
partition or if there's an AVB footer at the end.

This code is based on drivers/md/dm-verity-chromeos.c from ChromiumOS.

Bug: 31622239
Bug: 120445368
Test: Manually tested (other arch).
Signed-off-by: David Zeuthen <zeuthen@google.com>
[astrachan: re-diffed against a kernel without dm-android-verity]
Change-Id: I571b5a75461da38ad832a9bea33c298bef859e26
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:40:05 -07:00
Alistair Strachan
6ea18d95da ANDROID: cuttlefish_defconfig: Enable CONFIG_CPUSETS
Bug: 118439987
Bug: 120439617
Change-Id: I2e730890db891b7c258ce21004b382556af434f5
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:40:04 -07:00
Jin Qian
ad4b32c45d ANDROID: taskstats: track fsync syscalls
This adds a counter to the taskstats extended accounting fields, which
tracks the number of times fsync is called, and then plumbs it through
to the uid_sys_stats driver.

Bug: 120442023
Change-Id: I6c138de5b2332eea70f57e098134d1d141247b3f
Signed-off-by: Jin Qian <jinqian@google.com>
[AmitP: Refactored changes to align with changes from upstream commit
        9a07000400 ("sched/headers: Move CONFIG_TASK_XACCT bits from <linux/sched.h> to <linux/sched/xacct.h>")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
[tkjos: Needed for storaged fsync accounting ("storaged --uid" and
        "storaged --task").]
[astrachan: This is modifying a userspace interface and should probably
            be reworked]
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:40:04 -07:00
Jin Qian
ecc74079f6 ANDROID: uid_cputime: add per-uid IO usage accounting
IO usages are accounted in foreground and background buckets.
For each uid, io usage is calculated in two steps.

delta = current total of all uid tasks - previus total
current bucket += delta

Bucket is determined by current uid stat. Userspace writes to
/proc/uid_procstat/set <uid> <stat> when uid stat is updated.

/proc/uid_io/stats shows IO usage in this format.
<uid> <foreground IO> <background IO>

Bug: 34198239
Bug: 120442023
Change-Id: Ib8bebda53e7a56f45ea3eb0ec9a3153d44188102
Signed-off-by: Jin Qian <jinqian@google.com>
[connoro: Used by storaged.]
[astrachan: Note: this version does not track fsync syscalls; this is
            implemented in a follow up due to the fact it depends on
            modifications to the task_xacct feature.]
[astrachan: Folded in the following changes:
            e003a91d8f42 ("ANDROID: uid_sys_stats: allow writing same state")
            89b984bf2efd ("ANDROID: uid_sys_stats: fix negative write bytes.")
            bb5ee21cc4dd ("ANDROID: uid_sys_stats: change to use rt_mutex")
            9297d5a160c7 ("ANDROID: uid_sys_stats: reduce update_io_stats overhead")
            89402d07fe91 ("ANDROID: uid_sys_stats: defer io stats calulation for dead tasks")
            6dc5d8173a8c ("ANDROID: uid_sys_stats: check previous uid_entry before call find_or_register_uid")
            0ca2ece8f7ec ("ANDROID: uid_sys_stats: log task io with a debug flag")
            c9c096ef0e67 ("ANDROID: uid_sys_stats: Copy task_struct comm field to bigger buffer")]
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:40:04 -07:00
Alistair Strachan
c6a11373c1 ANDROID: cuttlefish_defconfig: Enable CONFIG_UID_SYS_STATS
Bug: 118439987
Bug: 120439617
Change-Id: I0a62a9c17f58d79201640be311ea7280a2a040fd
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:40:04 -07:00
Jin Qian
12788836b1 ANDROID: uid_cputime: Adds accounting for the cputimes per uid.
Adds proc files /proc/uid_cputime/show_uid_stat and
/proc/uid_cputime/remove_uid_range.

show_uid_stat lists the total utime and stime for the active as well as
terminated processes for each of the uids.

Writing a range of uids to remove_uid_range will delete the accounting
for all the uids within that range.

Bug: 120442023
Change-Id: I21d9210379da730b33ddc1a0ea663c8c9d2ac15b
Signed-off-by: Jin Qian <jinqian@google.com>
[AmitP: Refactored the original patch because upstream commit
        605dc2b31a ("tsacct: Convert obsolete cputime type to nsecs")
        made cputime_t type obsolete, so use u64 nanoseconds directly instead.
        Also folded following android-4.9 changes into this patch
        48a9906c0f ("ANDROID: proc: uid_cputime: create uids from kuids")
        453ac31cab ("ANDROID: proc: uid_cputime: fix show_uid_stat permission")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
[connoro: Used by batterystats.]
[astrachan: Folded in the file/kconfig rename and the following changes:
            da3687fbc393 ("ANDROID: uid_cputime: fix cputime overflow")
            71e3eb512d00 ("ANDROID: uid_cputime: Iterates over all the threads instead of processes.")
            c65f0080c300 ("ANDROID: uid_cputime: Check for the range while removing range of UIDs.")
            c8212458e3a5 ("ANDROID: uid_sys_stats: fix access of task_uid(task)")
            bb5ee21cc4dd ("ANDROID: uid_sys_stats: change to use rt_mutex")
            6dc5d8173a8c ("ANDROID: uid_sys_stats: check previous uid_entry before call find_or_register_uid")
            82b9872b3894 ("ANDROID: uid_sys_stats: Replace tasklist lock with RCU in uid_cputime_show")]
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:40:03 -07:00
Alistair Strachan
87f26154a6 ANDROID: cuttlefish_defconfig: Enable CONFIG_MMC
Bug: 118439987
Bug: 120439617
Change-Id: I7c63e4b9462bfe6fe46c6f7d5661b48dcecdb5e8
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:40:03 -07:00
Dmitry Shmidt
7e2004a986 ANDROID: mmc: core: Add "ignore mmc pm notify" functionality
Used to prevent remounting MMC on suspend/resume.

Bug: 120441127
Change-Id: I20821a82831b07ca037973d5d92e832372c6b583
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2019-05-03 10:40:03 -07:00
Alistair Strachan
d0473fa74d ANDROID: cuttlefish_defconfig: Enable CONFIG_USB_CONFIGFS_F_AUDIO_SRC
Bug: 118439987
Bug: 120439617
Change-Id: I0efbdae061dc79eb4a006b2499c9afd82fbd62fc
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:40:02 -07:00
Mike Lockwood
1983276ceb ANDROID: usb: gadget: f_audio_source: New gadget driver for audio output
This driver presents a standard USB audio class interface to the host
and an ALSA PCM device to userspace

Bug: 78114713
Bug: 120441124
[badhri: f_audio_source is being migrated to userspace.]
Change-Id: If16b14a5ff27045f9cb2daaf1ae9195c5eeab7d0
Signed-off-by: Mike Lockwood <lockwood@google.com>
[AmitP: Folded following android-4.9 commit changes into this patch
        Parts of e275439310 ("ANDROID: usb: gadget: Fixes and hacks to make android usb gadget compile on 3.8")
        i6d9285e2574a ("ANDROID: usb: gadget: f_audio_source:replace deprecated API")]
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
[astrachan: Folded the following changes into this patch:
            ddfd0c4070c1 ("ANDROID: usb: gadget: f_audio_source: Move to USB_FUNCTION API")
            a3ab81aaa19e ("ANDROID: usb: gadget: f_audio_source: Move gadget functions code")
            2095c953d894 ("ANDROID: usb: gadget: f_audio_source: change max ISO packet size")
            8671b3e53638 ("ANDROID: usb: gadget: f_audio_source: Fixed USB Audio Class Interface Descriptor")
            af98f36edbe2 ("ANDROID: usb: gadget: f_audio_source: disable the CPU C-states upon playback")
            a830751a338e ("CHROMIUM: usb: gadget: f_audio_source: add .free_func callback")]
Signed-off-by: Alistair Strachan <astrachan@google.com>
2019-05-03 10:40:02 -07:00
Winter Wang
1f03757257 ANDROID: usb: gadget: f_midi: set fi->f to NULL when free f_midi function
fi->f is set in f_midi's alloc_func, need to clean this to
NULL in free_func, otherwise on ConfigFS's function switch,
midi->usb_function it self is freed, fi->f will be a wild
pointer and run into below kernel panic:
---------------
[   58.950628] Unable to handle kernel paging request at virtual address 63697664
[   58.957869] pgd = c0004000
[   58.960583] [63697664] *pgd=00000000
[   58.964185] Internal error: Oops: 80000005 [#1] PREEMPT SMP ARM
[   58.970111] Modules linked in:
[   58.973191] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.1.15-03504-g34c857c-dirty #89
[   58.981024] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
[   58.987557] task: c110bd70 ti: c1100000 task.ti: c1100000
[   58.992962] PC is at 0x63697664
[   58.996120] LR is at android_setup+0x78/0x138
<..snip..>
[   60.044980] 1fc0: ffffffff ffffffff c1000684 00000000 00000000 c108ecd0 c11f7294 c11039c0
[   60.053181] 1fe0: c108eccc c110d148 1000406a 412fc09a 00000000 1000807c 00000000 00000000
[   60.061420] [<c073b1fc>] (android_setup) from [<c0730490>] (udc_irq+0x758/0x1034)
[   60.068951] [<c0730490>] (udc_irq) from [<c017c650>] (handle_irq_event_percpu+0x50/0x254)
[   60.077165] [<c017c650>] (handle_irq_event_percpu) from [<c017c890>] (handle_irq_event+0x3c/0x5c)
[   60.086072] [<c017c890>] (handle_irq_event) from [<c017f3ec>] (handle_fasteoi_irq+0xe0/0x198)
[   60.094630] [<c017f3ec>] (handle_fasteoi_irq) from [<c017bcfc>] (generic_handle_irq+0x2c/0x3c)
[   60.103271] [<c017bcfc>] (generic_handle_irq) from [<c017bfb8>] (__handle_domain_irq+0x7c/0xec)
[   60.112000] [<c017bfb8>] (__handle_domain_irq) from [<c0101450>] (gic_handle_irq+0x24/0x5c)
--------------

Bug: 111003288
Bug: 120441124
Change-Id: Iaf7cc809379c184048a2d9ab1f59e71ebaa3416e
Signed-off-by: Winter Wang <wente.wang@nxp.com>
2019-05-03 10:40:02 -07:00
Badhri Jagan Sridharan
14948a5ac3 ANDROID: usb: gadget: f_midi: create F_midi device
Android frameworks relies on the alsa
config reported by the f_midi device.

Bug: 111003288
Bug: 120441124
Change-Id: I0695e00b166fd953f50acea93802245b0d5a5240
[badhri: The framework should be moved away from this]
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
2019-05-03 10:40:01 -07:00