Commit Graph

976965 Commits

Author SHA1 Message Date
Liangliang Li
fe580539f6 ANDROID: vendor_hooks: Add hooks for account irqtime process tick
Add a hook in irqtime_account_process_tick, which helps to get
information about the high load task.

Bug: 187904818

Change-Id: I644f7d66b09d047ca6b0a0fbd2915a6387c8c007
Signed-off-by: Liangliang Li <liliangliang@vivo.com>
2021-05-13 08:26:15 +00:00
Ard Biesheuvel
cf061f35b0 BACKPORT: arm64: fpsimd: run kernel mode NEON with softirqs disabled
Kernel mode NEON can be used in task or softirq context, but only in
a non-nesting manner, i.e., softirq context is only permitted if the
interrupt was not taken at a point where the kernel was using the NEON
in task context.

This means all users of kernel mode NEON have to be aware of this
limitation, and either need to provide scalar fallbacks that may be much
slower (up to 20x for AES instructions) and potentially less safe, or
use an asynchronous interface that defers processing to a later time
when the NEON is guaranteed to be available.

Given that grabbing and releasing the NEON is cheap, we can relax this
restriction, by increasing the granularity of kernel mode NEON code, and
always disabling softirq processing while the NEON is being used in task
context.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20210302090118.30666-4-ardb@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
(cherry picked from commit 13150149aa)
Change-Id: Ieae8506a0fee843a0998bb8812e42a79064ce21f
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-05-13 07:53:33 +00:00
Ard Biesheuvel
7fd5bd54c4 UPSTREAM: arm64: assembler: introduce wxN aliases for wN registers
The AArch64 asm syntax has this slightly tedious property that the names
used in mnemonics to refer to registers depend on whether the opcode in
question targets the entire 64-bits (xN), or only the least significant
8, 16 or 32 bits (wN). When writing parameterized code such as macros,
this can be annoying, as macro arguments don't lend themselves to
indexed lookups, and so generating a reference to wN in a macro that
receives xN as an argument is problematic.

For instance, an upcoming patch that modifies the implementation of the
cond_yield macro to be able to refer to 32-bit registers would need to
modify invocations such as

  cond_yield	3f, x8

to

  cond_yield	3f, 8

so that the second argument can be token pasted after x or w to emit the
correct register reference. Unfortunately, this interferes with the self
documenting nature of the first example, where the second argument is
obviously a register, whereas in the second example, one would need to
go and look at the code to find out what '8' means.

So let's fix this by defining wxN aliases for all xN registers, which
resolve to the 32-bit alias of each respective 64-bit register. This
allows the macro implementation to paste the xN reference after a w to
obtain the correct register name.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20210302090118.30666-3-ardb@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
(cherry picked from commit 4c4dcd3541)
Change-Id: Ic97b4346d38776464310e6b65bcfe29fbe2c9c38
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-05-13 07:53:32 +00:00
Ard Biesheuvel
dccc5bf4b7 BACKPORT: arm64: assembler: remove conditional NEON yield macros
The users of the conditional NEON yield macros have all been switched to
the simplified cond_yield macro, and so the NEON specific ones can be
removed.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20210302090118.30666-2-ardb@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
(cherry picked from commit 27248fe1ab)
Change-Id: I9fc1c7d9fc4242809bfc81a684db28060c51e2b3
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-05-13 07:53:32 +00:00
Ard Biesheuvel
a9e54b6010 UPSTREAM: fsverity: relax build time dependency on CRYPTO_SHA256
CONFIG_CRYPTO_SHA256 denotes the generic C implementation of the SHA-256
shash algorithm, which is selected as the default crypto shash provider
for fsverity. However, fsverity has no strict link time dependency, and
the same shash could be exposed by an optimized implementation, and arm64
has a number of those (scalar, NEON-based and one based on special crypto
instructions). In such cases, it makes little sense to require that the
generic C implementation is incorporated as well, given that it will never
be called.

To address this, relax the 'select' clause to 'imply' so that the generic
driver can be omitted from the build if desired.

Bug: 153614920
Acked-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit e3a606f2c5)
Change-Id: I3546d2ff037f8015af0c47e58c9e5ea656734d22
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-05-13 07:53:32 +00:00
Ard Biesheuvel
f90c8ffbd8 UPSTREAM: fscrypt: relax Kconfig dependencies for crypto API algorithms
Even if FS encryption has strict functional dependencies on various
crypto algorithms and chaining modes. those dependencies could potentially
be satisified by other implementations than the generic ones, and no link
time dependency exists on the 'depends on' claused defined by
CONFIG_FS_ENCRYPTION_ALGS.

So let's relax these clauses to 'imply', so that the default behavior
is still to pull in those generic algorithms, but in a way that permits
them to be disabled again in Kconfig.

Bug: 153614920
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit a0fc20333e)
Change-Id: I7c0b154094149e85cacaf22527e40d785e4b0396
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-05-13 07:53:32 +00:00
Ard Biesheuvel
57e54404ba UPSTREAM: crypto: arm64/gcm - move authentication tag check to SIMD domain
Instead of copying the calculated authentication tag to memory and
calling crypto_memneq() to verify it, use vector bytewise compare and
min across vector instructions to decide whether the tag is valid. This
is more efficient, and given that the tag is only transiently held in a
NEON register, it is also safer, given that calculated tags for failed
decryptions should be withheld.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit 3ad99c22ce)
Bug: 153614920
Change-Id: I9b6625b3c7b2b6c54aaf9c5040d6fe8a6470b097
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-05-13 07:53:32 +00:00
Ard Biesheuvel
18525713bb UPSTREAM: crypto: arm64/crc-t10dif - move NEON yield to C code
Instead of yielding from the bowels of the asm routine if a reschedule
is needed, divide up the input into 4 KB chunks in the C glue. This
simplifies the code substantially, and avoids scheduling out the task
with the asm routine on the call stack, which is undesirable from a
CFI/instrumentation point of view.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit fc754c024a)
Bug: 153614920
Change-Id: I7bd6f660d7bc4a9a5d4c24dd813697a0efd699e2
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-05-13 07:53:32 +00:00
Ard Biesheuvel
3249282a95 UPSTREAM: crypto: arm64/aes-ce-mac - simplify NEON yield
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit f0070f4a79)
Bug: 153614920
Change-Id: I5a9e133f3813f5130d46a258179e59d5a7e3450e
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-05-13 07:53:32 +00:00
Ard Biesheuvel
4e2acf6395 UPSTREAM: crypto: arm64/aes-neonbs - remove NEON yield calls
There is no need for elaborate yield handling in the bit-sliced NEON
implementation of AES, given that skciphers are naturally bounded by the
size of the chunks returned by the skcipher_walk API. So remove the
yield calls from the asm code.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit f5943ef456)
Bug: 153614920
Change-Id: I4af32d733d28b5bc716d45e33d56be6a1bbba4e8
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-05-13 07:53:32 +00:00
Ard Biesheuvel
2a5f8c85c5 UPSTREAM: crypto: arm64/sha512-ce - simplify NEON yield
Instead of calling into kernel_neon_end() and kernel_neon_begin() (and
potentially into schedule()) from the assembler code when running in
task mode and a reschedule is pending, perform only the preempt count
check in assembler, but simply return early in this case, and let the C
code deal with the consequences.

This reverts commit 6caf7adc5e.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit 5f6cb2e617)
Bug: 153614920
Change-Id: If4b2acfe88c2602510b908e4039852e439e1c3f6
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-05-13 07:53:31 +00:00
Ard Biesheuvel
cfb375ea9f UPSTREAM: crypto: arm64/sha3-ce - simplify NEON yield
Instead of calling into kernel_neon_end() and kernel_neon_begin() (and
potentially into schedule()) from the assembler code when running in
task mode and a reschedule is pending, perform only the preempt count
check in assembler, but simply return early in this case, and let the C
code deal with the consequences.

This reverts commit 7edc86cb1c.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit 9ecc9f31d0)
Bug: 153614920
Change-Id: Iac9f43058b687182fe1bf7f47efb6b8aca128c29
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-05-13 07:53:31 +00:00
Ard Biesheuvel
7878a8b055 UPSTREAM: crypto: arm64/sha2-ce - simplify NEON yield
Instead of calling into kernel_neon_end() and kernel_neon_begin() (and
potentially into schedule()) from the assembler code when running in
task mode and a reschedule is pending, perform only the preempt count
check in assembler, but simply return early in this case, and let the C
code deal with the consequences.

This reverts commit d82f37ab5e.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit b2eadbf40e)
Bug: 153614920
Change-Id: Ie3f66f835bec71b29bd42fbeb9b32d36d1e0e7e4
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-05-13 07:53:31 +00:00
Ard Biesheuvel
0c278c4b40 UPSTREAM: crypto: arm64/sha1-ce - simplify NEON yield
Instead of calling into kernel_neon_end() and kernel_neon_begin() (and
potentially into schedule()) from the assembler code when running in
task mode and a reschedule is pending, perform only the preempt count
check in assembler, but simply return early in this case, and let the C
code deal with the consequences.

This reverts commit 7df8d16475.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit 5a69e1b73d)
Bug: 153614920
Change-Id: I1393f9c5b73316ba68ca64c975a3790c31793b4a
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-05-13 07:53:31 +00:00
Ard Biesheuvel
e7b1004dbf UPSTREAM: arm64: assembler: add cond_yield macro
Add a macro cond_yield that branches to a specified label when called if
the TIF_NEED_RESCHED flag is set and decreasing the preempt count would
make the task preemptible again, resulting in a schedule to occur. This
can be used by kernel mode SIMD code that keeps a lot of state in SIMD
registers, which would make chunking the input in order to perform the
cond_resched() check from C code disproportionately costly.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20210203113626.220151-2-ardb@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
(cherry picked from commit d13c613f13)
Bug: 153614920
Change-Id: I066dbeef516a023c384689adaddac2047da113e9
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-05-13 07:53:31 +00:00
Ard Biesheuvel
665fe01c67 UPSTREAM: crypto: remove cipher routines from public crypto API
The cipher routines in the crypto API are mostly intended for templates
implementing skcipher modes generically in software, and shouldn't be
used outside of the crypto subsystem. So move the prototypes and all
related definitions to a new header file under include/crypto/internal.
Also, let's use the new module namespace feature to move the symbol
exports into a new namespace CRYPTO_INTERNAL.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit 0eb76ba29d)
Bug: 153614920
Change-Id: I0ed1c7a197611f020a21d489cd15a09a650bb1e6
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-05-13 07:53:31 +00:00
Ard Biesheuvel
acff6cbc94 UPSTREAM: chcr_ktls: use AES library for single use cipher
Allocating a cipher via the crypto API only to free it again after using
it to encrypt a single block is unnecessary in cases where the algorithm
is known at compile time. So replace this pattern with a call to the AES
library.

Cc: Ayush Sawal <ayush.sawal@chelsio.com>
Cc: Vinay Kumar Yadav <vinay.yadav@chelsio.com>
Cc: Rohit Maheshwari <rohitm@chelsio.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
(cherry picked from commit a3b01ffddc)
Change-Id: I758bba01b655391044a4efbe768ca68a5c0d54e1
Signed-off-by: Ard Biesheuvel <ardb@google.com>
2021-05-13 07:53:31 +00:00
Jaegeuk Kim
bc6ca71187 ANDROID: add OWNERS for sysfs-fs-f2fs
This was generated with
$ build/synchronize_owners common-mainline/ android-mainline common12-5.10/

Bug: 181986413
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I1416402cc4e100b950473d9a0277c34f78857638
2021-05-13 01:02:49 +00:00
Liam Mark
4738608080 FROMGIT: mm/memory_hotplug: rate limit page migration warnings
When offlining memory the system can attempt to migrate a lot of pages, if
there are problems with migration this can flood the logs.  Printing all
the data hogs the CPU and cause some RT threads to run for a long time,
which may have some bad consequences.

Rate limit the page migration warnings in order to avoid this.

Link: https://lkml.kernel.org/r/20210505140542.24935-1-georgi.djakov@linaro.org
Signed-off-by: Liam Mark <lmark@codeaurora.org>
Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
Cc: David Hildenbrand <david@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

Bug: 187917022
(cherry picked from commit 6be9af0e0f77 https: //github.com/hnaz/linux-mm.git v5.13-rc1-mmots-2021-05-10-22-15)
Change-Id: I6754d380f8c31cf9b699c242edacf593807ef2b1
Signed-off-by: Chris Goldsworthy <quic_cgoldswo@quicinc.com>
2021-05-12 17:17:21 -07:00
John Stultz
b3a1591e82 ANDROID: db845c_gki.fragment: Add QCOM_TSENSE config to avoid thermal crashes
This adds QCOM_TSENSE to the db845c_gki.fragment which is
needed to avoid hard crashes seen on db845c (which crash into
USB dump mode). This was causing some troube in our testing
as we'd occasionally see hard crashes in certian CTS tests
(also reproducible with a forkbomb).

After lots of debugging we've narrowed down this config as
the change which avoids the hard crashes.

Thanks to: Vinod Koul <vinod.koul@linaro.org> and
Bjorn Andersson <bjorn.andersson@linaro.org> for helping debug
this issue!

Bug: 146449535
Reported-by: YongQin Liu <yongqin.liu@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Change-Id: I0752c85e44028e6272c14b59fa09d2baf2e18feb
2021-05-12 19:55:34 +00:00
Ruslan Bilovol
5abbf39685 UPSTREAM: usb: gadget: f_uac2: validate input parameters
Currently user can configure UAC2 function with
parameters that violate UAC2 spec or are not supported
by UAC2 gadget implementation.

This can lead to incorrect behavior if such gadget
is connected to the host - like enumeration failure
or other issues depending on host's UAC2 driver
implementation, bringing user to a long hours
of debugging the issue.

Instead of silently accept these parameters, throw
an error if they are not valid.

Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Link: https://lore.kernel.org/r/1614599375-8803-4-git-send-email-ruslan.bilovol@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 187332233
(cherry picked from commit 3713d5ceb0)
Change-Id: Icc684c620e039f7dbb3591e5669506f6f69574d6
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2021-05-12 17:00:55 +00:00
Pawel Laszczak
5feadee52b UPSTREAM: usb: f_uac2: adds support for SS and SSP
Patch adds support of SS and SSP speed.

Signed-off-by: Pawel Laszczak <pawell@cadence.com>
Link: https://lore.kernel.org/r/20210310105216.38202-1-pawell@gli-login.cadence.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 187332233
(cherry picked from commit f8cb3d556b)
Change-Id: I6689c8df4a17fcf561a65dc16d509e26f088c142
Signed-off-by: Jack Pham <jackp@codeaurora.org>
2021-05-12 17:00:44 +00:00
David Chao
446e972fab ANDROID: Update the ABI xml and symbol list
Leaf changes summary: 1 artifact changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 1 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

1 Added function:

  [A] 'function const char* trace_print_bitmask_seq(trace_seq*, void*, unsigned int)'

Bug: 172971380
Signed-off-by: David Chao <davidchao@google.com>
Change-Id: I3462f7b91ddb21075a088b56093fc02289b5642b
2021-05-12 17:18:00 +08:00
Abhijeet Dharmapurikar
ae8c2a7501 ANDROID: topology: Add flag to indicate topology has been updated
Commit f7128c7533 ("ANDROID: sched: Add vendor hooks for update_topology")
was intended for the modules to get informed when topology
initialization had completed.

However that is not sufficient, the module could be insmoded after
the hook was invoked.

For such situations create a flag for modules to detect that topology
initialization is completed.

Bug: 187234873
Change-Id: I2ed4dff9c921e3de67dd11049c80f38e3c1a64fd
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2021-05-11 22:55:07 +00:00
David Chao
101a64c6c8 ANDROID: Update the ABI xml and symbol list
Leaf changes summary: 2 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 1 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 1 Added variable

1 Added function:

  [A] 'function int __traceiter_android_vh_thermal_pm_notify_suspend(void*, thermal_zone_device*, int*)'

1 Added variable:

  [A] 'tracepoint __tracepoint_android_vh_thermal_pm_notify_suspend'

Bug: 170905417
Signed-off-by: David Chao <davidchao@google.com>
Change-Id: Ie57b489e6aa1fa22eec9beb57dd5345a7efbd124
2021-05-11 14:07:01 -07:00
Sami Tolvanen
27eb5ffcb7 ANDROID: Add missing CFI jump table symbols to kallsyms
With CONFIG_LTO_CLANG_FULL, LLVM drops all CFI jump table symbols
from vmlinux, which doesn't affect kernel functionality, but can
make stack traces and other kernel output that prints out jump
table addresses harder to read.

This change works around the issue for now by adding a script that
tells kallsyms about the missing jump table symbols, even though
they don't actually exist in the symbol table, and generates a
linker script to add the missing symbols to kernel modules.

Bug: 186152035
Bug: 187415564
Change-Id: Ic3c51751c756f2f5fb2a31229e16c3397eb6e666
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
2021-05-11 17:56:41 +00:00
Bart Van Assche
a1fbf0ead8 Revert "BACKPORT: bio: limit bio max size"
Revert most of commit 25a6f60b717d ("BACKPORT: bio: limit bio max size")
because it has been reported to cause data corruption and because it has
been reverted upstream. See also
https://lore.kernel.org/linux-block/1620571445.2k94orj8ee.none@localhost/T/#t

Cc: Changheun Lee <nanich.lee@samsung.com>
Cc: Jaegeuk Kim <jaegeuk@google.com>
Bug: 182716953
Change-Id: I79bf39d1d1a0c13cb30ff4b0f1da2b43e1c817f0
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2021-05-11 09:34:37 -07:00
David Chao
a4af23d274 ANDROID: thermal: Add vendor thermal_pm_notify_suspend function
Currently, most of the thermal_zones are IRQ capable and they do not need
to be updated while resuming. To improve the system performance and reduce
the resume time. Add a vendor function to check if the thermal_zone is
not IRQ capable and needs to be updated.

Bug: 170905417
Test: boot and vendor function worked properly.
Change-Id: I9389985bba29b551a7a20b55e1ed26b6c4da9b3d
Signed-off-by: David Chao <davidchao@google.com>
2021-05-11 15:15:04 +00:00
Subash Abhinov Kasiviswanathan
68d3da6c97 ANDROID: qcom: Add neighbor related symbols
Add neigh_lookup, arp_tbl and ipv6_stub which are needed by
rmnet modules.

Leaf changes summary: 3 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 1 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 2 Added variables

1 Added function:

  [A] 'function neighbour* neigh_lookup(neigh_table*, void*, net_device*)'

2 Added variables:

  [A] 'neigh_table arp_tbl'
  [A] 'const ipv6_stub* ipv6_stub'

Bug: 187741200
Change-Id: I2d7dae14f2879eafeb15f5f4d834ffac2035119a
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
2021-05-11 11:24:12 +00:00
Subbaraman Narayanamurthy
cd04f7fab9 ANDROID: usb: typec: ucsi: Ensure bounds check when accessing src_pdos
Currently, when reading the following properties under
ucsi-source-psy-*, src_pdos array is accessed but it only checks
for the condition num_pdos > 0.

- voltage_max
- voltage_now
- current_max

In the case if a PPM passes num_pdos greater than UCSI_MAX_PDOS,
an OOB access can be made. Fix it by checking the upper bound for
src_pdos which is UCSI_MAX_PDOS.

This issue is detected by enabling UBSAN.

Bug: 186400956
Fixes: 992a60ed0d ("usb: typec: ucsi: register with power_supply class")
Fixes: 4dbc6a4ef0 ("usb: typec: ucsi: save power data objects in PD mode")
Change-Id: Id0aca674208b23329be089671cba873baca930cf
Signed-off-by: Subbaraman Narayanamurthy <quic_subbaram@quicinc.com>
2021-05-11 09:07:13 +00:00
Kyle Tso
107ad0ea68 FROMGIT: usb: typec: tcpm: Fix wrong handling for Not_Supported in VDM AMS
Not_Supported Message is acceptable in VDM AMS. Redirect the VDM state
machine to VDM_STATE_DONE when receiving Not_Supported and finish the
VDM AMS.

Also, after the loop in vdm_state_machine_work, add more conditions of
VDM states to clear the vdm_sm_running flag because those are all
stopping states when leaving the loop.

In addition, finish the VDM AMS if the port partner responds BUSY.

Fixes: 8dea75e113 ("usb: typec: tcpm: Protocol Error handling")
Fixes: 8d3a0578ad ("usb: typec: tcpm: Respond Wait if VDM state machine is running")
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Kyle Tso <kyletso@google.com>
Link: https://lore.kernel.org/r/20210507062300.1945009-3-kyletso@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit f1fbd950b5
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-linus)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ia52ad69f054b2211924ec3815b5a3d2cc09d8b88
2021-05-11 06:52:24 +00:00
Rick Yiu
93d7a4c7ea ANDROID: Update the ABI xml and symbol list
Leaf changes summary: 2 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 1 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 1 Added variable

1 Added function:

  [A] 'function int __traceiter_android_rvh_cgroup_force_kthread_migration(void*, task_struct*, cgroup*, bool*)'

1 Added variable:

  [A] 'tracepoint __tracepoint_android_rvh_cgroup_force_kthread_migration'

Bug: 171740453
Signed-off-by: Rick Yiu <rickyiu@google.com>
Change-Id: Ibb66a118c14c9c2a4d8e65c862e94b1445053351
2021-05-11 00:21:09 +00:00
Marcel Hamer
c0df53e0ee FROMGIT: usb: dwc3: omap: improve extcon initialization
When extcon is used in combination with dwc3, it is assumed that the dwc3
registers are untouched and as such are only configured if VBUS is valid
or ID is tied to ground.

In case VBUS is not valid or ID is floating, the registers are not
configured as such during driver initialization, causing a wrong
default state during boot.

If the registers are not in a default state, because they are for
instance touched by a boot loader, this can cause for a kernel error.

Signed-off-by: Marcel Hamer <marcel@solidxs.se>
Link: https://lore.kernel.org/r/20210427122118.1948340-1-marcel@solidxs.se
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit e17b02d497
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-linus)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ic460a111f59e5a4fd77db0402fb297e53bbc1d9e
2021-05-10 15:05:13 +02:00
Andy Shevchenko
96d46a7342 FROMGIT: usb: typec: ucsi: Put fwnode in any case during ->probe()
device_for_each_child_node() bumps a reference counting of a returned variable.
We have to balance it whenever we return to the caller.

Fixes: c1b0bc2dab ("usb: typec: Add support for UCSI interface")
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20210504222337.3151726-1-andy.shevchenko@gmail.com
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit b9a0866a5b
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-linus)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I7c18e76218fa750ccb62839689e4e4f469a8913e
2021-05-10 15:02:44 +02:00
Wesley Cheng
e9c04db1d5 FROMGIT: usb: dwc3: gadget: Return success always for kick transfer in ep queue
If an error is received when issuing a start or update transfer
command, the error handler will stop all active requests (including
the current USB request), and call dwc3_gadget_giveback() to notify
function drivers of the requests which have been stopped.  Avoid
returning an error for kick transfer during EP queue, to remove
duplicate cleanup operations on the request being queued.

Fixes: 8d99087c2d ("usb: dwc3: gadget: Properly handle failed kick_transfer")
cc: stable@vger.kernel.org
Signed-off-by: Wesley Cheng <wcheng@codeaurora.org>
Link: https://lore.kernel.org/r/1620410119-24971-1-git-send-email-wcheng@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 18ffa988db
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-linus)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I78dd14dab53a4e48ef2aaa16f16397ed2361f597
2021-05-10 14:55:43 +02:00
Jack Pham
c3f92e5f6c FROMGIT: usb: dwc3: gadget: Free gadget structure only after freeing endpoints
As part of commit e81a7018d9 ("usb: dwc3: allocate gadget structure
dynamically") the dwc3_gadget_release() was added which will free
the dwc->gadget structure upon the device's removal when
usb_del_gadget_udc() is called in dwc3_gadget_exit().

However, simply freeing the gadget results a dangling pointer
situation: the endpoints created in dwc3_gadget_init_endpoints()
have their dep->endpoint.ep_list members chained off the list_head
anchored at dwc->gadget->ep_list.  Thus when dwc->gadget is freed,
the first dwc3_ep in the list now has a dangling prev pointer and
likewise for the next pointer of the dwc3_ep at the tail of the list.
The dwc3_gadget_free_endpoints() that follows will result in a
use-after-free when it calls list_del().

This was caught by enabling KASAN and performing a driver unbind.
The recent commit 568262bf54 ("usb: dwc3: core: Add shutdown
callback for dwc3") also exposes this as a panic during shutdown.

There are a few possibilities to fix this.  One could be to perform
a list_del() of the gadget->ep_list itself which removes it from
the rest of the dwc3_ep chain.

Another approach is what this patch does, by splitting up the
usb_del_gadget_udc() call into its separate "del" and "put"
components.  This allows dwc3_gadget_free_endpoints() to be
called before the gadget is finally freed with usb_put_gadget().

Fixes: e81a7018d9 ("usb: dwc3: allocate gadget structure dynamically")
Reviewed-by: Peter Chen <peter.chen@kernel.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Link: https://lore.kernel.org/r/20210501093558.7375-1-jackp@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit bb9c74a5bd
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-linus)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I0062f1ccdda604938d8e2f68de4ae27360397d9f
2021-05-10 14:55:18 +02:00
Phil Elwell
56f681803f FROMGIT: usb: dwc2: Fix gadget DMA unmap direction
The dwc2 gadget support maps and unmaps DMA buffers as necessary. When
mapping and unmapping it uses the direction of the endpoint to select
the direction of the DMA transfer, but this fails for Control OUT
transfers because the unmap occurs after the endpoint direction has
been reversed for the status phase.

A possible solution would be to unmap the buffer before the direction
is changed, but a safer, less invasive fix is to remember the buffer
direction independently of the endpoint direction.

Fixes: fe0b94abcd ("usb: dwc2: gadget: manage ep0 state in software")
Acked-by: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
Link: https://lore.kernel.org/r/20210506112200.2893922-1-phil@raspberrypi.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 75a41ce46b
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-linus)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I1cdc8528842a33cadb0e05852b95670360db8ad3
2021-05-10 14:51:38 +02:00
Jack Pham
28ceb4d07f FROMGIT: usb: dwc3: gadget: Rename EOPF event macros to Suspend
The device event corresponding to End of Periodic Frame is only
found on older IP revisions (2.10a and prior, according to a
cursory SNPS databook search).  On revisions 2.30a and newer,
including DWC3.1, the same event value and corresponding DEVTEN
bit were repurposed to indicate that the link has gone into
suspend state (U3 or L2/L1).

EOPF events had never been enabled before in this driver, and
going forward we expect current and future DWC3-based devices
won't likely to be using such old DWC3 IP revisions either.
Hence rather than keeping the deprecated EOPF macro names let's
rename them to indicate their usage for suspend events.

Acked-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Link: https://lore.kernel.org/r/20210428090111.3370-2-jackp@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 6f26ebb79a
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-linus)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I8351dd713ce0e60b2212a22a3b51d1139ae89779
2021-05-10 14:47:39 +02:00
Jack Pham
36695d0e77 FROMGIT: usb: dwc3: gadget: Enable suspend events
commit 72704f876f ("dwc3: gadget: Implement the suspend entry event
handler") introduced (nearly 5 years ago!) an interrupt handler for
U3/L1-L2 suspend events.  The problem is that these events aren't
currently enabled in the DEVTEN register so the handler is never
even invoked.  Fix this simply by enabling the corresponding bit
in dwc3_gadget_enable_irq() using the same revision check as found
in the handler.

Fixes: 72704f876f ("dwc3: gadget: Implement the suspend entry event handler")
Acked-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210428090111.3370-1-jackp@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit d1d90dd272
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-linus)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ia54cb4045149139ee7f21f9e4c6dc31e2ef52971
2021-05-10 14:47:20 +02:00
Greg Kroah-Hartman
d9d0c09e0a Revert "capabilities: require CAP_SETFCAP to map uid 0"
This reverts commit fb4c1c2e9f.

Fixes the ABI issues in 5.10.35 that at the moment, we can't handle due
to the KABI freeze.  These are not patches that mean much for android
systems, and will be reverted the next KABI "reset" point.

Bug: 161946584
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I7b12040440bc2bedfbabc71d60339cb843e59570
2021-05-08 13:23:05 +02:00
Greg Kroah-Hartman
0ddd59c5da Revert "driver core: add a min_align_mask field to struct device_dma_parameters"
This reverts commit 2e8b3b0b8e.

Fixes the ABI issues in 5.10.35 that at the moment, we can't handle due
to the KABI freeze.  These are not patches that mean much for android
systems, and will be reverted the next KABI "reset" point.

Bug: 161946584
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I03a41fc3ba455ded7274f2a6b5566bb369a75a86
2021-05-08 13:23:04 +02:00
Greg Kroah-Hartman
17ba7dfe20 Revert "swiotlb: add a IO_TLB_SIZE define"
This reverts commit 22163a8ec8.

Fixes the ABI issues in 5.10.35 that at the moment, we can't handle due
to the KABI freeze.  These are not patches that mean much for android
systems, and will be reverted the next KABI "reset" point.

Bug: 161946584
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ie256b7f1ed5b19f4600ff4c3681efaea5046adda
2021-05-08 13:23:03 +02:00
Greg Kroah-Hartman
78957dcb2c Revert "swiotlb: factor out an io_tlb_offset helper"
This reverts commit 1bbcc985d1.

Fixes the ABI issues in 5.10.35 that at the moment, we can't handle due
to the KABI freeze.  These are not patches that mean much for android
systems, and will be reverted the next KABI "reset" point.

Bug: 161946584
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I88427586de4df897c39bb3d48e8cba86ebf5c4bb
2021-05-08 13:23:02 +02:00
Greg Kroah-Hartman
cb27079661 Revert "swiotlb: factor out a nr_slots helper"
This reverts commit 1f2ef5a0f7.

Fixes the ABI issues in 5.10.35 that at the moment, we can't handle due
to the KABI freeze.  These are not patches that mean much for android
systems, and will be reverted the next KABI "reset" point.

Bug: 161946584
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I461f44ec54102dcf06ba73959a79172615cdb8fa
2021-05-08 13:23:01 +02:00
Greg Kroah-Hartman
28a2f5f10f Revert "swiotlb: clean up swiotlb_tbl_unmap_single"
This reverts commit 9efd5df078.

Fixes the ABI issues in 5.10.35 that at the moment, we can't handle due
to the KABI freeze.  These are not patches that mean much for android
systems, and will be reverted the next KABI "reset" point.

Bug: 161946584
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ia22b608e4d017c6056e481d2ec819074b35810cf
2021-05-08 13:23:00 +02:00
Greg Kroah-Hartman
0fb49e91d4 Revert "swiotlb: refactor swiotlb_tbl_map_single"
This reverts commit 25ed8827cf.

Fixes the ABI issues in 5.10.35 that at the moment, we can't handle due
to the KABI freeze.  These are not patches that mean much for android
systems, and will be reverted the next KABI "reset" point.

Bug: 161946584
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I9928cdc06a26b9db3052b93067c557011e53f735
2021-05-08 13:22:59 +02:00
Greg Kroah-Hartman
2201384121 Revert "swiotlb: don't modify orig_addr in swiotlb_tbl_sync_single"
This reverts commit 85a5a6875c.

Fixes the ABI issues in 5.10.35 that at the moment, we can't handle due
to the KABI freeze.  These are not patches that mean much for android
systems, and will be reverted the next KABI "reset" point.

Bug: 161946584
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ibe7639f73acc11b356f6b2f8f76011844c7f451b
2021-05-08 13:22:56 +02:00
Greg Kroah-Hartman
b4ae4430ab Revert "swiotlb: respect min_align_mask"
This reverts commit f8e71c667e.

Fixes the ABI issues in 5.10.35 that at the moment, we can't handle due
to the KABI freeze.  These are not patches that mean much for android
systems, and will be reverted the next KABI "reset" point.

Bug: 161946584
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I6684b40d913a86b79899220cba823a74aea5923f
2021-05-08 13:22:54 +02:00
Greg Kroah-Hartman
abc5254824 Revert "nvme-pci: set min_align_mask"
This reverts commit 2fa0387fa2.

Fixes the ABI issues in 5.10.35 that at the moment, we can't handle due
to the KABI freeze.  These are not patches that mean much for android
systems, and will be reverted the next KABI "reset" point.

Bug: 161946584
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: If6aba0f06d169907827ca1f76b52adc75c84c124
2021-05-08 13:21:45 +02:00
Greg Kroah-Hartman
bfac7b85a0 Merge 5.10.35 into android12-5.10
Changes in 5.10.35
	mips: Do not include hi and lo in clobber list for R6
	netfilter: conntrack: Make global sysctls readonly in non-init netns
	net: usb: ax88179_178a: initialize local variables before use
	igb: Enable RSS for Intel I211 Ethernet Controller
	bpf: Fix masking negation logic upon negative dst register
	bpf: Fix leakage of uninitialized bpf stack under speculation
	net: qrtr: Avoid potential use after free in MHI send
	perf data: Fix error return code in perf_data__create_dir()
	capabilities: require CAP_SETFCAP to map uid 0
	perf ftrace: Fix access to pid in array when setting a pid filter
	tools/cgroup/slabinfo.py: updated to work on current kernel
	driver core: add a min_align_mask field to struct device_dma_parameters
	swiotlb: add a IO_TLB_SIZE define
	swiotlb: factor out an io_tlb_offset helper
	swiotlb: factor out a nr_slots helper
	swiotlb: clean up swiotlb_tbl_unmap_single
	swiotlb: refactor swiotlb_tbl_map_single
	swiotlb: don't modify orig_addr in swiotlb_tbl_sync_single
	swiotlb: respect min_align_mask
	nvme-pci: set min_align_mask
	ovl: fix leaked dentry
	ovl: allow upperdir inside lowerdir
	ALSA: usb-audio: Add MIDI quirk for Vox ToneLab EX
	USB: Add LPM quirk for Lenovo ThinkPad USB-C Dock Gen2 Ethernet
	USB: Add reset-resume quirk for WD19's Realtek Hub
	platform/x86: thinkpad_acpi: Correct thermal sensor allocation
	perf/core: Fix unconditional security_locked_down() call
	vfio: Depend on MMU
	Linux 5.10.35

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Iff7d5abe7b821f453bbe4d9dad94dfd35fe0a082
2021-05-08 12:45:00 +02:00