Commit Graph

1159639 Commits

Author SHA1 Message Date
Ian Rogers
fd5c2e1399 UPSTREAM: objtool: Install libsubcmd in build
Including from tools/lib can create inadvertent dependencies. Install
libsubcmd in the objtool build and then include the headers from
there.

Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20230126190606.40739-2-irogers@google.com
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

Bug: 336872347
Bug: 335829879
Test: build x86_64 kernel with glibc 2.38
Change-Id: Id09c5b222519073214dbc01e151e59b18afb1ea8
(cherry picked from commit bdb8bf7d56)
Signed-off-by: Yifan Hong <elsk@google.com>
2024-06-17 18:15:32 +00:00
Kuniyuki Iwashima
de6fb073c6 UPSTREAM: af_unix: Update unix_sk(sk)->oob_skb under sk_receive_queue lock.
[ Upstream commit 9841991a446c87f90f66f4b9fee6fe934c1336a2 ]

Billy Jheng Bing-Jhong reported a race between __unix_gc() and
queue_oob().

__unix_gc() tries to garbage-collect close()d inflight sockets,
and then if the socket has MSG_OOB in unix_sk(sk)->oob_skb, GC
will drop the reference and set NULL to it locklessly.

However, the peer socket still can send MSG_OOB message and
queue_oob() can update unix_sk(sk)->oob_skb concurrently, leading
NULL pointer dereference. [0]

To fix the issue, let's update unix_sk(sk)->oob_skb under the
sk_receive_queue's lock and take it everywhere we touch oob_skb.

Note that we defer kfree_skb() in manage_oob() to silence lockdep
false-positive (See [1]).

[0]:
BUG: kernel NULL pointer dereference, address: 0000000000000008
 PF: supervisor write access in kernel mode
 PF: error_code(0x0002) - not-present page
PGD 8000000009f5e067 P4D 8000000009f5e067 PUD 9f5d067 PMD 0
Oops: 0002 [#1] PREEMPT SMP PTI
CPU: 3 PID: 50 Comm: kworker/3:1 Not tainted 6.9.0-rc5-00191-gd091e579b864 #110
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
Workqueue: events delayed_fput
RIP: 0010:skb_dequeue (./include/linux/skbuff.h:2386 ./include/linux/skbuff.h:2402 net/core/skbuff.c:3847)
Code: 39 e3 74 3e 8b 43 10 48 89 ef 83 e8 01 89 43 10 49 8b 44 24 08 49 c7 44 24 08 00 00 00 00 49 8b 14 24 49 c7 04 24 00 00 00 00 <48> 89 42 08 48 89 10 e8 e7 c5 42 00 4c 89 e0 5b 5d 41 5c c3 cc cc
RSP: 0018:ffffc900001bfd48 EFLAGS: 00000002
RAX: 0000000000000000 RBX: ffff8880088f5ae8 RCX: 00000000361289f9
RDX: 0000000000000000 RSI: 0000000000000206 RDI: ffff8880088f5b00
RBP: ffff8880088f5b00 R08: 0000000000080000 R09: 0000000000000001
R10: 0000000000000003 R11: 0000000000000001 R12: ffff8880056b6a00
R13: ffff8880088f5280 R14: 0000000000000001 R15: ffff8880088f5a80
FS:  0000000000000000(0000) GS:ffff88807dd80000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000008 CR3: 0000000006314000 CR4: 00000000007506f0
PKRU: 55555554
Call Trace:
 <TASK>
 unix_release_sock (net/unix/af_unix.c:654)
 unix_release (net/unix/af_unix.c:1050)
 __sock_release (net/socket.c:660)
 sock_close (net/socket.c:1423)
 __fput (fs/file_table.c:423)
 delayed_fput (fs/file_table.c:444 (discriminator 3))
 process_one_work (kernel/workqueue.c:3259)
 worker_thread (kernel/workqueue.c:3329 kernel/workqueue.c:3416)
 kthread (kernel/kthread.c:388)
 ret_from_fork (arch/x86/kernel/process.c:153)
 ret_from_fork_asm (arch/x86/entry/entry_64.S:257)
 </TASK>
Modules linked in:
CR2: 0000000000000008

Bug: 342490466
Link: https://lore.kernel.org/netdev/a00d3993-c461-43f2-be6d-07259c98509a@rbox.co/ [1]
Fixes: 1279f9d9dec2 ("af_unix: Call kfree_skb() for dead unix_(sk)->oob_skb in GC.")
Reported-by: Billy Jheng Bing-Jhong <billy@starlabs.sg>
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://lore.kernel.org/r/20240516134835.8332-1-kuniyu@amazon.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 518a994aa0b87d96f1bc6678a7035df5d1fcd7a1)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Ibf78b113496b5388a63207e7e582f77ddda8dec5
2024-06-17 09:58:14 +00:00
Kuniyuki Iwashima
0e9ee9221f UPSTREAM: af_unix: Don't peek OOB data without MSG_OOB.
[ Upstream commit 22dd70eb2c3d754862964377a75abafd3167346b ]

Currently, we can read OOB data without MSG_OOB by using MSG_PEEK
when OOB data is sitting on the front row, which is apparently
wrong.

  >>> from socket import *
  >>> c1, c2 = socketpair(AF_UNIX, SOCK_STREAM)
  >>> c1.send(b'a', MSG_OOB)
  1
  >>> c2.recv(1, MSG_PEEK | MSG_DONTWAIT)
  b'a'

If manage_oob() is called when no data has been copied, we only
check if the socket enables SO_OOBINLINE or MSG_PEEK is not used.
Otherwise, the skb is returned as is.

However, here we should return NULL if MSG_PEEK is set and no data
has been copied.

Also, in such a case, we should not jump to the redo label because
we will be caught in the loop and hog the CPU until normal data
comes in.

Then, we need to handle skb == NULL case with the if-clause below
the manage_oob() block.

With this patch:

  >>> from socket import *
  >>> c1, c2 = socketpair(AF_UNIX, SOCK_STREAM)
  >>> c1.send(b'a', MSG_OOB)
  1
  >>> c2.recv(1, MSG_PEEK | MSG_DONTWAIT)
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  BlockingIOError: [Errno 11] Resource temporarily unavailable

Bug: 342490466
Fixes: 314001f0bf ("af_unix: Add OOB support")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://lore.kernel.org/r/20240410171016.7621-3-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 022d81a709)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I4728977f8f908c19dfa5c861c7381a50499b7fe0
2024-06-17 09:58:10 +00:00
Kuniyuki Iwashima
30d168eb06 UPSTREAM: af_unix: Clear stale u->oob_skb.
[ Upstream commit b46f4eaa4f0ec38909fb0072eea3aeddb32f954e ]

syzkaller started to report deadlock of unix_gc_lock after commit
4090fa373f0e ("af_unix: Replace garbage collection algorithm."), but
it just uncovers the bug that has been there since commit 314001f0bf
("af_unix: Add OOB support").

The repro basically does the following.

  from socket import *
  from array import array

  c1, c2 = socketpair(AF_UNIX, SOCK_STREAM)
  c1.sendmsg([b'a'], [(SOL_SOCKET, SCM_RIGHTS, array("i", [c2.fileno()]))], MSG_OOB)
  c2.recv(1)  # blocked as no normal data in recv queue

  c2.close()  # done async and unblock recv()
  c1.close()  # done async and trigger GC

A socket sends its file descriptor to itself as OOB data and tries to
receive normal data, but finally recv() fails due to async close().

The problem here is wrong handling of OOB skb in manage_oob().  When
recvmsg() is called without MSG_OOB, manage_oob() is called to check
if the peeked skb is OOB skb.  In such a case, manage_oob() pops it
out of the receive queue but does not clear unix_sock(sk)->oob_skb.
This is wrong in terms of uAPI.

Let's say we send "hello" with MSG_OOB, and "world" without MSG_OOB.
The 'o' is handled as OOB data.  When recv() is called twice without
MSG_OOB, the OOB data should be lost.

  >>> from socket import *
  >>> c1, c2 = socketpair(AF_UNIX, SOCK_STREAM, 0)
  >>> c1.send(b'hello', MSG_OOB)  # 'o' is OOB data
  5
  >>> c1.send(b'world')
  5
  >>> c2.recv(5)  # OOB data is not received
  b'hell'
  >>> c2.recv(5)  # OOB date is skipped
  b'world'
  >>> c2.recv(5, MSG_OOB)  # This should return an error
  b'o'

In the same situation, TCP actually returns -EINVAL for the last
recv().

Also, if we do not clear unix_sk(sk)->oob_skb, unix_poll() always set
EPOLLPRI even though the data has passed through by previous recv().

To avoid these issues, we must clear unix_sk(sk)->oob_skb when dequeuing
it from recv queue.

The reason why the old GC did not trigger the deadlock is because the
old GC relied on the receive queue to detect the loop.

When it is triggered, the socket with OOB data is marked as GC candidate
because file refcount == inflight count (1).  However, after traversing
all inflight sockets, the socket still has a positive inflight count (1),
thus the socket is excluded from candidates.  Then, the old GC lose the
chance to garbage-collect the socket.

With the old GC, the repro continues to create true garbage that will
never be freed nor detected by kmemleak as it's linked to the global
inflight list.  That's why we couldn't even notice the issue.

Bug: 342490466
Fixes: 314001f0bf ("af_unix: Add OOB support")
Reported-by: syzbot+7f7f201cc2668a8fd169@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=7f7f201cc2668a8fd169
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20240405221057.2406-1-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 601a89ea24)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Ib4a11eed6b5710d9934d4f31cd29dfd4c7b3658f
2024-06-17 09:58:07 +00:00
Jaegeuk Kim
c0618d182a Revert "f2fs: fix to tag gcing flag on page during block migration"
This reverts commit 7c972c8945.

[  146.693904][ T8878] WARNING: CPU: 2 PID: 8878 at fs/f2fs/segment.c:3335 f2fs_allocate_data_block+0x130/0xd08

panic in:

f2fs_write_data_pages
 -> f2fs_write_multi_pages
  -> f2fs_write_single_data_page
   -> f2fs_do_write_data_page
    -> f2fs_outplace_write_data
     -> do_write_page
      -> f2fs_allocate_data_block

 if (from_gc) {
         f2fs_bug_on(sbi, GET_SEGNO(sbi, old_blkaddr) == NULL_SEGNO);
         se = get_seg_entry(sbi, GET_SEGNO(sbi, old_blkaddr));
         sanity_check_seg_type(sbi, se->type);
         f2fs_bug_on(sbi, IS_NODESEG(se->type));
 }

Bug: 345273844
Change-Id: I62732bbcb37a7864588886b862b590a463b4d1d9
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2024-06-16 07:24:12 -07:00
Yifan Hong
25216be1ac ANDROID: Delete obsolete 16k_gki.fragment.
The correct fragment is the one in build/kernel,
enabled by --page_size or kernel_build.page_size.
This fragment:

- Does not correctly enable incremental FS
- Does not correctly clear LOCALVERSION that
  has 4k for the 4k build.

Bug: 347036722
Bug: 340631213
Bug: 338659380
Change-Id: I31cb004ca639d8ec3dd6201112391c7214971eba
Signed-off-by: Yifan Hong <elsk@google.com>
2024-06-13 17:56:12 -07:00
Jaegeuk Kim
4c45e2f340 UPSTREAM: f2fs: clear writeback when compression failed
Let's stop issuing compressed writes and clear their writeback flags.

Bug: 345273844
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Change-Id: I69835bbcf0ac993cc03b11bcd7bdcfa2ff2bbd4a
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit 2174035a7f1148a52f5a3f371f04224168b5b00a)
2024-06-13 19:21:22 +00:00
Ajit Singh Raghav
7c734edeaa ANDROID: GKI: Add symbol list for exynosauto
dev_forward_skb
  dev_mc_sync
  dev_pre_changeaddr_notify
  dev_set_allmulti
  dev_uc_sync
  ip6_route_input_lookup
  ip_route_input_noref
  netdev_is_rx_handler_busy
  register_inet6addr_validator_notifier
  register_inetaddr_validator_notifier
  unregister_inet6addr_validator_notifier
  unregister_inetaddr_validator_notifier

These symbols are required so that our vendor can use IPVLAN and IP_NF_TARGET_TTL modules. These are not custom modules and are already part of android.

9 function symbol(s) added
  'int dev_forward_skb(struct net_device*, struct sk_buff*)'
  'int dev_pre_changeaddr_notify(struct net_device*, const char*, struct netlink_ext_ack*)'
  'struct dst_entry* ip6_route_input_lookup(struct net*, struct net_device*, struct flowi6*, const struct sk_buff*, int)'
  'int ip_route_input_noref(struct sk_buff*, __be32, __be32, u8, struct net_device*)'
  'bool netdev_is_rx_handler_busy(struct net_device*)'
  'int register_inet6addr_validator_notifier(struct notifier_block*)'
  'int register_inetaddr_validator_notifier(struct notifier_block*)'
  'int unregister_inet6addr_validator_notifier(struct notifier_block*)'
  'int unregister_inetaddr_validator_notifier(struct notifier_block*)'

Bug: 345881188

Change-Id: I2d129c0174844e692b1eb4dbbe54f4790fdeda40
Signed-off-by: Ajit Singh Raghav <ajit.raghav@samsung.com>
2024-06-13 08:53:38 +00:00
Peter Collingbourne
b22d7c4ca0 FROMGIT: arm64: mte: Make mte_check_tfsr_*() conditional on KASAN instead of MTE
The check in mte_check_tfsr_el1() is only necessary if HW tag
based KASAN is enabled. However, we were also executing the check
if MTE is enabled and KASAN is enabled at build time but disabled
at runtime. This turned out to cause a measurable increase in
power consumption on a specific microarchitecture after enabling
MTE. Moreover, on the same system, an increase in invalid syscall
latency (as measured by [1]) of around 20-30% (depending on the
cluster) was observed after enabling MTE; this almost entirely goes
away after removing this check. Therefore, make the check conditional
on whether KASAN is enabled rather than on whether MTE is enabled.

[1] https://lore.kernel.org/all/CAMn1gO4MwRV8bmFJ_SeY5tsYNPn2ZP56LjAhafygjFaKuu5ouw@mail.gmail.com/

Bug: 331979504
(cherry picked from commit 26ca4423604f15930d96088dc5238f29dc11d5bc
 https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/mte)
Signed-off-by: Peter Collingbourne <pcc@google.com>
Change-Id: I22d98d1483dd400a95595946552b769a5a1ad7bd
Link: https://linux-review.googlesource.com/id/I22d98d1483dd400a95595946552b769a5a1ad7bd
Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
Link: https://lore.kernel.org/r/20240528225131.3577704-1-pcc@google.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
2024-06-12 11:25:46 -07:00
Danesh Petigara
1331956fb5 ANDROID: gki_defconfig: Disable CONFIG_BRCMSTB_DPFE and CONFIG_BRCMSTB_MEMC
Recent changes to gki_defconfig enable CONFIG_MEMORY which results
in CONFIG_BRCMSTB_DPFE and CONFIG_BRCMSTB_MEMC being enabled as
builtin modules. Disable the two drivers as the Broadcom STB SoCs
expect them to be configured as loadable modules.

Bug: 346510475
Fixes: 974a6f430e ("ANDROID: gki_defconfig: Enable Tegra SoCs")
Change-Id: I80bf0ce419992d947468b7054327ba80f611d316
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
Signed-off-by: Pierre Couillaud <pierre@broadcom.com>
2024-06-12 13:15:55 +00:00
Zhiguo Niu
002be199aa FROMGIT: f2fs: fix to avoid use SSR allocate when do defragment
SSR allocate mode will be used when doing file defragment
if ATGC is working at the same time, that is because
set_page_private_gcing may make CURSEG_ALL_DATA_ATGC segment
type got in f2fs_allocate_data_block when defragment page
is writeback, which may cause file fragmentation is worse.

A file with 2 fragmentations is changed as following after defragment:

----------------file info-------------------
sensorsdata :
--------------------------------------------
dev       [254:48]
ino       [0x    3029 : 12329]
mode      [0x    81b0 : 33200]
nlink     [0x       1 : 1]
uid       [0x    27e6 : 10214]
gid       [0x    27e6 : 10214]
size      [0x  242000 : 2367488]
blksize   [0x    1000 : 4096]
blocks    [0x    1210 : 4624]
--------------------------------------------

file_pos   start_blk     end_blk        blks
       0    11361121    11361207          87
  356352    11361215    11361216           2
  364544    11361218    11361218           1
  368640    11361220    11361221           2
  376832    11361224    11361225           2
  385024    11361227    11361238          12
  434176    11361240    11361252          13
  487424    11361254    11361254           1
  491520    11361271    11361279           9
  528384     3681794     3681795           2
  536576     3681797     3681797           1
  540672     3681799     3681799           1
  544768     3681803     3681803           1
  548864     3681805     3681805           1
  552960     3681807     3681807           1
  557056     3681809     3681809           1

Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Bug: 345273844
(cherry picked from commit 9e2fc0b6f2cd47f4bbed67c2828d67149b96039f
 https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test)
Change-Id: I1c68e1d2c289482db31c7e882e4300423d4c97f3
Signed-off-by: Daeho Jeong <daehojeong@google.com>
2024-06-12 10:15:44 +00:00
Kalesh Singh
dda68b1657 ANDROID: 16K: Only check basename of linker context
Depending on the platform binary being executed, the linker
(interpreter) requested can be one of:

    1) /system/bin/bootstrap/linker64
    2) /system/bin/linker64
    3) /apex/com.android.runtime/bin/linker64

Relax the check to the basename (linker64), instead of the path.

Bug: 330767927
Bug: 335584973
Change-Id: I4a1f95b7cecd126f85ad8cefd9ff10d272947f9e
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-06-11 15:51:46 -07:00
Kalesh Singh
65aed0e2f7 ANDROID: 16K: Avoid and document padding madvise lock warning
Usually to modify vm_flags we need to take exclusive mmap_lock but here
only have the lock in read mode, to avoid all DONTNEED/DONTNEED_LOCKED
calls needing the write lock.

A race to the flags update can only happen with another MADV_DONTNEED on
the same process and same range (VMA).

In practice, this specific scenario is not possible  because the action
that could cause it is usually performed at most once per VMA and only by the dynamic linker.

Forego protection for this case, to avoid penalties in the common cases.

Bug: 344634072
Change-Id: I54ac1f204e0445291f3df3872fbaa16b37722812
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2024-06-11 16:26:56 +00:00
Giuliano Procida
ec795e4eaa ANDROID: arm64: vdso32: support user-supplied flags
This introduces a new environment variable, KCPPFLAGS_COMPAT.

One use-case is to ensure -ffile-prefix-map is passed to the arm32
compiler to normalise compilation directory and make the ELF build ID
reproducible.

Bug: 345452375
Change-Id: I6ae1df58172f4dadeac1dbbee2e3241b704a9256
Signed-off-by: Giuliano Procida <gprocida@google.com>
2024-06-10 16:22:50 +00:00
Pierre Couillaud
ac9706483e ANDROID: GKI: Add initial symbol list for bcmstb
Add initial symbol list for the bcmstb target that represents
the Broadcom Set Top Box SoCs.

INFO: 32 function symbol(s) added
  'u32 brcmstb_get_family_id()'
  'u32 brcmstb_get_product_id()'
  'int clk_hw_register_clkdev(struct clk_hw*, const char*, const char*)'
  'int device_get_ethdev_address(struct device*, struct net_device*)'
  'int ehci_resume(struct usb_hcd*, bool)'
  'int ehci_suspend(struct usb_hcd*, bool)'
  'int fixed_phy_set_link_update(struct phy_device*, int(*)(struct net_device*, struct fixed_phy_status*))'
  'int generic_access_phys(struct vm_area_struct*, unsigned long, void*, int, int)'
  'struct gpio_desc* gpiochip_request_own_desc(struct gpio_chip*, unsigned int, const char*, enum gpio_lookup_flags, enum gpiod_flags)'
  'void irq_gc_mask_disable_reg(struct irq_data*)'
  'void irq_gc_noop(struct irq_data*)'
  'void irq_gc_unmask_enable_reg(struct irq_data*)'
  'void netdev_crit(const struct net_device*, const char*, ...)'
  'bool of_device_is_big_endian(const struct device_node*)'
  'struct net_device* of_find_net_device_by_node(struct device_node*)'
  'int of_get_ethdev_address(struct device_node*, struct net_device*)'
  'const char* pci_speed_string(enum pci_bus_speed)'
  'struct phy_device* phy_attach(struct net_device*, const char*, phy_interface_t)'
  'int phy_resume(struct phy_device*)'
  'void phy_start_machine(struct phy_device*)'
  'bool phy_validate_pause(struct phy_device*, struct ethtool_pauseparam*)'
  'pgprot_t phys_mem_access_prot(struct file*, unsigned long, unsigned long, pgprot_t)'
  'const char* pinctrl_dev_get_devname(struct pinctrl_dev*)'
  'void recalc_sigpending()'
  'int restore_online_page_callback(online_page_callback_t)'
  'u16 sdhci_calc_clk(struct sdhci_host*, unsigned int, unsigned int*)'
  'int sdhci_pltfm_resume(struct device*)'
  'int sdhci_pltfm_suspend(struct device*)'
  'int serial8250_handle_irq(struct uart_port*, unsigned int)'
  'int set_online_page_callback(online_page_callback_t)'
  'int spi_split_transfers_maxsize(struct spi_controller*, struct spi_message*, size_t, gfp_t)'
  'void vm_unmap_aliases()'

4 variable symbol(s) added
  'unsigned long empty_zero_page[512]'
  'const unsigned char pcie_link_speed[16]'
  'unsigned long phy_basic_features[2]'
  'unsigned long phy_gbit_features[2]'

Bug: 343006993
Change-Id: Ia094cd3f5444ea60b273415990bceb7a523cfee8
Signed-off-by: Pierre Couillaud <pierre@broadcom.com>
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
2024-06-07 17:19:37 +00:00
Danesh Petigara
b164ce27fa ANDROID: gki_defconfig: Enable Broadcom STB SoCs
Enable configs required for Broadcom Set Top Box SoCs.

Also explicitly disable the Broadcom Set Top Box SoC
drivers that we wish to build as loadable modules.

Bug: 343006993
Change-Id: Ia3e542d0eeb519539aba2990fb4eb4eb2970a867
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
2024-06-07 09:06:09 -07:00
Jorge Ramirez-Ortiz
d385f8f23f UPSTREAM: mmc: core: Do not force a retune before RPMB switch
Requesting a retune before switching to the RPMB partition has been
observed to cause CRC errors on the RPMB reads (-EILSEQ).

Since RPMB reads can not be retried, the clients would be directly
affected by the errors.

This commit disables the retune request prior to switching to the RPMB
partition: mmc_retune_pause() no longer triggers a retune before the
pause period begins.

This was verified with the sdhci-of-arasan driver (ZynqMP) configured
for HS200 using two separate eMMC cards (DG4064 and 064GB2). In both
cases, the error was easy to reproduce triggering every few tenths of
reads.

With this commit, systems that were utilizing OP-TEE to access RPMB
variables will experience an enhanced performance. Specifically, when
OP-TEE is configured to employ RPMB as a secure storage solution, it not
only writes the data but also the secure filesystem within the
partition. As a result, retrieving any variable involves multiple RPMB
reads, typically around five.

For context, on ZynqMP, each retune request consumed approximately
8ms. Consequently, reading any RPMB variable used to take at the very
minimum 40ms.

After droping the need to retune before switching to the RPMB partition,
this is no longer the case.

Change-Id: I2320a38436b05b435ac528c6656b621a1e2eaeb7
Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
Acked-by: Avri Altman <avri.altman@wdc.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Link: https://lore.kernel.org/r/20240103112911.2954632-1-jorge@foundries.io
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
(cherry picked from commit 67380251e8bbd3302c64fea07f95c31971b91c22)
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
2024-06-07 09:06:09 -07:00
Ilkka Koskinen
5c4b00b73e UPSTREAM: arm64/arm: arm_pmuv3: perf: Don't truncate 64-bit registers
The driver used to truncate several 64-bit registers such as PMCEID[n]
registers used to describe whether architectural and microarchitectural
events in range 0x4000-0x401f exist. Due to discarding the bits, the
driver made the events invisible, even if they existed.

Moreover, PMCCFILTR and PMCR registers have additional bits in the upper
32 bits. This patch makes them available although they aren't currently
used. Finally, functions handling PMXEVCNTR and PMXEVTYPER registers are
removed as they not being used at all.

Fixes: df29ddf4f0 ("arm64: perf: Abstract system register accesses away")
Reported-by: Carl Worth <carl@os.amperecomputing.com>
Change-Id: Ic2ec717caa2fdda2456c560a82490e374565eb2d
Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com>
Acked-by: Will Deacon <will@kernel.org>
Closes: https://lore.kernel.org/..
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Link: https://lore.kernel.org/r/20231102183012.1251410-1-ilkka@os.amperecomputing.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
(cherry picked from commit 403edfa436286b21f5ffe6856ae5b36396e8966c)
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
2024-06-07 09:06:09 -07:00
Florian Fainelli
ad62d386c8 BACKPORT: net: phy: Allow drivers to always call into ->suspend()
A few PHY drivers are currently attempting to not suspend the PHY when
Wake-on-LAN is enabled, however that code is not currently executing at
all due to an early check in phy_suspend().

This prevents PHY drivers from making an appropriate decisions and put
the hardware into a low power state if desired.

In order to allow the PHY drivers to opt into getting their ->suspend
routine to be called, add a PHY_ALWAYS_CALL_SUSPEND bit which can be
set. A boolean that tracks whether the PHY or the attached MAC has
Wake-on-LAN enabled is also provided for convenience.

If phydev::wol_enabled then the PHY shall not prevent its own
Wake-on-LAN detection logic from working and shall not prevent the
Ethernet MAC from receiving packets for matching.

Reviewed-by: Simon Horman <simon.horman@corigine.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Change-Id: I9077fe16d2515b60a2cb58753e6914be95a6923a
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit a7e3448086)
[danesh: Moved phydev->wol_enabled to avoid KMI-break]
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
2024-06-07 09:05:51 -07:00
Geert Uytterhoeven
7c09ddbf94 UPSTREAM: ARM: perf: Mark all accessor functions inline
When just including <asm/arm_pmuv3.h>:

    arch/arm/include/asm/arm_pmuv3.h:110:13: error: ‘write_pmevtypern’ defined but not used [-Werror=unused-function]
      110 | static void write_pmevtypern(int n, unsigned long val)
	  |             ^~~~~~~~~~~~~~~~
    arch/arm/include/asm/arm_pmuv3.h:103:13: error: ‘write_pmevcntrn’ defined but not used [-Werror=unused-function]
      103 | static void write_pmevcntrn(int n, unsigned long val)
	  |             ^~~~~~~~~~~~~~~
    arch/arm/include/asm/arm_pmuv3.h:95:22: error: ‘read_pmevcntrn’ defined but not used [-Werror=unused-function]
       95 | static unsigned long read_pmevcntrn(int n)
	  |                      ^~~~~~~~~~~~~~

Fix this by adding the missing "inline" keywords to the three accessor
functions that lack them.

Fixes: 009d6dc87a ("ARM: perf: Allow the use of the PMUv3 driver on 32bit ARM")
Change-Id: I0877fa9d337a59857c8480a219515e2c641cfc55
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/3a7d9bc7470aa2d85696ee9765c74f8c03fb5454.1683561482.git.geert+renesas@glider.be
Signed-off-by: Will Deacon <will@kernel.org>
(cherry picked from commit 68e3f61eb9)
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
2024-06-07 04:37:56 -07:00
Geert Uytterhoeven
f5e0452e91 UPSTREAM: arm64: perf: Mark all accessor functions inline
When just including <asm/arm_pmuv3.h>:

    arch/arm64/include/asm/arm_pmuv3.h:31:13: error: ‘write_pmevtypern’ defined but not used [-Werror=unused-function]
       31 | static void write_pmevtypern(int n, unsigned long val)
	  |             ^~~~~~~~~~~~~~~~
    arch/arm64/include/asm/arm_pmuv3.h:24:13: error: ‘write_pmevcntrn’ defined but not used [-Werror=unused-function]
       24 | static void write_pmevcntrn(int n, unsigned long val)
	  |             ^~~~~~~~~~~~~~~
    arch/arm64/include/asm/arm_pmuv3.h:16:22: error: ‘read_pmevcntrn’ defined but not used [-Werror=unused-function]
       16 | static unsigned long read_pmevcntrn(int n)
	  |                      ^~~~~~~~~~~~~~

Fix this by adding the missing "inline" keywords to the three accessor
functions that lack them.

Fixes: df29ddf4f0 ("arm64: perf: Abstract system register accesses away")
Change-Id: I36e1360fc3b187b5e68619386ae9c142a9dda3c6
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/d53a19043c0c3bd25f6c203e73a2fb08a9661824.1683561482.git.geert+renesas@glider.be
Signed-off-by: Will Deacon <will@kernel.org>
(cherry picked from commit 3bc879e355)
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
2024-06-07 04:37:56 -07:00
Marc Zyngier
6d7eea37f7 UPSTREAM: perf/core: Drop __weak attribute from arch_perf_update_userpage() prototype
Reiji reports that the arm64 implementation of arch_perf_update_userpage()
is now ignored and replaced by the dummy stub in core code.
This seems to happen since the PMUv3 driver was moved to driver/perf.

As it turns out, dropping the __weak attribute from the *prototype*
of the function solves the problem. You're right, this doesn't seem
to make much sense. And yet... It appears that both symbols get
flagged as weak, and that the first one to appear in the link order
wins:

$ nm drivers/perf/arm_pmuv3.o|grep arch_perf_update_userpage
0000000000001db0 W arch_perf_update_userpage

Dropping the attribute from the prototype restores the expected
behaviour, and arm64 is able to enjoy arch_perf_update_userpage()
again.

Fixes: 7755cec63a ("arm64: perf: Move PMUv3 driver to drivers/perf")
Fixes: f1ec3a517b ("kernel/events: Add a missing prototype for arch_perf_update_userpage()")
Reported-by: Reiji Watanabe <reijiw@google.com>
Change-Id: I497041999776e66ac77c3fccdd09ce47aae544e9
Signed-off-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Reiji Watanabe <reijiw@google.com>
Link: https://lkml.kernel.org/r/20230616114831.3186980-1-maz@kernel.org
(cherry picked from commit b50f26a448)
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
2024-06-07 04:37:56 -07:00
Marc Zyngier
bf3022d3c3 UPSTREAM: ARM: perf: Allow the use of the PMUv3 driver on 32bit ARM
The only thing stopping the PMUv3 driver from compiling on 32bit
is the lack of defined system registers names and the handful of
required helpers.

This is easily solved by providing the sysreg accessors and updating
the Kconfig entry.

Change-Id: I3f7f46feaeac69bb7d20c86b013e4a3091fb4bce
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Co-developed-by: Zaid Al-Bassam <zalbassam@google.com>
Signed-off-by: Zaid Al-Bassam <zalbassam@google.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20230317195027.3746949-8-zalbassam@google.com
Signed-off-by: Will Deacon <will@kernel.org>
(cherry picked from commit 009d6dc87a)
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
2024-06-07 04:37:56 -07:00
Marc Zyngier
393be9f6d0 UPSTREAM: ARM: Make CONFIG_CPU_V7 valid for 32bit ARMv8 implementations
ARMv8 is a superset of ARMv7, and all the ARMv8 features are
discoverable with a set of ID registers. It means that we can
use CPU_V7 to guard ARMv8 features at compile time.

This commit simply amends the CPU_V7 configuration symbol comment
to reflect that CPU_V7 also covers ARMv8.

Change-Id: Ibfa141b7fcf77619cea6f95d562b8ddf959187a3
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Zaid Al-Bassam <zalbassam@google.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20230317195027.3746949-7-zalbassam@google.com
Signed-off-by: Will Deacon <will@kernel.org>
(cherry picked from commit 252309adc8)
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
2024-06-07 04:37:56 -07:00
Zaid Al-Bassam
9d0a91c993 UPSTREAM: perf: pmuv3: Change GENMASK to GENMASK_ULL
GENMASK macro uses "unsigned long" (32-bit wide on arm and 64-bit
on arm64), This causes build issues when enabling PMUv3 on arm as
it tries to access bits > 31. This patch switches the GENMASK to
GENMASK_ULL, which uses "unsigned long long" (64-bit on both arm
and arm64).

Change-Id: I44e30f5326202a4e691bf70ce15ac5c946cca19a
Signed-off-by: Zaid Al-Bassam <zalbassam@google.com>
Acked-by: Marc Zyngier <maz@kernel.org>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20230317195027.3746949-6-zalbassam@google.com
Signed-off-by: Will Deacon <will@kernel.org>
(cherry picked from commit b3a070869f)
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
2024-06-07 04:37:56 -07:00
Zaid Al-Bassam
ab26945ffd UPSTREAM: perf: pmuv3: Move inclusion of kvm_host.h to the arch-specific helper
KVM host support is available only on arm64.

By moving the inclusion of kvm_host.h to an arm64-specific file,
the 32bit architecture will be able to implement dummy helpers.

Change-Id: I219958c7d95fa89b3fadcfaa73eec7392717a534
Signed-off-by: Zaid Al-Bassam <zalbassam@google.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20230317195027.3746949-5-zalbassam@google.com
Signed-off-by: Will Deacon <will@kernel.org>
(cherry picked from commit 11fba29a8a)
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
2024-06-07 04:37:56 -07:00
Zaid Al-Bassam
3e7e6fa4da UPSTREAM: perf: pmuv3: Abstract PMU version checks
The current PMU version definitions are available for arm64 only,
As we want to add PMUv3 support to arm (32-bit), abstracts
these definitions by using arch-specific helpers.

Change-Id: I4d487c354c5b1384d2e8c95d097c0d3864907787
Signed-off-by: Zaid Al-Bassam <zalbassam@google.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20230317195027.3746949-4-zalbassam@google.com
Signed-off-by: Will Deacon <will@kernel.org>
(cherry picked from commit 711432770f)
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
2024-06-07 04:37:56 -07:00
Marc Zyngier
55cfecdaaa UPSTREAM: arm64: perf: Abstract system register accesses away
As we want to enable 32bit support, we need to distanciate the
PMUv3 driver from the AArch64 system register names.

This patch moves all system register accesses to an architecture
specific include file, allowing the 32bit counterpart to be
slotted in at a later time.

Change-Id: Ib5c22a45d2b0ed844ee7d03cb7a7fa855230fcca
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Co-developed-by: Zaid Al-Bassam <zalbassam@google.com>
Signed-off-by: Zaid Al-Bassam <zalbassam@google.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20230317195027.3746949-3-zalbassam@google.com
Signed-off-by: Will Deacon <will@kernel.org>
(cherry picked from commit df29ddf4f0)
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
2024-06-07 04:37:55 -07:00
Marc Zyngier
278e973f01 UPSTREAM: arm64: perf: Move PMUv3 driver to drivers/perf
Having the ARM PMUv3 driver sitting in arch/arm64/kernel is getting
in the way of being able to use perf on ARMv8 cores running a 32bit
kernel, such as 32bit KVM guests.

This patch moves it into drivers/perf/arm_pmuv3.c, with an include
file in include/linux/perf/arm_pmuv3.h. The only thing left in
arch/arm64 is some mundane perf stuff.

Change-Id: I1928ceb684a107ef991401175458f2ea6c711826
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Zaid Al-Bassam <zalbassam@google.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20230317195027.3746949-2-zalbassam@google.com
Signed-off-by: Will Deacon <will@kernel.org>
(cherry picked from commit 7755cec63a)
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
2024-06-07 04:37:55 -07:00
Anshuman Khandual
222a79a1bb UPSTREAM: arm64/perf: Replace PMU version number '0' with ID_AA64DFR0_EL1_PMUVer_NI
__armv8pmu_probe_pmu() returns if detected PMU is either not implemented or
implementation defined. Extracted ID_AA64DFR0_EL1_PMUVer value, when PMU is
not implemented is '0' which can be replaced with ID_AA64DFR0_EL1_PMUVer_NI
defined as '0b0000'.

Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: linux-perf-users@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Change-Id: I1d3b7e35313b967b19fb4370fde4ad3392f28db2
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20221128025449.39085-1-anshuman.khandual@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
(cherry picked from commit cc91b94816)
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
2024-06-07 04:37:55 -07:00
Wei Liu
62a4d78dda ANDROID: GKI: Update oplus symbol list
17 function symbol(s) added
  'void __netif_schedule(struct Qdisc*)'
  'void __qdisc_calculate_pkt_len(struct sk_buff*, const struct qdisc_size_table*)'
  'void gnet_stats_add_queue(struct gnet_stats_queue*, const struct gnet_stats_queue*, const struct gnet_stats_queue*)'
  'int gnet_stats_copy_basic(struct gnet_dump*, struct gnet_stats_basic_sync*, struct gnet_stats_basic_sync*, bool)'
  'int gnet_stats_copy_queue(struct gnet_dump*, struct gnet_stats_queue*, struct gnet_stats_queue*, __u32)'
  'void psched_ratecfg_precompute(struct psched_ratecfg*, const struct tc_ratespec*, u64)'
  'struct Qdisc* qdisc_create_dflt(struct netdev_queue*, const struct Qdisc_ops*, unsigned int, struct netlink_ext_ack*)'
  'void qdisc_hash_add(struct Qdisc*, bool)'
  'void qdisc_put(struct Qdisc*)'
  'void qdisc_reset(struct Qdisc*)'
  'void qdisc_tree_reduce_backlog(struct Qdisc*, int, int)'
  'void qdisc_watchdog_cancel(struct qdisc_watchdog*)'
  'void qdisc_watchdog_init(struct qdisc_watchdog*, struct Qdisc*)'
  'void qdisc_watchdog_schedule_range_ns(struct qdisc_watchdog*, u64, u64)'
  'int tcf_block_get(struct tcf_block**, struct tcf_proto**, struct Qdisc*, struct netlink_ext_ack*)'
  'void tcf_block_put(struct tcf_block*)'
  'int tcf_classify(struct sk_buff*, const struct tcf_block*, const struct tcf_proto*, struct tcf_result*, bool)'

2 variable symbol(s) added
  'struct Qdisc noop_qdisc'
  'struct Qdisc_ops pfifo_qdisc_ops'

Bug: 344702684
Change-Id: I42fa44b9e95c24b0ef3347f837561e79913878b9
Signed-off-by: Wei Liu <liuwei.a@oppo.com>
2024-06-06 17:22:56 +00:00
Qais Yousef
bfacfd198e UPSTREAM: block/blk-mq: Don't complete locally if capacities are different
The logic in blk_mq_complete_need_ipi() assumes SMP systems where all
CPUs have equal compute capacities and only LLC cache can make
a different on perceived performance. But this assumption falls apart on
HMP systems where LLC is shared, but the CPUs have different capacities.
Staying local then can have a big performance impact if the IO request
was done from a CPU with higher capacity but the interrupt is serviced
on a lower capacity CPU.

Use the new cpus_equal_capacity() function to check if we need to send
an IPI.

Without the patch I see the BLOCK softirq always running on little cores
(where the hardirq is serviced). With it I can see it running on all
cores.

This was noticed after the topology change [1] where now on a big.LITTLE
we truly get that the LLC is shared between all cores where as in the
past it was being misrepresented for historical reasons. The logic
exposed a missing dependency on capacities for such systems where there
can be a big performance difference between the CPUs.

This of course introduced a noticeable change in behavior depending on
how the topology is presented. Leading to regressions in some workloads
as the performance of the BLOCK softirq on littles can be noticeably
worse on some platforms.

Worth noting that we could have checked for capacities being greater
than or equal instead for equality. This will lead to favouring higher
performance always. But opted for equality instead to match the
performance of the requester without making an assumption that can lead
to power trade-offs which these systems tend to be sensitive about. If
the requester would like to run faster, it's better to rely on the
scheduler to give the IO requester via some facility to run on a faster
core; and then if the interrupt triggered on a CPU with different
capacity we'll make sure to match the performance the requester is
supposed to run at.

[1] https://lpc.events/event/16/contributions/1342/attachments/962/1883/LPC-2022-Android-MC-Phantom-Domains.pdf

Bug: 341551538
Signed-off-by: Qais Yousef <qyousef@layalina.io>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20240223155749.2958009-3-qyousef@layalina.io
Signed-off-by: Jens Axboe <axboe@kernel.dk>
(cherry picked from commit af550e4c968294398fc76b075f12d51c76caf753)
Signed-off-by: Qais Yousef <qyousef@google.com>
(cherry picked from https://android-review.googlesource.com/q/commit:d01dc1c7d020f49f31194254a89694bd23ad3dd5)
Merged-In: Iefed6a19b9d25102642e264118431f5e12e23fea
Change-Id: Iefed6a19b9d25102642e264118431f5e12e23fea
2024-06-06 15:43:07 +00:00
Qais Yousef
cf4893eb95 BACKPORT: sched: Add a new function to compare if two cpus have the same capacity
The new helper function is needed to help blk-mq check if it needs to
dispatch the softirq on another CPU to match the performance level the
IO requester is running at. This is important on HMP systems where not
all CPUs have the same compute capacity.

Bug: 341551538
Signed-off-by: Qais Yousef <qyousef@layalina.io>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Link: https://lore.kernel.org/r/20240223155749.2958009-2-qyousef@layalina.io
Signed-off-by: Jens Axboe <axboe@kernel.dk>
(cherry picked from commit b361c9027b4e4159e7bcca4eb64fd26507c19994)
[Trivial clash due to some code shuffling between versions]
Signed-off-by: Qais Yousef <qyousef@google.com>
(cherry picked from https://android-review.googlesource.com/q/commit:ee8168e00c6e4fb04bea953bacb61ff017a39f63)
Merged-In: I58f3f3e3560f4800b5c73b3c85bbfdf628e9764e
Change-Id: I58f3f3e3560f4800b5c73b3c85bbfdf628e9764e
2024-06-06 15:43:07 +00:00
Bian Jin chen
e4622d460e ANDROID: GKI: Update rockchip symbols for rndis_host.
3 function symbol(s) added
  'void usbnet_cdc_unbind(struct usbnet*, struct usb_interface*)'
  'int usbnet_cdc_zte_rx_fixup(struct usbnet*, struct sk_buff*)'
  'int usbnet_generic_cdc_bind(struct usbnet*, struct usb_interface*)'

Bug: 300024866
Signed-off-by: Bian Jin chen <kenjc.bian@rock-chips.com>
Change-Id: Ibd1798bc17f99767507eec2fb8ca7e1608e16488
2024-06-05 22:14:49 +00:00
Bian Jin chen
f601b06a7e ANDROID: GKI: Update rockchip symbols for snd multi dais.
2 function symbol(s) added
  'void snd_pcm_stream_lock_irq(struct snd_pcm_substream*)'
  'void snd_pcm_stream_unlock_irq(struct snd_pcm_substream*)'

Bug: 300024866
Signed-off-by: Bian Jin chen <kenjc.bian@rock-chips.com>
Change-Id: Ic35b2fc03132b0fb7edd5df3e4393109d7b47302
2024-06-05 22:14:49 +00:00
Wesley Cheng
986fffb590 UPSTREAM: usb: gadget: f_fs: Fix race between aio_cancel() and AIO request complete
FFS based applications can utilize the aio_cancel() callback to dequeue
pending USB requests submitted to the UDC.  There is a scenario where the
FFS application issues an AIO cancel call, while the UDC is handling a
soft disconnect.  For a DWC3 based implementation, the callstack looks
like the following:

    DWC3 Gadget                               FFS Application
dwc3_gadget_soft_disconnect()              ...
  --> dwc3_stop_active_transfers()
    --> dwc3_gadget_giveback(-ESHUTDOWN)
      --> ffs_epfile_async_io_complete()   ffs_aio_cancel()
        --> usb_ep_free_request()            --> usb_ep_dequeue()

There is currently no locking implemented between the AIO completion
handler and AIO cancel, so the issue occurs if the completion routine is
running in parallel to an AIO cancel call coming from the FFS application.
As the completion call frees the USB request (io_data->req) the FFS
application is also referencing it for the usb_ep_dequeue() call.  This can
lead to accessing a stale/hanging pointer.

commit b566d38857 ("usb: gadget: f_fs: use io_data->status consistently")
relocated the usb_ep_free_request() into ffs_epfile_async_io_complete().
However, in order to properly implement locking to mitigate this issue, the
spinlock can't be added to ffs_epfile_async_io_complete(), as
usb_ep_dequeue() (if successfully dequeuing a USB request) will call the
function driver's completion handler in the same context.  Hence, leading
into a deadlock.

Fix this issue by moving the usb_ep_free_request() back to
ffs_user_copy_worker(), and ensuring that it explicitly sets io_data->req
to NULL after freeing it within the ffs->eps_lock.  This resolves the race
condition above, as the ffs_aio_cancel() routine will not continue
attempting to dequeue a request that has already been freed, or the
ffs_user_copy_work() not freeing the USB request until the AIO cancel is
done referencing it.

This fix depends on
  commit b566d38857 ("usb: gadget: f_fs: use io_data->status
  consistently")

Fixes: 2e4c7553cd ("usb: gadget: f_fs: add aio support")
Cc: stable <stable@kernel.org>	# b566d38857 ("usb: gadget: f_fs: use io_data->status consistently")
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
Link: https://lore.kernel.org/r/20240409014059.6740-1-quic_wcheng@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 334976932
(cherry picked from commit 24729b307eefcd7c476065cd7351c1a018082c19)
Change-Id: I56f6b9d24c239e73edff94e1f9f33ab41a9bd37b
Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
2024-06-05 14:41:37 +05:30
John Keeping
163070bc79 UPSTREAM: usb: gadget: f_fs: use io_data->status consistently
Commit fb1f16d74e ("usb: gadget: f_fs: change ep->status safe in
ffs_epfile_io()") added a new ffs_io_data::status field to fix lifetime
issues in synchronous requests.

While there are no similar lifetime issues for asynchronous requests
(the separate ep member in ffs_io_data avoids them) using the status
field means the USB request can be freed earlier and that there is more
consistency between the synchronous and asynchronous I/O paths.

Cc: Linyu Yuan <quic_linyyuan@quicinc.com>
Signed-off-by: John Keeping <john@metanate.com>
Reviewed-by: Linyu Yuan <quic_linyyuan@quicinc.com>
Link: https://lore.kernel.org/r/20221124170430.3998755-1-john@metanate.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 334976932
(cherry picked from commit b566d38857)
Change-Id: I8cd4d95ff6ec694adac3881da80eff23f6c679d4
Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
2024-06-05 14:38:56 +05:30
Yifan Hong
3c19f7015e ANDROID: set rewrite_absolute_paths_in_config for GKI aarch64.
For GKI targets with kmi_symbol_list set,
also set rewrite_absolute_paths_in_config to True
so that CONFIG_UNUSED_KSYMS_WHITELIST is not an
absolute path any more, increasing reproducibility
on different machines.

This is made possible with c6427490ab
"Revert^2 "BACKPORT: FROMGIT: module: allow UNUSED_KSYMS_WHITELIST to be relative against objtree.""
so that Kbuild recognizes relative paths by searching
$(objtree) first.

This does not change x86 builds because it
doesn't have kmi_symbol_list set.

This change does not affect device builds like
db845c, rockpi and fips140. Adding the attribute
to these targets would be okay, but it is not
covered by this change.

Bug: 333769605
Bug: 342390208
Change-Id: I844c251979bae5277474837eaa055f1346b0afa2
Signed-off-by: Yifan Hong <elsk@google.com>
2024-06-05 00:27:00 +00:00
Xin Deng
9fcc2459ef UPSTREAM: wifi: cfg80211: Clear mlo_links info when STA disconnects
wdev->valid_links is not cleared when upper layer disconnect from a
wdev->AP MLD. It has been observed that this would prevent offchannel
operations like remain-on-channel which would be needed for user space
operations with Public Action frame.
Clear the wdev->valid_links when STA disconnects.

Signed-off-by: Xin Deng <quic_deng@quicinc.com>
Link: https://msgid.link/20240426092501.8592-1-quic_deng@quicinc.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Bug: 344476904
Change-Id: Ie84dda35e26d2792ed39f50d0c3f959682730d89
(cherry picked from commit 9f6d4b8d149af8dc3f9a1e3000168b99ca576390)
Signed-off-by: Xin Deng <quic_deng@quicinc.com>
2024-06-04 21:21:53 +00:00
Udipto Goswami
e2c5ee3d15 ANDROID: ABI: Add usb_gadget_connect & usb_gadget_disconnect symbol
Add the usb gadget connect/disconnect symbols to ABI to be used by
vendor driver:

usb_gadget_connect
usb_gadget_disconnect

Bug: 344835325
Change-Id: I506d142ed863e6ce0d21b7a0e31c1721f6bdba93
Signed-off-by: Udipto Goswami <quic_ugoswami@quicinc.com>
2024-06-04 17:42:51 +00:00
Seiya Wang
c5abb61725 ANDROID: GKI: Update symbol list for mtk
10 function symbol(s) added
  'struct fwnode_handle* fwnode_get_next_available_child_node(const struct fwnode_handle*, struct fwnode_handle*)'
  'int genphy_c45_aneg_done(struct phy_device*)'
  'int genphy_c45_pma_read_abilities(struct phy_device*)'
  'int genphy_c45_read_lpa(struct phy_device*)'
  'int genphy_read_master_slave(struct phy_device*)'
  'unsigned int linear_range_get_max_value(const struct linear_range*)'
  'int linear_range_get_selector_high(const struct linear_range*, unsigned int, unsigned int*, bool*)'
  'int phy_get_c45_ids(struct phy_device*)'
  'int regulator_get_bypass_regmap(struct regulator_dev*, bool*)'
  'int regulator_set_bypass_regmap(struct regulator_dev*, bool)'

Bug: 344729193
Change-Id: I2c3a565d9693baa19224cc4d0dd633ae14b2a38e
Signed-off-by: Seiya Wang <seiya.wang@mediatek.com>
2024-06-04 11:01:49 +00:00
Jason Gunthorpe
c36abc6d42 BACKPORT: iommu: Have __iommu_probe_device() check for already probed devices
This is a step toward making __iommu_probe_device() self contained.

It should, under proper locking, check if the device is already associated
with an iommu driver and resolve parallel probes. All but one of the
callers open code this test using two different means, but they all
rely on dev->iommu_group.

Currently the bus_iommu_probe()/probe_iommu_group() and
probe_acpi_namespace_devices() rejects already probed devices with an
unlocked read of dev->iommu_group. The OF and ACPI "replay" functions use
device_iommu_mapped() which is the same read without the pointless
refcount.

Move this test into __iommu_probe_device() and put it under the
iommu_probe_device_lock. The store to dev->iommu_group is in
iommu_group_add_device() which is also called under this lock for iommu
driver devices, making it properly locked.

The only path that didn't have this check is the hotplug path triggered by
BUS_NOTIFY_ADD_DEVICE. The only way to get dev->iommu_group assigned
outside the probe path is via iommu_group_add_device(). Today the only
caller is VFIO no-iommu which never associates with an iommu driver. Thus
adding this additional check is safe.

Bug: 337990354
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/1-v3-328044aa278c+45e49-iommu_probe_jgg@nvidia.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
(cherry picked from commit 6eb4da8cf5)
Change-Id: I079ee5467e96367a5e1aa2ae5f0d5f6837df597c
[quic_nprakash: Resolved conflicts in drivers/iommu/iommu.c]
Signed-off-by: Nikhil V <quic_nprakash@quicinc.com>
2024-06-03 17:16:48 +00:00
Greg Kroah-Hartman
a7462d7032 ANDROID: ABI fixup for abi break in struct dst_ops
In commit 92f1655aa2b2 ("net: fix __dst_negative_advice() race") the
struct dst_ops callback negative_advice is callback changes function
parameters.  But as this pointer is part of a structure that is tracked
in the ABI checker, the tool triggers when this is changed.

However, the callback pointer is internal to the networking stack, so
changing the function type is safe, so needing to preserve this is not
required.  To do so, switch the function pointer type back to the old
one so that the checking tools pass, AND then do a hard cast of the
function pointer to the new type when assigning and calling the
function.

[6.1.y backport note, work around --Werror=cast-function-type issue by
 abusing void * for function pointer types, despite its best effort, C
 still let's us shoot our foot off if we really want to!]

Bug: 343727534
Fixes: 92f1655aa2b2 ("net: fix __dst_negative_advice() race")
Change-Id: I48d4ab4bbd29f8edc8fbd7923828b7f78a23e12e
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2024-06-03 09:08:52 +00:00
Eric Dumazet
bd2bcb81d4 BACKPORT: net: fix __dst_negative_advice() race
__dst_negative_advice() does not enforce proper RCU rules when
sk->dst_cache must be cleared, leading to possible UAF.

RCU rules are that we must first clear sk->sk_dst_cache,
then call dst_release(old_dst).

Note that sk_dst_reset(sk) is implementing this protocol correctly,
while __dst_negative_advice() uses the wrong order.

Given that ip6_negative_advice() has special logic
against RTF_CACHE, this means each of the three ->negative_advice()
existing methods must perform the sk_dst_reset() themselves.

Note the check against NULL dst is centralized in
__dst_negative_advice(), there is no need to duplicate
it in various callbacks.

Many thanks to Clement Lecigne for tracking this issue.

This old bug became visible after the blamed commit, using UDP sockets.

Bug: 343727534
Fixes: a87cb3e48e ("net: Facility to report route quality of connected sockets")
Reported-by: Clement Lecigne <clecigne@google.com>
Diagnosed-by: Clement Lecigne <clecigne@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Tom Herbert <tom@herbertland.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20240528114353.1794151-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
(cherry picked from commit 92f1655aa2b2294d0b49925f3b875a634bd3b59e)
[Lee: Trivial/unrelated conflict - no change to the patch]
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I293734dca1b81fcb712e1de294f51e96a405f7e4
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2024-06-03 09:08:52 +00:00
Will McVicker
997e6b3f6a Revert "crypto: api - Disallow identical driver names"
This reverts commit 680eb0a993 which is
commit 27016f75f5ed47e2d8e0ca75a8ff1f40bc1a5e27 upstream.

This breaks for devices that use the downstream fips140 module.

Bug: 335718233
Bug: 335830134
Signed-off-by: Will McVicker <willmcvicker@google.com>
(cherry picked from https://android-review.googlesource.com/q/commit:0cf5cecba66e91b69268fd87ded20e755bee1938)
Merged-In: Ie465403c40fe75fee5934ea160b86a4c77ef8f17
Change-Id: Ie465403c40fe75fee5934ea160b86a4c77ef8f17
2024-06-03 08:48:20 +00:00
Roy Luo
74c507aab1 UPSTREAM: USB: gadget: core: create sysfs link between udc and gadget
udc device and gadget device are tightly coupled, yet there's no good
way to corelate the two. Add a sysfs link in udc that points to the
corresponding gadget device.
An example use case: userspace configures a f_midi configfs driver and
bind the udc device, then it tries to locate the corresponding midi
device, which is a child device of the gadget device. The gadget device
that's associated to the udc device has to be identified in order to
index the midi device. Having a sysfs link would make things much
easier.

Signed-off-by: Roy Luo <royluo@google.com>
Link: https://lore.kernel.org/r/20240307030922.3573161-1-royluo@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 333778731
Change-Id: I9e3f782543eba5e026a65031aaae754daafb69ab
(cherry picked from commit 0ef40f399aa2be8c04aee9b7430705612c104ce5)
Signed-off-by: Roy Luo <royluo@google.com>
2024-05-31 20:45:19 +00:00
Carlos Llamas
92704e00b5 ANDROID: GKI: add tegra20-cpufreq.ko to rockpi4 build
Enabling configs for Tegra SoCs required this module to be included in
the rockpi4 builds. This change fixes the following build issue:

ERROR: The following kernel modules are built but not copied. Add these lines to the module_outs attribute of @@//common:rockpi4_no_kgdb:
    "drivers/cpufreq/tegra20-cpufreq.ko",

Bug: 335325897
Change-Id: I898000725287f34956cb977b3b02685f189cd5a0
Signed-off-by: Carlos Llamas <cmllamas@google.com>
2024-05-31 05:17:35 +00:00
Carlos Llamas
8498700531 ANDROID: GKI: update symbol list for db845c
Enabling configs for Tegra SoCs required these symbols to be included.
This change fixes the following build issues:

  ERROR: modpost: "devm_tegra_memory_controller_get" [drivers/iommu/arm/arm-smmu/arm_smmu.ko] undefined!
  ERROR: modpost: "tegra_mc_probe_device" [drivers/iommu/arm/arm-smmu/arm_smmu.ko] undefined!

Also update the STG file accordingly:
2 function symbol(s) added
  'struct tegra_mc* devm_tegra_memory_controller_get(struct device*)'
  'int tegra_mc_probe_device(struct tegra_mc*, struct device*)'

Bug: 335325897
Change-Id: Ie357116189e074f1dc0e572553b2264abc910bd3
Signed-off-by: Carlos Llamas <cmllamas@google.com>
2024-05-31 05:17:13 +00:00
Ahmad Chaudhry
1e4532a4a3 ANDROID: Build some tegra configs as vendor module
Build some configs that are tristate and selected by
CONFIG_ARCH_TEGRA as vendor modules rather than built-in.

Bug: 335325897
Change-Id: I7ce4cf975fcbc834bc5fc3c90317d9d81162185a
Signed-off-by: Ahmad Chaudhry <ahmadc@nvidia.com>
2024-05-31 04:40:23 +00:00
Ahmad Chaudhry
974a6f430e ANDROID: gki_defconfig: Enable Tegra SoCs
Enable configs required for Tegra SoCs.

Bug: 335325897
Change-Id: I74fd9e1b16810ca417f656ed681e01dff8a4efc9
Signed-off-by: Ahmad Chaudhry <ahmadc@nvidia.com>
2024-05-31 04:40:23 +00:00