Commit Graph

975098 Commits

Author SHA1 Message Date
John Stultz
958c19b19b ANDROID: usb: typec: tcpm: Fix event storm caused by error in backport
As noted by Badhri, the patch
  https://lore.kernel.org/linux-usb/20210317181249.1062995-1-badhri@google.com/

Adds the power_supply_changed() to tcpm_psy_set_prop(), but the
patch submitted to Gerrit added it in tcpm_psy_get_prop()

This causes a uevent storm which results in lots of strange
behavior and error messages.

Thus, as suggested by Badhri, this patch removes the
power_supply_changed() call in the tcpm_psy_get_prop(), and adds
it to the tcpm_psy_get_prop() function to match the original
patch.

Debugged-and-Suggested-by: Badhri Jagan Sridharan <badhri@google.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Fixes: 6f85b7e0f8 ("UPSTREAM: usb: typec: tcpm: Invoke power_supply_changed for tcpm-source-psy-")
Change-Id: Ib161d15b82ef0fad541cda79f8832145218fb137
2021-03-19 08:38:26 +00:00
Greg Kroah-Hartman
0b6fadd02e ANDROID: GKI: USB: XHCI: add Android ABI padding to lots of xhci structures
Given that the xhci driver seems to be one of the more "modified" by
vendors, and that the xhci core is going to be built into the kernel in
the GKI 2 Android kernel, the xhci "platform" api is now a stable
boundry.

Try to handle any future changes in this api by adding some kabi padding
fields to allow for room to grow and change over the next 5+ years as
needed.

Bug: 151154716
Bug: 182336717
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I55c8cad8c8c51330fc2d72df41a1f04229a22e98
2021-03-19 08:38:00 +00:00
Marc Zyngier
6f00446c76 FROMGIT: KVM: arm64: Fix host's ZCR_EL2 restore on nVHE
We re-enter the EL1 host with CPTR_EL2.TZ set in order to
be able to lazily restore ZCR_EL2 when required.

However, the same CPTR_EL2 configuration also leads to trapping
when ZCR_EL2 is accessed from EL2. Duh!

Clear CPTR_EL2.TZ *before* writing to ZCR_EL2.

Fixes: beed09067b ("KVM: arm64: Trap host SVE accesses when the FPSIMD state is dirty")
Reported-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
(cherry picked from commit 5b08709313
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
Change-Id: Iea1c43f91edc32d176e351b80fd860d5f473fa19
2021-03-19 08:24:37 +00:00
Marc Zyngier
b0671cd753 FROMGIT: KVM: arm64: Force SCTLR_EL2.WXN when running nVHE
As the EL2 nVHE object is nicely split into sections and that
we already use differenciating permissions for data and code,
we can enable SCTLR_EL2.WXN so that we don't have to worry
about misconfiguration of the page tables.

Flip the WXN bit and get the ball running!

Acked-by: Will Deacon <will@kernel.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
(cherry picked from commit c8a4b35f50
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
Change-Id: I46464dc9ca6281d2cc2c4f23447c46240e7abced
2021-03-19 08:24:24 +00:00
Marc Zyngier
8f25c7432f FROMGIT: KVM: arm64: Turn SCTLR_ELx_FLAGS into INIT_SCTLR_EL2_MMU_ON
Only the nVHE EL2 code is using this define, so let's make it
plain that it is EL2 only, and refactor it to contain all the
bits we need when configuring the EL2 MMU, and only those.

Acked-by: Will Deacon <will@kernel.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
(cherry picked from commit fe2c8d1918
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
Change-Id: I43b562a2a0100b970910da06e2823b5e3858c06f
2021-03-19 08:24:13 +00:00
Marc Zyngier
f47a4d91e5 FROMGIT: KVM: arm64: Use INIT_SCTLR_EL2_MMU_OFF to disable the MMU on KVM teardown
Instead of doing a RMW on SCTLR_EL2 to disable the MMU, use the
existing define that loads the right set of bits.

Acked-by: Will Deacon <will@kernel.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
(cherry picked from commit bc6ddaa67a
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
Change-Id: I4e2538939f1306953cdd28e2a696d659fc8479ad
2021-03-19 08:24:00 +00:00
Marc Zyngier
3ff7250562 FROMGIT: arm64: Use INIT_SCTLR_EL1_MMU_OFF to disable the MMU on CPU restart
Instead of doing a RMW on SCTLR_EL1 to disable the MMU, use the
existing define that loads the right set of bits.

Acked-by: Will Deacon <will@kernel.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
(cherry picked from commit 45879a5775
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
Change-Id: I246b40baab912669d05bf493d1e8b6b60338f693
2021-03-19 08:22:53 +00:00
Daniel Kiss
a8a9fadaf8 FROMGIT: KVM: arm64: Enable SVE support for nVHE
Now that KVM is equipped to deal with SVE on nVHE, remove the code
preventing it from being used as well as the bits of documentation
that were mentioning the incompatibility.

Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Daniel Kiss <daniel.kiss@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
(cherry picked from commit 6e94095c55
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
Change-Id: Icf772a2d620f8c139417d01fe0bba439c28e500f
2021-03-19 08:22:06 +00:00
Marc Zyngier
b0e15c8c44 FROMGIT: KVM: arm64: Save/restore SVE state for nVHE
Implement the SVE save/restore for nVHE, following a similar
logic to that of the VHE implementation:

- the SVE state is switched on trap from EL1 to EL2

- no further changes to ZCR_EL2 occur as long as the guest isn't
  preempted or exit to userspace

- ZCR_EL2 is reset to its default value on the first SVE access from
  the host EL1, and ZCR_EL1 restored to the default guest value in
  vcpu_put()

Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
(cherry picked from commit 8c8010d69c
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
Change-Id: Ia1065d343be955c5ab4859a1a2faf371d27d257c
2021-03-19 08:21:55 +00:00
Marc Zyngier
194fd166b5 BACKPORT: FROMGIT: KVM: arm64: Trap host SVE accesses when the FPSIMD state is dirty
ZCR_EL2 controls the upper bound for ZCR_EL1, and is set to
a potentially lower limit when the guest uses SVE. In order
to restore the SVE state on the EL1 host, we must first
reset ZCR_EL2 to its original value.

To make it as lazy as possible on the EL1 host side, set
the SVE trapping in place when exiting from the guest.
On the first EL1 access to SVE, ZCR_EL2 will be restored
to its full glory.

Suggested-by: Andrew Scull <ascull@google.com>
Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
(cherry picked from commit beed09067b
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
[will: Fixed trivial conflicts with host stage-2 series]
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
Change-Id: I4e43e3ea710f105fe15b08825678109ac5ee2b78
2021-03-19 08:21:18 +00:00
Marc Zyngier
507e10616c FROMGIT: KVM: arm64: Save guest's ZCR_EL1 before saving the FPSIMD state
Make sure the guest's ZCR_EL1 is saved before we save/flush the
state. This will be useful in later patches.

Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
(cherry picked from commit b145a8437a
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
Change-Id: I1e3ee364780d9f63436d246431cd82e651dc6571
2021-03-19 08:21:05 +00:00
Marc Zyngier
4cb78b26ea FROMGIT: KVM: arm64: Map SVE context at EL2 when available
When running on nVHE, and that the vcpu supports SVE, map the
SVE state at EL2 so that KVM can access it.

Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
(cherry picked from commit 0a9a98fda3
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
Change-Id: Iacc17d38754d40ed36be2c1ff5e5104b75974415
2021-03-19 08:20:55 +00:00
Marc Zyngier
1105b4d1ce BACKPORT: FROMGIT: KVM: arm64: Rework SVE host-save/guest-restore
In order to keep the code readable, move the host-save/guest-restore
sequences in their own functions, with the following changes:
- the hypervisor ZCR is now set from C code
- ZCR_EL2 is always used as the EL2 accessor

This results in some minor assembler macro rework.
No functional change intended.

Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
(cherry picked from commit 52029198c1
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
[will: Fixed trivial context conflict with host stage-2 series in switch.h]
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
Change-Id: Ibcacce83e2eb142ae5c5672b534def83892060bc
2021-03-19 08:20:43 +00:00
Marc Zyngier
57171b3636 FROMGIT: arm64: sve: Provide a conditional update accessor for ZCR_ELx
A common pattern is to conditionally update ZCR_ELx in order
to avoid the "self-synchronizing" effect that writing to this
register has.

Let's provide an accessor that does exactly this.

Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
(cherry picked from commit 71ce1ae56e
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
Change-Id: I50af5ed0a57182d038f26c12a6ca9e733ac97ba4
2021-03-19 08:20:11 +00:00
Marc Zyngier
ac5f5708bb FROMGIT: KVM: arm64: Introduce vcpu_sve_vq() helper
The KVM code contains a number of "sve_vq_from_vl(vcpu->arch.sve_max_vl)"
instances, and we are about to add more.

Introduce vcpu_sve_vq() as a shorthand for this expression.

Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
(cherry picked from commit 468f3477ef
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
Change-Id: Ibfa1776c63b84c5b83504b94f76905d4da0dd979
2021-03-19 08:19:49 +00:00
Marc Zyngier
f9bab75599 FROMGIT: KVM: arm64: Let vcpu_sve_pffr() handle HYP VAs
The vcpu_sve_pffr() returns a pointer, which can be an interesting
thing to do on nVHE. Wrap the pointer with kern_hyp_va(), and
take this opportunity to remove the unnecessary casts (sve_state
being a void *).

Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
(cherry picked from commit 985d3a1bea
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
Change-Id: I01203df5e118b35c62f502652da6e6db7f521f7b
2021-03-19 08:19:37 +00:00
Marc Zyngier
c2469fa4b4 FROMGIT: KVM: arm64: Use {read,write}_sysreg_el1 to access ZCR_EL1
Switch to the unified EL1 accessors for ZCR_EL1, which will make
things easier for nVHE support.

Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
(cherry picked from commit 83857371d4
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
Change-Id: I33aeccbd0cf915db9fbc0cac8543394134de490e
2021-03-19 08:19:26 +00:00
Marc Zyngier
f5e060d65e FROMGIT: KVM: arm64: Provide KVM's own save/restore SVE primitives
as we are about to change the way KVM deals with SVE, provide
KVM with its own save/restore SVE primitives.

No functional change intended.

Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
(cherry picked from commit 297b8603e3
 git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next)
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 178098380
Test: atest VirtualizationHostTestCases on an EL2-enabled device
Change-Id: I77414def3e06f71324eec25f5a204d04e6c5c328
2021-03-19 08:19:15 +00:00
Greg Kroah-Hartman
af855ca1c9 ANDROID: GKI: USB: Gadget: add Android ABI padding to struct usb_gadget
Over time, this structure is being changed a bunch to fix issues found
in the gadget code as more and more people stress it.  So add padding to
handle any needed future changes that might occur.

Of course, now that the padding is there, there never will be any need
to change this structure again...

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I496797469268cc5d3cfafdb19c141b6b6196fe72
2021-03-19 06:18:51 +00:00
Liujie Xie
24149445ad ANDROID: vendor_hooks: Add hooks for memory when debug
Add vendors hooks for recording memory used

Bug: 182443489
Signed-off-by: Liujie Xie <xieliujie@oppo.com>
Change-Id: I62d8bb2b6650d8b187b433f97eb833ef0b784df1
2021-03-19 04:54:07 +00:00
duwenchao
00185a421a ANDROID: vendor_hooks: Add hooks for ufs scheduler
Add hooks to support oem's ufs scheduler feature.

Bug: 183085044
Signed-off-by: duwenchao <duwenchao@xiaomi.com>
Change-Id: I09bf9cba33412c81e4da83292772c0e95cf32022
2021-03-18 18:26:18 +00:00
Greg Kroah-Hartman
b8981993c2 ANDROID: GKI: sound/usb/card.h: add Android ABI padding to struct snd_usb_endpoint
There seems to be lots of people wanting to change this structure, and
while it feels internal, due to some SoC patches, there's an ABI that
needs to be preserved here over time.

So add some padding to struct snd_usb_endpoint so that we can maintain
this succesfully in the future.

Of course, now that the padding is there, there never will be any need
to change this structure again...

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I21cb3abbdca2961e33a94b2bc48b49f3fadbd206
2021-03-18 16:21:14 +01:00
Greg Kroah-Hartman
5a56f5119e ANDROID: GKI: user_namespace.h: add Android ABI padding to a structure
Try to mitigate potential future driver core api changes by adding a
padding to struct user_namespace.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I2c41281b191cd252db2ddc792699d869ce8d7a4d
2021-03-18 16:20:44 +01:00
Greg Kroah-Hartman
599e75fcfd ANDROID: GKI: timer.h: add Android ABI padding to a structure
Try to mitigate potential future driver core api changes by adding a
padding to struct timer_list.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I74673e2271cd757c4871c9bcb69fd73bb22a722b
2021-03-18 16:20:25 +01:00
Greg Kroah-Hartman
303a28f485 ANDROID: GKI: quota.h: add Android ABI padding to some structures
Try to mitigate potential future driver core api changes by adding a
padding to struct quota_format_ops, struct dquot_operations, and struct
quotactl_ops.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ia957d2f8d9b1a6939cddedc16a7481e9de1a8866
2021-03-18 16:20:07 +01:00
Greg Kroah-Hartman
a06d91262a ANDROID: GKI: mmu_notifier.h: add Android ABI padding to some structures
Try to mitigate potential future driver core api changes by adding a
padding to struct mmu_notifier_ops and struct mmu_notifier.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: If631445abf20c22830a1c764ff2ccd662a7bd204
2021-03-18 16:19:39 +01:00
Greg Kroah-Hartman
8faaa07702 ANDROID: GKI: mm.h: add Android ABI padding to a structure
Try to mitigate potential future driver core api changes by adding a
padding to struct vm_operations_struct.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I78f84148ef4d3524bd6c5b78e53e06503a4ac3ae
2021-03-18 16:18:52 +01:00
Greg Kroah-Hartman
f21777c57f ANDROID: GKI: kobject.h: add Android ABI padding to some structures
Try to mitigate potential future driver core api changes by adding a
padding to struct kobject, struct kobj_type, and struct kset.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I3c28826dc314c7f1b5c9bb167be82089d53768bb
2021-03-18 16:18:19 +01:00
Greg Kroah-Hartman
31f6b7a1ae ANDROID: GKI: kernfs.h: add Android ABI padding to some structures
Try to mitigate potential future driver core api changes by adding a
padding to struct kernfs_syscall_ops and struct kernfs_ops.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I1fcb0b81c3ea7d5300da283b275391f95d6d4ec8
2021-03-18 16:18:05 +01:00
Greg Kroah-Hartman
1a517d8668 ANDROID: GKI: irqdomain.h: add Android ABI padding to a structure
Try to mitigate potential future driver core api changes by adding a
padding to struct irq_domain.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I8ff0c2162ca5f7f0b6c7a51bf341c6b1b1c856e8
2021-03-18 16:17:47 +01:00
Greg Kroah-Hartman
c6adf0c7b9 ANDROID: GKI: ioport.h: add Android ABI padding to a structure
Try to mitigate potential future driver core api changes by adding a
padding to struct resource.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I5ff4401c540be7d095f1db27370281b7220af030
2021-03-18 16:17:31 +01:00
Greg Kroah-Hartman
c469de24a1 ANDROID: GKI: iomap.h: add Android ABI padding to a structure
Try to mitigate potential future driver core api changes by adding a
padding to struct iomap_ops.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I1803d5163f7a1d0320f567b983a8241777284c5e
2021-03-18 16:17:14 +01:00
Greg Kroah-Hartman
3cb5c28964 ANDROID: GKI: hrtimer.h: add Android ABI padding to a structure
Try to mitigate potential future driver core api changes by adding a
padding to struct hrtimer.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I5432e05386265281d993199599c6f9dcd17a9daf
2021-03-18 16:10:11 +01:00
Greg Kroah-Hartman
eff6517b1e ANDROID: GKI: genhd.h: add Android ABI padding to some structures
Try to mitigate potential future driver core api changes by adding a
padding to struct hd_struct, struct blk_integrity, and struct gendisk.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I5d19bf942fbedc64f705f5d27ae629c57209df27
2021-03-18 16:09:52 +01:00
Greg Kroah-Hartman
9a92773dc8 ANDROID: GKI: ethtool.h: add Android ABI padding to a structure
Try to mitigate potential future driver core api changes by adding a
padding to struct ethtool_ops.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: If9f449cb74e81d048a1c41b33c6b7c5b564ecaf3
2021-03-18 16:09:29 +01:00
Greg Kroah-Hartman
774168de67 ANDROID: GKI: dma-mapping.h: add Android ABI padding to a structure
Try to mitigate potential future driver core api changes by adding a
padding to struct dma_map_ops.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Icbec584dee3716f341a7831a4810025f690eab4a
2021-03-18 16:08:25 +01:00
Greg Kroah-Hartman
73ff58b01f ANDROID: GKI: networking: add Android ABI padding to a lot of networking structures
Try to mitigate potential future driver core api changes by adding a
padding to a lot of different networking structures:
	struct ipv6_devconf
	struct proto_ops
	struct header_ops
	struct napi_struct
	struct netdev_queue
	struct netdev_rx_queue
	struct xfrmdev_ops
	struct net_device_ops
	struct net_device
	struct packet_type
	struct sk_buff
	struct tlsdev_ops

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I590f004754dbc8beafa40e71cac70a0938c38b4a
2021-03-18 16:04:29 +01:00
Greg Kroah-Hartman
f0688df6b5 ANDROID: GKI: blk_types.h: add Android ABI padding to a structure
Try to mitigate potential future driver core api changes by adding a
padding to struct bio.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ib69c7bb8b553cacb9cb7bc020d8ac2bbc75621ba
2021-03-18 16:03:05 +01:00
Greg Kroah-Hartman
4a895f1f2b ANDROID: GKI: scsi.h: add Android ABI padding to a structure
Try to mitigate potential future driver core api changes by adding a
padding to struct scsi_disk.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I1191c786cb341df43a40fa1a82789759b0f431cf
2021-03-18 16:02:51 +01:00
Greg Kroah-Hartman
48691266ca ANDROID: GKI: pci: add Android ABI padding to some structures
Try to mitigate potential future driver core api changes by adding a
padding to struct pci_sriov, struct pci_dev, struct pci_bus, and struct
pci_driver.

Based on a change made to the RHEL/CENTOS 8 kernel.

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I236df60165b25a33b06fc81f76014162401ba742
2021-03-18 16:02:34 +01:00
Greg Kroah-Hartman
4c95a92b84 ANDROID: GKI: add Android ABI padding to struct nf_conn
Try to mitigate potential future driver core api changes by adding
padding to struct nf_conn;

Bug: 151154716
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ib18a9a929d351c66556f1f27b217cbf22b733a10
2021-03-18 14:54:15 +01:00
Badhri Jagan Sridharan
e6f5502bc3 UPSTREAM: usb: typec: tcpm: Skip sink_cap query only when VDM sm is busy
When port partner responds "Not supported" to the DiscIdentity command,
VDM state machine can remain in NVDM_STATE_ERR_TMOUT and this causes
querying sink cap to be skipped indefinitely. Hence check for
vdm_sm_running instead of checking for VDM_STATE_DONE.

Fixes: 8dc4bd0736 ("usb: typec: tcpm: Add support for Sink Fast Role SWAP(FRS)")
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210318064805.3747831-1-badhri@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 2b8c956ea6)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ie73eed677050a4ef15f2d36e159bf7e9c3879bfb
2021-03-18 09:48:17 +01:00
Badhri Jagan Sridharan
36547f2f6d FROMGIT: usb: typec: tcpm: PD3.0 sinks can send Discover Identity even in device mode
>From 6.4.4.2 Structured VDM:
• Either Port May be an Initiator of Structured VDMs except for the Enter
Mode and Exit Mode Commands which Shall only be initiated by the DFP."

The above implies that when PD3.0 link is established PD3.0 sinks
can send out discover identity command/AMS once PD negotiation is done.
This allows discovering identity for PD3.0 UFP ports as well.

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Link: https://lore.kernel.org/r/20210318065604.3757307-1-badhri@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit e00943e916
 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: I432847037c8e89cbacc7ca402b23568aa02ef42d
2021-03-18 09:36:38 +01:00
Jim Lin
3f7ada406d UPSTREAM: usb: gadget: configfs: Fix KASAN use-after-free
When gadget is disconnected, running sequence is like this.
. composite_disconnect
. Call trace:
  usb_string_copy+0xd0/0x128
  gadget_config_name_configuration_store+0x4
  gadget_config_name_attr_store+0x40/0x50
  configfs_write_file+0x198/0x1f4
  vfs_write+0x100/0x220
  SyS_write+0x58/0xa8
. configfs_composite_unbind
. configfs_composite_bind

In configfs_composite_bind, it has
"cn->strings.s = cn->configuration;"

When usb_string_copy is invoked. it would
allocate memory, copy input string, release previous pointed memory space,
and use new allocated memory.

When gadget is connected, host sends down request to get information.
Call trace:
  usb_gadget_get_string+0xec/0x168
  lookup_string+0x64/0x98
  composite_setup+0xa34/0x1ee8

If gadget is disconnected and connected quickly, in the failed case,
cn->configuration memory has been released by usb_string_copy kfree but
configfs_composite_bind hasn't been run in time to assign new allocated
"cn->configuration" pointer to "cn->strings.s".

When "strlen(s->s) of usb_gadget_get_string is being executed, the dangling
memory is accessed, "BUG: KASAN: use-after-free" error occurs.

Cc: stable@vger.kernel.org
Signed-off-by: Jim Lin <jilin@nvidia.com>
Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com>
Link: https://lore.kernel.org/r/1615444961-13376-1-git-send-email-macpaul.lin@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 98f153a10d)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I701efe7bf8b20ab35c84e0441a52633d223224e9
2021-03-18 06:49:05 +00:00
Elias Rudberg
9bd96584f4 UPSTREAM: usb: typec: Remove vdo[3] part of tps6598x_rx_identity_reg struct
Remove the unused "u32 vdo[3]" part in the tps6598x_rx_identity_reg
struct. This helps avoid "failed to register partner" errors which
happen when tps6598x_read_partner_identity() fails because the
amount of data read is 12 bytes smaller than the struct size.
Note that vdo[3] is already in usb_pd_identity and hence
shouldn't be added to tps6598x_rx_identity_reg as well.

Fixes: f6c56ca91b ("usb: typec: Add the Product Type VDOs to struct usb_pd_identity")
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Guido Günther <agx@sigxcpu.org>
Signed-off-by: Elias Rudberg <mail@eliasrudberg.se>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210311124710.6563-1-mail@eliasrudberg.se
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 3cac9104be)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I889e67c743ff494609477af21e1cfd672affeb73
2021-03-18 06:48:37 +00:00
Wesley Cheng
f2e7bdcdfa UPSTREAM: usb: dwc3: gadget: Prevent EP queuing while stopping transfers
In the situations where the DWC3 gadget stops active transfers, once
calling the dwc3_gadget_giveback(), there is a chance where a function
driver can queue a new USB request in between the time where the dwc3
lock has been released and re-aquired.  This occurs after we've already
issued an ENDXFER command.  When the stop active transfers continues
to remove USB requests from all dep lists, the newly added request will
also be removed, while controller still has an active TRB for it.
This can lead to the controller accessing an unmapped memory address.

Fix this by ensuring parameters to prevent EP queuing are set before
calling the stop active transfers API.

Fixes: ae7e86108b ("usb: dwc3: Stop active transfers before halting the controller")
Signed-off-by: Wesley Cheng <wcheng@codeaurora.org>
Link: https://lore.kernel.org/r/1615507142-23097-1-git-send-email-wcheng@codeaurora.org
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit f09ddcfcb8)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I7b12af154c9c4a0768a30767f4c1abe5b9c27bc7
2021-03-18 06:47:50 +00:00
Badhri Jagan Sridharan
462c92e8f2 FROMGIT: usb: typec: tcpci: Added few missing TCPCI register definitions
This change adds some of the register bit definitions from the TCPCI spec:
https://www.usb.org/sites/default/files/documents/
usb-port_controller_specification_rev2.0_v1.0_0.pdf

Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Link: https://lore.kernel.org/r/20210316221304.391206-1-badhri@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 55986146e103607ba5a7aba3c6110736b809a887
 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: Ie93044ca67a36265ddcf23e6557a6ce9b4db30a2
2021-03-18 06:47:04 +00:00
Badhri Jagan Sridharan
6f85b7e0f8 UPSTREAM: usb: typec: tcpm: Invoke power_supply_changed for tcpm-source-psy-
tcpm-source-psy- does not invoke power_supply_changed API when
one of the published power supply properties is changed.
power_supply_changed needs to be called to notify
userspace clients(uevents) and kernel clients.

Fixes: f2a8aa053c ("typec: tcpm: Represent source supply through power_supply")
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20210317181249.1062995-1-badhri@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 86629e098a)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I6c24e258f8fa19357a8c00027b498662cbaeb49b
2021-03-18 06:46:52 +00:00
Todd Kjos
8cf94785bb Revert "ANDROID: GKI: Enable bounds sanitizer"
This reverts commit 5f85626b13.

Temporarily reverting to let partner stabilize. Planning to
re-enable by end of March.

Bug: 182884953
Change-Id: Iffa933d7065d206a73750bd546adc71c637e1581
Signed-off-by: Todd Kjos <tkjos@google.com>
2021-03-17 21:22:15 +00:00
Todd Kjos
0eecc2aa30 ANDROID: GKI: temporarily disable LTO/CFI
Temporarily reverting to let partner stabilize. Planning to
re-enable by end of March.

Bug: 182884953
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I83dec946fcb9b6872d3f91aa33afd2ae71a4fe97
2021-03-17 21:21:21 +00:00