Commit Graph

976784 Commits

Author SHA1 Message Date
Geert Uytterhoeven
d3f36ae0bb UPSTREAM: ARM: 9035/1: uncompress: Add be32tocpu macro
DTB stores all values as 32-bit big-endian integers.
Add a macro to convert such values to native CPU endianness, to reduce
duplication.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>

(cherry picked from commit 0557ac83fd)
Bug: 178411248
Change-Id: I0807f36352dbfd5f5808959e358a7469dc9753bb
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-04-29 07:12:11 +00:00
Marco Elver
f72dbeced2 FROMGIT: kfence: use power-efficient work queue to run delayed work
Use the power-efficient work queue, to avoid the pathological case where
we keep pinning ourselves on the same possibly idle CPU on systems that
want to be power-efficient (https://lwn.net/Articles/731052/).

Link: https://lkml.kernel.org/r/20210421105132.3965998-4-elver@google.com
Signed-off-by: Marco Elver <elver@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Jann Horn <jannh@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>

Bug: 172317151
Bug: 185280916
Test: power team confirmed there's no regression
(cherry picked from commit e5bcc059aa2321383325e98628d65258bdcb306f
 https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git akpm)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: I53a2869987cdac165840e3878ff73735a03438fa
2021-04-29 08:13:58 +02:00
Marco Elver
f696af3d11 FROMGIT: kfence: maximize allocation wait timeout duration
The allocation wait timeout was initially added because of warnings due to
CONFIG_DETECT_HUNG_TASK=y [1].  While the 1 sec timeout is sufficient to
resolve the warnings (given the hung task timeout must be 1 sec or larger)
it may cause unnecessary wake-ups if the system is idle.  [1]
https://lkml.kernel.org/r/CADYN=9J0DQhizAGB0-jz4HOBBh+05kMBXb4c0cXMS7Qi5NAJiw@mail.gmail.com

Fix it by computing the timeout duration in terms of the current
sysctl_hung_task_timeout_secs value.

Link: https://lkml.kernel.org/r/20210421105132.3965998-3-elver@google.com
Signed-off-by: Marco Elver <elver@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Jann Horn <jannh@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>

Bug: 172317151
Bug: 185280916
Test: power team confirmed there's no regression
(cherry picked from commit 5d744ff5acbb40f3b8f1703cb433432889f88fbd
 https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git akpm)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: I1a8da1844aaded4827bda904ca621a27bbead4bc
2021-04-29 08:13:58 +02:00
Marco Elver
b9bb7f3153 FROMGIT: kfence: await for allocation using wait_event
Patch series "kfence: optimize timer scheduling", v2.

We have observed that mostly-idle systems with KFENCE enabled wake up
otherwise idle CPUs, preventing such to enter a lower power state.
Debugging revealed that KFENCE spends too much active time in
toggle_allocation_gate().

While the first version of KFENCE was using all the right bits to be
scheduling optimal, and thus power efficient, by simply using wait_event()
+ wake_up(), that code was unfortunately removed.

As KFENCE was exposed to various different configs and tests, the
scheduling optimal code slowly disappeared.  First because of hung task
warnings, and finally because of deadlocks when an allocation is made by
timer code with debug objects enabled.  Clearly, the "fixes" were not too
friendly for devices that want to be power efficient.

Therefore, let's try a little harder to fix the hung task and deadlock
problems that we have with wait_event() + wake_up(), while remaining as
scheduling friendly and power efficient as possible.

Crucially, we need to defer the wake_up() to an irq_work, avoiding any
potential for deadlock.

The result with this series is that on the devices where we observed a
power regression, power usage returns back to baseline levels.

This patch (of 3):

On mostly-idle systems, we have observed that toggle_allocation_gate() is
a cause of frequent wake-ups, preventing an otherwise idle CPU to go into
a lower power state.

A late change in KFENCE's development, due to a potential deadlock [1],
required changing the scheduling-friendly wait_event_timeout() and
wake_up() to an open-coded wait-loop using schedule_timeout().  [1]
https://lkml.kernel.org/r/000000000000c0645805b7f982e4@google.com

To avoid unnecessary wake-ups, switch to using wait_event_timeout().

Unfortunately, we still cannot use a version with direct wake_up() in
__kfence_alloc() due to the same potential for deadlock as in [1].
Instead, add a level of indirection via an irq_work that is scheduled if
we determine that the kfence_timer requires a wake_up().

Link: https://lkml.kernel.org/r/20210421105132.3965998-1-elver@google.com
Link: https://lkml.kernel.org/r/20210421105132.3965998-2-elver@google.com
Fixes: 0ce20dd840 ("mm: add Kernel Electric-Fence infrastructure")
Signed-off-by: Marco Elver <elver@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Jann Horn <jannh@google.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Hillf Danton <hdanton@sina.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>

Bug: 172317151
Bug: 185280916
Test: power team confirmed there's no regression
(cherry picked from commit 0ac66fbbadde5547db190e9d87ff2e77d245f9a2
 https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git akpm)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: Idba39683f0b76eb3f70df1113e43d94845fab5bf
2021-04-29 08:13:58 +02:00
Marco Elver
cb42770670 FROMGIT: kfence: zero guard page after out-of-bounds access
After an out-of-bounds accesses, zero the guard page before re-protecting
in kfence_guarded_free().  On one hand this helps make the failure mode of
subsequent out-of-bounds accesses more deterministic, but could also
prevent certain information leaks.

Link: https://lkml.kernel.org/r/20210312121653.348518-1-elver@google.com
Signed-off-by: Marco Elver <elver@google.com>
Acked-by: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Jann Horn <jannh@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>

Bug: 172317151
Test: build and run on an ARM64 device
(cherry picked from commit 35eaef74e16dcc85b0659db1c7b4a8d83f7a34ef
 https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git akpm)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: I2bad112b6cbf457892b1dd1a90b909cd88eee2c6
2021-04-29 08:13:58 +02:00
Marco Elver
372e663644 UPSTREAM: kfence: make compatible with kmemleak
Because memblock allocations are registered with kmemleak, the KFENCE
pool was seen by kmemleak as one large object.  Later allocations
through kfence_alloc() that were registered with kmemleak via
slab_post_alloc_hook() would then overlap and trigger a warning.
Therefore, once the pool is initialized, we can remove (free) it from
kmemleak again, since it should be treated as allocator-internal and be
seen as "free memory".

The second problem is that kmemleak is passed the rounded size, and not
the originally requested size, which is also the size of KFENCE objects.
To avoid kmemleak scanning past the end of an object and trigger a
KFENCE out-of-bounds error, fix the size if it is a KFENCE object.

For simplicity, to avoid a call to kfence_ksize() in
slab_post_alloc_hook() (and avoid new IS_ENABLED(CONFIG_DEBUG_KMEMLEAK)
guard), just call kfence_ksize() in mm/kmemleak.c:create_object().

Link: https://lkml.kernel.org/r/20210317084740.3099921-1-elver@google.com
Signed-off-by: Marco Elver <elver@google.com>
Reported-by: Luis Henriques <lhenriques@suse.de>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Tested-by: Luis Henriques <lhenriques@suse.de>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Jann Horn <jannh@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Bug: 172317151
Test: build and run on an ARM64 device
(cherry picked from commit 9551158069)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: Ida4d747d3b81b5e8a6f1047b864da89e8e110e61
2021-04-29 08:13:57 +02:00
Marco Elver
fba94942cc UPSTREAM: kfence: fix reports if constant function prefixes exist
Some architectures prefix all functions with a constant string ('.' on
ppc64).  Add ARCH_FUNC_PREFIX, which may optionally be defined in
<asm/kfence.h>, so that get_stack_skipnr() can work properly.

Link: https://lkml.kernel.org/r/f036c53d-7e81-763c-47f4-6024c6c5f058@csgroup.eu
Link: https://lkml.kernel.org/r/20210304144000.1148590-1-elver@google.com
Signed-off-by: Marco Elver <elver@google.com>
Reported-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Tested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Alexander Potapenko <glider@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Jann Horn <jannh@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Bug: 172317151
Test: build and run on an ARM64 device
(cherry picked from commit 0aa41cae92)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: Iad99dd75be77c26359723d1336e2d1b25beb5a26
2021-04-29 08:13:57 +02:00
Marco Elver
0dedbe7401 UPSTREAM: kfence: fix printk format for ptrdiff_t
Use %td for ptrdiff_t.

Link: https://lkml.kernel.org/r/3abbe4c9-16ad-c168-a90f-087978ccd8f7@csgroup.eu
Link: https://lkml.kernel.org/r/20210303121157.3430807-1-elver@google.com
Signed-off-by: Marco Elver <elver@google.com>
Reported-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Alexander Potapenko <glider@google.com>
Cc: Dmitriy Vyukov <dvyukov@google.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Jann Horn <jannh@google.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Bug: 172317151
Test: build and run on an ARM64 device
(cherry picked from commit 702b16d724)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: I49c7a8ed6dfecceafd4e25e979c6dd58b1d2dbe2
2021-04-29 08:13:57 +02:00
Will McVicker
7919cae0a9 ANDROID: Support disabling symbol trimming
Allow disabling symbol trimming on the command line when running
build.sh. This allows us to make GKI builds without trimming and without
modifying the build config. The main use case is when we want to update
the symbol list in a mixed build system.

Bug: 186549137
Signed-off-by: Will McVicker <willmcvicker@google.com>
Change-Id: I16d1c348270b4dbb378f009857286acd7b6d8aa3
2021-04-28 23:52:33 +00:00
Paul Lawrence
327b2266d2 ANDROID: Incremental fs: Fix pseudo-file attributes
Prior change

ANDROID: Incremental fs: stat should return actual used blocks

adds blocks to getattr. Unfortunately the code always looks for the
backing file, and pseudo files don't have backing files, so getattr
fails for pseudo files.

Bug: 186567511
Test: incfs_test passes, can do incremental installs on test device
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ia3df87f3683e095d05c822b69747515963c95f1c
(cherry picked from commit 9d00e67d8b)
2021-04-28 22:07:07 +00:00
Stephen Dickey
a64f42d1df ANDROID: sched: Fix missing RQCF_UPDATED in migrate_tasks
Currently, the sched code checks if the rq clock has been
updated after its lock has been held when CONFIG_SCHED_DEBUG
is enabled. It tracks this by clearing the RQCF_UPDATED bit
when a lock is acquired and setting it upon a subsequent
update_rq_clock() call. It warns if rq clock is read without
RQCF_UPDATED flag indicating the code path missed updating
the clock.

When migrate_tasks() is called during a pause_cpus() event,
the local variable orf is updated with the contents of *rf,
prior to the call to update_rq_clock(). As a result, when
migrate_tasks() restores *rf from the local variable the
RQCF_UPDATED flag is lost. This clearing out of the
RQCF_UPDATED flag leads to a warning when the next task
is being pushed out.

For example in migrate_tasks()

   orf = rf; // save flags, RQCF_UPDATE cleared
   update_rq_clock() // set RQCF_UPDATE
   for()
      ...
      __migrate_task(dead_rq, new_cpu)
      ...
      --> if migration, restore dead_rq's flags with orf.
         --> We loose RQCF_UPDATE
	 rq_relock(dead_rq, orf)

This leaves the current cpu's rq clock_update_flags with the
RQCF_UPDATED flag cleared, an error condition with
CONFIG_SCHED_DEBUG enabled.

Fix the issue for by ensuring that the local variable orf
has the RQCF_UPDATED flag set, allowing the current
CPU's rq to have the flag set and leaving it in a good state
for future usage.

pause_cpus() is currently Android specific. As cpu_pause does
not rely on stop_machine_cpuslocked() like the regular
hotunplug path does, there's a risk for another CPU to
read the rq_clock, after we cleared RQCF_UPDATE, when using
pause_cpus(). This change will have little or no impact outside
of Android currently. If pause_cpus() or drain_rq_cpu_stop()
are merged upstream this change should be merged as well.

Bug: 186222712
Change-Id: Id241122e1449cdd4dcd15f94eb68735b40e3d6f5
Signed-off-by: Stephen Dickey <dickey@codeaurora.org>
2021-04-28 21:28:55 +00:00
Collin Fijalkovich
28b4b1588e FROMLIST: mm, thp: Relax the VM_DENYWRITE constraint on file-backed THPs
Transparent huge pages are supported for read-only non-shmem files,
but are only used for vmas with VM_DENYWRITE. This condition ensures that
file THPs are protected from writes while an application is running
(ETXTBSY).  Any existing file THPs are then dropped from the page cache
when a file is opened for write in do_dentry_open(). Since sys_mmap
ignores MAP_DENYWRITE, this constrains the use of file THPs to vmas
produced by execve().

Systems that make heavy use of shared libraries (e.g. Android) are unable
to apply VM_DENYWRITE through the dynamic linker, preventing them from
benefiting from the resultant reduced contention on the TLB.

This patch reduces the constraint on file THPs allowing use with any
executable mapping from a file not opened for write (see
inode_is_open_for_write()). It also introduces additional conditions to
ensure that files opened for write will never be backed by file THPs.

Restricting the use of THPs to executable mappings eliminates the risk that
a read-only file later opened for write would encounter significant
latencies due to page cache truncation.

The ld linker flag '-z max-page-size=(hugepage size)' can be used to
produce executables with the necessary layout. The dynamic linker must
map these file's segments at a hugepage size aligned vma for the mapping to
be backed with THPs.

Comparison of the performance characteristics of 4KB and 2MB-backed
libraries follows; the Android dex2oat tool was used to AOT compile an
example application on a single ARM core.

4KB Pages:
==========

count              event_name            # count / runtime
598,995,035,942    cpu-cycles            # 1.800861 GHz
 81,195,620,851    raw-stall-frontend    # 244.112 M/sec
347,754,466,597    iTLB-loads            # 1.046 G/sec
  2,970,248,900    iTLB-load-misses      # 0.854122% miss rate

Total test time: 332.854998 seconds.

2MB Pages:
==========

count              event_name            # count / runtime
592,872,663,047    cpu-cycles            # 1.800358 GHz
 76,485,624,143    raw-stall-frontend    # 232.261 M/sec
350,478,413,710    iTLB-loads            # 1.064 G/sec
    803,233,322    iTLB-load-misses      # 0.229182% miss rate

Total test time: 329.826087 seconds

A check of /proc/$(pidof dex2oat64)/smaps shows THPs in use:

/apex/com.android.art/lib64/libart.so
FilePmdMapped:      4096 kB

/apex/com.android.art/lib64/libart-compiler.so
FilePmdMapped:      2048 kB

Bug: 158135888
Link: https://lore.kernel.org/patchwork/patch/1408266/

Reviewed-by: William Kucharski <william.kucharski@oracle.com>
Acked-by: Hugh Dickins <hughd@google.com>
Acked-by: Song Liu <song@kernel.org>
Signed-off-by: Collin Fijalkovich <cfijalkovich@google.com>
Change-Id: I75c693a4b4e7526d374ef2c010bde3094233eef2
2021-04-28 18:41:35 +00:00
Saravana Kannan
c2c576792a ANDROID: GKI: Update the generic symbol list
Add a few more symbols.

Bug: 182844240
Signed-off-by: Saravana Kannan <saravanak@google.com>
Change-Id: Ide0ca453ff7819b17264adac6af2df574f8dbced
2021-04-27 21:51:14 -07:00
Elliot Berman
edc5c62da7 ANDROID: ABI: Add symbols for crypto
Add symbols for crypto engine.

Leaf changes summary: 19 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 19 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

19 Added functions:

  [A] 'function int crypto_ahash_digest(ahash_request*)'
  [A] 'function int crypto_ahash_setkey(crypto_ahash*, const u8*, unsigned int)'
  [A] 'function crypto_ahash* crypto_alloc_ahash(const char*, u32, u32)'
  [A] 'function crypto_sync_skcipher* crypto_alloc_sync_skcipher(const char*, u32, u32)'
  [A] 'function crypto_async_request* crypto_dequeue_request(crypto_queue*)'
  [A] 'function int crypto_enqueue_request(crypto_queue*, crypto_async_request*)'
  [A] 'function void crypto_init_queue(crypto_queue*, unsigned int)'
  [A] 'function int crypto_register_aead(aead_alg*)'
  [A] 'function int crypto_register_ahash(ahash_alg*)'
  [A] 'function int crypto_register_algs(crypto_alg*, int)'
  [A] 'function int crypto_register_skcipher(skcipher_alg*)'
  [A] 'function void crypto_unregister_aead(aead_alg*)'
  [A] 'function void crypto_unregister_ahash(ahash_alg*)'
  [A] 'function void crypto_unregister_algs(crypto_alg*, int)'
  [A] 'function void crypto_unregister_skcipher(skcipher_alg*)'
  [A] 'function scatterlist* scatterwalk_ffwd(scatterlist*, scatterlist*, unsigned int)'
  [A] 'function void scatterwalk_map_and_copy(void*, scatterlist*, unsigned int, unsigned int, int)'
  [A] 'function size_t sg_copy_from_buffer(scatterlist*, unsigned int, void*, size_t)'
  [A] 'function size_t sg_copy_to_buffer(scatterlist*, unsigned int, void*, size_t)'

Bug: 185467822
Change-Id: I6d7bf85324852f69c6d5d113ce38e23663523004
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
2021-04-27 15:15:07 -07:00
J. Avila
5a641fb83f ANDROID: ABI: Update the ABI XML
KMI_GENERATION bumped to 3.

Leaf changes summary: 3152 artifacts changed
Changed leaf types summary: 3 leaf types changed
Removed/Changed/Added functions summary: 0 Removed, 3094 Changed, 0 Added function
Removed/Changed/Added variables summary: 0 Removed, 55 Changed, 0 Added variable

Bug: 186415778
Signed-off-by: J. Avila <elavila@google.com>
Change-Id: Ib1b13031e83e293fb761bdd335e5450ae8df3445
2021-04-27 21:08:03 +00:00
J. Avila
39111fc404 Revert "ANDROID: GKI: Change UCLAMP_BUCKETS_COUNT to 20"
This reverts commit 327402e1e9.

Reason for revert: This patch causes us to hit the SCHED_WARN_ON in
uclamp_rq_dec_id. Revert until this is fixed appropriately.

Bug: 186415778
Change-Id: I5be50723b4058008ed24daa7ca303792ba81b567
Signed-off-by: J. Avila <elavila@google.com>
2021-04-27 21:08:02 +00:00
xieliujie
2337b9185a ANDROID: vendor_hooks: Add hook for binder
Add hook to support oem's performance feature.

Bug: 186482511

Signed-off-by: xieliujie <xieliujie@oppo.com>
Change-Id: Ib495e80e569cc293eaa98d87a050aee8915eb415
2021-04-27 19:18:56 +00:00
Eric Biggers
cf881c74d3 UPSTREAM: crypto: arm/blake2s - fix for big endian
The new ARM BLAKE2s code doesn't work correctly (fails the self-tests)
in big endian kernel builds because it doesn't swap the endianness of
the message words when loading them.  Fix this.

Fixes: 5172d322d3 ("crypto: arm/blake2s - add ARM scalar optimized BLAKE2s")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit d2f2516a38)
Bug: 178411248
Change-Id: Iff419963407eeb0435b9550ef126db4bf137a8a1
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-04-27 18:52:26 +00:00
Eric Biggers
0126a08dcd UPSTREAM: crypto: arm/blake2b - drop unnecessary return statement
Neither crypto_unregister_shashes() nor the module_exit function return
a value, so the explicit 'return' is unnecessary.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit 6131e97077)
Bug: 178411248
Change-Id: I2b15c03f1d0379effdf3a2f1d16e79a5ada84362
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-04-27 18:52:16 +00:00
Andrey Konovalov
ccc8708bde FROMGIT: kasan, arm64: tests supports for HW_TAGS async mode
This change adds KASAN-KUnit tests support for the async HW_TAGS mode.

In async mode, tag fault aren't being generated synchronously when a
bad access happens, but are instead explicitly checked for by the kernel.

As each KASAN-KUnit test expect a fault to happen before the test is over,
check for faults as a part of the test handler.

Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Link: https://lore.kernel.org/r/20210315132019.33202-10-vincenzo.frascino@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Bug: 170327579
Bug: 172318110
(cherry picked from commit e80a76aa1a
 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/
 for-next/mte-async-kernel-mode)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: I45a6bc351bce937797b1b08e9220a137225f9d55
2021-04-27 10:40:13 +02:00
Vincenzo Frascino
d5a19199c7 FROMGIT: arm64: mte: Report async tag faults before suspend
When MTE async mode is enabled TFSR_EL1 contains the accumulative
asynchronous tag check faults for EL1 and EL0.

During the suspend/resume operations the firmware might perform some
operations that could change the state of the register resulting in
a spurious tag check fault report.

Report asynchronous tag faults before suspend and clear the TFSR_EL1
register after resume to prevent this to happen.

Cc: Will Deacon <will@kernel.org>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Reviewed-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Link: https://lore.kernel.org/r/20210315132019.33202-9-vincenzo.frascino@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Bug: 170327579
Bug: 172318110
(cherry picked from commit eab0e6e17d
 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/
 for-next/mte-async-kernel-mode)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: I16efc3a886e57ac2f0a4f8a1bc70afcf17a86f26
2021-04-27 10:40:13 +02:00
Vincenzo Frascino
27ecc98407 FROMGIT: arm64: mte: Enable async tag check fault
MTE provides a mode that asynchronously updates the TFSR_EL1 register
when a tag check exception is detected.

To take advantage of this mode the kernel has to verify the status of
the register at:
  1. Context switching
  2. Return to user/EL0 (Not required in entry from EL0 since the kernel
  did not run)
  3. Kernel entry from EL1
  4. Kernel exit to EL1

If the register is non-zero a trace is reported.

Add the required features for EL1 detection and reporting.

Note: ITFSB bit is set in the SCTLR_EL1 register hence it guaranties that
the indirect writes to TFSR_EL1 are synchronized at exception entry to
EL1. On the context switch path the synchronization is guarantied by the
dsb() in __switch_to().
The dsb(nsh) in mte_check_tfsr_exit() is provisional pending
confirmation by the architects.

Cc: Will Deacon <will@kernel.org>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Link: https://lore.kernel.org/r/20210315132019.33202-8-vincenzo.frascino@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Bug: 170327579
Bug: 172318110
(cherry picked from commit 65812c6921
 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/
 for-next/mte-async-kernel-mode)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: Ia3e8df665b1fd88a50c649a6eda6ee790e28a7d4
2021-04-27 10:40:13 +02:00
Vincenzo Frascino
c3ca7ea141 FROMGIT: arm64: mte: Conditionally compile mte_enable_kernel_*()
mte_enable_kernel_*() are not needed if KASAN_HW is disabled.

Add ash defines around the functions to conditionally compile the
functions.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Link: https://lore.kernel.org/r/20210315132019.33202-7-vincenzo.frascino@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Bug: 170327579
Bug: 172318110
(cherry picked from commit d8969752cc
 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/
 for-next/mte-async-kernel-mode)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: If6ce3c28e970efda838b5f0112c409953265d083
2021-04-27 10:40:12 +02:00
Will McVicker
a2f1f07ff4 ANDROID: ABI: Update the ABI xml
Leaf changes summary: 7 artifacts changed (1 filtered out)
Changed leaf types summary: 0 (1 filtered out) leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 6 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 1 Added variable

6 Added functions:

  [A] 'function pwm_device* devm_pwm_get(device*, const char*)'
  [A] 'function int hid_add_device(hid_device*)'
  [A] 'function hid_device* hid_allocate_device()'
  [A] 'function void hid_destroy_device(hid_device*)'
  [A] 'function int hid_input_report(hid_device*, int, u8*, u32, int)'
  [A] 'function int hid_parse_report(hid_device*, __u8*, unsigned int)'

1 Added variable:

  [A] 'int hid_debug'

Bug: 186426346
Signed-off-by: Will McVicker <willmcvicker@google.com>
Change-Id: I328c02fcd832e00b5f06fe8cac354c3271b7a25b
2021-04-26 22:41:54 +00:00
Will McVicker
621d2bbc84 ANDROID: ABI: Update the generic symbol list
Add new symbols.

Bug: 186426346
Signed-off-by: Will McVicker <willmcvicker@google.com>
Change-Id: I6e87634a8f59fba90fa290c454bfef771feb3750
2021-04-26 22:41:43 +00:00
Kuan-Ying Lee
546252f29c ANDROID: selinux: add vendor hook in selinux
Add vendor hook for selinux_state, so we can know
if the selinux_state is initialized

Bug: 186363840

Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
Change-Id: Ideed051a1d53ed1bce7d7915e38366264a7d77eb
2021-04-26 10:27:58 -07:00
Vincenzo Frascino
4870b68f3f FROMGIT: arm64: mte: Enable TCO in functions that can read beyond buffer limits
load_unaligned_zeropad() and __get/put_kernel_nofault() functions can
read past some buffer limits which may include some MTE granule with a
different tag.

When MTE async mode is enabled, the load operation crosses the boundaries
and the next granule has a different tag the PE sets the TFSR_EL1.TF1 bit
as if an asynchronous tag fault is happened.

Enable Tag Check Override (TCO) in these functions  before the load and
disable it afterwards to prevent this to happen.

Note: The same condition can be hit in MTE sync mode but we deal with it
through the exception handling.
In the current implementation, mte_async_mode flag is set only at boot
time but in future kasan might acquire some runtime features that
that change the mode dynamically, hence we disable it when sync mode is
selected for future proof.

Cc: Will Deacon <will@kernel.org>
Reported-by: Branislav Rankov <Branislav.Rankov@arm.com>
Tested-by: Branislav Rankov <Branislav.Rankov@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Link: https://lore.kernel.org/r/20210315132019.33202-6-vincenzo.frascino@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Bug: 170327579
Bug: 172318110
(cherry picked from commit e60beb95c0
 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/
 for-next/mte-async-kernel-mode)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: Id1bf44c5f41bd6de4b2ddf286939cd35712f2299
2021-04-26 18:40:43 +02:00
JianMin Liu
f3f8d55011 ANDROID: sched: Add vendor hooks for update_load_avg
Add vh before and after __update_load_avg_se
  in order to collect load change of tasks.

Bug: 185557444

Change-Id: I210973f7e388164b68ed766074d1420cdf9d4c32
Signed-off-by: JianMin Liu <jian-min.liu@mediatek.com>
2021-04-26 13:29:25 +00:00
Quentin Perret
2f77dca33d ANDROID: Update ABI with __traceiter_*() additions
Leaf changes summary: 132 artifacts changed (1 filtered out)
Changed leaf types summary: 0 (1 filtered out) leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 132 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

132 Added functions:

  [A] 'function int __traceiter_android_rvh_account_irq(void*, task_struct*, int, s64)'
  [A] 'function int __traceiter_android_rvh_build_perf_domains(void*, bool*)'
  [A] 'function int __traceiter_android_rvh_can_migrate_task(void*, task_struct*, int, int*)'
  [A] 'function int __traceiter_android_rvh_check_preempt_wakeup(void*, rq*, task_struct*, bool*, bool*, int, sched_entity*, sched_entity*, int, unsigned int)'
  [A] 'function int __traceiter_android_rvh_cpu_cgroup_attach(void*, cgroup_taskset*)'
  [A] 'function int __traceiter_android_rvh_cpu_cgroup_can_attach(void*, cgroup_taskset*, int*)'
  [A] 'function int __traceiter_android_rvh_cpu_cgroup_online(void*, cgroup_subsys_state*)'
  [A] 'function int __traceiter_android_rvh_cpu_overutilized(void*, int, int*)'
  [A] 'function int __traceiter_android_rvh_cpufreq_transition(void*, cpufreq_policy*)'
  [A] 'function int __traceiter_android_rvh_dequeue_task(void*, rq*, task_struct*, int)'
  [A] 'function int __traceiter_android_rvh_enqueue_task(void*, rq*, task_struct*, int)'
  [A] 'function int __traceiter_android_rvh_find_busiest_queue(void*, int, sched_group*, cpumask*, rq**, int*)'
  [A] 'function int __traceiter_android_rvh_find_energy_efficient_cpu(void*, task_struct*, int, int, int*)'
  [A] 'function int __traceiter_android_rvh_find_lowest_rq(void*, task_struct*, cpumask*, int, int*)'
  [A] 'function int __traceiter_android_rvh_flush_task(void*, task_struct*)'
  [A] 'function int __traceiter_android_rvh_irqs_disable(void*, unsigned long int, unsigned long int)'
  [A] 'function int __traceiter_android_rvh_irqs_enable(void*, unsigned long int, unsigned long int)'
  [A] 'function int __traceiter_android_rvh_migrate_queued_task(void*, rq*, rq_flags*, task_struct*, int, int*)'
  [A] 'function int __traceiter_android_rvh_new_task_stats(void*, task_struct*)'
  [A] 'function int __traceiter_android_rvh_pick_next_entity(void*, cfs_rq*, sched_entity*, sched_entity**)'
  [A] 'function int __traceiter_android_rvh_place_entity(void*, cfs_rq*, sched_entity*, int, u64)'
  [A] 'function int __traceiter_android_rvh_preempt_disable(void*, unsigned long int, unsigned long int)'
  [A] 'function int __traceiter_android_rvh_preempt_enable(void*, unsigned long int, unsigned long int)'
  [A] 'function int __traceiter_android_rvh_replace_next_task_fair(void*, rq*, task_struct**, sched_entity**, bool*, bool, task_struct*)'
  [A] 'function int __traceiter_android_rvh_resume_cpus(void*, cpumask*, int*)'
  [A] 'function int __traceiter_android_rvh_sched_balance_rt(void*, rq*, task_struct*, int*)'
  [A] 'function int __traceiter_android_rvh_sched_cpu_dying(void*, int)'
  [A] 'function int __traceiter_android_rvh_sched_cpu_starting(void*, int)'
  [A] 'function int __traceiter_android_rvh_sched_exec(void*, bool*)'
  [A] 'function int __traceiter_android_rvh_sched_fork(void*, task_struct*)'
  [A] 'function int __traceiter_android_rvh_sched_fork_init(void*, task_struct*)'
  [A] 'function int __traceiter_android_rvh_sched_newidle_balance(void*, rq*, rq_flags*, int*, int*)'
  [A] 'function int __traceiter_android_rvh_sched_nohz_balancer_kick(void*, rq*, unsigned int*, int*)'
  [A] 'function int __traceiter_android_rvh_sched_rebalance_domains(void*, rq*, int*)'
  [A] 'function int __traceiter_android_rvh_sched_setaffinity(void*, task_struct*, const cpumask*, int*)'
  [A] 'function int __traceiter_android_rvh_schedule(void*, task_struct*, task_struct*, rq*)'
  [A] 'function int __traceiter_android_rvh_schedule_bug(void*, task_struct*)'
  [A] 'function int __traceiter_android_rvh_select_fallback_rq(void*, int, task_struct*, int*)'
  [A] 'function int __traceiter_android_rvh_select_task_rq_fair(void*, task_struct*, int, int, int, int*)'
  [A] 'function int __traceiter_android_rvh_select_task_rq_rt(void*, task_struct*, int, int, int, int*)'
  [A] 'function int __traceiter_android_rvh_set_gfp_zone_flags(void*, gfp_t*)'
  [A] 'function int __traceiter_android_rvh_set_iowait(void*, task_struct*, int*)'
  [A] 'function int __traceiter_android_rvh_set_readahead_gfp_mask(void*, gfp_t*)'
  [A] 'function int __traceiter_android_rvh_set_skip_swapcache_flags(void*, gfp_t*)'
  [A] 'function int __traceiter_android_rvh_set_task_cpu(void*, task_struct*, unsigned int)'
  [A] 'function int __traceiter_android_rvh_tick_entry(void*, rq*)'
  [A] 'function int __traceiter_android_rvh_try_to_wake_up(void*, task_struct*)'
  [A] 'function int __traceiter_android_rvh_try_to_wake_up_success(void*, task_struct*)'
  [A] 'function int __traceiter_android_rvh_ttwu_cond(void*, bool*)'
  [A] 'function int __traceiter_android_rvh_typec_tcpci_chk_contaminant(void*, tcpci*, tcpci_data*, int*)'
  [A] 'function int __traceiter_android_rvh_typec_tcpci_get_vbus(void*, tcpci*, tcpci_data*, int*, int*)'
  [A] 'function int __traceiter_android_rvh_uclamp_eff_get(void*, task_struct*, uclamp_id, uclamp_se*, uclamp_se*, int*)'
  [A] 'function int __traceiter_android_rvh_update_cpu_capacity(void*, int, unsigned long int*)'
  [A] 'function int __traceiter_android_rvh_update_cpus_allowed(void*, task_struct*, cpumask*, const cpumask*, int*)'
  [A] 'function int __traceiter_android_rvh_update_misfit_status(void*, task_struct*, rq*, bool*)'
  [A] 'function int __traceiter_android_rvh_util_est_update(void*, cfs_rq*, task_struct*, bool, int*)'
  [A] 'function int __traceiter_android_rvh_wake_up_new_task(void*, task_struct*)'
  [A] 'function int __traceiter_android_vh_allow_domain_state(void*, generic_pm_domain*, uint32_t, bool*)'
  [A] 'function int __traceiter_android_vh_arch_set_freq_scale(void*, const cpumask*, unsigned long int, unsigned long int, unsigned long int*)'
  [A] 'function int __traceiter_android_vh_binder_restore_priority(void*, binder_transaction*, task_struct*)'
  [A] 'function int __traceiter_android_vh_binder_set_priority(void*, binder_transaction*, task_struct*)'
  [A] 'function int __traceiter_android_vh_binder_transaction_init(void*, binder_transaction*)'
  [A] 'function int __traceiter_android_vh_binder_wakeup_ilocked(void*, task_struct*, bool, binder_proc*)'
  [A] 'function int __traceiter_android_vh_cma_alloc_finish(void*, cma*, page*, unsigned long int, unsigned int, gfp_t, s64)'
  [A] 'function int __traceiter_android_vh_cma_alloc_start(void*, s64*)'
  [A] 'function int __traceiter_android_vh_cpu_idle_enter(void*, int*, cpuidle_device*)'
  [A] 'function int __traceiter_android_vh_cpu_idle_exit(void*, int, cpuidle_device*)'
  [A] 'function int __traceiter_android_vh_dump_throttled_rt_tasks(void*, int, u64, ktime_t, u64, s64)'
  [A] 'function int __traceiter_android_vh_enable_thermal_genl_check(void*, int, int, int*)'
  [A] 'function int __traceiter_android_vh_ep_create_wakeup_source(void*, char*, int)'
  [A] 'function int __traceiter_android_vh_freq_table_limits(void*, cpufreq_policy*, unsigned int, unsigned int)'
  [A] 'function int __traceiter_android_vh_ftrace_dump_buffer(void*, trace_seq*, bool*)'
  [A] 'function int __traceiter_android_vh_ftrace_format_check(void*, bool*)'
  [A] 'function int __traceiter_android_vh_ftrace_oops_enter(void*, bool*)'
  [A] 'function int __traceiter_android_vh_ftrace_oops_exit(void*, bool*)'
  [A] 'function int __traceiter_android_vh_ftrace_size_check(void*, unsigned long int, bool*)'
  [A] 'function int __traceiter_android_vh_gic_v3_set_affinity(void*, irq_data*, const cpumask*, u64*, bool, void*)'
  [A] 'function int __traceiter_android_vh_gpio_block_read(void*, gpio_device*, bool*)'
  [A] 'function int __traceiter_android_vh_iommu_setup_dma_ops(void*, device*, u64, u64)'
  [A] 'function int __traceiter_android_vh_ipi_stop(void*, pt_regs*)'
  [A] 'function int __traceiter_android_vh_jiffies_update(void*, void*)'
  [A] 'function int __traceiter_android_vh_logbuf(void*, printk_ringbuffer*, printk_record*)'
  [A] 'function int __traceiter_android_vh_pagecache_get_page(void*, address_space*, unsigned long int, int, gfp_t, page*)'
  [A] 'function int __traceiter_android_vh_printk_hotplug(void*, int*)'
  [A] 'function int __traceiter_android_vh_rmqueue(void*, zone*, zone*, unsigned int, gfp_t, unsigned int, int)'
  [A] 'function int __traceiter_android_vh_scheduler_tick(void*, rq*)'
  [A] 'function int __traceiter_android_vh_show_max_freq(void*, cpufreq_policy*, unsigned int*)'
  [A] 'function int __traceiter_android_vh_show_resume_epoch_val(void*, u64)'
  [A] 'function int __traceiter_android_vh_show_suspend_epoch_val(void*, u64, u64)'
  [A] 'function int __traceiter_android_vh_timer_calc_index(void*, unsigned int, unsigned long int*)'
  [A] 'function int __traceiter_android_vh_timerfd_create(void*, char*, int)'
  [A] 'function int __traceiter_android_vh_typec_store_partner_src_caps(void*, tcpm_port*, unsigned int*, u32[7]*)'
  [A] 'function int __traceiter_android_vh_typec_tcpci_override_toggling(void*, tcpci*, tcpci_data*, int*)'
  [A] 'function int __traceiter_android_vh_typec_tcpm_adj_current_limit(void*, const char*, u32, u32, bool, u32*, bool*)'
  [A] 'function int __traceiter_android_vh_typec_tcpm_get_timer(void*, const char*, typec_timer, unsigned int*)'
  [A] 'function int __traceiter_android_vh_ufs_check_int_errors(void*, ufs_hba*, bool)'
  [A] 'function int __traceiter_android_vh_ufs_compl_command(void*, ufs_hba*, ufshcd_lrb*)'
  [A] 'function int __traceiter_android_vh_ufs_fill_prdt(void*, ufs_hba*, ufshcd_lrb*, unsigned int, int*)'
  [A] 'function int __traceiter_android_vh_ufs_prepare_command(void*, ufs_hba*, request*, ufshcd_lrb*, int*)'
  [A] 'function int __traceiter_android_vh_ufs_send_command(void*, ufs_hba*, ufshcd_lrb*)'
  [A] 'function int __traceiter_android_vh_ufs_send_tm_command(void*, ufs_hba*, int, const char*)'
  [A] 'function int __traceiter_android_vh_ufs_send_uic_command(void*, ufs_hba*, uic_command*, const char*)'
  [A] 'function int __traceiter_android_vh_ufs_update_sysfs(void*, ufs_hba*)'
  [A] 'function int __traceiter_binder_transaction_received(void*, binder_transaction*)'
  [A] 'function int __traceiter_cpu_frequency_limits(void*, cpufreq_policy*)'
  [A] 'function int __traceiter_cpu_idle(void*, unsigned int, unsigned int)'
  [A] 'function int __traceiter_device_pm_callback_end(void*, device*, int)'
  [A] 'function int __traceiter_device_pm_callback_start(void*, device*, const char*, int)'
  [A] 'function int __traceiter_hrtimer_expire_entry(void*, hrtimer*, ktime_t*)'
  [A] 'function int __traceiter_hrtimer_expire_exit(void*, hrtimer*)'
  [A] 'function int __traceiter_ipi_entry(void*, const char*)'
  [A] 'function int __traceiter_ipi_exit(void*, const char*)'
  [A] 'function int __traceiter_ipi_raise(void*, const cpumask*, const char*)'
  [A] 'function int __traceiter_irq_handler_entry(void*, int, irqaction*)'
  [A] 'function int __traceiter_irq_handler_exit(void*, int, irqaction*, int)'
  [A] 'function int __traceiter_pelt_cfs_tp(void*, cfs_rq*)'
  [A] 'function int __traceiter_pelt_dl_tp(void*, rq*)'
  [A] 'function int __traceiter_pelt_irq_tp(void*, rq*)'
  [A] 'function int __traceiter_pelt_rt_tp(void*, rq*)'
  [A] 'function int __traceiter_pelt_se_tp(void*, sched_entity*)'
  [A] 'function int __traceiter_rwmmio_post_read(void*, unsigned long int, u64, u8, const volatile void*)'
  [A] 'function int __traceiter_rwmmio_read(void*, unsigned long int, u8, const volatile void*)'
  [A] 'function int __traceiter_rwmmio_write(void*, unsigned long int, u64, u8, volatile void*)'
  [A] 'function int __traceiter_sched_cpu_capacity_tp(void*, rq*)'
  [A] 'function int __traceiter_sched_overutilized_tp(void*, root_domain*, bool)'
  [A] 'function int __traceiter_sched_switch(void*, bool, task_struct*, task_struct*)'
  [A] 'function int __traceiter_sched_util_est_cfs_tp(void*, cfs_rq*)'
  [A] 'function int __traceiter_suspend_resume(void*, const char*, int, bool)'
  [A] 'function int __traceiter_workqueue_execute_end(void*, work_struct*, work_func_t)'
  [A] 'function int __traceiter_workqueue_execute_start(void*, work_struct*)'
  [A] 'function void mmc_crypto_prepare_req(mmc_queue_req*)'
  [A] 'function void mmc_crypto_setup_queue(request_queue*, mmc_host*)'

Bug: 185777726
Signed-off-by: Quentin Perret <qperret@google.com>
Change-Id: If5fc3c6ebffa6c326d1b8f227ce4f6ec016e32aa
2021-04-26 09:45:39 +00:00
Quentin Perret
6ac06f08b2 ANDROID: Update the cf symbol list
The extract_symbols script has also been updated to make sure
__traceiter*() symbols are added to the list automatically in subsequent
updates.

Bug: 185777726
Signed-off-by: Quentin Perret <qperret@google.com>
Change-Id: I63789145dcfb0ab9d8411b236d797dc35a36b287
2021-04-26 08:54:09 +00:00
Quentin Perret
eef08d7dc9 ANDROID: Update the qcom symbol list
The extract_symbols script has also been updated to make sure
__traceiter*() symbols are added to the list automatically in subsequent
updates.

Bug: 185777726
Signed-off-by: Quentin Perret <qperret@google.com>
Change-Id: I616df9b718f50a7ab261de9d9b1186aaee1b17fa
2021-04-26 08:54:09 +00:00
Quentin Perret
020f00a46d ANDROID: Update the hikey960 symbol list
The extract_symbols script has also been updated to make sure
__traceiter*() symbols are added to the list automatically in subsequent
updates.

Bug: 185777726
Signed-off-by: Quentin Perret <qperret@google.com>
Change-Id: Id7efe0cee50d3969182b965ed51b8c1803c4b41a
2021-04-26 08:54:09 +00:00
Quentin Perret
2d2d6428cd ANDROID: Update the generic symbol list
The extract_symbols script has also been updated to make sure
__traceiter*() symbols are added to the list automatically in subsequent
updates.

Bug: 185777726
Signed-off-by: Quentin Perret <qperret@google.com>
Change-Id: Id7f96b205c9daf9f4a1507a670cf351442bc5815
2021-04-26 08:54:08 +00:00
Quentin Perret
dbe96fb1b9 ANDROID: Update the exynos symbol list
The extract_symbols script has also been updated to make sure
__traceiter*() symbols are added to the list automatically in subsequent
updates.

Bug: 185777726
Signed-off-by: Quentin Perret <qperret@google.com>
Change-Id: I9fabda88f22c364e4a6963638f2cb01d3e70e5ff
2021-04-26 08:54:08 +00:00
Quentin Perret
da07f99f19 ANDROID: Update the db845c symbol list
The extract_symbols script has also been updated to make sure
__traceiter*() symbols are added to the list automatically in subsequent
updates.

Bug: 185777726
Signed-off-by: Quentin Perret <qperret@google.com>
Change-Id: I7481aec17bfa7c85f3f8f626d5c9baba472d251b
2021-04-26 08:54:08 +00:00
Catalin Marinas
c7d0729a2c UPSTREAM: arm64: Move PSTATE.TCO setting to separate functions
For consistency with __uaccess_{disable,enable}_hw_pan(), move the
PSTATE.TCO setting into dedicated __uaccess_{disable,enable}_tco()
functions.

Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>

Bug: 170327579
Bug: 172318110
(cherry picked from commit 83b5bd628f)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: Ib7374b4f2ae8353afd062f740a355248507efa01
2021-04-25 14:59:34 +02:00
Vincenzo Frascino
9a928af2cc FROMGIT: kasan: Add report for async mode
KASAN provides an asynchronous mode of execution.

Add reporting functionality for this mode.

Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Reviewed-by: Andrey Konovalov <andreyknvl@google.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Link: https://lore.kernel.org/r/20210315132019.33202-5-vincenzo.frascino@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Bug: 170327579
Bug: 172318110
(cherry picked from commit 8f7b505475
 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/
 for-next/mte-async-kernel-mode)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: Ida1f470c21f378034dfa201c2b392e8af6bddee3
2021-04-25 14:59:34 +02:00
Vincenzo Frascino
f47de37f1f FROMGIT: arm64: mte: Drop arch_enable_tagging()
arch_enable_tagging() was left in memory.h after the introduction of
async mode to not break the bysectability of the KASAN KUNIT tests.

Remove the function now that KASAN has been fully converted.

Cc: Will Deacon <will@kernel.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Link: https://lore.kernel.org/r/20210315132019.33202-4-vincenzo.frascino@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Bug: 170327579
Bug: 172318110
(cherry picked from commit c137c6145b
 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/
 for-next/mte-async-kernel-mode)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: Ie497d187488a315be4d7b07803924dd4842fd32d
2021-04-25 14:59:34 +02:00
Todd Kjos
8bd9e809e9 ANDROID: GKI: 4/23 KMI update
Set KMI_GENERATION=2 for 4/23 KMI update

Bug: 186241007
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I5d07a9750c00e23c596a682d7d5b32b820b71f3f
2021-04-24 14:15:43 -07:00
Vincenzo Frascino
563c7d9596 FROMGIT: kasan: Add KASAN mode kernel parameter
Architectures supported by KASAN_HW_TAGS can provide a sync or async mode
of execution. On an MTE enabled arm64 hw for example this can be identified
with the synchronous or asynchronous tagging mode of execution.
In synchronous mode, an exception is triggered if a tag check fault occurs.
In asynchronous mode, if a tag check fault occurs, the TFSR_EL1 register is
updated asynchronously. The kernel checks the corresponding bits
periodically.

KASAN requires a specific kernel command line parameter to make use of this
hw features.

Add KASAN HW execution mode kernel command line parameter.

Note: This patch adds the kasan.mode kernel parameter and the
sync/async kernel command line options to enable the described features.

[ Add a new var instead of exposing kasan_arg_mode to be consistent with
  flags for other command line arguments. ]

Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Reviewed-by: Andrey Konovalov <andreyknvl@google.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Link: https://lore.kernel.org/r/20210315132019.33202-3-vincenzo.frascino@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Bug: 170327579
Bug: 172318110
(cherry picked from commit 2603f8a78d
 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/
 for-next/mte-async-kernel-mode)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: I193e9eb0c016abc525ef69a1b9b2bb7254856162
2021-04-24 19:37:58 +02:00
Vincenzo Frascino
433b85479b FROMGIT: arm64: mte: Add asynchronous mode support
MTE provides an asynchronous mode for detecting tag exceptions. In
particular instead of triggering a fault the arm64 core updates a
register which is checked by the kernel after the asynchronous tag
check fault has occurred.

Add support for MTE asynchronous mode.

The exception handling mechanism will be added with a future patch.

Note: KASAN HW activates async mode via kasan.mode kernel parameter.
The default mode is set to synchronous.
The code that verifies the status of TFSR_EL1 will be added with a
future patch.

Cc: Will Deacon <will@kernel.org>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Reviewed-by: Andrey Konovalov <andreyknvl@google.com>
Acked-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Link: https://lore.kernel.org/r/20210315132019.33202-2-vincenzo.frascino@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Bug: 170327579
Bug: 172318110
(cherry picked from commit f3b7deef8d
 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/
 for-next/mte-async-kernel-mode)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: I5a2778bbb03595c24eb6cddb6c2b2dcb383b7907
2021-04-24 19:37:58 +02:00
Todd Kjos
ea97f39295 ANDROID: GKI: update ABI description
Update ABI description in prperation for 4/23 KMI update

Leaf changes summary: 3103 artifacts changed
Changed leaf types summary: 15 leaf types changed
Removed/Changed/Added functions summary: 0 Removed, 3030 Changed, 0 Added function
Removed/Changed/Added variables summary: 0 Removed, 58 Changed, 0 Added variable

3030 functions with some sub-type change:

  [C] 'function int dev_pm_genpd_set_next_wakeup(device*, ktime_t)' at domain.c:441:1 has some sub-type changes:
    CRC (modversions) changed from 0x5f5fcb7c to 0xf61e0895
    return type changed:
      type name changed from 'int' to 'void'
      type size changed from 32 to 0 (in bits)

  [C] 'function void* PDE_DATA(const inode*)' at generic.c:799:1 has some sub-type changes:
    CRC (modversions) changed from 0x44ca679 to 0xcab3cd66

  [C] 'function void __ClearPageMovable(page*)' at compaction.c:138:1 has some sub-type changes:
    CRC (modversions) changed from 0x44484f05 to 0x9fa7085b

  [C] 'function void __SetPageMovable(page*, address_space*)' at compaction.c:130:1 has some sub-type changes:
    CRC (modversions) changed from 0x8978c2df to 0x41b1ba1a

  ... 3026 omitted; 3029 symbols have only CRC changes

58 Changed variables:

  [C] 'static_key_false cpu_hwcap_keys[61]' was changed to 'static_key_false cpu_hwcap_keys[76]' at cpufeature.c:150:1:
    size of symbol changed from 976 to 1216
    CRC (modversions) changed from 0x4c98d79b to 0xec2fc692
    type of variable changed:
      type name changed from 'static_key_false[61]' to 'static_key_false[76]'
      array type size changed from 7808 to 9728
      array type subrange 1 changed length from 61 to 76

  [C] 'unsigned long int cpu_hwcaps[1]' was changed to 'unsigned long int cpu_hwcaps[2]' at cpufeature.c:100:1:
    size of symbol changed from 8 to 16
    CRC (modversions) changed from 0xaebd1b18 to 0x8b9f70c7
    type of variable changed:
      type name changed from 'unsigned long int[1]' to 'unsigned long int[2]'
      array type size changed from 64 to 128
      array type subrange 1 changed length from 1 to 2

  [C] 'const vm_operations_struct drm_gem_cma_vm_ops' was changed at drm_gem_cma_helper.c:263:1:
    size of symbol changed from 136 to 144
    CRC (modversions) changed from 0xafd38045 to 0xc092767b
    type of variable changed:

  [C] 'net init_net' was changed at net_namespace.c:47:1:
    CRC (modversions) changed from 0x75836cf9 to 0x8c00edd2
    type of variable changed:
      type size hasn't changed
      there are data member changes:
        type 'struct netns_xfrm' of 'net::xfrm' changed:
          type size hasn't changed
          1 data member insertion:
            'seqcount_t xfrm_state_hash_generation', at offset 6176 (in bits) at xfrm.h:76:1
          there are data member changes:
            'spinlock_t xfrm_policy_lock' offset changed (by +32 bits)
            'mutex xfrm_cfg_mutex' offset changed (by +64 bits)
          3361 impacted interfaces
      3361 impacted interfaces

  [C] 'rq runqueues' was changed at core.c:49:1:
    size of symbol changed from 4160 to 4416
    CRC (modversions) changed from 0xfbaeea47 to 0x5137fc66
    type of variable changed:
      type size changed from 33280 to 35328 (in bits)
      there are data member changes:
        'uclamp_rq uclamp[2]' size changed from 768 to 2688 (in bits) (by +1920 bits)
        'unsigned int uclamp_flags' offset changed (by +1920 bits)
        61 ('cfs_rq cfs' .. 'u64 android_kabi_reserved4') offsets changed (by +2048 bits)
      3361 impacted interfaces

  [C] 'const vm_operations_struct vb2_common_vm_ops' was changed at videobuf2-memops.c:122:1:
    size of symbol changed from 136 to 144
    CRC (modversions) changed from 0x18a6cc01 to 0xfde2ba08
    type of variable changed:

  [C] 'vm_event_state vm_event_states' was changed at vmstat.c:108:1:
    size of symbol changed from 720 to 728
    CRC (modversions) changed from 0x85d767b0 to 0x62cac127
    type of variable changed:
      type size changed from 5760 to 5824 (in bits)
      there are data member changes:
        type 'unsigned long int[90]' of 'vm_event_state::event' changed:
          type name changed from 'unsigned long int[90]' to 'unsigned long int[91]'
          array type size changed from 5760 to 5824
          array type subrange 1 changed length from 90 to 91
      one impacted interface

  [C] 'bus_type amba_bustype' was changed at bus.c:215:1:
    CRC (modversions) changed from 0xbbb1e519 to 0x84856996

  [C] 'const address_space_operations balloon_aops' was changed at balloon_compaction.c:253:1:
    CRC (modversions) changed from 0x7769d265 to 0x807e3fab

  [C] 'const clk_ops clk_fixed_factor_ops' was changed at clk-fixed-factor.c:60:1:
    CRC (modversions) changed from 0x8a6ece13 to 0x26b088f0

  ... 48 omitted; 51 symbols have only CRC changes

'struct dma_buf at dma-buf.h:397:1' changed (indirectly):
  type size changed from 3328 to 3392 (in bits)
  there are data member changes:
    type 'struct vm_operations_struct' of 'dma_buf::vm_ops' changed:
      type size changed from 1088 to 1152 (in bits)
      1 data member insertion:
        'typedef bool ()* allow_speculation', at offset 832 (in bits) at mm.h:651:1
      there are data member changes:
        4 ('u64 android_kabi_reserved1' .. 'u64 android_kabi_reserved4') offsets changed (by +64 bits)
      3361 impacted interfaces
  421 impacted interfaces

'struct dma_slave_config at dmaengine.h:434:1' changed:
  type size changed from 448 to 576 (in bits)
  2 data member insertions:
    'void* peripheral_config', at offset 448 (in bits) at dmaengine.h:449:1
    'size_t peripheral_size', at offset 512 (in bits) at dmaengine.h:450:1
  33 impacted interfaces

'struct dwc3 at core.h:1079:1' changed:
  type size hasn't changed
  1 data member insertion:
    'unsigned int usb2_gadget_lpm_disable', at offset 16 (in bits) at core.h:1250:1
  there are data member changes:
    21 ('unsigned int dis_tx_ipgap_linecheck_quirk' .. 'unsigned int dis_u2_freeclk_exists_quirk') offsets changed (by +1 bits)
    'unsigned int dis_del_phy_power_chg_quirk' offset changed (by -31 bits)
  2 impacted interfaces

'struct net at net_namespace.h:56:1' changed (indirectly):
  details were reported earlier

'struct netns_xfrm at xfrm.h:32:1' changed:
  details were reported earlier

'struct rq at sched.h:907:1' changed (indirectly):
  details were reported earlier

'struct snd_soc_component_driver at soc-component.h:67:1' changed:
  type size changed from 2752 to 2816 (in bits)
  1 data member insertion:
    'int (snd_soc_component*, snd_pcm_substream*)* ack', at offset 2304 (in bits) at soc-component.h:149:1
  there are data member changes:
    8 ('const snd_compress_ops* compress_ops' .. 'int be_pcm_base') offsets changed (by +64 bits)
  65 impacted interfaces

'struct snd_soc_dai_link at soc.h:749:1' changed:
  type size changed from 1088 to 1600 (in bits)
  1 data member insertion:
    'snd_soc_dobj dobj', at offset 1088 (in bits) at soc.h:847:1
  65 impacted interfaces

'struct soc_enum at soc.h:1257:1' changed:
  type size changed from 320 to 832 (in bits)
  1 data member insertion:
    'snd_soc_dobj dobj', at offset 320 (in bits) at soc.h:1267:1
  one impacted interface

'struct tcpm_port at tcpm.c:297:1' changed:
  type size hasn't changed
  1 data member insertion:
    'bool slow_charger_loop', at offset 32080 (in bits) at tcpm.c:471:1
  13 impacted interfaces

'struct uclamp_rq at sched.h:892:1' changed:
  type size changed from 384 to 1344 (in bits)
  there are data member changes:
    type 'uclamp_bucket[5]' of 'uclamp_rq::bucket' changed:
      type name changed from 'uclamp_bucket[5]' to 'uclamp_bucket[20]'
      array type size changed from 320 to 1280
      array type subrange 1 changed length from 5 to 20
  3361 impacted interfaces

'struct uclamp_se at sched.h:623:1' changed (indirectly):
  type size hasn't changed
  there are data member changes:
    2 ('unsigned int active' .. 'unsigned int user_defined') offsets changed (by +2 bits)
  3361 impacted interfaces

'struct user_struct at user.h:13:1' changed:
  type size changed from 960 to 1088 (in bits)
  1 data member insertion:
    'u64 android_oem_data1[2]', at offset 960 (in bits) at user.h:45:1
  3361 impacted interfaces

'struct vm_event_state at vmstat.h:54:1' changed:
  details were reported earlier

'struct vm_operations_struct at mm.h:589:1' changed:
  details were reported earlier

Bug: 186241007
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I9725b5164da30547176b67b96cb1cef66ef2bfdc
2021-04-24 05:12:08 +00:00
Siddharth Gupta
4ccc2a6dbc FROMLIST: remoteproc: core: Move cdev add before device add
When cdev_add is called after device_add has been called there is no
way for the userspace to know about the addition of a cdev as cdev_add
itself doesn't trigger a uevent notification, or for the kernel to
know about the change to devt. This results in two problems:
 - mknod is never called for the cdev and hence no cdev appears on
   devtmpfs.
 - sysfs links to the new cdev are not established.

Based on how cdev_device_add[1] is written, it appears that the correct
way to use these APIs is to call cdev_add before device_add is called.
Since the cdev is an optional feature for remoteproc we cannot directly
use the existing API. Hence moving rproc_char_device_add() before
device_add() in rproc_add().

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/char_dev.c#n537

Signed-off-by: Siddharth Gupta <sidgup@codeaurora.org>

Bug: 185924092
Change-Id: Iad8a45f564996d73cd3f33ed124427cb73497dad
Link: https://lore.kernel.org/linux-remoteproc/1618946805-26970-1-git-send-email-sidgup@codeaurora.org/
Signed-off-by: Siddharth Gupta <quic_sidgup@quicinc.com>
2021-04-23 18:42:39 -07:00
Vinayak Menon
35eacb5c87 ANDROID: mm: allow vmas with vm_ops to be speculatively handled
Right now only anonymous page faults are speculatively handled,
thus leaving out a large percentage of faults still requiring to
take mmap_sem. These were left out since there can be fault
handlers mainly in the fs layer which may use vma in unknown ways.
This patch enables speculative fault for ext4, f2fs and shmem. The
feature is disabled by default and enabled via allow_file_spec_access
kernel param.

Bug: 171954515
Change-Id: I0d23ebf299000e4ac5e2c71bc0b7fc9006e98da9
Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
2021-04-23 18:42:39 -07:00
lijianzhong
77e791866b ANDROID: sched: Add ANDROID_OEM_DATA_ARRAY in user_struct.
add ANDROID_OEM_DATA_ARRAY for implement of oem gki.

Bug: 183674818
Signed-off-by: lijianzhong <lijianzhong@xiaomi.com>
Change-Id: I418293391bc62a68207eae51a79bd45a7f6cd2ed
2021-04-23 18:42:38 -07:00
lijianzhong
54f66141a8 ANDROID: sched: Add vendor hooks for sched.
Add vendor hooks in sched to support oem's feature.

Bug: 183674818

Signed-off-by: lijianzhong <lijianzhong@xiaomi.com>
Change-Id: I8415958749948b3702e411f835c227ad4f8d8e92
2021-04-23 18:42:38 -07:00
lijianzhong
58b10706f3 ANDROID: sched: Add vendor hooks to compute new cpu freq.
add vendor hooks to compute new cpu freq for oem feature.

Bug: 183674818

Signed-off-by: lijianzhong <lijianzhong@xiaomi.com>
Change-Id: I232d2e1ae885d6736eca9e4709870f4272b4873d
2021-04-23 18:42:38 -07:00
Greg Kroah-Hartman
a629454175 Revert "Revert "net: xfrm: Localize sequence counter per network namespace""
This reverts commit 1aff922933 as we are
free to update the ABI at this point in time.

Bug: 161946584
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Iba293953586fd78503ef5f47db40ccdc03b098f5
2021-04-23 18:42:38 -07:00
Badhri Jagan Sridharan
2d9841f98d FROMGIT: usb: typec: tcpm: Allow slow charging loops to comply to pSnkStby
When a PD charger advertising Rp-3.0 is connected to a sink port, the
sink port current limit would 3A, during SNK_DISCOVERY, till power
negotiation starts. Once the negotiation starts the power limit needs
to drop down to pSnkStby(500mA @ 5V) and to negotiated current limit
once the explicit contract is in place. Not all charging loops can ramp
up to 3A and drop down to 500mA within tSnkStdby which is 15ms. The port
partner might hard reset if tSnkStdby is not met.

To solve this problem, this patch introduces slow-charger-loop which
when set makes the port request PD_P_SNK_STDBY_MW upon entering
SNK_DISCOVERY(instead of 3A or the 1.5A during SNK_DISCOVERY) and the
actual currrent limit after RX of PD_CTRL_PSRDY for PD link or during
SNK_READY for non-pd link.

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Link: https://lore.kernel.org/r/20210414024000.4175263-2-badhri@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 1373fefc62
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I811b7f9ec732da0cab715837737ea09ea4a5bbbf
2021-04-23 18:42:38 -07:00
Thinh Nguyen
4e2ca165ba FROMGIT: usb: dwc3: gadget: Check for disabled LPM quirk
If the device doesn't support LPM, make sure to disable the LPM
capability and don't advertise to the host that it supports it.

Acked-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://lore.kernel.org/r/9e68527ff932b1646f92a7593d4092a903754666.1618366071.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 475e8be53d
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I917918988617cfe892d3555022616a0254afa0b7
2021-04-23 18:42:38 -07:00