From 825e1059b5c95bb18b1f647295cb70f57cdbd61a Mon Sep 17 00:00:00 2001 From: Vincent Donnefort Date: Wed, 29 Jun 2022 16:32:56 +0100 Subject: [PATCH 001/124] ANDROID: KVM: arm64: Free shadow data vCPUs memcache In protected mode, shadow VM structures are created at EL2. They include shadow vCPUs and their memcache where some pages donated by the host might be temporarily stored. They need to be freed on VM teardown to not get lost. Pages found there have not been used for anything by the hypervisor. Clearing is therefore not necessary. Bug: 237506543 Change-Id: Ic37d794ac33e9f844fa6ae1b4943febcdad5b033 Signed-off-by: Vincent Donnefort --- arch/arm64/kvm/hyp/nvhe/pkvm.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c index d97988b941ae..9b2e303dd124 100644 --- a/arch/arm64/kvm/hyp/nvhe/pkvm.c +++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c @@ -600,6 +600,25 @@ static int check_shadow_size(int nr_vcpus, size_t shadow_size) return 0; } +static void drain_shadow_vcpus(struct shadow_vcpu_state *shadow_vcpus, + unsigned int nr_vcpus, + struct kvm_hyp_memcache *mc) +{ + int i; + + for (i = 0; i < nr_vcpus; i++) { + struct kvm_vcpu *shadow_vcpu = &shadow_vcpus[i].vcpu; + struct kvm_hyp_memcache *vcpu_mc = &shadow_vcpu->arch.pkvm_memcache; + void *addr; + + while (vcpu_mc->nr_pages) { + addr = pop_hyp_memcache(vcpu_mc, hyp_phys_to_virt); + push_hyp_memcache(mc, addr, hyp_virt_to_phys); + WARN_ON(__pkvm_hyp_donate_host(hyp_virt_to_pfn(addr), 1)); + } + } +} + /* * Initialize the shadow copy of the protected VM state using the memory * donated by the host. @@ -753,6 +772,7 @@ int __pkvm_teardown_shadow(int shadow_handle) /* Reclaim guest pages, and page-table pages */ mc = &vm->host_kvm->arch.pkvm.teardown_mc; reclaim_guest_pages(vm, mc); + drain_shadow_vcpus(vm->shadow_vcpus, vm->created_vcpus, mc); unpin_host_vcpus(vm->shadow_vcpus, vm->created_vcpus); /* Push the metadata pages to the teardown memcache */ From 037c2b81acb0d79fa98b009d842c778595d93f59 Mon Sep 17 00:00:00 2001 From: Suren Baghdasaryan Date: Fri, 1 Jul 2022 11:40:22 -0700 Subject: [PATCH 002/124] ANDROID: Fix warning for undeclared struct acr_info The following warning is generated with CONFIG_CONTIG_ALLOC=n build: include/trace/hooks/mm.h:54:25: warning: 'struct acr_info' declared inside parameter list will not be visible outside of this definition or declaration Fix this by adding struct acr_info forward declaration. Fixes: 45cb58e13408 ("ANDROID: vendor_hooks: add vendor hoook to report acr_info in cma_alloc()") Signed-off-by: Suren Baghdasaryan Change-Id: I88f3f41e65f7239a8ab199bed27f33418566387d --- include/trace/hooks/mm.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index c6a017a0ea4d..b45a6bdd4e52 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -33,6 +33,7 @@ struct mem_cgroup; #include #endif /* __GENKSYMS__ */ struct cma; +struct acr_info; DECLARE_RESTRICTED_HOOK(android_rvh_set_skip_swapcache_flags, TP_PROTO(gfp_t *flags), From f6acdedf61a6ed65d81f9dec88e1b48ce1900bef Mon Sep 17 00:00:00 2001 From: Robin Peng Date: Wed, 6 Jul 2022 17:06:32 +0800 Subject: [PATCH 003/124] ANDROID: GKI: forward declare struct tcpci_data in vendor hooks The inclusion of the internal drivers/usb/typec/tcpm/tcpci.h header broke some androidci builds. Bug: 233047575 Fixes: f677cbf07662 ("ANDROID: GKI: include more type definitions in vendor hooks") Signed-off-by: Robin Peng Change-Id: I59f2f19889d2646fc5169506df1fba8cfeda305e --- include/trace/hooks/typec.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/include/trace/hooks/typec.h b/include/trace/hooks/typec.h index 8c31b8eff7c3..e386f487eeba 100644 --- a/include/trace/hooks/typec.h +++ b/include/trace/hooks/typec.h @@ -10,12 +10,8 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ +/* Including ../drivers/usb/typec/tcpm/tcpci.h breaks builds. */ struct tcpci_data; -#else -/* struct tcpci_data */ -#include <../drivers/usb/typec/tcpm/tcpci.h> -#endif /* __GENKSYMS__ */ struct tcpci; struct tcpm_port; From ace01eaf6ba62423ed80bffe191dc818681805b0 Mon Sep 17 00:00:00 2001 From: Li Li Date: Thu, 26 May 2022 15:00:18 -0700 Subject: [PATCH 004/124] FROMGIT: Binder: add TF_UPDATE_TXN to replace outdated txn When the target process is busy, incoming oneway transactions are queued in the async_todo list. If the clients continue sending extra oneway transactions while the target process is frozen, this queue can become too large to accommodate new transactions. That's why binder driver introduced ONEWAY_SPAM_DETECTION to detect this situation. It's helpful to debug the async binder buffer exhausting issue, but the issue itself isn't solved directly. In real cases applications are designed to send oneway transactions repeatedly, delivering updated inforamtion to the target process. Typical examples are Wi-Fi signal strength and some real time sensor data. Even if the apps might only care about the lastet information, all outdated oneway transactions are still accumulated there until the frozen process is thawed later. For this kind of situations, there's no existing method to skip those outdated transactions and deliver the latest one only. This patch introduces a new transaction flag TF_UPDATE_TXN. To use it, use apps can set this new flag along with TF_ONE_WAY. When such an oneway transaction is to be queued into the async_todo list of a frozen process, binder driver will check if any previous pending transactions can be superseded by comparing their code, flags and target node. If such an outdated pending transaction is found, the latest transaction will supersede that outdated one. This effectively prevents the async binder buffer running out and saves unnecessary binder read workloads. Acked-by: Todd Kjos Signed-off-by: Li Li Link: https://lore.kernel.org/r/20220526220018.3334775-2-dualli@chromium.org Signed-off-by: Greg Kroah-Hartman Bug: 231624308 Test: manually check async binder buffer size of frozen apps Test: stress test with kernel 4.14/4.19/5.10/5.15 (cherry picked from commit 9864bb4801331daa48514face9d0f4861e4d485b git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git char-misc-next) Change-Id: I1c4bff1eda1ca15aaaad5bf696c8fc00be743176 --- drivers/android/binder.c | 78 +++++++++++++++++++++++++++++ drivers/android/binder_trace.h | 4 ++ include/uapi/linux/android/binder.h | 1 + 3 files changed, 83 insertions(+) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 0cbaee418ea0..336a13ff60a9 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -2495,6 +2495,56 @@ static int binder_fixup_parent(struct binder_transaction *t, return 0; } +/** + * binder_can_update_transaction() - Can a txn be superseded by an updated one? + * @t1: the pending async txn in the frozen process + * @t2: the new async txn to supersede the outdated pending one + * + * Return: true if t2 can supersede t1 + * false if t2 can not supersede t1 + */ +static bool binder_can_update_transaction(struct binder_transaction *t1, + struct binder_transaction *t2) +{ + if ((t1->flags & t2->flags & (TF_ONE_WAY | TF_UPDATE_TXN)) != + (TF_ONE_WAY | TF_UPDATE_TXN) || !t1->to_proc || !t2->to_proc) + return false; + if (t1->to_proc->tsk == t2->to_proc->tsk && t1->code == t2->code && + t1->flags == t2->flags && t1->buffer->pid == t2->buffer->pid && + t1->buffer->target_node->ptr == t2->buffer->target_node->ptr && + t1->buffer->target_node->cookie == t2->buffer->target_node->cookie) + return true; + return false; +} + +/** + * binder_find_outdated_transaction_ilocked() - Find the outdated transaction + * @t: new async transaction + * @target_list: list to find outdated transaction + * + * Return: the outdated transaction if found + * NULL if no outdated transacton can be found + * + * Requires the proc->inner_lock to be held. + */ +static struct binder_transaction * +binder_find_outdated_transaction_ilocked(struct binder_transaction *t, + struct list_head *target_list) +{ + struct binder_work *w; + + list_for_each_entry(w, target_list, entry) { + struct binder_transaction *t_queued; + + if (w->type != BINDER_WORK_TRANSACTION) + continue; + t_queued = container_of(w, struct binder_transaction, work); + if (binder_can_update_transaction(t_queued, t)) + return t_queued; + } + return NULL; +} + /** * binder_proc_transaction() - sends a transaction to a process and wakes it up * @t: transaction to send @@ -2520,6 +2570,7 @@ static int binder_proc_transaction(struct binder_transaction *t, struct binder_node *node = t->buffer->target_node; bool oneway = !!(t->flags & TF_ONE_WAY); bool pending_async = false; + struct binder_transaction *t_outdated = NULL; BUG_ON(!node); binder_node_lock(node); @@ -2557,6 +2608,17 @@ static int binder_proc_transaction(struct binder_transaction *t, } else if (!pending_async) { binder_enqueue_work_ilocked(&t->work, &proc->todo); } else { + if ((t->flags & TF_UPDATE_TXN) && proc->is_frozen) { + t_outdated = binder_find_outdated_transaction_ilocked(t, + &node->async_todo); + if (t_outdated) { + binder_debug(BINDER_DEBUG_TRANSACTION, + "txn %d supersedes %d\n", + t->debug_id, t_outdated->debug_id); + list_del_init(&t_outdated->work.entry); + proc->outstanding_txns--; + } + } binder_enqueue_work_ilocked(&t->work, &node->async_todo); } @@ -2567,6 +2629,22 @@ static int binder_proc_transaction(struct binder_transaction *t, binder_inner_proc_unlock(proc); binder_node_unlock(node); + /* + * To reduce potential contention, free the outdated transaction and + * buffer after releasing the locks. + */ + if (t_outdated) { + struct binder_buffer *buffer = t_outdated->buffer; + + t_outdated->buffer = NULL; + buffer->transaction = NULL; + trace_binder_transaction_update_buffer_release(buffer); + binder_transaction_buffer_release(proc, NULL, buffer, 0, 0); + binder_alloc_free_buf(&proc->alloc, buffer); + kfree(t_outdated); + binder_stats_deleted(BINDER_STAT_TRANSACTION); + } + return 0; } diff --git a/drivers/android/binder_trace.h b/drivers/android/binder_trace.h index a70e23716ad0..8c4a6c3774a1 100644 --- a/drivers/android/binder_trace.h +++ b/drivers/android/binder_trace.h @@ -306,6 +306,10 @@ DEFINE_EVENT(binder_buffer_class, binder_transaction_failed_buffer_release, TP_PROTO(struct binder_buffer *buffer), TP_ARGS(buffer)); +DEFINE_EVENT(binder_buffer_class, binder_transaction_update_buffer_release, + TP_PROTO(struct binder_buffer *buffer), + TP_ARGS(buffer)); + TRACE_EVENT(binder_update_page_range, TP_PROTO(struct binder_alloc *alloc, bool allocate, void __user *start, void __user *end), diff --git a/include/uapi/linux/android/binder.h b/include/uapi/linux/android/binder.h index 2d3f015e2ae3..7badb670f24f 100644 --- a/include/uapi/linux/android/binder.h +++ b/include/uapi/linux/android/binder.h @@ -319,6 +319,7 @@ enum transaction_flags { TF_STATUS_CODE = 0x08, /* contents are a 32-bit status code */ TF_ACCEPT_FDS = 0x10, /* allow replies with file descriptors */ TF_CLEAR_BUF = 0x20, /* clear buffer on txn complete */ + TF_UPDATE_TXN = 0x40, /* update the outdated pending async txn */ }; struct binder_transaction_data { From 2957657ac3adcd977bf1a37b19328aa57e0174b1 Mon Sep 17 00:00:00 2001 From: Sophia Wang Date: Thu, 14 Jul 2022 10:26:24 -0700 Subject: [PATCH 005/124] ANDROID: power: Add vendor hook for suspend The purpose of this vendor hook is to calculating the total resume latency for device, CPU and console, etc. Current vendor hook only supports individual resume latency for device, each individual CPU, etc, but lacking of the total resume latency tracing. Bug: 232541623 Signed-off-by: Sophia Wang Change-Id: Idd7c999dcd822cc0f7747baa11ec200eed5f5172 --- drivers/android/vendor_hooks.c | 3 +++ include/trace/hooks/suspend.h | 24 ++++++++++++++++++++++++ kernel/power/suspend.c | 3 +++ 3 files changed, 30 insertions(+) create mode 100644 include/trace/hooks/suspend.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index da2ecc40162e..ba7fa1c5ec77 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -75,6 +75,7 @@ #include #include #include +#include /* * Export tracepoints that act as a bare tracehook (ie: have no trace event @@ -404,3 +405,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_rt_rq_load_avg); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_pci_d3_sleep); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_rq_clock_pelt); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpumask_any_and_distribute); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_resume_begin); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_resume_end); diff --git a/include/trace/hooks/suspend.h b/include/trace/hooks/suspend.h new file mode 100644 index 000000000000..0a4319d00ffa --- /dev/null +++ b/include/trace/hooks/suspend.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#undef TRACE_SYSTEM +#define TRACE_SYSTEM suspend + +#define TRACE_INCLUDE_PATH trace/hooks + +#if !defined(_TRACE_HOOK_SUSPEND_H) || defined(TRACE_HEADER_MULTI_READ) +#define _TRACE_HOOK_SUSPEND_H + +#include + +DECLARE_HOOK(android_vh_resume_begin, + TP_PROTO(void *unused), + TP_ARGS(unused)) +DECLARE_HOOK(android_vh_resume_end, + TP_PROTO(void *unused), + TP_ARGS(unused)) + +/* macro versions of hooks are no longer required */ + +#endif /* _TRACE_HOOK_SUSPEND_H */ +/* This part must be outside protection */ +#include + diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 0b20b2a456a3..2e1072aacccc 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "power.h" @@ -517,6 +518,7 @@ int suspend_devices_and_enter(suspend_state_t state) } while (!error && !wakeup && platform_suspend_again(state)); Resume_devices: + trace_android_vh_resume_begin(NULL); suspend_test_start(); dpm_resume_end(PMSG_RESUME); suspend_test_finish("resume devices"); @@ -527,6 +529,7 @@ int suspend_devices_and_enter(suspend_state_t state) Close: platform_resume_end(state); pm_suspend_target_state = PM_SUSPEND_ON; + trace_android_vh_resume_end(NULL); return error; Recover_platform: From 81a1ae6b4395a27ade467f6260b2c4e88ee1836c Mon Sep 17 00:00:00 2001 From: Vinayak Menon Date: Mon, 13 Sep 2021 16:27:10 +0530 Subject: [PATCH 006/124] ANDROID: mm: unlock the page on speculative fault retry It is observed that certain file accesses are failing when speculative file faults are enabled via "allow_file_spec_access". This is because of not unlocking the page on error in filemap_map_pages, and the locked page causes endless retry of fault. Bug: 199706590 Fixes: 35eacb5c87b9 ("ANDROID: mm: allow vmas with vm_ops to be speculatively handled") Change-Id: Ic7643ea8188aa281754318866fde09eea094c5da Signed-off-by: Vinayak Menon (cherry picked from commit 4d9d866fe52c579a423be7c9d0dda2d4790ec7ee) --- mm/filemap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index d60dd67000fb..632734e9f8f1 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2996,6 +2996,8 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf, addr = vma->vm_start + ((start_pgoff - vma->vm_pgoff) << PAGE_SHIFT); if (!pte_map_lock_addr(vmf, addr)) { + unlock_page(head); + put_page(head); ret = VM_FAULT_RETRY; goto out; } From 55f267ee04972c78405367ea11bc77b15258df7e Mon Sep 17 00:00:00 2001 From: Daniel Rosenberg Date: Wed, 13 Jul 2022 15:50:52 -0700 Subject: [PATCH 007/124] ANDROID: fuse-bpf: Fix use of get_fuse_inode get_fuse_inode uses container_of, which results in a strange result if the inode is NULL. We should check if the inode is NULL instead. Fixes: 4ad093cae178 ("ANDROID: fuse-bpf: Make inodes with backing_fd reachable") Bug: 219958836 Change-Id: I386c4641edaa4dbc8d8e02f592c959c206851eda Signed-off-by: Daniel Rosenberg --- fs/fuse/backing.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/fuse/backing.c b/fs/fuse/backing.c index 0c39771a9527..3fea31bec40a 100644 --- a/fs/fuse/backing.c +++ b/fs/fuse/backing.c @@ -262,7 +262,7 @@ int fuse_create_open_backing( struct dentry *newent; int err = 0; const struct fuse_create_in *fci = fa->in_args[0].value; - struct fuse_inode *fuse_inode = get_fuse_inode(entry->d_inode); + struct inode *d_inode = entry->d_inode; u64 target_nodeid = 0; if (!dir_fuse_inode || !dir_fuse_dentry) @@ -295,8 +295,8 @@ int fuse_create_open_backing( }; path_get(&get_fuse_dentry(entry)->backing_path); - if (fuse_inode) - target_nodeid = fuse_inode->nodeid; + if (d_inode) + target_nodeid = get_fuse_inode(d_inode)->nodeid; inode = fuse_iget_backing(dir->i_sb, target_nodeid, get_fuse_dentry(entry)->backing_path.dentry->d_inode); @@ -1178,7 +1178,7 @@ struct dentry *fuse_lookup_finalize(struct fuse_bpf_args *fa, struct inode *dir, struct fuse_dentry *fd; struct dentry *bd; struct inode *inode, *backing_inode; - struct fuse_inode *fuse_inode = get_fuse_inode(entry->d_inode); + struct inode *d_inode = entry->d_inode; struct fuse_entry_out *feo = fa->out_args[0].value; struct fuse_entry_bpf_out *febo = fa->out_args[1].value; struct fuse_entry_bpf *feb = container_of(febo, struct fuse_entry_bpf, out); @@ -1194,8 +1194,8 @@ struct dentry *fuse_lookup_finalize(struct fuse_bpf_args *fa, struct inode *dir, if (!backing_inode) return 0; - if (fuse_inode) - target_nodeid = fuse_inode->nodeid; + if (d_inode) + target_nodeid = get_fuse_inode(d_inode)->nodeid; inode = fuse_iget_backing(dir->i_sb, target_nodeid, backing_inode); From 329650e3b970981426846c3cdf5d099d7394b221 Mon Sep 17 00:00:00 2001 From: Daniel Rosenberg Date: Wed, 6 Jul 2022 14:57:14 -0700 Subject: [PATCH 008/124] ANDROID: fuse: Don't use readdirplus w/ nodeid 0 If we have a nodeid of 0, we've probably got a backing inode, and a regular getattr will be fast. Otherwise, userspace is likely ill suited to properly handle a readdirplus anyways. Test: fuse_test Bug: 219958836 Signed-off-by: Daniel Rosenberg Change-Id: I02f031d87dcc5fcbe1e080e4f8ec92187b00fe2d --- fs/fuse/readdir.c | 2 + .../selftests/filesystems/fuse/fuse_test.c | 104 +++++++++++++++++- .../selftests/filesystems/fuse/test_bpf.c | 10 ++ 3 files changed, 115 insertions(+), 1 deletion(-) diff --git a/fs/fuse/readdir.c b/fs/fuse/readdir.c index 9787a197860d..5b3123316238 100644 --- a/fs/fuse/readdir.c +++ b/fs/fuse/readdir.c @@ -20,6 +20,8 @@ static bool fuse_use_readdirplus(struct inode *dir, struct dir_context *ctx) if (!fc->do_readdirplus) return false; + if (fi->nodeid == 0) + return false; if (!fc->readdirplus_auto) return true; if (test_and_clear_bit(FUSE_I_ADVISE_RDPLUS, &fi->state)) diff --git a/tools/testing/selftests/filesystems/fuse/fuse_test.c b/tools/testing/selftests/filesystems/fuse/fuse_test.c index b94bbc8c0cbe..a30648ece91b 100644 --- a/tools/testing/selftests/filesystems/fuse/fuse_test.c +++ b/tools/testing/selftests/filesystems/fuse/fuse_test.c @@ -1677,6 +1677,107 @@ out: return result; } +static int bpf_test_no_readdirplus_without_nodeid(const char *mount_dir) +{ + const char *folder1 = "folder1"; + const char *folder2 = "folder2"; + int result = TEST_FAILURE; + int fuse_dev = -1; + int src_fd = -1; + int content_fd = -1; + int bpf_fd = -1; + int pid = -1; + int status; + + TESTEQUAL(install_elf_bpf("test_bpf.bpf", "test_readdirplus", + &bpf_fd, NULL, NULL), 0); + TESTSYSCALL(s_mkdir(s_path(s(ft_src), s(folder1)), 0777)); + TESTSYSCALL(s_mkdir(s_path(s(ft_src), s(folder2)), 0777)); + TESTEQUAL(mount_fuse_no_init(mount_dir, -1, -1, &fuse_dev), 0); + FUSE_ACTION + DIR *open_dir = NULL; + struct dirent *dirent; + + // Folder 1: Readdir with no nodeid + TEST(open_dir = s_opendir(s_path(s(ft_dst), s(folder1))), + open_dir != NULL); + TEST(dirent = readdir(open_dir), dirent == NULL); + TESTCOND(errno == EINVAL); + TESTSYSCALL(closedir(open_dir)); + open_dir = NULL; + + // Folder 2: Readdir with a nodeid + TEST(open_dir = s_opendir(s_path(s(ft_dst), s(folder2))), + open_dir != NULL); + TEST(dirent = readdir(open_dir), dirent == NULL); + TESTCOND(errno == EINVAL); + TESTSYSCALL(closedir(open_dir)); + open_dir = NULL; + FUSE_DAEMON + size_t read_size; + struct fuse_in_header *in_header = (struct fuse_in_header *)bytes_in; + struct fuse_attr attr = {}; + int backing_fd = -1; + + TESTFUSEINITFLAGS(FUSE_DO_READDIRPLUS | FUSE_READDIRPLUS_AUTO); + + // folder 1: Set 0 as nodeid, Expect READDIR + TESTFUSELOOKUP(folder1, 0); + TEST(backing_fd = s_open(s_path(s(ft_src), s(folder1)), + O_DIRECTORY | O_RDONLY | O_CLOEXEC), + backing_fd != -1); + TESTFUSEOUT2(fuse_entry_out, ((struct fuse_entry_out) { + .nodeid = 0, + .generation = 0, + .entry_valid = UINT64_MAX, + .attr_valid = UINT64_MAX, + .entry_valid_nsec = UINT32_MAX, + .attr_valid_nsec = UINT32_MAX, + .attr = attr, + }), fuse_entry_bpf_out, ((struct fuse_entry_bpf_out) { + .backing_action = FUSE_ACTION_REPLACE, + .backing_fd = backing_fd, + .bpf_action = FUSE_ACTION_REPLACE, + .bpf_fd = bpf_fd, + })); + TESTSYSCALL(close(backing_fd)); + TEST(read_size = read(fuse_dev, bytes_in, sizeof(bytes_in)), read_size > 0); + TESTEQUAL(in_header->opcode, FUSE_READDIR); + TESTFUSEOUTERROR(-EINVAL); + + // folder 2: Set 10 as nodeid, Expect READDIRPLUS + TESTFUSELOOKUP(folder2, 0); + TEST(backing_fd = s_open(s_path(s(ft_src), s(folder2)), + O_DIRECTORY | O_RDONLY | O_CLOEXEC), + backing_fd != -1); + TESTFUSEOUT2(fuse_entry_out, ((struct fuse_entry_out) { + .nodeid = 10, + .generation = 0, + .entry_valid = UINT64_MAX, + .attr_valid = UINT64_MAX, + .entry_valid_nsec = UINT32_MAX, + .attr_valid_nsec = UINT32_MAX, + .attr = attr, + }), fuse_entry_bpf_out, ((struct fuse_entry_bpf_out) { + .backing_action = FUSE_ACTION_REPLACE, + .backing_fd = backing_fd, + .bpf_action = FUSE_ACTION_REPLACE, + .bpf_fd = bpf_fd, + })); + TESTSYSCALL(close(backing_fd)); + TEST(read_size = read(fuse_dev, bytes_in, sizeof(bytes_in)), read_size > 0); + TESTEQUAL(in_header->opcode, FUSE_READDIRPLUS); + TESTFUSEOUTERROR(-EINVAL); + FUSE_DONE + result = TEST_SUCCESS; +out: + close(fuse_dev); + close(content_fd); + close(src_fd); + close(bpf_fd); + umount(mount_dir); + return result; +} static int parse_options(int argc, char *const *argv) { @@ -1782,7 +1883,8 @@ int main(int argc, char *argv[]) MAKE_TEST(inotify_test), MAKE_TEST(bpf_test_statfs), MAKE_TEST(bpf_test_lseek), - MAKE_TEST(bpf_test_readdirplus_not_overriding_backing) + MAKE_TEST(bpf_test_readdirplus_not_overriding_backing), + MAKE_TEST(bpf_test_no_readdirplus_without_nodeid) }; #undef MAKE_TEST diff --git a/tools/testing/selftests/filesystems/fuse/test_bpf.c b/tools/testing/selftests/filesystems/fuse/test_bpf.c index 3f4a9e727b68..472a02aef5b5 100644 --- a/tools/testing/selftests/filesystems/fuse/test_bpf.c +++ b/tools/testing/selftests/filesystems/fuse/test_bpf.c @@ -514,3 +514,13 @@ int error_test(struct fuse_bpf_args *fa) } } +SEC("test_readdirplus") +int readdirplus_test(struct fuse_bpf_args *fa) +{ + switch (fa->opcode) { + case FUSE_READDIR | FUSE_PREFILTER: { + return 0; + } + } + return FUSE_BPF_BACKING; +} From a06f77a0ddc8107ba6a41b4e3ca9c8acf9ffd751 Mon Sep 17 00:00:00 2001 From: Dmitrii Merkurev Date: Fri, 8 Jul 2022 23:38:18 +0000 Subject: [PATCH 009/124] ANDROID: fuse-bpf: Fix revalidate error path and backing handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently we have 2 different problems 1. Every revalidate considered as a error because of added args->out_argvar = true; inside fuse_lookup_init which makes fuse_simple_request return out argument size which is considered as an error by revalidate code. 2. We’re ignoring backing_fd and bpf_program set by daemon lookup code called by revalidate. Problem 1 makes any revalidate (lookup to userspace) useless and any result lead us to the full lookup because it was interpreted as an error. This CL fixes both and introducing revalidate test case which makes sure: 1. We’re receiving only one lookup as a part of revalidate 2. We’re setting backing_fd as a part of revalidate’s lookup result Test is failed before the fix and passed after. Bug: 219958836 Test: Booted device 5 times to make sure we’re not receiving redundant lookups anymore. Test: selftests Signed-off-by: Dmitrii Merkurev Change-Id: Ifa62e56b42ca5580b25682eb5f16b5c91826cf49 --- fs/fuse/backing.c | 177 +++++++++++------- fs/fuse/dir.c | 67 +++---- fs/fuse/fuse_i.h | 7 + .../selftests/filesystems/fuse/fuse_test.c | 114 ++++++++++- 4 files changed, 254 insertions(+), 111 deletions(-) diff --git a/fs/fuse/backing.c b/fs/fuse/backing.c index 3fea31bec40a..d21ab1a076ec 100644 --- a/fs/fuse/backing.c +++ b/fs/fuse/backing.c @@ -1172,6 +1172,105 @@ int fuse_lookup_backing(struct fuse_bpf_args *fa, struct inode *dir, return 0; } +int handle_inode_backing_fd(struct inode *inode, struct dentry *entry, + struct fuse_entry_bpf_out *febo, + struct fuse_entry_bpf *feb) +{ + struct fuse_inode *fi = get_fuse_inode(inode); + struct fuse_dentry *fd = get_fuse_dentry(entry); + int ret = 0; + + switch (febo->backing_action) { + case FUSE_ACTION_KEEP: + /* backing inode/path are added in fuse_lookup_backing */ + break; + + case FUSE_ACTION_REMOVE: + iput(fi->backing_inode); + fi->backing_inode = NULL; + path_put_init(&fd->backing_path); + break; + + case FUSE_ACTION_REPLACE: { + struct file *backing_file = feb->backing_file; + + if (!backing_file) + return -EINVAL; + if (IS_ERR(backing_file)) + return PTR_ERR(backing_file); + + if (fi->backing_inode) + iput(fi->backing_inode); + fi->backing_inode = backing_file->f_inode; + ihold(fi->backing_inode); + + path_put(&fd->backing_path); + fd->backing_path = backing_file->f_path; + path_get(&fd->backing_path); + + fput(backing_file); + break; + } + + default: + return -EINVAL; + } + + return ret; +} + +int handle_inode_bpf(struct inode *inode, struct inode *parent, + struct fuse_entry_bpf_out *febo, + struct fuse_entry_bpf *feb) +{ + struct fuse_inode *fi = get_fuse_inode(inode); + struct fuse_inode *pi; + int ret = 0; + + // Parent isn't presented, but we want to keep + // Don't touch bpf program at all in this case + if (febo->bpf_action == FUSE_ACTION_KEEP && !parent) { + goto out; + } + + if (fi->bpf) { + bpf_prog_put(fi->bpf); + fi->bpf = NULL; + } + + switch (febo->bpf_action) { + case FUSE_ACTION_KEEP: + pi = get_fuse_inode(parent); + fi->bpf = pi->bpf; + if (fi->bpf) + bpf_prog_inc(fi->bpf); + break; + + case FUSE_ACTION_REMOVE: + break; + + case FUSE_ACTION_REPLACE: { + struct file *bpf_file = feb->bpf_file; + struct bpf_prog *bpf_prog = ERR_PTR(-EINVAL); + + if (bpf_file && !IS_ERR(bpf_file)) + bpf_prog = fuse_get_bpf_prog(bpf_file); + + if (IS_ERR(bpf_prog)) + return PTR_ERR(bpf_prog); + + fi->bpf = bpf_prog; + break; + } + + default: + return -EINVAL; + } + +out: + return ret; +} + struct dentry *fuse_lookup_finalize(struct fuse_bpf_args *fa, struct inode *dir, struct dentry *entry, unsigned int flags) { @@ -1182,6 +1281,7 @@ struct dentry *fuse_lookup_finalize(struct fuse_bpf_args *fa, struct inode *dir, struct fuse_entry_out *feo = fa->out_args[0].value; struct fuse_entry_bpf_out *febo = fa->out_args[1].value; struct fuse_entry_bpf *feb = container_of(febo, struct fuse_entry_bpf, out); + int error = -1; u64 target_nodeid = 0; fd = get_fuse_dentry(entry); @@ -1202,78 +1302,13 @@ struct dentry *fuse_lookup_finalize(struct fuse_bpf_args *fa, struct inode *dir, if (IS_ERR(inode)) return ERR_PTR(PTR_ERR(inode)); - /* TODO Make sure this handles invalid handles */ - /* TODO Do we need the same code in revalidate */ - if (get_fuse_inode(inode)->bpf) { - bpf_prog_put(get_fuse_inode(inode)->bpf); - get_fuse_inode(inode)->bpf = NULL; - } + error = handle_inode_bpf(inode, dir, febo, feb); + if (error) + return ERR_PTR(error); - switch (febo->bpf_action) { - case FUSE_ACTION_KEEP: - get_fuse_inode(inode)->bpf = get_fuse_inode(dir)->bpf; - if (get_fuse_inode(inode)->bpf) - bpf_prog_inc(get_fuse_inode(inode)->bpf); - break; - - case FUSE_ACTION_REMOVE: - get_fuse_inode(inode)->bpf = NULL; - break; - - case FUSE_ACTION_REPLACE: { - struct file *bpf_file = feb->bpf_file; - struct bpf_prog *bpf_prog = ERR_PTR(-EINVAL); - - if (bpf_file && !IS_ERR(bpf_file)) - bpf_prog = fuse_get_bpf_prog(bpf_file); - - if (IS_ERR(bpf_prog)) - return ERR_PTR(PTR_ERR(bpf_prog)); - - get_fuse_inode(inode)->bpf = bpf_prog; - break; - } - - default: - return ERR_PTR(-EIO); - } - - switch (febo->backing_action) { - case FUSE_ACTION_KEEP: - /* backing inode/path are added in fuse_lookup_backing */ - break; - - case FUSE_ACTION_REMOVE: - iput(get_fuse_inode(inode)->backing_inode); - get_fuse_inode(inode)->backing_inode = NULL; - path_put_init(&get_fuse_dentry(entry)->backing_path); - break; - - case FUSE_ACTION_REPLACE: { - struct fuse_conn *fc; - struct file *backing_file; - - fc = get_fuse_mount(dir)->fc; - backing_file = feb->backing_file; - if (!backing_file || IS_ERR(backing_file)) - return ERR_PTR(-EIO); - - iput(get_fuse_inode(inode)->backing_inode); - get_fuse_inode(inode)->backing_inode = - backing_file->f_inode; - ihold(get_fuse_inode(inode)->backing_inode); - - path_put(&get_fuse_dentry(entry)->backing_path); - get_fuse_dentry(entry)->backing_path = backing_file->f_path; - path_get(&get_fuse_dentry(entry)->backing_path); - - fput(backing_file); - break; - } - - default: - return ERR_PTR(-EIO); - } + error = handle_inode_backing_fd(inode, entry, febo, feb); + if (error) + return ERR_PTR(error); get_fuse_inode(inode)->nodeid = feo->nodeid; diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index b8debd29573c..b679b60a5d9e 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -238,25 +238,23 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) ret = fuse_simple_request(fm, &args); dput(parent); - /* - * TODO This doesn't seem sufficient, though we don't plan to - * change the backing file ever, so not sure what is correct - * here yet, especially as we can't return an error to user - */ - if (bpf_arg.out.backing_action == FUSE_ACTION_REPLACE) { - struct file *file = bpf_arg.backing_file; +#ifdef CONFIG_FUSE_BPF + if (ret == sizeof(bpf_arg.out)) { + ret = -ENOENT; + if (!entry) + goto out; - if (file && !IS_ERR(file)) - fput(file); + ret = handle_inode_backing_fd(inode, entry, + &bpf_arg.out, &bpf_arg); + if (ret) + goto out; + + ret = handle_inode_bpf(inode, entry->d_parent->d_inode, + &bpf_arg.out, &bpf_arg); + if (ret) + goto out; } - - if (bpf_arg.out.bpf_action == FUSE_ACTION_REPLACE) { - struct file *file = bpf_arg.bpf_file; - - if (file && !IS_ERR(file)) - fput(file); - } - +#endif /* Zero nodeid is same as -ENOENT */ if (!ret && !outarg.nodeid) ret = -ENOENT; @@ -528,7 +526,6 @@ int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name #ifdef CONFIG_FUSE_BPF if (err == sizeof(bpf_arg.out)) { /* TODO Make sure this handles invalid handles */ - /* TODO Do we need the same code in revalidate */ struct file *backing_file; struct inode *backing_inode; @@ -537,37 +534,29 @@ int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name goto out_queue_forget; err = -EINVAL; - if (bpf_arg.out.backing_action != FUSE_ACTION_REPLACE) + backing_file = bpf_arg.backing_file; + if (!backing_file) goto out_queue_forget; - backing_file = bpf_arg.backing_file; - if (!backing_file || IS_ERR(backing_file)) + if (IS_ERR(backing_file)) { + err = PTR_ERR(backing_file); goto out_queue_forget; + } backing_inode = backing_file->f_inode; *inode = fuse_iget_backing(sb, outarg->nodeid, backing_inode); if (!*inode) goto bpf_arg_out; - if (bpf_arg.out.bpf_action == FUSE_ACTION_REPLACE) { - struct file *bpf_file = bpf_arg.bpf_file; - struct bpf_prog *bpf_prog = ERR_PTR(-EINVAL); - - if (bpf_file && !IS_ERR(bpf_file)) - bpf_prog = fuse_get_bpf_prog(bpf_file);; - - if (IS_ERR(bpf_prog)) { - iput(*inode); - *inode = NULL; - err = PTR_ERR(bpf_prog); - goto bpf_arg_out; - } - get_fuse_inode(*inode)->bpf = bpf_prog; - } - - get_fuse_dentry(entry)->backing_path = backing_file->f_path; - path_get(&get_fuse_dentry(entry)->backing_path); + err = handle_inode_backing_fd(*inode, entry, + &bpf_arg.out, &bpf_arg); + if (err) + goto out; + err = handle_inode_bpf(*inode, NULL, + &bpf_arg.out, &bpf_arg); + if (err) + goto out; bpf_arg_out: fput(backing_file); } else diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 38bdf467ee64..03c5ab29997a 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1597,6 +1597,13 @@ struct fuse_lookup_io { struct fuse_entry_bpf feb; }; +int handle_inode_backing_fd(struct inode *inode, struct dentry *entry, + struct fuse_entry_bpf_out *febo, + struct fuse_entry_bpf *feb); +int handle_inode_bpf(struct inode *inode, struct inode *parent, + struct fuse_entry_bpf_out *febo, + struct fuse_entry_bpf *feb); + int fuse_lookup_initialize(struct fuse_bpf_args *fa, struct fuse_lookup_io *feo, struct inode *dir, struct dentry *entry, unsigned int flags); int fuse_lookup_backing(struct fuse_bpf_args *fa, struct inode *dir, diff --git a/tools/testing/selftests/filesystems/fuse/fuse_test.c b/tools/testing/selftests/filesystems/fuse/fuse_test.c index a30648ece91b..cc47e7f5e3fd 100644 --- a/tools/testing/selftests/filesystems/fuse/fuse_test.c +++ b/tools/testing/selftests/filesystems/fuse/fuse_test.c @@ -1779,6 +1779,117 @@ out: return result; } +/* + * State: + * Original: dst/folder1/content.txt + * ^ + * | + * | + * Backing: src/folder1/content.txt + * + * Step 1: open(folder1) - lookup folder1 with entry_timeout set to 0 + * Step 2: open(folder1) - lookup folder1 again to trigger revalidate wich will + * set backing fd + * + * Check 1: cat(content.txt) - check not receiving call on the fuse daemon + * and content is the same + */ +static int bpf_test_revalidate_handle_backing_fd(const char *mount_dir) +{ + const char *folder1 = "folder1"; + const char *content_file = "content.txt"; + const char *content = "hello world"; + int result = TEST_FAILURE; + int fuse_dev = -1; + int src_fd = -1; + int content_fd = -1; + int pid = -1; + int status; + TESTSYSCALL(s_mkdir(s_path(s(ft_src), s(folder1)), 0777)); + TEST(content_fd = s_creat(s_pathn(3, s(ft_src), s(folder1), s(content_file)), 0777), + content_fd != -1); + TESTEQUAL(write(content_fd, content, strlen(content)), strlen(content)); + TESTSYSCALL(close(content_fd)); + content_fd = -1; + TESTEQUAL(mount_fuse_no_init(mount_dir, -1, -1, &fuse_dev), 0); + FUSE_ACTION + int dst_folder1_fd = -1; + int dst_content_fd = -1; + int dst_content_read_size = -1; + char content_buffer[9] = {0}; + // Step 1: Lookup folder1 + TESTERR(dst_folder1_fd = s_open(s_path(s(mount_dir), s(folder1)), + O_RDONLY | O_CLOEXEC), dst_folder1_fd != -1); + TESTSYSCALL(close(dst_folder1_fd)); + dst_folder1_fd = -1; + // Step 2: Lookup folder1 again + TESTERR(dst_folder1_fd = s_open(s_path(s(mount_dir), s(folder1)), + O_RDONLY | O_CLOEXEC), dst_folder1_fd != -1); + TESTSYSCALL(close(dst_folder1_fd)); + dst_folder1_fd = -1; + // Check 1: Read content file (must be backed) + TESTERR(dst_content_fd = + s_open(s_pathn(3, s(mount_dir), s(folder1), s(content_file)), + O_RDONLY | O_CLOEXEC), dst_content_fd != -1); + TEST(dst_content_read_size = + read(dst_content_fd, content_buffer, strlen(content)), + dst_content_read_size == strlen(content) && + strcmp(content, content_buffer) == 0); + TESTSYSCALL(close(dst_content_fd)); + dst_content_fd = -1; + FUSE_DAEMON + struct fuse_attr attr = {}; + int backing_fd = -1; + TESTFUSEINITFLAGS(FUSE_DO_READDIRPLUS | FUSE_READDIRPLUS_AUTO); + // Step 1: Lookup folder1 set entry_timeout to 0 to trigger + // revalidate later + TESTFUSELOOKUP(folder1, 0); + TESTSYSCALL(s_fuse_attr(s_path(s(ft_src), s(folder1)), &attr)); + TEST(backing_fd = s_open(s_path(s(ft_src), s(folder1)), + O_DIRECTORY | O_RDONLY | O_CLOEXEC), + backing_fd != -1); + TESTFUSEOUT2(fuse_entry_out, ((struct fuse_entry_out) { + .nodeid = attr.ino, + .generation = 0, + .entry_valid = 0, + .attr_valid = UINT64_MAX, + .entry_valid_nsec = 0, + .attr_valid_nsec = UINT32_MAX, + .attr = attr, + }), fuse_entry_bpf_out, ((struct fuse_entry_bpf_out) { + .backing_action = FUSE_ACTION_REPLACE, + .backing_fd = backing_fd, + })); + TESTSYSCALL(close(backing_fd)); + // Step 1: Lookup folder1 as a reaction to revalidate call + TESTFUSELOOKUP(folder1, 0); + TESTSYSCALL(s_fuse_attr(s_path(s(ft_src), s(folder1)), &attr)); + TEST(backing_fd = s_open(s_path(s(ft_src), s(folder1)), + O_DIRECTORY | O_RDONLY | O_CLOEXEC), + backing_fd != -1); + TESTFUSEOUT2(fuse_entry_out, ((struct fuse_entry_out) { + .nodeid = attr.ino, + .generation = 0, + .entry_valid = UINT64_MAX, + .attr_valid = UINT64_MAX, + .entry_valid_nsec = UINT32_MAX, + .attr_valid_nsec = UINT32_MAX, + .attr = attr, + }), fuse_entry_bpf_out, ((struct fuse_entry_bpf_out) { + .backing_action = FUSE_ACTION_REPLACE, + .backing_fd = backing_fd, + })); + TESTSYSCALL(close(backing_fd)); + FUSE_DONE + result = TEST_SUCCESS; +out: + close(fuse_dev); + close(content_fd); + close(src_fd); + umount(mount_dir); + return result; +} + static int parse_options(int argc, char *const *argv) { signed char c; @@ -1884,7 +1995,8 @@ int main(int argc, char *argv[]) MAKE_TEST(bpf_test_statfs), MAKE_TEST(bpf_test_lseek), MAKE_TEST(bpf_test_readdirplus_not_overriding_backing), - MAKE_TEST(bpf_test_no_readdirplus_without_nodeid) + MAKE_TEST(bpf_test_no_readdirplus_without_nodeid), + MAKE_TEST(bpf_test_revalidate_handle_backing_fd) }; #undef MAKE_TEST From a8b1cff5341f36e9c0a51cb93a70e128aed97e94 Mon Sep 17 00:00:00 2001 From: Daniel Rosenberg Date: Thu, 14 Jul 2022 18:16:16 -0700 Subject: [PATCH 010/124] ANDROID: fuse-bpf: Adjust backing handle funcs Cleaned up some args, and adjusted so we can choose to not update the actual values for the next patch. Test: fuse_test Bug: 219958836 Change-Id: I025b7026357b119e2cd588f25f0976f5d4b68090 Signed-off-by: Daniel Rosenberg --- fs/fuse/backing.c | 65 ++++++++++++++++++++--------------------------- fs/fuse/dir.c | 18 ++++++------- fs/fuse/fuse_i.h | 10 +++----- 3 files changed, 41 insertions(+), 52 deletions(-) diff --git a/fs/fuse/backing.c b/fs/fuse/backing.c index d21ab1a076ec..db71e77f2bfb 100644 --- a/fs/fuse/backing.c +++ b/fs/fuse/backing.c @@ -1172,23 +1172,17 @@ int fuse_lookup_backing(struct fuse_bpf_args *fa, struct inode *dir, return 0; } -int handle_inode_backing_fd(struct inode *inode, struct dentry *entry, - struct fuse_entry_bpf_out *febo, - struct fuse_entry_bpf *feb) -{ - struct fuse_inode *fi = get_fuse_inode(inode); - struct fuse_dentry *fd = get_fuse_dentry(entry); - int ret = 0; - - switch (febo->backing_action) { +int fuse_handle_backing(struct fuse_entry_bpf *feb, struct inode **backing_inode, + struct path *backing_path) { + switch (feb->out.backing_action) { case FUSE_ACTION_KEEP: /* backing inode/path are added in fuse_lookup_backing */ break; case FUSE_ACTION_REMOVE: - iput(fi->backing_inode); - fi->backing_inode = NULL; - path_put_init(&fd->backing_path); + iput(*backing_inode); + *backing_inode = NULL; + path_put_init(backing_path); break; case FUSE_ACTION_REPLACE: { @@ -1199,14 +1193,14 @@ int handle_inode_backing_fd(struct inode *inode, struct dentry *entry, if (IS_ERR(backing_file)) return PTR_ERR(backing_file); - if (fi->backing_inode) - iput(fi->backing_inode); - fi->backing_inode = backing_file->f_inode; - ihold(fi->backing_inode); + if (backing_inode) + iput(*backing_inode); + *backing_inode = backing_file->f_inode; + ihold(*backing_inode); - path_put(&fd->backing_path); - fd->backing_path = backing_file->f_path; - path_get(&fd->backing_path); + path_put(backing_path); + *backing_path = backing_file->f_path; + path_get(backing_path); fput(backing_file); break; @@ -1216,34 +1210,31 @@ int handle_inode_backing_fd(struct inode *inode, struct dentry *entry, return -EINVAL; } - return ret; + return 0; } -int handle_inode_bpf(struct inode *inode, struct inode *parent, - struct fuse_entry_bpf_out *febo, - struct fuse_entry_bpf *feb) +int fuse_handle_bpf_prog(struct fuse_entry_bpf *feb, struct inode *parent, + struct bpf_prog **bpf) { - struct fuse_inode *fi = get_fuse_inode(inode); struct fuse_inode *pi; - int ret = 0; // Parent isn't presented, but we want to keep // Don't touch bpf program at all in this case - if (febo->bpf_action == FUSE_ACTION_KEEP && !parent) { + if (feb->out.bpf_action == FUSE_ACTION_KEEP && !parent) { goto out; } - if (fi->bpf) { - bpf_prog_put(fi->bpf); - fi->bpf = NULL; + if (*bpf) { + bpf_prog_put(*bpf); + *bpf = NULL; } - switch (febo->bpf_action) { + switch (feb->out.bpf_action) { case FUSE_ACTION_KEEP: pi = get_fuse_inode(parent); - fi->bpf = pi->bpf; - if (fi->bpf) - bpf_prog_inc(fi->bpf); + *bpf = pi->bpf; + if (*bpf) + bpf_prog_inc(*bpf); break; case FUSE_ACTION_REMOVE: @@ -1259,7 +1250,7 @@ int handle_inode_bpf(struct inode *inode, struct inode *parent, if (IS_ERR(bpf_prog)) return PTR_ERR(bpf_prog); - fi->bpf = bpf_prog; + *bpf = bpf_prog; break; } @@ -1268,7 +1259,7 @@ int handle_inode_bpf(struct inode *inode, struct inode *parent, } out: - return ret; + return 0; } struct dentry *fuse_lookup_finalize(struct fuse_bpf_args *fa, struct inode *dir, @@ -1302,11 +1293,11 @@ struct dentry *fuse_lookup_finalize(struct fuse_bpf_args *fa, struct inode *dir, if (IS_ERR(inode)) return ERR_PTR(PTR_ERR(inode)); - error = handle_inode_bpf(inode, dir, febo, feb); + error = fuse_handle_bpf_prog(feb, dir, &get_fuse_inode(inode)->bpf); if (error) return ERR_PTR(error); - error = handle_inode_backing_fd(inode, entry, febo, feb); + error = fuse_handle_backing(feb, &get_fuse_inode(inode)->backing_inode, &fd->backing_path); if (error) return ERR_PTR(error); diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index b679b60a5d9e..e86768ef91df 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -236,7 +236,6 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) fuse_lookup_init(fm->fc, &args, get_node_id(d_inode(parent)), &entry->d_name, &outarg, &bpf_arg.out); ret = fuse_simple_request(fm, &args); - dput(parent); #ifdef CONFIG_FUSE_BPF if (ret == sizeof(bpf_arg.out)) { @@ -244,17 +243,18 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) if (!entry) goto out; - ret = handle_inode_backing_fd(inode, entry, - &bpf_arg.out, &bpf_arg); + ret = fuse_handle_backing(&bpf_arg, &get_fuse_inode(inode)->backing_inode, + &get_fuse_dentry(entry)->backing_path); if (ret) goto out; - ret = handle_inode_bpf(inode, entry->d_parent->d_inode, - &bpf_arg.out, &bpf_arg); + ret = fuse_handle_bpf_prog(&bpf_arg, parent->d_inode, + &get_fuse_inode(inode)->bpf); if (ret) goto out; } #endif + dput(parent); /* Zero nodeid is same as -ENOENT */ if (!ret && !outarg.nodeid) ret = -ENOENT; @@ -548,13 +548,13 @@ int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name if (!*inode) goto bpf_arg_out; - err = handle_inode_backing_fd(*inode, entry, - &bpf_arg.out, &bpf_arg); + err = fuse_handle_backing(&bpf_arg, + &get_fuse_inode(*inode)->backing_inode, + &get_fuse_dentry(entry)->backing_path); if (err) goto out; - err = handle_inode_bpf(*inode, NULL, - &bpf_arg.out, &bpf_arg); + err = fuse_handle_bpf_prog(&bpf_arg, NULL, &get_fuse_inode(*inode)->bpf); if (err) goto out; bpf_arg_out: diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 03c5ab29997a..163340ef066d 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1597,12 +1597,10 @@ struct fuse_lookup_io { struct fuse_entry_bpf feb; }; -int handle_inode_backing_fd(struct inode *inode, struct dentry *entry, - struct fuse_entry_bpf_out *febo, - struct fuse_entry_bpf *feb); -int handle_inode_bpf(struct inode *inode, struct inode *parent, - struct fuse_entry_bpf_out *febo, - struct fuse_entry_bpf *feb); +int fuse_handle_backing(struct fuse_entry_bpf *feb, struct inode **backing_inode, + struct path *backing_path); +int fuse_handle_bpf_prog(struct fuse_entry_bpf *feb, struct inode *parent, + struct bpf_prog **bpf); int fuse_lookup_initialize(struct fuse_bpf_args *fa, struct fuse_lookup_io *feo, struct inode *dir, struct dentry *entry, unsigned int flags); From 094905c87771b0682610f9d6d92c921180a0ecda Mon Sep 17 00:00:00 2001 From: Daniel Rosenberg Date: Mon, 11 Jul 2022 15:05:15 -0700 Subject: [PATCH 011/124] ANDROID: fuse-bpf: Always call revalidate for backing If we have a backing dentry, we must call it's revalidate always, or we may end up using an invalid lower dentry. Revalidate is called for dentries, not inodes, and the dentry may be negative. This goes against all of the macro conventions, so we're just calling the backing function directly. Signed-off-by: Daniel Rosenberg Bug: 219958836 Test: fuse_test Change-Id: Ia28da5bd2ce42b40466c577137d5440d9f2f6600 --- fs/fuse/backing.c | 9 +- fs/fuse/dir.c | 108 ++++++++++++------ fs/fuse/fuse_i.h | 5 +- .../selftests/filesystems/fuse/fuse_test.c | 21 ++++ 4 files changed, 97 insertions(+), 46 deletions(-) diff --git a/fs/fuse/backing.c b/fs/fuse/backing.c index db71e77f2bfb..b536fd9e99b7 100644 --- a/fs/fuse/backing.c +++ b/fs/fuse/backing.c @@ -1306,8 +1306,7 @@ struct dentry *fuse_lookup_finalize(struct fuse_bpf_args *fa, struct inode *dir, return d_splice_alias(inode, entry); } -int fuse_revalidate_backing(struct fuse_bpf_args *fa, struct inode *dir, - struct dentry *entry, unsigned int flags) +int fuse_revalidate_backing(struct dentry *entry, unsigned int flags) { struct fuse_dentry *fuse_dentry = get_fuse_dentry(entry); struct dentry *backing_entry = fuse_dentry->backing_path.dentry; @@ -1324,12 +1323,6 @@ int fuse_revalidate_backing(struct fuse_bpf_args *fa, struct inode *dir, return 1; } -void *fuse_revalidate_finalize(struct fuse_bpf_args *fa, struct inode *dir, - struct dentry *entry, unsigned int flags) -{ - return 0; -} - int fuse_canonical_path_initialize(struct fuse_bpf_args *fa, struct fuse_dummy_io *fdi, const struct path *path, diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index e86768ef91df..0eacbe8cf9c8 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -173,6 +173,44 @@ static void fuse_lookup_init(struct fuse_conn *fc, struct fuse_args *args, args->out_args[1].value = bpf_outarg; } +#ifdef CONFIG_FUSE_BPF +static bool backing_data_changed(struct fuse_inode *fi, struct dentry *entry, + struct fuse_entry_bpf *bpf_arg) +{ + struct path new_backing_path; + struct inode *new_backing_inode; + struct bpf_prog *bpf = NULL; + int err; + bool ret = true; + + if (!entry) + return false; + + get_fuse_backing_path(entry, &new_backing_path); + new_backing_inode = fi->backing_inode; + ihold(new_backing_inode); + + err = fuse_handle_backing(bpf_arg, &new_backing_inode, &new_backing_path); + + if (err) + goto put_inode; + + err = fuse_handle_bpf_prog(bpf_arg, entry->d_parent->d_inode, &bpf); + if (err) + goto put_bpf; + + ret = (bpf != fi->bpf || fi->backing_inode != new_backing_inode || + !path_equal(&get_fuse_dentry(entry)->backing_path, &new_backing_path)); +put_bpf: + if (bpf) + bpf_prog_put(bpf); +put_inode: + iput(new_backing_inode); + path_put(&new_backing_path); + return ret; +} +#endif + /* * Check whether the dentry is still valid * @@ -193,7 +231,28 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) inode = d_inode_rcu(entry); if (inode && fuse_is_bad(inode)) goto invalid; - else if (time_before64(fuse_dentry_time(entry), get_jiffies_64()) || + +#ifdef CONFIG_FUSE_BPF + /* TODO: Do we need bpf support for revalidate? + * If the lower filesystem says the entry is invalid, FUSE probably shouldn't + * try to fix that without going through the normal lookup path... + */ + if (get_fuse_dentry(entry)->backing_path.dentry) { + ret = fuse_revalidate_backing(entry, flags); + if (ret <= 0) { + goto out; + } + } + /* TODO: Respect timeouts for lookups with backing inodes */ + parent = dget_parent(entry); + if (get_fuse_inode(d_inode_rcu(parent))->backing_inode) { + dput(parent); + ret = 1; + goto out; + } + dput(parent); +#endif + if (time_before64(fuse_dentry_time(entry), get_jiffies_64()) || (flags & LOOKUP_REVAL)) { struct fuse_entry_out outarg; struct fuse_entry_bpf bpf_arg; @@ -208,20 +267,6 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) ret = -ECHILD; if (flags & LOOKUP_RCU) goto out; -#ifdef CONFIG_FUSE_BPF - { - struct fuse_err_ret fer; - - fer = fuse_bpf_backing(entry->d_parent->d_inode, - struct fuse_lookup_io, - fuse_lookup_initialize, - fuse_revalidate_backing, - fuse_revalidate_finalize, - d_inode(entry->d_parent), entry, flags); - if (fer.ret) - return PTR_ERR(fer.result); - } -#endif fm = get_fuse_mount(inode); forget = fuse_alloc_forget(); @@ -233,34 +278,29 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) parent = dget_parent(entry); + /* TODO: Once we're handling timeouts for backing inodes, do a + * bpf based lookup_revalidate here. + */ + if (get_fuse_inode(parent->d_inode)->backing_inode) { + ret = 1; + goto out; + } + fuse_lookup_init(fm->fc, &args, get_node_id(d_inode(parent)), &entry->d_name, &outarg, &bpf_arg.out); ret = fuse_simple_request(fm, &args); - -#ifdef CONFIG_FUSE_BPF - if (ret == sizeof(bpf_arg.out)) { - ret = -ENOENT; - if (!entry) - goto out; - - ret = fuse_handle_backing(&bpf_arg, &get_fuse_inode(inode)->backing_inode, - &get_fuse_dentry(entry)->backing_path); - if (ret) - goto out; - - ret = fuse_handle_bpf_prog(&bpf_arg, parent->d_inode, - &get_fuse_inode(inode)->bpf); - if (ret) - goto out; - } -#endif dput(parent); + /* Zero nodeid is same as -ENOENT */ if (!ret && !outarg.nodeid) ret = -ENOENT; - if (!ret) { + if (!ret || ret == sizeof(bpf_arg.out)) { fi = get_fuse_inode(inode); if (outarg.nodeid != get_node_id(inode) || +#ifdef CONFIG_FUSE_BPF + (ret == sizeof(bpf_arg.out) && + backing_data_changed(fi, entry, &bpf_arg)) || +#endif (bool) IS_AUTOMOUNT(inode) != (bool) (outarg.attr.flags & FUSE_ATTR_SUBMOUNT)) { fuse_queue_forget(fm->fc, forget, outarg.nodeid, 1); diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 163340ef066d..87de62763a6c 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -1608,10 +1608,7 @@ int fuse_lookup_backing(struct fuse_bpf_args *fa, struct inode *dir, struct dentry *entry, unsigned int flags); struct dentry *fuse_lookup_finalize(struct fuse_bpf_args *fa, struct inode *dir, struct dentry *entry, unsigned int flags); -int fuse_revalidate_backing(struct fuse_bpf_args *fa, struct inode *dir, - struct dentry *entry, unsigned int flags); -void *fuse_revalidate_finalize(struct fuse_bpf_args *fa, struct inode *dir, - struct dentry *entry, unsigned int flags); +int fuse_revalidate_backing(struct dentry *entry, unsigned int flags); int fuse_canonical_path_initialize(struct fuse_bpf_args *fa, struct fuse_dummy_io *fdi, diff --git a/tools/testing/selftests/filesystems/fuse/fuse_test.c b/tools/testing/selftests/filesystems/fuse/fuse_test.c index cc47e7f5e3fd..58a0dd587fec 100644 --- a/tools/testing/selftests/filesystems/fuse/fuse_test.c +++ b/tools/testing/selftests/filesystems/fuse/fuse_test.c @@ -1862,6 +1862,27 @@ static int bpf_test_revalidate_handle_backing_fd(const char *mount_dir) })); TESTSYSCALL(close(backing_fd)); // Step 1: Lookup folder1 as a reaction to revalidate call + // This attempts to change the backing node, which is not allowed on revalidate + TESTFUSELOOKUP(folder1, 0); + TESTSYSCALL(s_fuse_attr(s_path(s(ft_src), s(folder1)), &attr)); + TEST(backing_fd = s_open(s_path(s(ft_src), s(folder1)), + O_DIRECTORY | O_RDONLY | O_CLOEXEC), + backing_fd != -1); + TESTFUSEOUT2(fuse_entry_out, ((struct fuse_entry_out) { + .nodeid = attr.ino, + .generation = 0, + .entry_valid = UINT64_MAX, + .attr_valid = UINT64_MAX, + .entry_valid_nsec = UINT32_MAX, + .attr_valid_nsec = UINT32_MAX, + .attr = attr, + }), fuse_entry_bpf_out, ((struct fuse_entry_bpf_out) { + .backing_action = FUSE_ACTION_REPLACE, + .backing_fd = backing_fd, + })); + TESTSYSCALL(close(backing_fd)); + + // Lookup folder1 as a reaction to failed revalidate TESTFUSELOOKUP(folder1, 0); TESTSYSCALL(s_fuse_attr(s_path(s(ft_src), s(folder1)), &attr)); TEST(backing_fd = s_open(s_path(s(ft_src), s(folder1)), From a6b9536c10ab7e20c3b2026ba353692fad5ef8fe Mon Sep 17 00:00:00 2001 From: Quentin Perret Date: Mon, 18 Jul 2022 14:44:32 +0000 Subject: [PATCH 012/124] ANDROID: KVM: arm64: Increase size of FF-A buffer As it turns out, the kernel's DMA code doesn't enforce the SG_MAX_SEGMENTS limit on the number of elements in an sglist, which can confuse the pKVM FF-A proxy which has a buffer sized to contain a descriptor of at most SG_MAX_SEGMENTS constituents. As the number of elements in an sglist doesn't seem to have an actual upper bound, let's paper over the issue for now by increasing the size of the pKVM buffer based on empirical 'measurements'. Longer term we might need to make this value configurable on the kernel's cmdline, or to rework the FF-A proxy to sanely handle large descriptors, although this is not clear how at the time of writing. Bug: 221256863 Signed-off-by: Quentin Perret Change-Id: If252f01bec8ae71c0fe1f7007a3ca7b037924c84 --- arch/arm64/include/asm/kvm_pkvm.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kvm_pkvm.h b/arch/arm64/include/asm/kvm_pkvm.h index 89895ed9c591..766811f71a48 100644 --- a/arch/arm64/include/asm/kvm_pkvm.h +++ b/arch/arm64/include/asm/kvm_pkvm.h @@ -327,10 +327,27 @@ static inline unsigned long host_s2_pgtable_pages(void) #define KVM_FFA_MBOX_NR_PAGES 1 +/* + * Maximum number of consitutents allowed in a descriptor. This number is + * arbitrary, see comment below on SG_MAX_SEGMENTS in hyp_ffa_proxy_pages(). + */ +#define KVM_FFA_MAX_NR_CONSTITUENTS 4096 + static inline unsigned long hyp_ffa_proxy_pages(void) { size_t desc_max; + /* + * SG_MAX_SEGMENTS is supposed to bound the number of elements in an + * sglist, which should match the number of consituents in the + * corresponding FFA descriptor. As such, the EL2 buffer needs to be + * large enough to hold a descriptor with SG_MAX_SEGMENTS consituents + * at least. But the kernel's DMA code doesn't enforce the limit, and + * it is sometimes abused, so let's allow larger descriptors and hope + * for the best. + */ + BUILD_BUG_ON(KVM_FFA_MAX_NR_CONSTITUENTS < SG_MAX_SEGMENTS); + /* * The hypervisor FFA proxy needs enough memory to buffer a fragmented * descriptor returned from EL3 in response to a RETRIEVE_REQ call. @@ -338,7 +355,7 @@ static inline unsigned long hyp_ffa_proxy_pages(void) desc_max = sizeof(struct ffa_mem_region) + sizeof(struct ffa_mem_region_attributes) + sizeof(struct ffa_composite_mem_region) + - SG_MAX_SEGMENTS * sizeof(struct ffa_mem_region_addr_range); + KVM_FFA_MAX_NR_CONSTITUENTS * sizeof(struct ffa_mem_region_addr_range); /* Plus a page each for the hypervisor's RX and TX mailboxes. */ return (2 * KVM_FFA_MBOX_NR_PAGES) + DIV_ROUND_UP(desc_max, PAGE_SIZE); From 561c27072501a1042c79c3900ae569b80717ec3c Mon Sep 17 00:00:00 2001 From: xiaofeng Date: Wed, 20 Jul 2022 11:41:45 +0800 Subject: [PATCH 013/124] ANDROID: vendor_hooks: tune reclaim scan type for specified mem_cgroup Add memcg support for hooks in the reclaim path Bug: 230450931 Change-Id: Ia3e6949985d915c8640139fbb93800d91e1e46f8 Signed-off-by: xiaofeng --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/vmscan.h | 3 +++ mm/vmscan.c | 1 + 3 files changed, 5 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index ba7fa1c5ec77..6ea36ef85a4b 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -407,3 +407,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_rq_clock_pelt); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpumask_any_and_distribute); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_resume_begin); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_resume_end); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_memcg_scan_type); diff --git a/include/trace/hooks/vmscan.h b/include/trace/hooks/vmscan.h index 4a3af8e75839..d3da574714ba 100644 --- a/include/trace/hooks/vmscan.h +++ b/include/trace/hooks/vmscan.h @@ -27,6 +27,9 @@ DECLARE_HOOK(android_vh_do_shrink_slab, DECLARE_RESTRICTED_HOOK(android_rvh_set_balance_anon_file_reclaim, TP_PROTO(bool *balance_anon_file_reclaim), TP_ARGS(balance_anon_file_reclaim), 1); +DECLARE_HOOK(android_vh_tune_memcg_scan_type, + TP_PROTO(struct mem_cgroup *memcg, char *scan_type), + TP_ARGS(memcg, scan_type)); #endif /* _TRACE_HOOK_VMSCAN_H */ /* This part must be outside protection */ #include diff --git a/mm/vmscan.c b/mm/vmscan.c index cb1a9b5b0729..4b645071a610 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2504,6 +2504,7 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, denominator = ap + fp; out: trace_android_vh_tune_scan_type((char *)(&scan_balance)); + trace_android_vh_tune_memcg_scan_type(memcg, (char *)(&scan_balance)); for_each_evictable_lru(lru) { int file = is_file_lru(lru); unsigned long lruvec_size; From eb4344203d9749ef8dc0f1b85185bed9006f0eae Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 8 Jul 2022 15:06:54 -0700 Subject: [PATCH 014/124] FROMLIST: scsi: ufs: Fix a race condition related to device management commands If a completion happens after wait_for_completion_timeout() times out and before ufshcd_clear_cmds() is called then the completion code may crash on the complete() call in __ufshcd_transfer_req_compl(). This patch fixes the following crash: Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008 Call trace: complete+0x64/0x178 __ufshcd_transfer_req_compl+0x30c/0x9c0 ufshcd_poll+0xf0/0x208 ufshcd_sl_intr+0xb8/0xf0 ufshcd_intr+0x168/0x2f4 __handle_irq_event_percpu+0xa0/0x30c handle_irq_event+0x84/0x178 handle_fasteoi_irq+0x150/0x2e8 __handle_domain_irq+0x114/0x1e4 gic_handle_irq.31846+0x58/0x300 el1_irq+0xe4/0x1c0 efi_header_end+0x110/0x680 __irq_exit_rcu+0x108/0x124 __handle_domain_irq+0x118/0x1e4 gic_handle_irq.31846+0x58/0x300 el1_irq+0xe4/0x1c0 cpuidle_enter_state+0x3ac/0x8c4 do_idle+0x2fc/0x55c cpu_startup_entry+0x84/0x90 kernel_init+0x0/0x310 start_kernel+0x0/0x608 start_kernel+0x4ec/0x608 Bug: 238156478 Link: https://lore.kernel.org/linux-scsi/20220713184008.2232094-1-bvanassche@acm.org/T/#u Change-Id: Icf646e1e536e2d4918e5625574117f6f42e1ff7d Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 57 ++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 31c435015691..b9df2db533d2 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -3016,37 +3016,58 @@ ufshcd_dev_cmd_completion(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, int max_timeout) { - int err = 0; - unsigned long time_left; + unsigned long time_left = msecs_to_jiffies(max_timeout); unsigned long flags; + bool pending; + int err; +retry: time_left = wait_for_completion_timeout(hba->dev_cmd.complete, - msecs_to_jiffies(max_timeout)); + time_left); - spin_lock_irqsave(hba->host->host_lock, flags); - hba->dev_cmd.complete = NULL; if (likely(time_left)) { + /* + * The caller of this function still owns the @lrbp tag so the + * code below does not trigger any race conditions. + */ + hba->dev_cmd.complete = NULL; err = ufshcd_get_tr_ocs(lrbp); if (!err) err = ufshcd_dev_cmd_completion(hba, lrbp); - } - spin_unlock_irqrestore(hba->host->host_lock, flags); - - if (!time_left) { + } else { err = -ETIMEDOUT; dev_dbg(hba->dev, "%s: dev_cmd request timedout, tag %d\n", __func__, lrbp->task_tag); - if (!ufshcd_clear_cmds(hba, 1U << lrbp->task_tag)) + if (!ufshcd_clear_cmds(hba, 1U << lrbp->task_tag)) { /* successfully cleared the command, retry if needed */ err = -EAGAIN; - /* - * in case of an error, after clearing the doorbell, - * we also need to clear the outstanding_request - * field in hba - */ - spin_lock_irqsave(&hba->outstanding_lock, flags); - __clear_bit(lrbp->task_tag, &hba->outstanding_reqs); - spin_unlock_irqrestore(&hba->outstanding_lock, flags); + /* + * Since clearing the command succeeded we also need to + * clear the task tag bit from the outstanding_reqs + * variable. + */ + spin_lock_irqsave(&hba->outstanding_lock, flags); + pending = test_bit(lrbp->task_tag, + &hba->outstanding_reqs); + if (pending) { + hba->dev_cmd.complete = NULL; + __clear_bit(lrbp->task_tag, + &hba->outstanding_reqs); + } + spin_unlock_irqrestore(&hba->outstanding_lock, flags); + + if (!pending) { + /* + * A race occurred between this function and the + * completion handler. + */ + time_left = 1; + goto retry; + } + } else { + dev_err(hba->dev, "%s: failed to clear tag %d\n", __func__, + lrbp->task_tag); + } } return err; From 885349f53dd73183f2900d397a3f57aee46e3220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?haibinzhang=20=28=E5=BC=A0=E6=B5=B7=E6=96=8C=29?= Date: Sat, 2 Jul 2022 05:43:19 +0000 Subject: [PATCH 015/124] FROMGIT: arm64: fix oops in concurrently setting insn_emulation sysctls emulation_proc_handler() changes table->data for proc_dointvec_minmax and can generate the following Oops if called concurrently with itself: | Unable to handle kernel NULL pointer dereference at virtual address 0000000000000010 | Internal error: Oops: 96000006 [#1] SMP | Call trace: | update_insn_emulation_mode+0xc0/0x148 | emulation_proc_handler+0x64/0xb8 | proc_sys_call_handler+0x9c/0xf8 | proc_sys_write+0x18/0x20 | __vfs_write+0x20/0x48 | vfs_write+0xe4/0x1d0 | ksys_write+0x70/0xf8 | __arm64_sys_write+0x20/0x28 | el0_svc_common.constprop.0+0x7c/0x1c0 | el0_svc_handler+0x2c/0xa0 | el0_svc+0x8/0x200 To fix this issue, keep the table->data as &insn->current_mode and use container_of() to retrieve the insn pointer. Another mutex is used to protect against the current_mode update but not for retrieving insn_emulation as table->data is no longer changing. Bug: 237540956 Co-developed-by: hewenliang Signed-off-by: hewenliang Signed-off-by: Haibin Zhang Reviewed-by: Catalin Marinas Link: https://lore.kernel.org/r/20220128090324.2727688-1-hewenliang4@huawei.com Link: https://lore.kernel.org/r/9A004C03-250B-46C5-BF39-782D7551B00E@tencent.com Signed-off-by: Will Deacon [Lee: Added Fixes: tag] (cherry picked from commit af483947d472eccb79e42059276c4deed76f99a6 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core) Fixes: 587064b610c7 ("arm64: Add framework for legacy instruction emulation") Signed-off-by: Lee Jones Change-Id: If9b96bb79c79903f9d8292e719b06fdef57ef1c5 --- arch/arm64/kernel/armv8_deprecated.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c index 0e86e8b9cedd..c5da9d1e954a 100644 --- a/arch/arm64/kernel/armv8_deprecated.c +++ b/arch/arm64/kernel/armv8_deprecated.c @@ -59,6 +59,7 @@ struct insn_emulation { static LIST_HEAD(insn_emulation); static int nr_insn_emulated __initdata; static DEFINE_RAW_SPINLOCK(insn_emulation_lock); +static DEFINE_MUTEX(insn_emulation_mutex); static void register_emulation_hooks(struct insn_emulation_ops *ops) { @@ -207,10 +208,10 @@ static int emulation_proc_handler(struct ctl_table *table, int write, loff_t *ppos) { int ret = 0; - struct insn_emulation *insn = (struct insn_emulation *) table->data; + struct insn_emulation *insn = container_of(table->data, struct insn_emulation, current_mode); enum insn_emulation_mode prev_mode = insn->current_mode; - table->data = &insn->current_mode; + mutex_lock(&insn_emulation_mutex); ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); if (ret || !write || prev_mode == insn->current_mode) @@ -223,7 +224,7 @@ static int emulation_proc_handler(struct ctl_table *table, int write, update_insn_emulation_mode(insn, INSN_UNDEF); } ret: - table->data = insn; + mutex_unlock(&insn_emulation_mutex); return ret; } @@ -247,7 +248,7 @@ static void __init register_insn_emulation_sysctl(void) sysctl->maxlen = sizeof(int); sysctl->procname = insn->ops->name; - sysctl->data = insn; + sysctl->data = &insn->current_mode; sysctl->extra1 = &insn->min; sysctl->extra2 = &insn->max; sysctl->proc_handler = emulation_proc_handler; From 1f44e4411f9e914fac45dd1a232ccabcc05811b3 Mon Sep 17 00:00:00 2001 From: liujinbao1 Date: Fri, 8 Jul 2022 15:01:25 +0800 Subject: [PATCH 016/124] UPSTREAM: exfat: reduce block requests when zeroing a cluster If 'dirsync' is enabled, when zeroing a cluster, submitting sector by sector will generate many block requests, will cause the block device to not fully perform its performance. This commit makes the sectors in a cluster to be submitted in once, it will reduce the number of block requests. This will make the block device to give full play to its performance. Test create 1000 directories on SD card with: $ time (for ((i=0;i<1000;i++)); do mkdir dir${i}; done) Performance has been improved by more than 73% on imx6q-sabrelite. Cluster size Before After Improvement 64 KBytes 3m34.036s 0m56.052s 73.8% 128 KBytes 6m2.644s 1m13.354s 79.8% 256 KBytes 11m22.202s 1m39.451s 85.4% imx6q-sabrelite: - CPU: 792 MHz x4 - Memory: 1GB DDR3 - SD Card: SanDisk 8GB Class 4 Bug: 239500767 Signed-off-by: Yuezhang Mo Reviewed-by: Andy Wu Reviewed-by: Aoyama Wataru Reviewed-by: Christoph Hellwig Acked-by: Sungjong Seo (cherry picked from commit 1b6138385499507147e8f654840f4c39afe6adbf) Signed-off-by: Namjae Jeon Signed-off-by: liujinbao1 Change-Id: Ie9ed20fb90caed2fce2692f7fb81272cf647faa7 --- fs/exfat/fatent.c | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c index 6078cbfdfe8a..3ef327f73881 100644 --- a/fs/exfat/fatent.c +++ b/fs/exfat/fatent.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "exfat_raw.h" #include "exfat_fs.h" @@ -233,10 +234,10 @@ int exfat_zeroed_cluster(struct inode *dir, unsigned int clu) { struct super_block *sb = dir->i_sb; struct exfat_sb_info *sbi = EXFAT_SB(sb); - struct buffer_head *bhs[MAX_BUF_PER_PAGE]; - int nr_bhs = MAX_BUF_PER_PAGE; + struct buffer_head *bh; + struct address_space *mapping = sb->s_bdev->bd_inode->i_mapping; sector_t blknr, last_blknr; - int err, i, n; + int i; blknr = exfat_cluster_to_sector(sbi, clu); last_blknr = blknr + sbi->sect_per_clus; @@ -250,30 +251,22 @@ int exfat_zeroed_cluster(struct inode *dir, unsigned int clu) } /* Zeroing the unused blocks on this cluster */ - while (blknr < last_blknr) { - for (n = 0; n < nr_bhs && blknr < last_blknr; n++, blknr++) { - bhs[n] = sb_getblk(sb, blknr); - if (!bhs[n]) { - err = -ENOMEM; - goto release_bhs; - } - memset(bhs[n]->b_data, 0, sb->s_blocksize); - } + for (i = blknr; i < last_blknr; i++) { + bh = sb_getblk(sb, i); + if (!bh) + return -ENOMEM; - err = exfat_update_bhs(bhs, n, IS_DIRSYNC(dir)); - if (err) - goto release_bhs; - - for (i = 0; i < n; i++) - brelse(bhs[i]); + memset(bh->b_data, 0, sb->s_blocksize); + set_buffer_uptodate(bh); + mark_buffer_dirty(bh); + brelse(bh); } - return 0; + if (IS_DIRSYNC(dir)) + return filemap_write_and_wait_range(mapping, + EXFAT_BLK_TO_B(blknr, sb), + EXFAT_BLK_TO_B(last_blknr, sb) - 1); -release_bhs: - exfat_err(sb, "failed zeroed sect %llu\n", (unsigned long long)blknr); - for (i = 0; i < n; i++) - bforget(bhs[i]); - return err; + return 0; } int exfat_alloc_cluster(struct inode *inode, unsigned int num_alloc, From f2cf53322feb15cf8976e73923145d9272b2076c Mon Sep 17 00:00:00 2001 From: Daniel Rosenberg Date: Mon, 25 Jul 2022 14:28:33 -0700 Subject: [PATCH 017/124] ANDROID: fuse-bpf: Fix RCU/reference issue 094905c87771 ("ANDROID: fuse-bpf: Always call revalidate for backing") called dget_parent/dput improperly within an RCU context. Additionally, it failed to free/put some references. Fixes: 094905c87771 ("ANDROID: fuse-bpf: Always call revalidate for backing") Signed-off-by: Daniel Rosenberg Change-Id: Iedeee7550ff88366bc5310eedece285019336814 --- fs/fuse/dir.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 0eacbe8cf9c8..7d464480d74f 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -243,14 +243,6 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) goto out; } } - /* TODO: Respect timeouts for lookups with backing inodes */ - parent = dget_parent(entry); - if (get_fuse_inode(d_inode_rcu(parent))->backing_inode) { - dput(parent); - ret = 1; - goto out; - } - dput(parent); #endif if (time_before64(fuse_dentry_time(entry), get_jiffies_64()) || (flags & LOOKUP_REVAL)) { @@ -269,23 +261,26 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) goto out; fm = get_fuse_mount(inode); - forget = fuse_alloc_forget(); - ret = -ENOMEM; - if (!forget) - goto out; - - attr_version = fuse_get_attr_version(fm->fc); - parent = dget_parent(entry); /* TODO: Once we're handling timeouts for backing inodes, do a * bpf based lookup_revalidate here. */ if (get_fuse_inode(parent->d_inode)->backing_inode) { + dput(parent); ret = 1; goto out; } + forget = fuse_alloc_forget(); + ret = -ENOMEM; + if (!forget) { + dput(parent); + goto out; + } + + attr_version = fuse_get_attr_version(fm->fc); + fuse_lookup_init(fm->fc, &args, get_node_id(d_inode(parent)), &entry->d_name, &outarg, &bpf_arg.out); ret = fuse_simple_request(fm, &args); From 3821e5b25c4067d2263bc47c674fde57a17cf7c4 Mon Sep 17 00:00:00 2001 From: Darren Hsu Date: Thu, 28 Jul 2022 20:58:48 +0800 Subject: [PATCH 018/124] ANDROID: power: add a vendor hook to log unfrozen tasks We recently noticed an issue where freezing of user space tasks is failed due to a process being in uninterruptible sleep state. Currently, the logging of unfrozen tasks is disabled by default. Although it can be enabled for debugging via a adb command, it's usually hard to reproduce the issue. So we want to add a vendor hook to log unfrozen tasks. Bug: 240091483 Test: all presubmit tests passed Change-Id: Ief3d4196ea7220d4897c00a37ab96f456dbf2259 Signed-off-by: Darren Hsu --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/power.h | 4 ++++ kernel/power/process.c | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 6ea36ef85a4b..bb6d5eb7a31f 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -202,6 +202,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sched_balance_rt); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_timer_calc_index); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_watchdog_timer_softlockup); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_try_to_freeze_todo); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_try_to_freeze_todo_logging); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_try_to_freeze_todo_unfrozen); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_dequeue_task_idle); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_die_kernel_fault); diff --git a/include/trace/hooks/power.h b/include/trace/hooks/power.h index aab4b37b2d6a..3c735b7a5abd 100644 --- a/include/trace/hooks/power.h +++ b/include/trace/hooks/power.h @@ -25,6 +25,10 @@ DECLARE_HOOK(android_vh_try_to_freeze_todo, TP_PROTO(unsigned int todo, unsigned int elapsed_msecs, bool wq_busy), TP_ARGS(todo, elapsed_msecs, wq_busy)); +DECLARE_HOOK(android_vh_try_to_freeze_todo_logging, + TP_PROTO(bool *logging_on), + TP_ARGS(logging_on)); + DECLARE_HOOK(android_vh_try_to_freeze_todo_unfrozen, TP_PROTO(struct task_struct *p), TP_ARGS(p)); diff --git a/kernel/power/process.c b/kernel/power/process.c index ba51823759ea..7564fd30766b 100644 --- a/kernel/power/process.c +++ b/kernel/power/process.c @@ -40,6 +40,7 @@ static int try_to_freeze_tasks(bool user_only) unsigned int elapsed_msecs; bool wakeup = false; int sleep_usecs = USEC_PER_MSEC; + bool todo_logging_on = false; start = ktime_get_boottime(); @@ -101,7 +102,8 @@ static int try_to_freeze_tasks(bool user_only) if (wq_busy) show_workqueue_state(); - if (pm_debug_messages_on) { + trace_android_vh_try_to_freeze_todo_logging(&todo_logging_on); + if (pm_debug_messages_on || todo_logging_on) { read_lock(&tasklist_lock); for_each_process_thread(g, p) { if (p != current && !freezer_should_skip(p) From feb89f3850e6b261347209b3b8329c32e8898229 Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Fri, 29 Jul 2022 00:59:18 +0000 Subject: [PATCH 019/124] ANDROID: fix kernelci error in fs/fuse/dir.c kernelci reported the following error when !CONFIG_FUSE_BPF: fs/fuse/dir.c:269:40: error: no member named 'backing_inode' in 'struct fuse_inode' Fixed by wrapping that new code in #ifdef CONFIG_FUSE_BPF. Fixes: 094905c87771 ("ANDROID: fuse-bpf: Always call revalidate for backing") Signed-off-by: Todd Kjos Change-Id: I08760f340cebf21d3084ca84ac1792bc70f311ff --- fs/fuse/dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 7d464480d74f..25ddb77d7266 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c @@ -263,6 +263,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) parent = dget_parent(entry); +#ifdef CONFIG_FUSE_BPF /* TODO: Once we're handling timeouts for backing inodes, do a * bpf based lookup_revalidate here. */ @@ -271,7 +272,7 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) ret = 1; goto out; } - +#endif forget = fuse_alloc_forget(); ret = -ENOMEM; if (!forget) { From 254dfc7e984730412724de0cd9f1797d1daeee06 Mon Sep 17 00:00:00 2001 From: Star Chang Date: Fri, 29 Jul 2022 10:48:12 +0000 Subject: [PATCH 020/124] ANDROID: Update the ABI representation Leaf changes summary: 3 artifact changed Changed leaf types summary: 0 leaf type changed Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 2 Added function Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 1 Added variable 2 Added function: [A] 'function int nf_register_net_hooks(net*, const nf_hook_ops*, unsigned int)' [A] 'function void nf_unregister_net_hooks(net*, const nf_hook_ops*, unsigned int)' 1 Added variable: [A] 'rwlock_t dev_base_lock' Bug: 238271023 Signed-off-by: Star Chang Change-Id: I0338eb6f92605d7abae95581a598c5e00b442c6c --- android/abi_gki_aarch64.xml | 640 ++++++++++++++++++-------------- android/abi_gki_aarch64_generic | 3 + 2 files changed, 359 insertions(+), 284 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index 0b211916b116..9c530cc6d97a 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -2251,6 +2251,8 @@ + + @@ -3856,6 +3858,7 @@ + @@ -4270,7 +4273,7 @@ - + @@ -4879,7 +4882,7 @@ - + @@ -8719,7 +8722,7 @@ - + @@ -17840,6 +17843,7 @@ + @@ -22086,6 +22090,11 @@ + + + + + @@ -25272,7 +25281,7 @@ - + @@ -39600,6 +39609,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -41335,7 +41364,7 @@ - + @@ -59658,7 +59687,7 @@ - + @@ -59740,7 +59769,7 @@ - + @@ -65321,6 +65350,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -69366,27 +69415,27 @@ - + - + - + - + - + - + - + @@ -69402,22 +69451,22 @@ - + - + - + - + - + - + @@ -69441,36 +69490,36 @@ - + - + - + - + - + - + - + - + - + - + @@ -69481,7 +69530,7 @@ - + @@ -69505,96 +69554,96 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -70772,6 +70821,7 @@ + @@ -74021,7 +74071,14 @@ - + + + + + + + + @@ -74168,7 +74225,7 @@ - + @@ -79157,6 +79214,7 @@ + @@ -84172,7 +84230,7 @@ - + @@ -84252,22 +84310,22 @@ - + - + - + - + - + - + @@ -96155,7 +96213,7 @@ - + @@ -96163,7 +96221,7 @@ - + @@ -96171,7 +96229,7 @@ - + @@ -96179,12 +96237,12 @@ - + - + @@ -96192,7 +96250,7 @@ - + @@ -96203,7 +96261,7 @@ - + @@ -96211,18 +96269,18 @@ - + - + - - + + @@ -96236,12 +96294,12 @@ - + - + @@ -96249,12 +96307,12 @@ - + - + @@ -96262,12 +96320,12 @@ - + - + @@ -96284,7 +96342,7 @@ - + @@ -96292,7 +96350,7 @@ - + @@ -96300,12 +96358,12 @@ - + - + @@ -96313,7 +96371,7 @@ - + @@ -96321,7 +96379,7 @@ - + @@ -96338,12 +96396,12 @@ - + - + @@ -96369,7 +96427,7 @@ - + @@ -96380,7 +96438,7 @@ - + @@ -96400,7 +96458,7 @@ - + @@ -96423,7 +96481,7 @@ - + @@ -96458,7 +96516,7 @@ - + @@ -96469,7 +96527,7 @@ - + @@ -96483,12 +96541,12 @@ - + - + @@ -96499,7 +96557,7 @@ - + @@ -96513,7 +96571,7 @@ - + @@ -96524,7 +96582,7 @@ - + @@ -96538,7 +96596,7 @@ - + @@ -96552,12 +96610,12 @@ - + - + @@ -96565,7 +96623,7 @@ - + @@ -96579,7 +96637,7 @@ - + @@ -96587,7 +96645,7 @@ - + @@ -96598,7 +96656,7 @@ - + @@ -96615,7 +96673,7 @@ - + @@ -96635,7 +96693,7 @@ - + @@ -96652,7 +96710,7 @@ - + @@ -96663,7 +96721,7 @@ - + @@ -96671,7 +96729,7 @@ - + @@ -96679,7 +96737,7 @@ - + @@ -96687,7 +96745,7 @@ - + @@ -96701,7 +96759,7 @@ - + @@ -96709,7 +96767,7 @@ - + @@ -96720,7 +96778,7 @@ - + @@ -96737,7 +96795,7 @@ - + @@ -97517,7 +97575,7 @@ - + @@ -99648,6 +99706,7 @@ + @@ -101467,7 +101526,7 @@ - + @@ -104182,7 +104241,7 @@ - + @@ -105635,7 +105694,7 @@ - + @@ -107252,19 +107311,19 @@ - - - - - + + + + + - - - - - - + + + + + + @@ -107369,25 +107428,25 @@ - - - - + + + + - - - - - - - - + + + + + + + + - - - + + + @@ -107447,21 +107506,21 @@ - - - + + + - - - - + + + + - - - - + + + + @@ -107482,13 +107541,13 @@ - - - - - - - + + + + + + + @@ -107497,14 +107556,14 @@ - - - - - - - - + + + + + + + + @@ -107578,38 +107637,38 @@ - - - - - - - - - - - - - - - + - - - + + + - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + @@ -107868,8 +107927,8 @@ - - + + @@ -107884,9 +107943,9 @@ - - - + + + @@ -107896,15 +107955,15 @@ - - - + + + - + - + @@ -107916,11 +107975,11 @@ - - - - - + + + + + @@ -110847,6 +110906,7 @@ + @@ -118052,6 +118112,18 @@ + + + + + + + + + + + + @@ -119616,7 +119688,7 @@ - + @@ -122927,8 +122999,8 @@ - - + + @@ -123537,30 +123609,30 @@ - - - + + + - - - - + + + + - - - - - + + + + + - - - - - - + + + + + + @@ -123598,74 +123670,74 @@ - - - - - - - + + + + + + + - - - - - - + + + + + + - - - - - - - + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index ed5a0a57b1bc..9e36c1056f9d 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -374,6 +374,7 @@ desc_to_gpio destroy_workqueue dev_alloc_name + dev_base_lock dev_close _dev_crit dev_driver_string @@ -1351,6 +1352,8 @@ netlink_kernel_release netlink_unicast net_ratelimit + nf_register_net_hooks + nf_unregister_net_hooks nla_append nla_memcpy __nla_parse From b5a6bcf9dceba33673293d458b87ea9dbcbb2567 Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Mon, 1 Aug 2022 13:20:20 -0700 Subject: [PATCH 021/124] ANDROID: Remove all but top-level OWNERS Now that the branch is used to create production GKI images, need to institute ACK DrNo for all commits. The DrNo approvers are in the android-mainline branch at /OWNERS_DrNo. Bug: 240999246 Signed-off-by: Todd Kjos Change-Id: Id5bb83d7add5f314df6816c1c51b4bf2d8018e79 --- Documentation/ABI/testing/OWNERS | 2 -- Documentation/filesystems/OWNERS | 2 -- android/OWNERS | 8 -------- arch/arm/OWNERS | 2 -- arch/arm64/OWNERS | 2 -- arch/x86/OWNERS | 2 -- block/OWNERS | 2 -- crypto/OWNERS | 2 -- drivers/OWNERS | 2 -- fs/OWNERS | 2 -- fs/f2fs/OWNERS | 2 -- fs/fuse/OWNERS | 2 -- fs/incfs/OWNERS | 2 -- include/OWNERS | 2 -- include/linux/OWNERS | 2 -- include/trace/events/OWNERS | 2 -- include/uapi/linux/OWNERS | 2 -- kernel/sched/OWNERS | 2 -- mm/OWNERS | 2 -- net/OWNERS | 2 -- tools/testing/selftests/filesystems/fuse/OWNERS | 2 -- tools/testing/selftests/filesystems/incfs/OWNERS | 2 -- 22 files changed, 50 deletions(-) delete mode 100644 Documentation/ABI/testing/OWNERS delete mode 100644 Documentation/filesystems/OWNERS delete mode 100644 android/OWNERS delete mode 100644 arch/arm/OWNERS delete mode 100644 arch/arm64/OWNERS delete mode 100644 arch/x86/OWNERS delete mode 100644 block/OWNERS delete mode 100644 crypto/OWNERS delete mode 100644 drivers/OWNERS delete mode 100644 fs/OWNERS delete mode 100644 fs/f2fs/OWNERS delete mode 100644 fs/fuse/OWNERS delete mode 100644 fs/incfs/OWNERS delete mode 100644 include/OWNERS delete mode 100644 include/linux/OWNERS delete mode 100644 include/trace/events/OWNERS delete mode 100644 include/uapi/linux/OWNERS delete mode 100644 kernel/sched/OWNERS delete mode 100644 mm/OWNERS delete mode 100644 net/OWNERS delete mode 100644 tools/testing/selftests/filesystems/fuse/OWNERS delete mode 100644 tools/testing/selftests/filesystems/incfs/OWNERS diff --git a/Documentation/ABI/testing/OWNERS b/Documentation/ABI/testing/OWNERS deleted file mode 100644 index 75edfd5b3a32..000000000000 --- a/Documentation/ABI/testing/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/Documentation/ABI/testing/OWNERS diff --git a/Documentation/filesystems/OWNERS b/Documentation/filesystems/OWNERS deleted file mode 100644 index 5b6ec532f1e2..000000000000 --- a/Documentation/filesystems/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/Documentation/filesystems/OWNERS diff --git a/android/OWNERS b/android/OWNERS deleted file mode 100644 index 3a9d87457d81..000000000000 --- a/android/OWNERS +++ /dev/null @@ -1,8 +0,0 @@ -# If we ever add another OWNERS above this directory, it's likely to be -# more permissive, so don't inherit from it -set noparent -include kernel/common:android-mainline:/OWNERS_DrNo - -# Downstream boards maintained directly in this manifest branch -per-file abi_gki_aarch64_cuttlefish = adelva@google.com, rammuthiah@google.com -per-file abi_gki_aarch64_goldfish = rkir@google.com diff --git a/arch/arm/OWNERS b/arch/arm/OWNERS deleted file mode 100644 index 1e390c75956e..000000000000 --- a/arch/arm/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/arch/arm/OWNERS diff --git a/arch/arm64/OWNERS b/arch/arm64/OWNERS deleted file mode 100644 index 257f4cf26809..000000000000 --- a/arch/arm64/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/arch/arm64/OWNERS diff --git a/arch/x86/OWNERS b/arch/x86/OWNERS deleted file mode 100644 index ae2c29f6c3b7..000000000000 --- a/arch/x86/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/arch/x86/OWNERS diff --git a/block/OWNERS b/block/OWNERS deleted file mode 100644 index 7786d734d5c6..000000000000 --- a/block/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/block/OWNERS diff --git a/crypto/OWNERS b/crypto/OWNERS deleted file mode 100644 index f74b7ed228f7..000000000000 --- a/crypto/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/crypto/OWNERS diff --git a/drivers/OWNERS b/drivers/OWNERS deleted file mode 100644 index 22c7eece228f..000000000000 --- a/drivers/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/drivers/OWNERS diff --git a/fs/OWNERS b/fs/OWNERS deleted file mode 100644 index a838344a1137..000000000000 --- a/fs/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/fs/OWNERS diff --git a/fs/f2fs/OWNERS b/fs/f2fs/OWNERS deleted file mode 100644 index f981f44fbffd..000000000000 --- a/fs/f2fs/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/fs/f2fs/OWNERS diff --git a/fs/fuse/OWNERS b/fs/fuse/OWNERS deleted file mode 100644 index 6c04da7a65d5..000000000000 --- a/fs/fuse/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/fs/fuse/OWNERS diff --git a/fs/incfs/OWNERS b/fs/incfs/OWNERS deleted file mode 100644 index 17131f337364..000000000000 --- a/fs/incfs/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/fs/incfs/OWNERS diff --git a/include/OWNERS b/include/OWNERS deleted file mode 100644 index ab8142b271b4..000000000000 --- a/include/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/include/OWNERS diff --git a/include/linux/OWNERS b/include/linux/OWNERS deleted file mode 100644 index c88808c07797..000000000000 --- a/include/linux/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/include/linux/OWNERS diff --git a/include/trace/events/OWNERS b/include/trace/events/OWNERS deleted file mode 100644 index de3838b6df38..000000000000 --- a/include/trace/events/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/include/trace/events/OWNERS diff --git a/include/uapi/linux/OWNERS b/include/uapi/linux/OWNERS deleted file mode 100644 index 113046844b1c..000000000000 --- a/include/uapi/linux/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/include/uapi/linux/OWNERS diff --git a/kernel/sched/OWNERS b/kernel/sched/OWNERS deleted file mode 100644 index fc027b64b61b..000000000000 --- a/kernel/sched/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/kernel/sched/OWNERS diff --git a/mm/OWNERS b/mm/OWNERS deleted file mode 100644 index f89766e706e0..000000000000 --- a/mm/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/mm/OWNERS diff --git a/net/OWNERS b/net/OWNERS deleted file mode 100644 index ddb7653770ec..000000000000 --- a/net/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/net/OWNERS diff --git a/tools/testing/selftests/filesystems/fuse/OWNERS b/tools/testing/selftests/filesystems/fuse/OWNERS deleted file mode 100644 index 5eb371e1a5a3..000000000000 --- a/tools/testing/selftests/filesystems/fuse/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/tools/testing/selftests/filesystems/incfs/OWNERS diff --git a/tools/testing/selftests/filesystems/incfs/OWNERS b/tools/testing/selftests/filesystems/incfs/OWNERS deleted file mode 100644 index 5eb371e1a5a3..000000000000 --- a/tools/testing/selftests/filesystems/incfs/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# include OWNERS from the authoritative android-mainline branch -include kernel/common:android-mainline:/tools/testing/selftests/filesystems/incfs/OWNERS From 999976097d70e80452dee159710847f007e147f2 Mon Sep 17 00:00:00 2001 From: Carlos Llamas Date: Fri, 22 Jul 2022 01:19:38 +0000 Subject: [PATCH 022/124] ANDROID: binder: fix pending prio state for early exit When calling binder_do_set_priority() with the same policy and priority values as the current task, we exit early since there is nothing to do. However, the BINDER_PRIO_PENDING state might be set and in this case we fail to update it. A subsequent call to binder_transaction_priority() will then read an incorrect state and save the wrong priority. Fix this by setting thread->prio_state to BINDER_PRIO_SET on our way out. Bug: 199309216 Fixes: cac827f2619b ("ANDROID: binder: fix race in priority restore") Signed-off-by: Carlos Llamas Change-Id: I21e906cf4b2ebee908af41fe101ecd458ae1991c (cherry picked from commit 72193be6d4bd9ad29dacd998c14dff97f7a6c6c9) --- drivers/android/binder.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 336a13ff60a9..6fee6d574986 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -657,8 +657,13 @@ static void binder_do_set_priority(struct binder_thread *thread, bool has_cap_nice; unsigned int policy = desired->sched_policy; - if (task->policy == policy && task->normal_prio == desired->prio) + if (task->policy == policy && task->normal_prio == desired->prio) { + spin_lock(&thread->prio_lock); + if (thread->prio_state == BINDER_PRIO_PENDING) + thread->prio_state = BINDER_PRIO_SET; + spin_unlock(&thread->prio_lock); return; + } has_cap_nice = has_capability_noaudit(task, CAP_SYS_NICE); From 19bb609b45fbbab4cfd9a8765dc8cb9c90cfda34 Mon Sep 17 00:00:00 2001 From: Carlos Llamas Date: Mon, 1 Aug 2022 18:25:11 +0000 Subject: [PATCH 023/124] FROMLIST: binder: fix UAF of ref->proc caused by race condition A transaction of type BINDER_TYPE_WEAK_HANDLE can fail to increment the reference for a node. In this case, the target proc normally releases the failed reference upon close as expected. However, if the target is dying in parallel the call will race with binder_deferred_release(), so the target could have released all of its references by now leaving the cleanup of the new failed reference unhandled. The transaction then ends and the target proc gets released making the ref->proc now a dangling pointer. Later on, ref->node is closed and we attempt to take spin_lock(&ref->proc->inner_lock), which leads to the use-after-free bug reported below. Let's fix this by cleaning up the failed reference on the spot instead of relying on the target to do so. ================================================================== BUG: KASAN: use-after-free in _raw_spin_lock+0xa8/0x150 Write of size 4 at addr ffff5ca207094238 by task kworker/1:0/590 CPU: 1 PID: 590 Comm: kworker/1:0 Not tainted 5.19.0-rc8 #10 Hardware name: linux,dummy-virt (DT) Workqueue: events binder_deferred_func Call trace: dump_backtrace.part.0+0x1d0/0x1e0 show_stack+0x18/0x70 dump_stack_lvl+0x68/0x84 print_report+0x2e4/0x61c kasan_report+0xa4/0x110 kasan_check_range+0xfc/0x1a4 __kasan_check_write+0x3c/0x50 _raw_spin_lock+0xa8/0x150 binder_deferred_func+0x5e0/0x9b0 process_one_work+0x38c/0x5f0 worker_thread+0x9c/0x694 kthread+0x188/0x190 ret_from_fork+0x10/0x20 Signed-off-by: Carlos Llamas Acked-by: Christian Brauner (Microsoft) Bug: 239630375 Link: https://lore.kernel.org/all/20220801182511.3371447-1-cmllamas@google.com/ Signed-off-by: Carlos Llamas Change-Id: I5085dd0dc805a780a64c057e5819f82dd8f02868 (cherry picked from commit ae3fa5d16a02ba7c7b170e0e1ab56d6f0ba33964) --- drivers/android/binder.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 6fee6d574986..0a4f0e77689a 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -1519,6 +1519,18 @@ static int binder_inc_ref_for_node(struct binder_proc *proc, } ret = binder_inc_ref_olocked(ref, strong, target_list); *rdata = ref->data; + if (ret && ref == new_ref) { + /* + * Cleanup the failed reference here as the target + * could now be dead and have already released its + * references by now. Calling on the new reference + * with strong=0 and a tmp_refs will not decrement + * the node. The new_ref gets kfree'd below. + */ + binder_cleanup_ref_olocked(new_ref); + ref = NULL; + } + binder_proc_unlock(proc); if (new_ref && ref != new_ref) /* From 0380da7fd63ac93caf96a75d1b31e388d3c754e9 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Tue, 19 Jul 2022 12:52:51 +0100 Subject: [PATCH 024/124] FROMGIT: io_uring: Use original task for req identity in io_identity_cow() This issue is conceptually identical to the one fixed in 29f077d07051 ("io_uring: always use original task when preparing req identity"), so rather than reinvent the wheel, I'm shamelessly quoting the commit message from that patch - thanks Jens: "If the ring is setup with IORING_SETUP_IOPOLL and we have more than one task doing submissions on a ring, we can up in a situation where we assign the context from the current task rather than the request originator. Always use req->task rather than assume it's the same as current. No upstream patch exists for this issue, as only older kernels with the non-native workers have this problem." Bug: 238177383 Cc: Jens Axboe Cc: Pavel Begunkov Cc: Alexander Viro Cc: io-uring@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Fixes: 5c3462cfd123b ("io_uring: store io_identity in io_uring_task") Signed-off-by: Lee Jones Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 2ee0cab11f6626071f8a64c7792406dabdd94c8d git: //git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-5.10.y) Signed-off-by: Lee Jones Change-Id: I98adc653dbe03f8e9d214d9430fe50d351a45910 --- fs/io_uring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 31551e9041b3..b5fe82659792 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1318,7 +1318,7 @@ static void io_req_clean_work(struct io_kiocb *req) */ static bool io_identity_cow(struct io_kiocb *req) { - struct io_uring_task *tctx = current->io_uring; + struct io_uring_task *tctx = req->task->io_uring; const struct cred *creds = NULL; struct io_identity *id; From bc80ea8a4296c4d75f7e3e27b65718cae09f20f1 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 19 May 2022 06:05:27 -0600 Subject: [PATCH 025/124] BACKPORT: io_uring: always grab file table for deferred statx Lee reports that there's a use-after-free of the process file table. There's an assumption that we don't need the file table for some variants of statx invocation, but that turns out to be false and we end up with not grabbing a reference for the request even if the deferred execution uses it. Get rid of the REQ_F_NO_FILE_TABLE optimization for statx, and always grab that reference. This issues doesn't exist upstream since the native workers got introduced with 5.12. Bug: 220738351 Link: https://lore.kernel.org/io-uring/YoOJ%2FT4QRKC+fAZE@google.com/ Reported-by: Lee Jones Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 3c48558be571e01f67e65edcf03193484eeb2b79) Signed-off-by: Lee Jones Change-Id: Ife51536d95368bffdc393ad2a5e737a0e6ddf18f --- fs/io_uring.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index b5fe82659792..846aec5fbd23 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4250,12 +4250,8 @@ static int io_statx(struct io_kiocb *req, bool force_nonblock) struct io_statx *ctx = &req->statx; int ret; - if (force_nonblock) { - /* only need file table for an actual valid fd */ - if (ctx->dfd == -1 || ctx->dfd == AT_FDCWD) - req->flags |= REQ_F_NO_FILE_TABLE; + if (force_nonblock) return -EAGAIN; - } ret = do_statx(ctx->dfd, ctx->filename, ctx->flags, ctx->mask, ctx->buffer); From 2f9fed9ce805cf4d97cffb2f59d57b41b8e7fca8 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 21 Jul 2022 09:10:50 -0700 Subject: [PATCH 026/124] BACKPORT: Bluetooth: L2CAP: Fix use-after-free caused by l2cap_chan_put commit d0be8347c623e0ac4202a1d4e0373882821f56b0 upstream. This fixes the following trace which is caused by hci_rx_work starting up *after* the final channel reference has been put() during sock_close() but *before* the references to the channel have been destroyed, so instead the code now rely on kref_get_unless_zero/l2cap_chan_hold_unless_zero to prevent referencing a channel that is about to be destroyed. refcount_t: increment on 0; use-after-free. BUG: KASAN: use-after-free in refcount_dec_and_test+0x20/0xd0 Read of size 4 at addr ffffffc114f5bf18 by task kworker/u17:14/705 CPU: 4 PID: 705 Comm: kworker/u17:14 Tainted: G S W 4.14.234-00003-g1fb6d0bd49a4-dirty #28 Hardware name: Qualcomm Technologies, Inc. SM8150 V2 PM8150 Google Inc. MSM sm8150 Flame DVT (DT) Workqueue: hci0 hci_rx_work Call trace: dump_backtrace+0x0/0x378 show_stack+0x20/0x2c dump_stack+0x124/0x148 print_address_description+0x80/0x2e8 __kasan_report+0x168/0x188 kasan_report+0x10/0x18 __asan_load4+0x84/0x8c refcount_dec_and_test+0x20/0xd0 l2cap_chan_put+0x48/0x12c l2cap_recv_frame+0x4770/0x6550 l2cap_recv_acldata+0x44c/0x7a4 hci_acldata_packet+0x100/0x188 hci_rx_work+0x178/0x23c process_one_work+0x35c/0x95c worker_thread+0x4cc/0x960 kthread+0x1a8/0x1c4 ret_from_fork+0x10/0x18 Bug: 165329981 Cc: stable@kernel.org Reported-by: Lee Jones Signed-off-by: Luiz Augusto von Dentz Tested-by: Lee Jones Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Change-Id: I6efae55d8014740aebc8c3534846c2d249068b29 --- include/net/bluetooth/l2cap.h | 1 + net/bluetooth/l2cap_core.c | 61 +++++++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 8c99677077b6..26459016f150 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -855,6 +855,7 @@ enum { }; void l2cap_chan_hold(struct l2cap_chan *c); +struct l2cap_chan *l2cap_chan_hold_unless_zero(struct l2cap_chan *c); void l2cap_chan_put(struct l2cap_chan *c); static inline void l2cap_chan_lock(struct l2cap_chan *chan) diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 0ddbc415ce15..d507c0163350 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c @@ -111,7 +111,8 @@ static struct l2cap_chan *__l2cap_get_chan_by_scid(struct l2cap_conn *conn, } /* Find channel with given SCID. - * Returns locked channel. */ + * Returns a reference locked channel. + */ static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, u16 cid) { @@ -119,15 +120,19 @@ static struct l2cap_chan *l2cap_get_chan_by_scid(struct l2cap_conn *conn, mutex_lock(&conn->chan_lock); c = __l2cap_get_chan_by_scid(conn, cid); - if (c) - l2cap_chan_lock(c); + if (c) { + /* Only lock if chan reference is not 0 */ + c = l2cap_chan_hold_unless_zero(c); + if (c) + l2cap_chan_lock(c); + } mutex_unlock(&conn->chan_lock); return c; } /* Find channel with given DCID. - * Returns locked channel. + * Returns a reference locked channel. */ static struct l2cap_chan *l2cap_get_chan_by_dcid(struct l2cap_conn *conn, u16 cid) @@ -136,8 +141,12 @@ static struct l2cap_chan *l2cap_get_chan_by_dcid(struct l2cap_conn *conn, mutex_lock(&conn->chan_lock); c = __l2cap_get_chan_by_dcid(conn, cid); - if (c) - l2cap_chan_lock(c); + if (c) { + /* Only lock if chan reference is not 0 */ + c = l2cap_chan_hold_unless_zero(c); + if (c) + l2cap_chan_lock(c); + } mutex_unlock(&conn->chan_lock); return c; @@ -162,8 +171,12 @@ static struct l2cap_chan *l2cap_get_chan_by_ident(struct l2cap_conn *conn, mutex_lock(&conn->chan_lock); c = __l2cap_get_chan_by_ident(conn, ident); - if (c) - l2cap_chan_lock(c); + if (c) { + /* Only lock if chan reference is not 0 */ + c = l2cap_chan_hold_unless_zero(c); + if (c) + l2cap_chan_lock(c); + } mutex_unlock(&conn->chan_lock); return c; @@ -497,6 +510,16 @@ void l2cap_chan_hold(struct l2cap_chan *c) kref_get(&c->kref); } +struct l2cap_chan *l2cap_chan_hold_unless_zero(struct l2cap_chan *c) +{ + BT_DBG("chan %p orig refcnt %u", c, kref_read(&c->kref)); + + if (!kref_get_unless_zero(&c->kref)) + return NULL; + + return c; +} + void l2cap_chan_put(struct l2cap_chan *c) { BT_DBG("chan %p orig refcnt %d", c, kref_read(&c->kref)); @@ -1964,7 +1987,10 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm, src_match = !bacmp(&c->src, src); dst_match = !bacmp(&c->dst, dst); if (src_match && dst_match) { - l2cap_chan_hold(c); + c = l2cap_chan_hold_unless_zero(c); + if (!c) + continue; + read_unlock(&chan_list_lock); return c; } @@ -1979,7 +2005,7 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm, } if (c1) - l2cap_chan_hold(c1); + c1 = l2cap_chan_hold_unless_zero(c1); read_unlock(&chan_list_lock); @@ -4459,6 +4485,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, unlock: l2cap_chan_unlock(chan); + l2cap_chan_put(chan); return err; } @@ -4572,6 +4599,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, done: l2cap_chan_unlock(chan); + l2cap_chan_put(chan); return err; } @@ -5299,6 +5327,7 @@ send_move_response: l2cap_send_move_chan_rsp(chan, result); l2cap_chan_unlock(chan); + l2cap_chan_put(chan); return 0; } @@ -5391,6 +5420,7 @@ static void l2cap_move_continue(struct l2cap_conn *conn, u16 icid, u16 result) } l2cap_chan_unlock(chan); + l2cap_chan_put(chan); } static void l2cap_move_fail(struct l2cap_conn *conn, u8 ident, u16 icid, @@ -5420,6 +5450,7 @@ static void l2cap_move_fail(struct l2cap_conn *conn, u8 ident, u16 icid, l2cap_send_move_chan_cfm(chan, L2CAP_MC_UNCONFIRMED); l2cap_chan_unlock(chan); + l2cap_chan_put(chan); } static int l2cap_move_channel_rsp(struct l2cap_conn *conn, @@ -5483,6 +5514,7 @@ static int l2cap_move_channel_confirm(struct l2cap_conn *conn, l2cap_send_move_chan_cfm_rsp(conn, cmd->ident, icid); l2cap_chan_unlock(chan); + l2cap_chan_put(chan); return 0; } @@ -5518,6 +5550,7 @@ static inline int l2cap_move_channel_confirm_rsp(struct l2cap_conn *conn, } l2cap_chan_unlock(chan); + l2cap_chan_put(chan); return 0; } @@ -5890,12 +5923,11 @@ static inline int l2cap_le_credits(struct l2cap_conn *conn, if (credits > max_credits) { BT_ERR("LE credits overflow"); l2cap_send_disconn_req(chan, ECONNRESET); - l2cap_chan_unlock(chan); /* Return 0 so that we don't trigger an unnecessary * command reject packet. */ - return 0; + goto unlock; } chan->tx_credits += credits; @@ -5906,7 +5938,9 @@ static inline int l2cap_le_credits(struct l2cap_conn *conn, if (chan->tx_credits) chan->ops->resume(chan); +unlock: l2cap_chan_unlock(chan); + l2cap_chan_put(chan); return 0; } @@ -7586,6 +7620,7 @@ drop: done: l2cap_chan_unlock(chan); + l2cap_chan_put(chan); } static void l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, @@ -8073,7 +8108,7 @@ static struct l2cap_chan *l2cap_global_fixed_chan(struct l2cap_chan *c, if (src_type != c->src_type) continue; - l2cap_chan_hold(c); + c = l2cap_chan_hold_unless_zero(c); read_unlock(&chan_list_lock); return c; } From d9d8680e9f7c32c493e9e15d60aa281733c2c3ae Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Fri, 20 May 2022 13:48:11 -0400 Subject: [PATCH 027/124] BACKPORT: KVM: x86/mmu: fix NULL pointer dereference on guest INVPCID commit 9f46c187e2e680ecd9de7983e4d081c3391acc76 upstream. With shadow paging enabled, the INVPCID instruction results in a call to kvm_mmu_invpcid_gva. If INVPCID is executed with CR0.PG=0, the invlpg callback is not set and the result is a NULL pointer dereference. Fix it trivially by checking for mmu->invlpg before every call. There are other possibilities: - check for CR0.PG, because KVM (like all Intel processors after P5) flushes guest TLB on CR0.PG changes so that INVPCID/INVLPG are a nop with paging disabled - check for EFER.LMA, because KVM syncs and flushes when switching MMU contexts outside of 64-bit mode All of these are tricky, go for the simple solution. This is CVE-2022-1789. Bug: 235691682 Reported-by: Yongkang Jia Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini [fix conflict due to missing b9e5603c2a3accbadfec570ac501a54431a6bdba] Signed-off-by: Vegard Nossum Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Change-Id: If558163c4ddd4606274b456324278ed3fb5b093c --- arch/x86/kvm/mmu/mmu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 20d29ae8ed70..9506cfcb86be 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -5176,14 +5176,16 @@ void kvm_mmu_invpcid_gva(struct kvm_vcpu *vcpu, gva_t gva, unsigned long pcid) uint i; if (pcid == kvm_get_active_pcid(vcpu)) { - mmu->invlpg(vcpu, gva, mmu->root_hpa); + if (mmu->invlpg) + mmu->invlpg(vcpu, gva, mmu->root_hpa); tlb_flush = true; } for (i = 0; i < KVM_MMU_NUM_PREV_ROOTS; i++) { if (VALID_PAGE(mmu->prev_roots[i].hpa) && pcid == kvm_get_pcid(vcpu, mmu->prev_roots[i].pgd)) { - mmu->invlpg(vcpu, gva, mmu->prev_roots[i].hpa); + if (mmu->invlpg) + mmu->invlpg(vcpu, gva, mmu->prev_roots[i].hpa); tlb_flush = true; } } From 0a21a3eb9fcea0609f3bc8bee1f796788e0a770e Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 1 Mar 2022 11:04:24 +0300 Subject: [PATCH 028/124] BACKPORT: usb: gadget: rndis: prevent integer overflow in rndis_set_response() commit 65f3324f4b6fed78b8761c3b74615ecf0ffa81fa upstream. If "BufOffset" is very large the "BufOffset + 8" operation can have an integer overflow. Bug: 239842288 Cc: stable@kernel.org Fixes: 38ea1eac7d88 ("usb: gadget: rndis: check size of RNDIS_MSG_SET command") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/20220301080424.GA17208@kili Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Change-Id: I4dcecb9ada2680a4211e5ccc9b27de2df964e404 --- drivers/usb/gadget/function/rndis.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/gadget/function/rndis.c b/drivers/usb/gadget/function/rndis.c index 0f14c5291af0..4150de96b937 100644 --- a/drivers/usb/gadget/function/rndis.c +++ b/drivers/usb/gadget/function/rndis.c @@ -640,6 +640,7 @@ static int rndis_set_response(struct rndis_params *params, BufLength = le32_to_cpu(buf->InformationBufferLength); BufOffset = le32_to_cpu(buf->InformationBufferOffset); if ((BufLength > RNDIS_MAX_TOTAL_SIZE) || + (BufOffset > RNDIS_MAX_TOTAL_SIZE) || (BufOffset + 8 >= RNDIS_MAX_TOTAL_SIZE)) return -EINVAL; From 0c79c40888edaa0a82bbc569849999631278cad7 Mon Sep 17 00:00:00 2001 From: Felix Kuehling Date: Wed, 7 Apr 2021 18:19:58 -0400 Subject: [PATCH 029/124] BACKPORT: drm/amdkfd: Use drm_priv to pass VM from KFD to amdgpu commit b40a6ab2cf9213923bf8e821ce7fa7f6a0a26990 upstream. amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu needs the drm_priv to allow mmap to access the BO through the corresponding file descriptor. The VM can also be extracted from drm_priv, so drm_priv can replace the vm parameter in the kfd2kgd interface. Bug: 225381233 Signed-off-by: Felix Kuehling Reviewed-by: Philip Yang Signed-off-by: Alex Deucher [This is a partial cherry-pick of the upstream commit.] Signed-off-by: Lee Jones Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Change-Id: I49c141ce1727fd5822f0ce09b2dc4887caa65766 --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c index 26f8a2138377..1b4c7ced8b92 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c @@ -1024,11 +1024,15 @@ int amdgpu_amdkfd_gpuvm_acquire_process_vm(struct kgd_dev *kgd, struct dma_fence **ef) { struct amdgpu_device *adev = get_amdgpu_device(kgd); - struct drm_file *drm_priv = filp->private_data; - struct amdgpu_fpriv *drv_priv = drm_priv->driver_priv; - struct amdgpu_vm *avm = &drv_priv->vm; + struct amdgpu_fpriv *drv_priv; + struct amdgpu_vm *avm; int ret; + ret = amdgpu_file_to_fpriv(filp, &drv_priv); + if (ret) + return ret; + avm = &drv_priv->vm; + /* Already a compute VM? */ if (avm->process_info) return -EINVAL; From 913113f05fa2b14c1afbc827dc4273e8ed9fcafe Mon Sep 17 00:00:00 2001 From: Carlos Llamas Date: Fri, 1 Jul 2022 18:20:41 +0000 Subject: [PATCH 030/124] UPSTREAM: binder: fix redefinition of seq_file attributes The patchset in [1] exported some definitions to binder_internal.h in order to make the debugfs entries such as 'stats' and 'transaction_log' available in a binderfs instance. However, the DEFINE_SHOW_ATTRIBUTE macro expands into a static function/variable pair, which in turn get redefined each time a source file includes this internal header. This problem was made evident after a report from the kernel test robot where several W=1 build warnings are seen in downstream kernels. See the following example: include/../drivers/android/binder_internal.h:111:23: warning: 'binder_stats_fops' defined but not used [-Wunused-const-variable=] 111 | DEFINE_SHOW_ATTRIBUTE(binder_stats); | ^~~~~~~~~~~~ include/linux/seq_file.h:174:37: note: in definition of macro 'DEFINE_SHOW_ATTRIBUTE' 174 | static const struct file_operations __name ## _fops = { \ | ^~~~~~ This patch fixes the above issues by moving back the definitions into binder.c and instead creates an array of the debugfs entries which is more convenient to share with binderfs and iterate through. [1] https://lore.kernel.org/all/20190903161655.107408-1-hridya@google.com/ Fixes: 0e13e452dafc ("binder: Add stats, state and transactions files") Fixes: 03e2e07e3814 ("binder: Make transaction_log available in binderfs") Reported-by: kernel test robot Signed-off-by: Carlos Llamas Link: https://lore.kernel.org/r/20220701182041.2134313-1-cmllamas@google.com Signed-off-by: Greg Kroah-Hartman Bug: 240404657 (cherry picked from commit b7e241bbff24f9e106bf616408fd58bcedc44bae) Signed-off-by: Carlos Llamas Change-Id: I7e9ca1ab1f3a5a4a272e50f24d404c17cad55d32 --- drivers/android/binder.c | 114 +++++++++++++++++++++--------- drivers/android/binder_internal.h | 46 +++--------- drivers/android/binderfs.c | 47 +++--------- 3 files changed, 100 insertions(+), 107 deletions(-) diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 0a4f0e77689a..07330027e6c5 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -173,8 +173,32 @@ static inline void binder_stats_created(enum binder_stat_types type) atomic_inc(&binder_stats.obj_created[type]); } -struct binder_transaction_log binder_transaction_log; -struct binder_transaction_log binder_transaction_log_failed; +struct binder_transaction_log_entry { + int debug_id; + int debug_id_done; + int call_type; + int from_proc; + int from_thread; + int target_handle; + int to_proc; + int to_thread; + int to_node; + int data_size; + int offsets_size; + int return_error_line; + uint32_t return_error; + uint32_t return_error_param; + char context_name[BINDERFS_MAX_NAME + 1]; +}; + +struct binder_transaction_log { + atomic_t cur; + bool full; + struct binder_transaction_log_entry entry[32]; +}; + +static struct binder_transaction_log binder_transaction_log; +static struct binder_transaction_log binder_transaction_log_failed; static struct binder_transaction_log_entry *binder_transaction_log_add( struct binder_transaction_log *log) @@ -6071,8 +6095,7 @@ static void print_binder_proc_stats(struct seq_file *m, print_binder_stats(m, " ", &proc->stats); } - -int binder_state_show(struct seq_file *m, void *unused) +static int state_show(struct seq_file *m, void *unused) { struct binder_proc *proc; struct binder_node *node; @@ -6111,7 +6134,7 @@ int binder_state_show(struct seq_file *m, void *unused) return 0; } -int binder_stats_show(struct seq_file *m, void *unused) +static int stats_show(struct seq_file *m, void *unused) { struct binder_proc *proc; @@ -6127,7 +6150,7 @@ int binder_stats_show(struct seq_file *m, void *unused) return 0; } -int binder_transactions_show(struct seq_file *m, void *unused) +static int transactions_show(struct seq_file *m, void *unused) { struct binder_proc *proc; @@ -6183,7 +6206,7 @@ static void print_binder_transaction_log_entry(struct seq_file *m, "\n" : " (incomplete)\n"); } -int binder_transaction_log_show(struct seq_file *m, void *unused) +static int transaction_log_show(struct seq_file *m, void *unused) { struct binder_transaction_log *log = m->private; unsigned int log_cur = atomic_read(&log->cur); @@ -6215,6 +6238,45 @@ const struct file_operations binder_fops = { .release = binder_release, }; +DEFINE_SHOW_ATTRIBUTE(state); +DEFINE_SHOW_ATTRIBUTE(stats); +DEFINE_SHOW_ATTRIBUTE(transactions); +DEFINE_SHOW_ATTRIBUTE(transaction_log); + +const struct binder_debugfs_entry binder_debugfs_entries[] = { + { + .name = "state", + .mode = 0444, + .fops = &state_fops, + .data = NULL, + }, + { + .name = "stats", + .mode = 0444, + .fops = &stats_fops, + .data = NULL, + }, + { + .name = "transactions", + .mode = 0444, + .fops = &transactions_fops, + .data = NULL, + }, + { + .name = "transaction_log", + .mode = 0444, + .fops = &transaction_log_fops, + .data = &binder_transaction_log, + }, + { + .name = "failed_transaction_log", + .mode = 0444, + .fops = &transaction_log_fops, + .data = &binder_transaction_log_failed, + }, + {} /* terminator */ +}; + static int __init init_binder_device(const char *name) { int ret; @@ -6260,36 +6322,18 @@ static int __init binder_init(void) atomic_set(&binder_transaction_log_failed.cur, ~0U); binder_debugfs_dir_entry_root = debugfs_create_dir("binder", NULL); - if (binder_debugfs_dir_entry_root) + if (binder_debugfs_dir_entry_root) { + const struct binder_debugfs_entry *db_entry; + + binder_for_each_debugfs_entry(db_entry) + debugfs_create_file(db_entry->name, + db_entry->mode, + binder_debugfs_dir_entry_root, + db_entry->data, + db_entry->fops); + binder_debugfs_dir_entry_proc = debugfs_create_dir("proc", binder_debugfs_dir_entry_root); - - if (binder_debugfs_dir_entry_root) { - debugfs_create_file("state", - 0444, - binder_debugfs_dir_entry_root, - NULL, - &binder_state_fops); - debugfs_create_file("stats", - 0444, - binder_debugfs_dir_entry_root, - NULL, - &binder_stats_fops); - debugfs_create_file("transactions", - 0444, - binder_debugfs_dir_entry_root, - NULL, - &binder_transactions_fops); - debugfs_create_file("transaction_log", - 0444, - binder_debugfs_dir_entry_root, - &binder_transaction_log, - &binder_transaction_log_fops); - debugfs_create_file("failed_transaction_log", - 0444, - binder_debugfs_dir_entry_root, - &binder_transaction_log_failed, - &binder_transaction_log_fops); } if (!IS_ENABLED(CONFIG_ANDROID_BINDERFS) && diff --git a/drivers/android/binder_internal.h b/drivers/android/binder_internal.h index a25df99bd30b..5bbd87dd6c25 100644 --- a/drivers/android/binder_internal.h +++ b/drivers/android/binder_internal.h @@ -107,41 +107,19 @@ static inline int __init init_binderfs(void) } #endif -int binder_stats_show(struct seq_file *m, void *unused); -DEFINE_SHOW_ATTRIBUTE(binder_stats); - -int binder_state_show(struct seq_file *m, void *unused); -DEFINE_SHOW_ATTRIBUTE(binder_state); - -int binder_transactions_show(struct seq_file *m, void *unused); -DEFINE_SHOW_ATTRIBUTE(binder_transactions); - -int binder_transaction_log_show(struct seq_file *m, void *unused); -DEFINE_SHOW_ATTRIBUTE(binder_transaction_log); - -struct binder_transaction_log_entry { - int debug_id; - int debug_id_done; - int call_type; - int from_proc; - int from_thread; - int target_handle; - int to_proc; - int to_thread; - int to_node; - int data_size; - int offsets_size; - int return_error_line; - uint32_t return_error; - uint32_t return_error_param; - char context_name[BINDERFS_MAX_NAME + 1]; +struct binder_debugfs_entry { + const char *name; + umode_t mode; + const struct file_operations *fops; + void *data; }; -struct binder_transaction_log { - atomic_t cur; - bool full; - struct binder_transaction_log_entry entry[32]; -}; +extern const struct binder_debugfs_entry binder_debugfs_entries[]; + +#define binder_for_each_debugfs_entry(entry) \ + for ((entry) = binder_debugfs_entries; \ + (entry)->name; \ + (entry)++) enum binder_stat_types { BINDER_STAT_PROC, @@ -617,6 +595,4 @@ struct binder_object { }; }; -extern struct binder_transaction_log binder_transaction_log; -extern struct binder_transaction_log binder_transaction_log_failed; #endif /* _LINUX_BINDER_INTERNAL_H */ diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c index 346f315e8bd7..8d4eb491d4a6 100644 --- a/drivers/android/binderfs.c +++ b/drivers/android/binderfs.c @@ -619,6 +619,7 @@ static int init_binder_features(struct super_block *sb) static int init_binder_logs(struct super_block *sb) { struct dentry *binder_logs_root_dir, *dentry, *proc_log_dir; + const struct binder_debugfs_entry *db_entry; struct binderfs_info *info; int ret = 0; @@ -629,43 +630,15 @@ static int init_binder_logs(struct super_block *sb) goto out; } - dentry = binderfs_create_file(binder_logs_root_dir, "stats", - &binder_stats_fops, NULL); - if (IS_ERR(dentry)) { - ret = PTR_ERR(dentry); - goto out; - } - - dentry = binderfs_create_file(binder_logs_root_dir, "state", - &binder_state_fops, NULL); - if (IS_ERR(dentry)) { - ret = PTR_ERR(dentry); - goto out; - } - - dentry = binderfs_create_file(binder_logs_root_dir, "transactions", - &binder_transactions_fops, NULL); - if (IS_ERR(dentry)) { - ret = PTR_ERR(dentry); - goto out; - } - - dentry = binderfs_create_file(binder_logs_root_dir, - "transaction_log", - &binder_transaction_log_fops, - &binder_transaction_log); - if (IS_ERR(dentry)) { - ret = PTR_ERR(dentry); - goto out; - } - - dentry = binderfs_create_file(binder_logs_root_dir, - "failed_transaction_log", - &binder_transaction_log_fops, - &binder_transaction_log_failed); - if (IS_ERR(dentry)) { - ret = PTR_ERR(dentry); - goto out; + binder_for_each_debugfs_entry(db_entry) { + dentry = binderfs_create_file(binder_logs_root_dir, + db_entry->name, + db_entry->fops, + db_entry->data); + if (IS_ERR(dentry)) { + ret = PTR_ERR(dentry); + goto out; + } } proc_log_dir = binderfs_create_dir(binder_logs_root_dir, "proc"); From 5ac3e909a43c541e26886522a9c411d2c5381478 Mon Sep 17 00:00:00 2001 From: Seiya Wang Date: Wed, 3 Feb 2021 13:53:47 +0800 Subject: [PATCH 031/124] UPSTREAM: arm64: perf: add support for Cortex-A78 Add support for Cortex-A78 using generic PMUv3 for now. Signed-off-by: Seiya Wang Acked-by: Mark Rutland Link: https://lore.kernel.org/r/20210203055348.4935-2-seiya.wang@mediatek.com Signed-off-by: Will Deacon (cherry picked from commit db2bb91f2e8e73d85876d1665608e834d91d21ee) Signed-off-by: Will Deacon Bug: 238597093 Change-Id: I8c695a7625216cb8dc08dab4e3dd8734cd12254d --- arch/arm64/kernel/perf_event.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index cdb3d4549b3a..31b95caa3be5 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -1188,6 +1188,12 @@ static int armv8_a77_pmu_init(struct arm_pmu *cpu_pmu) armv8_pmuv3_map_event); } +static int armv8_a78_pmu_init(struct arm_pmu *cpu_pmu) +{ + return armv8_pmu_init_nogroups(cpu_pmu, "armv8_cortex_a78", + armv8_pmuv3_map_event); +} + static int armv8_e1_pmu_init(struct arm_pmu *cpu_pmu) { return armv8_pmu_init_nogroups(cpu_pmu, "armv8_neoverse_e1", @@ -1225,6 +1231,7 @@ static const struct of_device_id armv8_pmu_of_device_ids[] = { {.compatible = "arm,cortex-a75-pmu", .data = armv8_a75_pmu_init}, {.compatible = "arm,cortex-a76-pmu", .data = armv8_a76_pmu_init}, {.compatible = "arm,cortex-a77-pmu", .data = armv8_a77_pmu_init}, + {.compatible = "arm,cortex-a78-pmu", .data = armv8_a78_pmu_init}, {.compatible = "arm,neoverse-e1-pmu", .data = armv8_e1_pmu_init}, {.compatible = "arm,neoverse-n1-pmu", .data = armv8_n1_pmu_init}, {.compatible = "cavium,thunder-pmu", .data = armv8_thunder_pmu_init}, From 96dc76e1b1542af5163098000754bb74e9ee88cd Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Tue, 14 Dec 2021 14:16:13 +0000 Subject: [PATCH 032/124] UPSTREAM: arm64: perf: Support Denver and Carmel PMUs Add support for the NVIDIA Denver and Carmel PMUs using the generic PMUv3 event map for now. Acked-by: Mark Rutland Signed-off-by: Thierry Reding [ rm: reorder entries alphabetically ] Signed-off-by: Robin Murphy Link: https://lore.kernel.org/r/5f0f69d47acca78a9e479501aa4d8b429e23cf11.1639490264.git.robin.murphy@arm.com Signed-off-by: Will Deacon (cherry picked from commit d4c4844a9b47dc1c7e8ccce0cdd899602f5479fd) Signed-off-by: Will Deacon Bug: 238597093 Change-Id: I078644d2bb973fb7bd6777ad0bb702c430c05967 --- arch/arm64/kernel/perf_event.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index 31b95caa3be5..6a797b14c0d1 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -1218,6 +1218,18 @@ static int armv8_vulcan_pmu_init(struct arm_pmu *cpu_pmu) armv8_vulcan_map_event); } +static int armv8_carmel_pmu_init(struct arm_pmu *cpu_pmu) +{ + return armv8_pmu_init_nogroups(cpu_pmu, "armv8_nvidia_carmel", + armv8_pmuv3_map_event); +} + +static int armv8_denver_pmu_init(struct arm_pmu *cpu_pmu) +{ + return armv8_pmu_init_nogroups(cpu_pmu, "armv8_nvidia_denver", + armv8_pmuv3_map_event); +} + static const struct of_device_id armv8_pmu_of_device_ids[] = { {.compatible = "arm,armv8-pmuv3", .data = armv8_pmuv3_init}, {.compatible = "arm,cortex-a34-pmu", .data = armv8_a34_pmu_init}, @@ -1236,6 +1248,8 @@ static const struct of_device_id armv8_pmu_of_device_ids[] = { {.compatible = "arm,neoverse-n1-pmu", .data = armv8_n1_pmu_init}, {.compatible = "cavium,thunder-pmu", .data = armv8_thunder_pmu_init}, {.compatible = "brcm,vulcan-pmu", .data = armv8_vulcan_pmu_init}, + {.compatible = "nvidia,carmel-pmu", .data = armv8_carmel_pmu_init}, + {.compatible = "nvidia,denver-pmu", .data = armv8_denver_pmu_init}, {}, }; From be08fd28ca58286b4b1396147ce290f97c67f3de Mon Sep 17 00:00:00 2001 From: Robin Murphy Date: Tue, 14 Dec 2021 14:16:14 +0000 Subject: [PATCH 033/124] UPSTREAM: arm64: perf: Simplify registration boilerplate With the trend for per-core events moving to userspace JSON, registering names for PMUv3 implementations is increasingly a pure boilerplate exercise. Let's wrap things a step further so we can generate the basic PMUv3 init function with a macro invocation, and reduce further new addition to just 2 lines each. Suggested-by: Mark Rutland Signed-off-by: Robin Murphy Link: https://lore.kernel.org/r/b79477ea3b97f685d00511d4ecd2f686184dca34.1639490264.git.robin.murphy@arm.com Signed-off-by: Will Deacon (cherry picked from commit 6ac9f30bd43baf9e05696e9a614fcd7e83c74afa) Signed-off-by: Will Deacon Bug: 238597093 Change-Id: I635d3978555c84b4234b6a791c8012ad4f5170c4 --- arch/arm64/kernel/perf_event.c | 113 +++++++++------------------------ 1 file changed, 31 insertions(+), 82 deletions(-) diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index 6a797b14c0d1..cd741485650c 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -1116,17 +1116,26 @@ static int armv8_pmu_init_nogroups(struct arm_pmu *cpu_pmu, char *name, return armv8_pmu_init(cpu_pmu, name, map_event, NULL, NULL, NULL); } -static int armv8_pmuv3_init(struct arm_pmu *cpu_pmu) -{ - return armv8_pmu_init_nogroups(cpu_pmu, "armv8_pmuv3", - armv8_pmuv3_map_event); +#define PMUV3_INIT_SIMPLE(name) \ +static int name##_pmu_init(struct arm_pmu *cpu_pmu) \ +{ \ + return armv8_pmu_init_nogroups(cpu_pmu, #name, armv8_pmuv3_map_event);\ } -static int armv8_a34_pmu_init(struct arm_pmu *cpu_pmu) -{ - return armv8_pmu_init_nogroups(cpu_pmu, "armv8_cortex_a34", - armv8_pmuv3_map_event); -} +PMUV3_INIT_SIMPLE(armv8_pmuv3) + +PMUV3_INIT_SIMPLE(armv8_cortex_a34) +PMUV3_INIT_SIMPLE(armv8_cortex_a55) +PMUV3_INIT_SIMPLE(armv8_cortex_a65) +PMUV3_INIT_SIMPLE(armv8_cortex_a75) +PMUV3_INIT_SIMPLE(armv8_cortex_a76) +PMUV3_INIT_SIMPLE(armv8_cortex_a77) +PMUV3_INIT_SIMPLE(armv8_cortex_a78) +PMUV3_INIT_SIMPLE(armv8_neoverse_e1) +PMUV3_INIT_SIMPLE(armv8_neoverse_n1) + +PMUV3_INIT_SIMPLE(armv8_nvidia_carmel) +PMUV3_INIT_SIMPLE(armv8_nvidia_denver) static int armv8_a35_pmu_init(struct arm_pmu *cpu_pmu) { @@ -1140,24 +1149,12 @@ static int armv8_a53_pmu_init(struct arm_pmu *cpu_pmu) armv8_a53_map_event); } -static int armv8_a55_pmu_init(struct arm_pmu *cpu_pmu) -{ - return armv8_pmu_init_nogroups(cpu_pmu, "armv8_cortex_a55", - armv8_pmuv3_map_event); -} - static int armv8_a57_pmu_init(struct arm_pmu *cpu_pmu) { return armv8_pmu_init_nogroups(cpu_pmu, "armv8_cortex_a57", armv8_a57_map_event); } -static int armv8_a65_pmu_init(struct arm_pmu *cpu_pmu) -{ - return armv8_pmu_init_nogroups(cpu_pmu, "armv8_cortex_a65", - armv8_pmuv3_map_event); -} - static int armv8_a72_pmu_init(struct arm_pmu *cpu_pmu) { return armv8_pmu_init_nogroups(cpu_pmu, "armv8_cortex_a72", @@ -1170,42 +1167,6 @@ static int armv8_a73_pmu_init(struct arm_pmu *cpu_pmu) armv8_a73_map_event); } -static int armv8_a75_pmu_init(struct arm_pmu *cpu_pmu) -{ - return armv8_pmu_init_nogroups(cpu_pmu, "armv8_cortex_a75", - armv8_pmuv3_map_event); -} - -static int armv8_a76_pmu_init(struct arm_pmu *cpu_pmu) -{ - return armv8_pmu_init_nogroups(cpu_pmu, "armv8_cortex_a76", - armv8_pmuv3_map_event); -} - -static int armv8_a77_pmu_init(struct arm_pmu *cpu_pmu) -{ - return armv8_pmu_init_nogroups(cpu_pmu, "armv8_cortex_a77", - armv8_pmuv3_map_event); -} - -static int armv8_a78_pmu_init(struct arm_pmu *cpu_pmu) -{ - return armv8_pmu_init_nogroups(cpu_pmu, "armv8_cortex_a78", - armv8_pmuv3_map_event); -} - -static int armv8_e1_pmu_init(struct arm_pmu *cpu_pmu) -{ - return armv8_pmu_init_nogroups(cpu_pmu, "armv8_neoverse_e1", - armv8_pmuv3_map_event); -} - -static int armv8_n1_pmu_init(struct arm_pmu *cpu_pmu) -{ - return armv8_pmu_init_nogroups(cpu_pmu, "armv8_neoverse_n1", - armv8_pmuv3_map_event); -} - static int armv8_thunder_pmu_init(struct arm_pmu *cpu_pmu) { return armv8_pmu_init_nogroups(cpu_pmu, "armv8_cavium_thunder", @@ -1218,38 +1179,26 @@ static int armv8_vulcan_pmu_init(struct arm_pmu *cpu_pmu) armv8_vulcan_map_event); } -static int armv8_carmel_pmu_init(struct arm_pmu *cpu_pmu) -{ - return armv8_pmu_init_nogroups(cpu_pmu, "armv8_nvidia_carmel", - armv8_pmuv3_map_event); -} - -static int armv8_denver_pmu_init(struct arm_pmu *cpu_pmu) -{ - return armv8_pmu_init_nogroups(cpu_pmu, "armv8_nvidia_denver", - armv8_pmuv3_map_event); -} - static const struct of_device_id armv8_pmu_of_device_ids[] = { - {.compatible = "arm,armv8-pmuv3", .data = armv8_pmuv3_init}, - {.compatible = "arm,cortex-a34-pmu", .data = armv8_a34_pmu_init}, + {.compatible = "arm,armv8-pmuv3", .data = armv8_pmuv3_pmu_init}, + {.compatible = "arm,cortex-a34-pmu", .data = armv8_cortex_a34_pmu_init}, {.compatible = "arm,cortex-a35-pmu", .data = armv8_a35_pmu_init}, {.compatible = "arm,cortex-a53-pmu", .data = armv8_a53_pmu_init}, - {.compatible = "arm,cortex-a55-pmu", .data = armv8_a55_pmu_init}, + {.compatible = "arm,cortex-a55-pmu", .data = armv8_cortex_a55_pmu_init}, {.compatible = "arm,cortex-a57-pmu", .data = armv8_a57_pmu_init}, - {.compatible = "arm,cortex-a65-pmu", .data = armv8_a65_pmu_init}, + {.compatible = "arm,cortex-a65-pmu", .data = armv8_cortex_a65_pmu_init}, {.compatible = "arm,cortex-a72-pmu", .data = armv8_a72_pmu_init}, {.compatible = "arm,cortex-a73-pmu", .data = armv8_a73_pmu_init}, - {.compatible = "arm,cortex-a75-pmu", .data = armv8_a75_pmu_init}, - {.compatible = "arm,cortex-a76-pmu", .data = armv8_a76_pmu_init}, - {.compatible = "arm,cortex-a77-pmu", .data = armv8_a77_pmu_init}, - {.compatible = "arm,cortex-a78-pmu", .data = armv8_a78_pmu_init}, - {.compatible = "arm,neoverse-e1-pmu", .data = armv8_e1_pmu_init}, - {.compatible = "arm,neoverse-n1-pmu", .data = armv8_n1_pmu_init}, + {.compatible = "arm,cortex-a75-pmu", .data = armv8_cortex_a75_pmu_init}, + {.compatible = "arm,cortex-a76-pmu", .data = armv8_cortex_a76_pmu_init}, + {.compatible = "arm,cortex-a77-pmu", .data = armv8_cortex_a77_pmu_init}, + {.compatible = "arm,cortex-a78-pmu", .data = armv8_cortex_a78_pmu_init}, + {.compatible = "arm,neoverse-e1-pmu", .data = armv8_neoverse_e1_pmu_init}, + {.compatible = "arm,neoverse-n1-pmu", .data = armv8_neoverse_n1_pmu_init}, {.compatible = "cavium,thunder-pmu", .data = armv8_thunder_pmu_init}, {.compatible = "brcm,vulcan-pmu", .data = armv8_vulcan_pmu_init}, - {.compatible = "nvidia,carmel-pmu", .data = armv8_carmel_pmu_init}, - {.compatible = "nvidia,denver-pmu", .data = armv8_denver_pmu_init}, + {.compatible = "nvidia,carmel-pmu", .data = armv8_nvidia_carmel_pmu_init}, + {.compatible = "nvidia,denver-pmu", .data = armv8_nvidia_denver_pmu_init}, {}, }; @@ -1272,7 +1221,7 @@ static int __init armv8_pmu_driver_init(void) if (acpi_disabled) return platform_driver_register(&armv8_pmu_driver); else - return arm_pmu_acpi_probe(armv8_pmuv3_init); + return arm_pmu_acpi_probe(armv8_pmuv3_pmu_init); } device_initcall(armv8_pmu_driver_init) From 9f4fae40a971daf4199ed9a59e2ec44b10237d73 Mon Sep 17 00:00:00 2001 From: Robin Murphy Date: Tue, 14 Dec 2021 14:16:15 +0000 Subject: [PATCH 034/124] UPSTREAM: arm64: perf: Support new DT compatibles Wire up the new DT compatibles so we can present appropriate PMU names to userspace for the latest and greatest CPUs. Signed-off-by: Robin Murphy Link: https://lore.kernel.org/r/62d14ba12d847ec7f1fba7cb0b3b881b437e1cc5.1639490264.git.robin.murphy@arm.com Signed-off-by: Will Deacon (cherry picked from commit 893c34b60a59cd0bdb496084f5c096be720bd244) Signed-off-by: Will Deacon Bug: 238597093 Change-Id: I7aef375698c5192d4adbf551cae3ea9f8027f101 --- arch/arm64/kernel/perf_event.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index cd741485650c..e41cee4e1bb9 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -1131,8 +1131,14 @@ PMUV3_INIT_SIMPLE(armv8_cortex_a75) PMUV3_INIT_SIMPLE(armv8_cortex_a76) PMUV3_INIT_SIMPLE(armv8_cortex_a77) PMUV3_INIT_SIMPLE(armv8_cortex_a78) +PMUV3_INIT_SIMPLE(armv9_cortex_a510) +PMUV3_INIT_SIMPLE(armv9_cortex_a710) +PMUV3_INIT_SIMPLE(armv8_cortex_x1) +PMUV3_INIT_SIMPLE(armv9_cortex_x2) PMUV3_INIT_SIMPLE(armv8_neoverse_e1) PMUV3_INIT_SIMPLE(armv8_neoverse_n1) +PMUV3_INIT_SIMPLE(armv9_neoverse_n2) +PMUV3_INIT_SIMPLE(armv8_neoverse_v1) PMUV3_INIT_SIMPLE(armv8_nvidia_carmel) PMUV3_INIT_SIMPLE(armv8_nvidia_denver) @@ -1193,8 +1199,14 @@ static const struct of_device_id armv8_pmu_of_device_ids[] = { {.compatible = "arm,cortex-a76-pmu", .data = armv8_cortex_a76_pmu_init}, {.compatible = "arm,cortex-a77-pmu", .data = armv8_cortex_a77_pmu_init}, {.compatible = "arm,cortex-a78-pmu", .data = armv8_cortex_a78_pmu_init}, + {.compatible = "arm,cortex-a510-pmu", .data = armv9_cortex_a510_pmu_init}, + {.compatible = "arm,cortex-a710-pmu", .data = armv9_cortex_a710_pmu_init}, + {.compatible = "arm,cortex-x1-pmu", .data = armv8_cortex_x1_pmu_init}, + {.compatible = "arm,cortex-x2-pmu", .data = armv9_cortex_x2_pmu_init}, {.compatible = "arm,neoverse-e1-pmu", .data = armv8_neoverse_e1_pmu_init}, {.compatible = "arm,neoverse-n1-pmu", .data = armv8_neoverse_n1_pmu_init}, + {.compatible = "arm,neoverse-n2-pmu", .data = armv9_neoverse_n2_pmu_init}, + {.compatible = "arm,neoverse-v1-pmu", .data = armv8_neoverse_v1_pmu_init}, {.compatible = "cavium,thunder-pmu", .data = armv8_thunder_pmu_init}, {.compatible = "brcm,vulcan-pmu", .data = armv8_vulcan_pmu_init}, {.compatible = "nvidia,carmel-pmu", .data = armv8_nvidia_carmel_pmu_init}, From ffe2cbbff9719fcb33336ac5d3a358438e931395 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Tue, 29 Mar 2022 11:28:07 -0700 Subject: [PATCH 035/124] BACKPORT: f2fs: fix wrong condition check when failing metapage read This patch fixes wrong initialization. Bug: 239451498 Fixes: 50c63009f6ab ("f2fs: avoid an infinite loop in f2fs_sync_dirty_inodes") Signed-off-by: Jaegeuk Kim (cherry picked from commit 6dff2f6fa8278c1f0bdd90cd07c3a1d88d687a33) Change-Id: I27aa190a58d59558a49e8cd35c2f7a94318d7b0d --- fs/f2fs/checkpoint.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index bd2a0f5854aa..13ee979b65cf 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -98,9 +98,9 @@ repeat: } if (unlikely(!PageUptodate(page))) { - if (page->index == sbi->metapage_eio_ofs && - sbi->metapage_eio_cnt++ == MAX_RETRY_META_PAGE_EIO) { - set_ckpt_flags(sbi, CP_ERROR_FLAG); + if (page->index == sbi->metapage_eio_ofs) { + if (sbi->metapage_eio_cnt++ == MAX_RETRY_META_PAGE_EIO) + set_ckpt_flags(sbi, CP_ERROR_FLAG); } else { sbi->metapage_eio_ofs = page->index; sbi->metapage_eio_cnt = 0; From 6d2d344c5f272a3dc858f291bb6238a3ff24e1a1 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 22 Mar 2022 14:39:13 -0700 Subject: [PATCH 036/124] BACKPORT: f2fs: replace congestion_wait() calls with io_schedule_timeout() As congestion is no longer tracked, congestion_wait() is effectively equivalent to io_schedule_timeout(). So introduce f2fs_io_schedule_timeout() which sets TASK_UNINTERRUPTIBLE and call that instead. Bug: 239451498 Link: https://lkml.kernel.org/r/164549983744.9187.6425865370954230902.stgit@noble.brown Signed-off-by: NeilBrown Cc: Anna Schumaker Cc: Chao Yu Cc: Darrick J. Wong Cc: Ilya Dryomov Cc: Jaegeuk Kim Cc: Jan Kara Cc: Jeff Layton Cc: Jens Axboe Cc: Lars Ellenberg Cc: Miklos Szeredi Cc: Paolo Valente Cc: Philipp Reisner Cc: Ryusuke Konishi Cc: Trond Myklebust Cc: Wu Fengguang Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds (cherry picked from commit 7634669ca55379537e5358bd5783b29bf15f67e4) Change-Id: Ia09696633e0f957838771efbee8ee23c9d8c6c46 --- fs/f2fs/compress.c | 4 +--- fs/f2fs/data.c | 3 +-- fs/f2fs/f2fs.h | 6 ++++++ fs/f2fs/segment.c | 8 +++----- fs/f2fs/super.c | 6 ++---- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index 750573d1feaa..e98a0ef71941 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -1503,9 +1503,7 @@ continue_unlock: if (IS_NOQUOTA(cc->inode)) return 0; ret = 0; - cond_resched(); - congestion_wait(BLK_RW_ASYNC, - DEFAULT_IO_TIMEOUT); + f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT); goto retry_write; } return ret; diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 5c49817dbcc9..46a4322401b1 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -3081,8 +3081,7 @@ result: } else if (ret == -EAGAIN) { ret = 0; if (wbc->sync_mode == WB_SYNC_ALL) { - cond_resched(); - congestion_wait(BLK_RW_ASYNC, + f2fs_io_schedule_timeout( DEFAULT_IO_TIMEOUT); goto retry_write; } diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 6b5b3e293ae1..a8b5be59cc22 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -4533,6 +4533,12 @@ static inline bool f2fs_block_unit_discard(struct f2fs_sb_info *sbi) return F2FS_OPTION(sbi).discard_unit == DISCARD_UNIT_BLOCK; } +static inline void f2fs_io_schedule_timeout(long timeout) +{ + set_current_state(TASK_UNINTERRUPTIBLE); + io_schedule_timeout(timeout); +} + #define EFSBADCRC EBADMSG /* Bad CRC detected */ #define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */ diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index e5e4956ead31..de1f4ac8191a 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -314,8 +314,7 @@ next: skip: iput(inode); } - congestion_wait(BLK_RW_ASYNC, DEFAULT_IO_TIMEOUT); - cond_resched(); + f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT); if (gc_failure) { if (++looped >= count) return; @@ -806,8 +805,7 @@ int f2fs_flush_device_cache(struct f2fs_sb_info *sbi) do { ret = __submit_flush_wait(sbi, FDEV(i).bdev); if (ret) - congestion_wait(BLK_RW_ASYNC, - DEFAULT_IO_TIMEOUT); + f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT); } while (ret && --count); if (ret) { @@ -3140,7 +3138,7 @@ next: blk_finish_plug(&plug); mutex_unlock(&dcc->cmd_lock); trimmed += __wait_all_discard_cmd(sbi, NULL); - congestion_wait(BLK_RW_ASYNC, DEFAULT_IO_TIMEOUT); + f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT); goto next; } skip: diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 3d13fe053b30..48daa85746f8 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2156,8 +2156,7 @@ static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi) /* we should flush all the data to keep data consistency */ do { sync_inodes_sb(sbi->sb); - cond_resched(); - congestion_wait(BLK_RW_ASYNC, DEFAULT_IO_TIMEOUT); + f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT); } while (get_pages(sbi, F2FS_DIRTY_DATA) && retry--); if (unlikely(retry < 0)) @@ -2526,8 +2525,7 @@ retry: &page, &fsdata); if (unlikely(err)) { if (err == -ENOMEM) { - congestion_wait(BLK_RW_ASYNC, - DEFAULT_IO_TIMEOUT); + f2fs_io_schedule_timeout(DEFAULT_IO_TIMEOUT); goto retry; } set_sbi_flag(F2FS_SB(sb), SBI_QUOTA_NEED_REPAIR); From 0d59b2578a0a0a636f12bcb0db955e7ab53adbde Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Tue, 29 Mar 2022 16:25:54 -0700 Subject: [PATCH 037/124] BACKPORT: f2fs: avoid infinite loop to flush node pages xfstests/generic/475 can give EIO all the time which give an infinite loop to flush node page like below. Let's avoid it. [16418.518551] Call Trace: [16418.518553] ? dm_submit_bio+0x48/0x400 [16418.518574] ? submit_bio_checks+0x1ac/0x5a0 [16418.525207] __submit_bio+0x1a9/0x230 [16418.525210] ? kmem_cache_alloc+0x29e/0x3c0 [16418.525223] submit_bio_noacct+0xa8/0x2b0 [16418.525226] submit_bio+0x4d/0x130 [16418.525238] __submit_bio+0x49/0x310 [f2fs] [16418.525339] ? bio_add_page+0x6a/0x90 [16418.525344] f2fs_submit_page_bio+0x134/0x1f0 [f2fs] [16418.525365] read_node_page+0x125/0x1b0 [f2fs] [16418.525388] __get_node_page.part.0+0x58/0x3f0 [f2fs] [16418.525409] __get_node_page+0x2f/0x60 [f2fs] [16418.525431] f2fs_get_dnode_of_data+0x423/0x860 [f2fs] [16418.525452] ? asm_sysvec_apic_timer_interrupt+0x12/0x20 [16418.525458] ? __mod_memcg_state.part.0+0x2a/0x30 [16418.525465] ? __mod_memcg_lruvec_state+0x27/0x40 [16418.525467] ? __xa_set_mark+0x57/0x70 [16418.525472] f2fs_do_write_data_page+0x10e/0x7b0 [f2fs] [16418.525493] f2fs_write_single_data_page+0x555/0x830 [f2fs] [16418.525514] ? sysvec_apic_timer_interrupt+0x4e/0x90 [16418.525518] ? asm_sysvec_apic_timer_interrupt+0x12/0x20 [16418.525523] f2fs_write_cache_pages+0x303/0x880 [f2fs] [16418.525545] ? blk_flush_plug_list+0x47/0x100 [16418.525548] f2fs_write_data_pages+0xfd/0x320 [f2fs] [16418.525569] do_writepages+0xd5/0x210 [16418.525648] filemap_fdatawrite_wbc+0x7d/0xc0 [16418.525655] filemap_fdatawrite+0x50/0x70 [16418.525658] f2fs_sync_dirty_inodes+0xa4/0x230 [f2fs] [16418.525679] f2fs_write_checkpoint+0x16d/0x1720 [f2fs] [16418.525699] ? ttwu_do_wakeup+0x1c/0x160 [16418.525709] ? ttwu_do_activate+0x6d/0xd0 [16418.525711] ? __wait_for_common+0x11d/0x150 [16418.525715] kill_f2fs_super+0xca/0x100 [f2fs] [16418.525733] deactivate_locked_super+0x3b/0xb0 [16418.525739] deactivate_super+0x40/0x50 [16418.525741] cleanup_mnt+0x139/0x190 [16418.525747] __cleanup_mnt+0x12/0x20 [16418.525749] task_work_run+0x6d/0xa0 [16418.525765] exit_to_user_mode_prepare+0x1ad/0x1b0 [16418.525771] syscall_exit_to_user_mode+0x27/0x50 [16418.525774] do_syscall_64+0x48/0xc0 [16418.525776] entry_SYSCALL_64_after_hwframe+0x44/0xae Bug: 239451498 Signed-off-by: Jaegeuk Kim (cherry picked from commit 059bfa5616af9343da13063ac7d5079c2f4baeea) Change-Id: I8e1e03208e28b3e9d21e6348cfb57a1adbcbd527 --- fs/f2fs/checkpoint.c | 8 +------- fs/f2fs/f2fs.h | 23 +++++++++++++++++++---- fs/f2fs/node.c | 23 ++++++++++++----------- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 13ee979b65cf..d93db6d29704 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -98,13 +98,7 @@ repeat: } if (unlikely(!PageUptodate(page))) { - if (page->index == sbi->metapage_eio_ofs) { - if (sbi->metapage_eio_cnt++ == MAX_RETRY_META_PAGE_EIO) - set_ckpt_flags(sbi, CP_ERROR_FLAG); - } else { - sbi->metapage_eio_ofs = page->index; - sbi->metapage_eio_cnt = 0; - } + f2fs_handle_page_eio(sbi, page->index, META); f2fs_put_page(page, 1); return ERR_PTR(-EIO); } diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index a8b5be59cc22..8783238d9526 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -577,8 +577,8 @@ enum { /* maximum retry quota flush count */ #define DEFAULT_RETRY_QUOTA_FLUSH_COUNT 8 -/* maximum retry of EIO'ed meta page */ -#define MAX_RETRY_META_PAGE_EIO 100 +/* maximum retry of EIO'ed page */ +#define MAX_RETRY_PAGE_EIO 100 #define F2FS_LINK_MAX 0xffffffff /* maximum link count per file */ @@ -1620,8 +1620,8 @@ struct f2fs_sb_info { /* keep migration IO order for LFS mode */ struct f2fs_rwsem io_order_lock; mempool_t *write_io_dummy; /* Dummy pages */ - pgoff_t metapage_eio_ofs; /* EIO page offset */ - int metapage_eio_cnt; /* EIO count */ + pgoff_t page_eio_ofs[NR_PAGE_TYPE]; /* EIO page offset */ + int page_eio_cnt[NR_PAGE_TYPE]; /* EIO count */ /* for checkpoint */ struct f2fs_checkpoint *ckpt; /* raw checkpoint pointer */ @@ -4539,6 +4539,21 @@ static inline void f2fs_io_schedule_timeout(long timeout) io_schedule_timeout(timeout); } +static inline void f2fs_handle_page_eio(struct f2fs_sb_info *sbi, pgoff_t ofs, + enum page_type type) +{ + if (unlikely(f2fs_cp_error(sbi))) + return; + + if (ofs == sbi->page_eio_ofs[type]) { + if (sbi->page_eio_cnt[type]++ == MAX_RETRY_PAGE_EIO) + set_ckpt_flags(sbi, CP_ERROR_FLAG); + } else { + sbi->page_eio_ofs[type] = ofs; + sbi->page_eio_cnt[type] = 0; + } +} + #define EFSBADCRC EBADMSG /* Bad CRC detected */ #define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */ diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index ba0766a56dfa..db601763e2c7 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1416,8 +1416,7 @@ repeat: err = read_node_page(page, 0); if (err < 0) { - f2fs_put_page(page, 1); - return ERR_PTR(err); + goto out_put_err; } else if (err == LOCKED_PAGE) { err = 0; goto page_hit; @@ -1443,19 +1442,21 @@ repeat: goto out_err; } page_hit: - if (unlikely(nid != nid_of_node(page))) { - f2fs_warn(sbi, "inconsistent node block, nid:%lu, node_footer[nid:%u,ino:%u,ofs:%u,cpver:%llu,blkaddr:%u]", + if (likely(nid == nid_of_node(page))) + return page; + + f2fs_warn(sbi, "inconsistent node block, nid:%lu, node_footer[nid:%u,ino:%u,ofs:%u,cpver:%llu,blkaddr:%u]", nid, nid_of_node(page), ino_of_node(page), ofs_of_node(page), cpver_of_node(page), next_blkaddr_of_node(page)); - set_sbi_flag(sbi, SBI_NEED_FSCK); - err = -EINVAL; + set_sbi_flag(sbi, SBI_NEED_FSCK); + err = -EINVAL; out_err: - ClearPageUptodate(page); - f2fs_put_page(page, 1); - return ERR_PTR(err); - } - return page; + ClearPageUptodate(page); +out_put_err: + f2fs_handle_page_eio(sbi, page->index, NODE); + f2fs_put_page(page, 1); + return ERR_PTR(err); } struct page *f2fs_get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid) From 406e9b3d0b8ae09737fe8ae456cb28e5a280a8c5 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Sat, 18 Jun 2022 00:42:24 -0700 Subject: [PATCH 038/124] BACKPORT: f2fs: do not count ENOENT for error case Otherwise, we can get a wrong cp_error mark. Bug: 239451498 Cc: Fixes: a7b8618aa2f0 ("f2fs: avoid infinite loop to flush node pages") Signed-off-by: Jaegeuk Kim (cherry picked from commit 1a81f1ba6f9e0e7ab72b32bbd8184892319f1583) Change-Id: Ic28a139341e96cb6fb0eca9f614895ae14e96946 --- fs/f2fs/node.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index db601763e2c7..ed09cdcab6e7 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -1454,7 +1454,9 @@ page_hit: out_err: ClearPageUptodate(page); out_put_err: - f2fs_handle_page_eio(sbi, page->index, NODE); + /* ENOENT comes from read_node_page which is not an error. */ + if (err != -ENOENT) + f2fs_handle_page_eio(sbi, page->index, NODE); f2fs_put_page(page, 1); return ERR_PTR(err); } From a48ad117ec81bb281dfe60b97964187873e4678d Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Wed, 3 Aug 2022 20:33:54 -0700 Subject: [PATCH 039/124] BACKPORT: f2fs: do not set compression bit if kernel doesn't support If kernel doesn't have CONFIG_F2FS_FS_COMPRESSION, a file having FS_COMPR_FL via ioctl(FS_IOC_SETFLAGS) is unaccessible due to f2fs_is_compress_backend_ready(). Let's avoid it. Bug: 240921972 Signed-off-by: Jaegeuk Kim (cherry picked from commit 376523b97c005fa57bb2f8e70f61ab965f16e160) Change-Id: Ieb0f8945175ea5ccb0060690e882f054360fb8f0 --- fs/f2fs/f2fs.h | 7 ++++++- fs/f2fs/file.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 8783238d9526..552ad16feeac 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -4277,8 +4277,9 @@ static inline void f2fs_update_extent_tree_range_compressed(struct inode *inode, unsigned int c_len) { } #endif -static inline void set_compress_context(struct inode *inode) +static inline int set_compress_context(struct inode *inode) { +#ifdef CONFIG_F2FS_FS_COMPRESSION struct f2fs_sb_info *sbi = F2FS_I_SB(inode); F2FS_I(inode)->i_compress_algorithm = @@ -4301,6 +4302,10 @@ static inline void set_compress_context(struct inode *inode) stat_inc_compr_inode(inode); inc_compr_inode_stat(inode); f2fs_mark_inode_dirty_sync(inode, true); + return 0; +#else + return -EOPNOTSUPP; +#endif } static inline bool f2fs_disable_compressed_file(struct inode *inode) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 387b653e1ad2..ea2a5260758c 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1872,8 +1872,8 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) return -EINVAL; if (S_ISREG(inode->i_mode) && inode->i_size) return -EINVAL; - - set_compress_context(inode); + if (set_compress_context(inode)) + return -EOPNOTSUPP; } } if ((iflags ^ masked_flags) & F2FS_NOCOMP_FL) { From 571f9fff874f41808c5298b221a90602a343ca8a Mon Sep 17 00:00:00 2001 From: Darren Hsu Date: Fri, 12 Aug 2022 15:26:16 +0800 Subject: [PATCH 040/124] ANDROID: Update the ABI representation 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_try_to_freeze_todo_logging( void*, bool*)' 1 Added variable: [A] 'tracepoint __tracepoint_android_vh_try_to_freeze_todo_logging' Bug: 240091483 Signed-off-by: Darren Hsu Change-Id: I2ba595d12385ba86f2d90e6f1014fcf411269591 --- android/abi_gki_aarch64.xml | 258 ++++++++++++++++---------------- android/abi_gki_aarch64_generic | 2 + 2 files changed, 135 insertions(+), 125 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index 9c530cc6d97a..5411c229c95b 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -284,6 +284,7 @@ + @@ -3791,6 +3792,7 @@ + @@ -4882,7 +4884,7 @@ - + @@ -8722,7 +8724,7 @@ - + @@ -25281,7 +25283,7 @@ - + @@ -41364,7 +41366,7 @@ - + @@ -59687,7 +59689,7 @@ - + @@ -59769,7 +59771,7 @@ - + @@ -69415,27 +69417,27 @@ - + - + - + - + - + - + - + @@ -69451,22 +69453,22 @@ - + - + - + - + - + - + @@ -69490,36 +69492,36 @@ - + - + - + - + - + - + - + - + - + - + @@ -69530,7 +69532,7 @@ - + @@ -69554,96 +69556,96 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -74225,7 +74227,7 @@ - + @@ -84230,7 +84232,7 @@ - + @@ -84310,22 +84312,22 @@ - + - + - + - + - + - + @@ -96213,7 +96215,7 @@ - + @@ -96221,7 +96223,7 @@ - + @@ -96229,7 +96231,7 @@ - + @@ -96237,12 +96239,12 @@ - + - + @@ -96250,7 +96252,7 @@ - + @@ -96261,7 +96263,7 @@ - + @@ -96269,18 +96271,18 @@ - + - + - - + + @@ -96294,12 +96296,12 @@ - + - + @@ -96307,12 +96309,12 @@ - + - + @@ -96320,12 +96322,12 @@ - + - + @@ -96342,7 +96344,7 @@ - + @@ -96350,7 +96352,7 @@ - + @@ -96358,12 +96360,12 @@ - + - + @@ -96371,7 +96373,7 @@ - + @@ -96379,7 +96381,7 @@ - + @@ -96396,12 +96398,12 @@ - + - + @@ -96427,7 +96429,7 @@ - + @@ -96438,7 +96440,7 @@ - + @@ -96458,7 +96460,7 @@ - + @@ -96481,7 +96483,7 @@ - + @@ -96516,7 +96518,7 @@ - + @@ -96527,7 +96529,7 @@ - + @@ -96541,12 +96543,12 @@ - + - + @@ -96557,7 +96559,7 @@ - + @@ -96571,7 +96573,7 @@ - + @@ -96582,7 +96584,7 @@ - + @@ -96596,7 +96598,7 @@ - + @@ -96610,12 +96612,12 @@ - + - + @@ -96623,7 +96625,7 @@ - + @@ -96637,7 +96639,7 @@ - + @@ -96645,7 +96647,7 @@ - + @@ -96656,7 +96658,7 @@ - + @@ -96673,7 +96675,7 @@ - + @@ -96693,7 +96695,7 @@ - + @@ -96710,7 +96712,7 @@ - + @@ -96721,7 +96723,7 @@ - + @@ -96729,7 +96731,7 @@ - + @@ -96737,7 +96739,7 @@ - + @@ -96745,7 +96747,7 @@ - + @@ -96759,7 +96761,7 @@ - + @@ -96767,7 +96769,7 @@ - + @@ -96778,7 +96780,7 @@ - + @@ -96795,7 +96797,7 @@ - + @@ -97575,7 +97577,7 @@ - + @@ -101526,7 +101528,7 @@ - + @@ -104241,7 +104243,7 @@ - + @@ -107637,6 +107639,11 @@ + + + + + @@ -107975,6 +107982,7 @@ + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index 9e36c1056f9d..12760e16f9da 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -2255,6 +2255,7 @@ __traceiter_android_vh_thermal_pm_notify_suspend __traceiter_android_vh_timerfd_create __traceiter_android_vh_try_grab_compound_head + __traceiter_android_vh_try_to_freeze_todo_logging __traceiter_android_vh_typec_store_partner_src_caps __traceiter_android_vh_typec_tcpci_override_toggling __traceiter_android_vh_typec_tcpm_get_timer @@ -2368,6 +2369,7 @@ __tracepoint_android_vh_thermal_pm_notify_suspend __tracepoint_android_vh_timerfd_create __tracepoint_android_vh_try_grab_compound_head + __tracepoint_android_vh_try_to_freeze_todo_logging __tracepoint_android_vh_typec_store_partner_src_caps __tracepoint_android_vh_typec_tcpci_override_toggling __tracepoint_android_vh_typec_tcpm_get_timer From 4a84a59cb80ac519ba9385e683ddb067bb737ee2 Mon Sep 17 00:00:00 2001 From: xiaofeng Date: Tue, 12 Jul 2022 20:43:49 +0800 Subject: [PATCH 041/124] ANDROID: vendor_hooks:vendor hook for pidfd_open Add vendor hook when detecting process status through pidfd_open. Bug: 238725692 Change-Id: I565988cb8bf6dd44ab4dc15c410c2dcf50703def Signed-off-by: xiaofeng --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/sched.h | 4 ++++ kernel/pid.c | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index bb6d5eb7a31f..7f1fc3947472 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -409,3 +409,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpumask_any_and_distribute); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_resume_begin); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_resume_end); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_memcg_scan_type); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_pidfd_open); diff --git a/include/trace/hooks/sched.h b/include/trace/hooks/sched.h index cdb3bf7dda52..3bac9bd4c8a5 100644 --- a/include/trace/hooks/sched.h +++ b/include/trace/hooks/sched.h @@ -451,6 +451,10 @@ DECLARE_RESTRICTED_HOOK(android_rvh_update_rq_clock_pelt, TP_PROTO(struct rq *rq, s64 delta, bool *ret), TP_ARGS(rq, delta, ret), 1); +DECLARE_HOOK(android_vh_pidfd_open, + TP_PROTO(struct pid *p), + TP_ARGS(p)); + /* macro versions of hooks are no longer required */ #endif /* _TRACE_HOOK_SCHED_H */ diff --git a/kernel/pid.c b/kernel/pid.c index 48babb1dd3e1..468d04810b40 100644 --- a/kernel/pid.c +++ b/kernel/pid.c @@ -45,6 +45,9 @@ #include #include +#undef CREATE_TRACE_POINTS +#include + struct pid init_struct_pid = { .count = REFCOUNT_INIT(1), .tasks = { @@ -602,6 +605,7 @@ SYSCALL_DEFINE2(pidfd_open, pid_t, pid, unsigned int, flags) else fd = -EINVAL; + trace_android_vh_pidfd_open(p); put_pid(p); return fd; } From 19b9be6d3568c95c2e622d4e8113d6a5d6f1f62e Mon Sep 17 00:00:00 2001 From: xiaofeng Date: Wed, 13 Jul 2022 10:23:51 +0800 Subject: [PATCH 042/124] ANDROID: vendor_hooks:vendor hook for mmput add vendor hook in mmput while mm_users decreased to 0. Bug: 238821038 Change-Id: I42a717cbeeb3176bac14b4b2391fdb2366c972d3 Signed-off-by: xiaofeng --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/sched.h | 3 +++ kernel/fork.c | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 7f1fc3947472..bde787a929d9 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -410,3 +410,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_resume_begin); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_resume_end); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_memcg_scan_type); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_pidfd_open); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmput); diff --git a/include/trace/hooks/sched.h b/include/trace/hooks/sched.h index 3bac9bd4c8a5..defc23107762 100644 --- a/include/trace/hooks/sched.h +++ b/include/trace/hooks/sched.h @@ -455,6 +455,9 @@ DECLARE_HOOK(android_vh_pidfd_open, TP_PROTO(struct pid *p), TP_ARGS(p)); +DECLARE_HOOK(android_vh_mmput, + TP_PROTO(void *unused), + TP_ARGS(unused)); /* macro versions of hooks are no longer required */ #endif /* _TRACE_HOOK_SCHED_H */ diff --git a/kernel/fork.c b/kernel/fork.c index 0a45df6f3309..a33cb21a05a5 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1159,8 +1159,10 @@ void mmput(struct mm_struct *mm) { might_sleep(); - if (atomic_dec_and_test(&mm->mm_users)) + if (atomic_dec_and_test(&mm->mm_users)) { + trace_android_vh_mmput(NULL); __mmput(mm); + } } EXPORT_SYMBOL_GPL(mmput); From 737a5314c9f35665fa61e2356f65501e0dc53b92 Mon Sep 17 00:00:00 2001 From: Ziyi Cui Date: Tue, 16 Aug 2022 20:57:48 +0000 Subject: [PATCH 043/124] ANDROID: power: Add vendor hook for suspend The purpose of this vendor hook is to trace early resume latency. Bug: 241946090 Signed-off-by: Ziyi Cui Change-Id: I508f5a34fd3210178af0cb142461baf814196b9f --- drivers/android/vendor_hooks.c | 2 ++ include/trace/hooks/suspend.h | 3 +++ kernel/power/suspend.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index bde787a929d9..24f21436bd70 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -411,3 +411,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_resume_end); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_memcg_scan_type); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_pidfd_open); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmput); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_early_resume_begin); + diff --git a/include/trace/hooks/suspend.h b/include/trace/hooks/suspend.h index 0a4319d00ffa..6e78f3bfdbc0 100644 --- a/include/trace/hooks/suspend.h +++ b/include/trace/hooks/suspend.h @@ -15,6 +15,9 @@ DECLARE_HOOK(android_vh_resume_begin, DECLARE_HOOK(android_vh_resume_end, TP_PROTO(void *unused), TP_ARGS(unused)) +DECLARE_HOOK(android_vh_early_resume_begin, + TP_PROTO(void *unused), + TP_ARGS(unused)) /* macro versions of hooks are no longer required */ diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 2e1072aacccc..731e79844739 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -440,7 +440,7 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) BUG_ON(!irqs_disabled()); system_state = SYSTEM_SUSPEND; - + trace_android_vh_early_resume_begin(NULL); error = syscore_suspend(); if (!error) { *wakeup = pm_wakeup_pending(); From b8762fa2655469fb3f2c40a38f67e6f05afe4136 Mon Sep 17 00:00:00 2001 From: Minchan Kim Date: Thu, 19 May 2022 14:08:54 -0700 Subject: [PATCH 044/124] BACKPORT: mm: don't be stuck to rmap lock on reclaim path The rmap locks(i_mmap_rwsem and anon_vma->root->rwsem) could be contended under memory pressure if processes keep working on their vmas(e.g., fork, mmap, munmap). It makes reclaim path stuck. In our real workload traces, we see kswapd is waiting the lock for 300ms+(worst case, a sec) and it makes other processes entering direct reclaim, which were also stuck on the lock. This patch makes lru aging path try_lock mode like shink_page_list so the reclaim context will keep working with next lru pages without being stuck. if it found the rmap lock contended, it rotates the page back to head of lru in both active/inactive lrus to make them consistent behavior, which is basic starting point rather than adding more heristic. Since this patch introduces a new "contended" field as out-param along with try_lock in-param in rmap_walk_control, it's not immutable any longer if the try_lock is set so remove const keywords on rmap related functions. Since rmap walking is already expensive operation, I doubt the const would help sizable benefit( And we didn't have it until 5.17). In a heavy app workload in Android, trace shows following statistics. It almost removes rmap lock contention from reclaim path. Martin Liu reported: Before: max_dur(ms) min_dur(ms) max-min(dur)ms avg_dur(ms) sum_dur(ms) count blocked_function 1632 0 1631 151.542173 31672 209 page_lock_anon_vma_read 601 0 601 145.544681 28817 198 rmap_walk_file After: max_dur(ms) min_dur(ms) max-min(dur)ms avg_dur(ms) sum_dur(ms) count blocked_function NaN NaN NaN NaN NaN 0.0 NaN 0 0 0 0.127645 1 12 rmap_walk_file [minchan@kernel.org: add comment, per Matthew] Link: https://lkml.kernel.org/r/YnNqeB5tUf6LZ57b@google.com Link: https://lkml.kernel.org/r/20220510215423.164547-1-minchan@kernel.org Signed-off-by: Minchan Kim Acked-by: Johannes Weiner Cc: Suren Baghdasaryan Cc: Michal Hocko Cc: John Dias Cc: Tim Murray Cc: Matthew Wilcox Cc: Vladimir Davydov Cc: Martin Liu Cc: Minchan Kim Cc: Matthew Wilcox Signed-off-by: Andrew Morton Conflicts: folio->page (cherry picked from commit 6d4675e601357834dadd2ba1d803f6484596015c) Bug: 239681156 Signed-off-by: Minchan Kim Change-Id: I0c63e0291120c8a1b5f2d83b8a7b210cb56c27a2 --- include/linux/fs.h | 5 +++++ include/linux/rmap.h | 24 +++++++++++++++++------ mm/huge_memory.c | 2 +- mm/ksm.c | 8 +++++++- mm/memory-failure.c | 2 +- mm/page_idle.c | 6 +++--- mm/rmap.c | 45 +++++++++++++++++++++++++++++++++++++------- mm/vmscan.c | 7 ++++++- 8 files changed, 79 insertions(+), 20 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 4019e6fa3b95..8cf258fc9162 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -515,6 +515,11 @@ static inline void i_mmap_unlock_write(struct address_space *mapping) up_write(&mapping->i_mmap_rwsem); } +static inline int i_mmap_trylock_read(struct address_space *mapping) +{ + return down_read_trylock(&mapping->i_mmap_rwsem); +} + static inline void i_mmap_lock_read(struct address_space *mapping) { down_read(&mapping->i_mmap_rwsem); diff --git a/include/linux/rmap.h b/include/linux/rmap.h index 7482da1ea67b..26f49f146f02 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -130,6 +130,11 @@ static inline void anon_vma_lock_read(struct anon_vma *anon_vma) down_read(&anon_vma->root->rwsem); } +static inline int anon_vma_trylock_read(struct anon_vma *anon_vma) +{ + return down_read_trylock(&anon_vma->root->rwsem); +} + static inline void anon_vma_unlock_read(struct anon_vma *anon_vma) { up_read(&anon_vma->root->rwsem); @@ -252,17 +257,14 @@ void try_to_munlock(struct page *); void remove_migration_ptes(struct page *old, struct page *new, bool locked); -/* - * Called by memory-failure.c to kill processes. - */ -struct anon_vma *page_lock_anon_vma_read(struct page *page); -void page_unlock_anon_vma_read(struct anon_vma *anon_vma); int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma); /* * rmap_walk_control: To control rmap traversing for specific needs * * arg: passed to rmap_one() and invalid_vma() + * try_lock: bail out if the rmap lock is contended + * contended: indicate the rmap traversal bailed out due to lock contention * rmap_one: executed on each vma where page is mapped * done: for checking traversing termination condition * anon_lock: for getting anon_lock by optimized way rather than default @@ -270,6 +272,8 @@ int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma); */ struct rmap_walk_control { void *arg; + bool try_lock; + bool contended; /* * Return false if page table scanning in rmap_walk should be stopped. * Otherwise, return true. @@ -277,13 +281,21 @@ struct rmap_walk_control { bool (*rmap_one)(struct page *page, struct vm_area_struct *vma, unsigned long addr, void *arg); int (*done)(struct page *page); - struct anon_vma *(*anon_lock)(struct page *page); + struct anon_vma *(*anon_lock)(struct page *page, + struct rmap_walk_control *rwc); bool (*invalid_vma)(struct vm_area_struct *vma, void *arg); }; void rmap_walk(struct page *page, struct rmap_walk_control *rwc); void rmap_walk_locked(struct page *page, struct rmap_walk_control *rwc); +/* + * Called by memory-failure.c to kill processes. + */ +struct anon_vma *page_lock_anon_vma_read(struct page *page, + struct rmap_walk_control *rwc); +void page_unlock_anon_vma_read(struct anon_vma *anon_vma); + #else /* !CONFIG_MMU */ #define anon_vma_init() do {} while (0) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 123f3e032871..b42288c06b96 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1481,7 +1481,7 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf, pmd_t pmd) */ get_page(page); spin_unlock(vmf->ptl); - anon_vma = page_lock_anon_vma_read(page); + anon_vma = page_lock_anon_vma_read(page, NULL); /* Confirm the PMD did not change while page_table_lock was released */ spin_lock(vmf->ptl); diff --git a/mm/ksm.c b/mm/ksm.c index 25b8362a4f89..d09f8d7d6417 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -2626,7 +2626,13 @@ again: struct vm_area_struct *vma; cond_resched(); - anon_vma_lock_read(anon_vma); + if (!anon_vma_trylock_read(anon_vma)) { + if (rwc->try_lock) { + rwc->contended = true; + return; + } + anon_vma_lock_read(anon_vma); + } anon_vma_interval_tree_foreach(vmac, &anon_vma->rb_root, 0, ULONG_MAX) { unsigned long addr; diff --git a/mm/memory-failure.c b/mm/memory-failure.c index aef267c6a724..4bd73d6dc18a 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -477,7 +477,7 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill, struct anon_vma *av; pgoff_t pgoff; - av = page_lock_anon_vma_read(page); + av = page_lock_anon_vma_read(page, NULL); if (av == NULL) /* Not actually mapped anymore */ return; diff --git a/mm/page_idle.c b/mm/page_idle.c index 144fb4ed961d..b5613232e881 100644 --- a/mm/page_idle.c +++ b/mm/page_idle.c @@ -92,10 +92,10 @@ static bool page_idle_clear_pte_refs_one(struct page *page, static void page_idle_clear_pte_refs(struct page *page) { /* - * Since rwc.arg is unused, rwc is effectively immutable, so we - * can make it static const to save some cycles and stack. + * Since rwc.try_lock is unused, rwc is effectively immutable, so we + * can make it static to save some cycles and stack. */ - static const struct rmap_walk_control rwc = { + static struct rmap_walk_control rwc = { .rmap_one = page_idle_clear_pte_refs_one, .anon_lock = page_lock_anon_vma_read, }; diff --git a/mm/rmap.c b/mm/rmap.c index 52291f59b0b4..75ac41429c0b 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -517,9 +517,11 @@ out: * * Its a little more complex as it tries to keep the fast path to a single * atomic op -- the trylock. If we fail the trylock, we fall back to getting a - * reference like with page_get_anon_vma() and then block on the mutex. + * reference like with page_get_anon_vma() and then block on the mutex + * on !rwc->try_lock case. */ -struct anon_vma *page_lock_anon_vma_read(struct page *page) +struct anon_vma *page_lock_anon_vma_read(struct page *page, + struct rmap_walk_control *rwc) { struct anon_vma *anon_vma = NULL; struct anon_vma *root_anon_vma; @@ -547,6 +549,12 @@ struct anon_vma *page_lock_anon_vma_read(struct page *page) goto out; } + if (rwc && rwc->try_lock) { + anon_vma = NULL; + rwc->contended = true; + goto out; + } + /* trylock failed, we got to sleep */ if (!atomic_inc_not_zero(&anon_vma->refcount)) { anon_vma = NULL; @@ -848,8 +856,10 @@ static bool invalid_page_referenced_vma(struct vm_area_struct *vma, void *arg) * @memcg: target memory cgroup * @vm_flags: collect encountered vma->vm_flags who actually referenced the page * - * Quick test_and_clear_referenced for all mappings to a page, - * returns the number of ptes which referenced the page. + * Quick test_and_clear_referenced for all mappings of a page, + * + * Return: The number of mappings which referenced the page. Return -1 if + * the function bailed out due to rmap lock contention. */ int page_referenced(struct page *page, int is_locked, @@ -865,6 +875,7 @@ int page_referenced(struct page *page, .rmap_one = page_referenced_one, .arg = (void *)&pra, .anon_lock = page_lock_anon_vma_read, + .try_lock = true, }; *vm_flags = 0; @@ -895,7 +906,7 @@ int page_referenced(struct page *page, if (we_locked) unlock_page(page); - return pra.referenced; + return rwc.contended ? -1 : pra.referenced; } static bool page_mkclean_one(struct page *page, struct vm_area_struct *vma, @@ -1819,7 +1830,7 @@ static struct anon_vma *rmap_walk_anon_lock(struct page *page, struct anon_vma *anon_vma; if (rwc->anon_lock) - return rwc->anon_lock(page); + return rwc->anon_lock(page, rwc); /* * Note: remove_migration_ptes() cannot use page_lock_anon_vma_read() @@ -1831,7 +1842,17 @@ static struct anon_vma *rmap_walk_anon_lock(struct page *page, if (!anon_vma) return NULL; + if (anon_vma_trylock_read(anon_vma)) + goto out; + + if (rwc->try_lock) { + anon_vma = NULL; + rwc->contended = true; + goto out; + } + anon_vma_lock_read(anon_vma); +out: return anon_vma; } @@ -1922,8 +1943,18 @@ static void rmap_walk_file(struct page *page, struct rmap_walk_control *rwc, pgoff_start = page_to_pgoff(page); pgoff_end = pgoff_start + thp_nr_pages(page) - 1; - if (!locked) + if (!locked) { + if (i_mmap_trylock_read(mapping)) + goto lookup; + + if (rwc->try_lock) { + rwc->contended = true; + return; + } + i_mmap_lock_read(mapping); + } +lookup: vma_interval_tree_foreach(vma, &mapping->i_mmap, pgoff_start, pgoff_end) { unsigned long address = vma_address(page, vma); diff --git a/mm/vmscan.c b/mm/vmscan.c index 4b645071a610..d09d63861544 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1046,6 +1046,10 @@ static enum page_references page_check_references(struct page *page, if (vm_flags & VM_LOCKED) return PAGEREF_RECLAIM; + /* rmap lock contention: rotate */ + if (referenced_ptes == -1) + return PAGEREF_KEEP; + if (referenced_ptes) { /* * All mapped pages start out with page table @@ -2131,8 +2135,9 @@ static void shrink_active_list(unsigned long nr_to_scan, } } + /* Referenced or rmap lock contention: rotate */ if (page_referenced(page, 0, sc->target_mem_cgroup, - &vm_flags)) { + &vm_flags) != 0) { /* * Identify referenced, file-backed active pages and * give them one more trip around the active list. So From f509b285d7d39368918a39fad23cfef6b03a74e4 Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Fri, 19 Aug 2022 02:51:15 +0000 Subject: [PATCH 045/124] ANDROID: Update the ABI representation 3 symbol(s) added 'struct gpio_desc * devm_fwnode_gpiod_get_index(struct device *, struct fwnode_handle *, const char *, int, enum gpiod_flags, const char *)' 'struct gpio_descs * devm_gpiod_get_array_optional(struct device *, const char *, enum gpiod_flags)' 'int regulator_set_active_discharge_regmap(struct regulator_dev *, bool)' Bug: 240242346 Signed-off-by: Leo Chen Change-Id: I070f3539a23e4c140b00f78eca3a23428af4cb27 --- android/abi_gki_aarch64.xml | 825 ++++++++++++++++---------------- android/abi_gki_aarch64_generic | 4 + 2 files changed, 428 insertions(+), 401 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index 5411c229c95b..ce9870316ebc 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -1006,6 +1006,7 @@ + @@ -1015,6 +1016,7 @@ + @@ -2717,6 +2719,7 @@ + @@ -12668,18 +12671,18 @@ - + - + - + - + - + @@ -16234,75 +16237,75 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -17306,7 +17309,7 @@ - + @@ -20529,66 +20532,66 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -37661,81 +37664,81 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -39640,21 +39643,21 @@ - + - + - + - + - + - + @@ -42893,24 +42896,24 @@ - + - + - + - + - + - + - + @@ -44359,24 +44362,24 @@ - + - + - + - + - + - + - + @@ -48939,114 +48942,114 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -53126,96 +53129,96 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -59397,36 +59400,36 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -67902,45 +67905,45 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -68430,23 +68433,23 @@ - + - + - + - + - + - + - + @@ -72277,24 +72280,24 @@ - + - + - + - + - + - + - + @@ -72908,81 +72911,81 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -75830,213 +75833,213 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -76674,7 +76677,7 @@ - + @@ -86163,12 +86166,12 @@ - + - + - + @@ -94790,15 +94793,15 @@ - + - + - + - + @@ -103964,18 +103967,18 @@ - + - + - + - + - + @@ -104037,15 +104040,15 @@ - + - + - + - + @@ -104956,174 +104959,174 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -107074,10 +107077,10 @@ - - - - + + + + @@ -111651,6 +111654,15 @@ + + + + + + + + + @@ -111708,6 +111720,12 @@ + + + + + + @@ -114481,8 +114499,8 @@ - - + + @@ -114502,13 +114520,13 @@ - - - + + + - - + + @@ -114516,8 +114534,8 @@ - - + + @@ -114851,9 +114869,9 @@ - - - + + + @@ -114878,8 +114896,8 @@ - - + + @@ -116135,7 +116153,7 @@ - + @@ -119391,9 +119409,9 @@ - - - + + + @@ -119958,8 +119976,8 @@ - - + + @@ -120523,6 +120541,11 @@ + + + + + @@ -123157,8 +123180,8 @@ - - + + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index 12760e16f9da..956aea9d453f 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -332,6 +332,7 @@ crypto_register_notifier crypto_register_scomp crypto_register_shash + crypto_req_done crypto_shash_digest crypto_shash_final crypto_shash_finup @@ -443,11 +444,13 @@ devm_extcon_dev_allocate devm_extcon_dev_register devm_free_irq + devm_fwnode_gpiod_get_index devm_fwnode_pwm_get devm_gen_pool_create devm_gpiochip_add_data_with_key devm_gpiod_get devm_gpiod_get_array + devm_gpiod_get_array_optional devm_gpiod_get_optional devm_gpiod_put_array devm_gpio_free @@ -1768,6 +1771,7 @@ regulator_notifier_call_chain regulator_put regulator_register + regulator_set_active_discharge_regmap regulator_set_load regulator_set_voltage regulator_set_voltage_sel_regmap From fc6f47b6fce17e1362864ee71c3e733d328ae393 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 24 Aug 2022 17:25:50 +0200 Subject: [PATCH 046/124] Revert "ANDROID: module: Add vendor hook" This reverts commit 4d63efb9ae67783d184a924bb73b38745c9a1119. The hooks android_vh_set_module_permit_before_init and android_vh_set_module_permit_after_init is not used by any vendor, so remove it to help with merge issues with future LTS releases. If this is needed by any real user, it can easily be reverted to add it back and then the symbol should be added to the abi list at the same time to prevent it from being removed again later. Bug: 203756332 Bug: 181639260 Cc: Kuan-Ying Lee Signed-off-by: Greg Kroah-Hartman Change-Id: I3bbc5d4190d9fbf34469d2c5c1386dcbf998fb4b --- drivers/android/vendor_hooks.c | 3 --- include/trace/hooks/module.h | 29 ----------------------------- kernel/module.c | 26 -------------------------- 3 files changed, 58 deletions(-) delete mode 100644 include/trace/hooks/module.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 24f21436bd70..9f6add6883ca 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include @@ -274,8 +273,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_memory_x); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_memory_nx); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_memory_ro); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_memory_rw); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_module_permit_before_init); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_module_permit_after_init); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_util_est_update); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_meminfo_proc_show); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_exit_mm); diff --git a/include/trace/hooks/module.h b/include/trace/hooks/module.h deleted file mode 100644 index 9188e5556aac..000000000000 --- a/include/trace/hooks/module.h +++ /dev/null @@ -1,29 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#undef TRACE_SYSTEM -#define TRACE_SYSTEM module - -#define TRACE_INCLUDE_PATH trace/hooks -#if !defined(_TRACE_HOOK_MODULE_H) || defined(TRACE_HEADER_MULTI_READ) -#define _TRACE_HOOK_MODULE_H -#include -/* - * Following tracepoints are not exported in tracefs and provide a - * mechanism for vendor modules to hook and extend functionality - */ -#ifdef __GENKSYMS__ -struct module; -#else -/* struct module */ -#include -#endif /* __GENKSYMS__ */ -DECLARE_HOOK(android_vh_set_module_permit_before_init, - TP_PROTO(const struct module *mod), - TP_ARGS(mod)); - -DECLARE_HOOK(android_vh_set_module_permit_after_init, - TP_PROTO(const struct module *mod), - TP_ARGS(mod)); - -#endif /* _TRACE_HOOK_MODULE_H */ -/* This part must be outside protection */ -#include diff --git a/kernel/module.c b/kernel/module.c index b81200591e6d..4aea1350a226 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -63,10 +63,6 @@ #define CREATE_TRACE_POINTS #include -#undef CREATE_TRACE_POINTS -#include -#include - #ifndef ARCH_SHF_SMALL #define ARCH_SHF_SMALL 0 #endif @@ -2263,10 +2259,6 @@ static void free_module(struct module *mod) /* This may be empty, but that's OK */ module_arch_freeing_init(mod); - trace_android_vh_set_memory_rw((unsigned long)mod->init_layout.base, - (mod->init_layout.size)>>PAGE_SHIFT); - trace_android_vh_set_memory_nx((unsigned long)mod->init_layout.base, - (mod->init_layout.size)>>PAGE_SHIFT); module_memfree(mod->init_layout.base); kfree(mod->args); percpu_modfree(mod); @@ -2275,10 +2267,6 @@ static void free_module(struct module *mod) lockdep_free_key_range(mod->core_layout.base, mod->core_layout.size); /* Finally, free the core (containing the module structure) */ - trace_android_vh_set_memory_rw((unsigned long)mod->core_layout.base, - (mod->core_layout.size)>>PAGE_SHIFT); - trace_android_vh_set_memory_nx((unsigned long)mod->core_layout.base, - (mod->core_layout.size)>>PAGE_SHIFT); module_memfree(mod->core_layout.base); } @@ -3655,15 +3643,7 @@ static void module_deallocate(struct module *mod, struct load_info *info) { percpu_modfree(mod); module_arch_freeing_init(mod); - trace_android_vh_set_memory_rw((unsigned long)mod->init_layout.base, - (mod->init_layout.size)>>PAGE_SHIFT); - trace_android_vh_set_memory_nx((unsigned long)mod->init_layout.base, - (mod->init_layout.size)>>PAGE_SHIFT); module_memfree(mod->init_layout.base); - trace_android_vh_set_memory_rw((unsigned long)mod->core_layout.base, - (mod->core_layout.size)>>PAGE_SHIFT); - trace_android_vh_set_memory_nx((unsigned long)mod->core_layout.base, - (mod->core_layout.size)>>PAGE_SHIFT); module_memfree(mod->core_layout.base); } @@ -3806,13 +3786,8 @@ static noinline int do_init_module(struct module *mod) rcu_assign_pointer(mod->kallsyms, &mod->core_kallsyms); #endif module_enable_ro(mod, true); - trace_android_vh_set_module_permit_after_init(mod); mod_tree_remove_init(mod); module_arch_freeing_init(mod); - trace_android_vh_set_memory_rw((unsigned long)mod->init_layout.base, - (mod->init_layout.size)>>PAGE_SHIFT); - trace_android_vh_set_memory_nx((unsigned long)mod->init_layout.base, - (mod->init_layout.size)>>PAGE_SHIFT); mod->init_layout.base = NULL; mod->init_layout.size = 0; mod->init_layout.ro_size = 0; @@ -3919,7 +3894,6 @@ static int complete_formation(struct module *mod, struct load_info *info) module_enable_ro(mod, false); module_enable_nx(mod); module_enable_x(mod); - trace_android_vh_set_module_permit_before_init(mod); /* Mark state as coming so strong_try_module_get() ignores us, * but kallsyms etc. can see us. */ From 039f38f9aab85bf99272a6825c0b1466abd175fa Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 24 Aug 2022 18:44:40 +0200 Subject: [PATCH 047/124] Revert "ANDROID: mm: add vendor hook for vmpressure" This reverts commit 444a0b77522e1fca71ac16848d5da5bd7a27908e. The hook android_vh_vmpressure is not used by any vendor, so remove it to help with merge issues with future LTS releases. If this is needed by any real user, it can easily be reverted to add it back and then the symbol should be added to the abi list at the same time to prevent it from being removed again later. Bug: 203756332 Bug: 191534577 Cc: Liangliang Li Signed-off-by: Greg Kroah-Hartman Change-Id: I63d2a210dc6a6ded20ea8779af719d70f368ce0f --- drivers/android/vendor_hooks.c | 1 - include/trace/hooks/mm.h | 3 --- mm/vmpressure.c | 7 ------- 3 files changed, 11 deletions(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 9f6add6883ca..5e27095e8b7a 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -343,7 +343,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_gpio_cd_irqt); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_save_vmalloc_stack); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_stack_hash); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_save_track_hash); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_vmpressure); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_set_task_comm); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpufreq_acct_update_power); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_typec_tcpm_log); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index b45a6bdd4e52..a5db2918abbb 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -131,9 +131,6 @@ DECLARE_HOOK(android_vh_show_stack_hash, DECLARE_HOOK(android_vh_save_track_hash, TP_PROTO(bool alloc, unsigned long p), TP_ARGS(alloc, p)); -DECLARE_HOOK(android_vh_vmpressure, - TP_PROTO(struct mem_cgroup *memcg, bool *bypass), - TP_ARGS(memcg, bypass)); DECLARE_HOOK(android_vh_mem_cgroup_alloc, TP_PROTO(struct mem_cgroup *memcg), TP_ARGS(memcg)); diff --git a/mm/vmpressure.c b/mm/vmpressure.c index 632b88e9d49b..9b172561fded 100644 --- a/mm/vmpressure.c +++ b/mm/vmpressure.c @@ -21,8 +21,6 @@ #include #include -#include - /* * The window size (vmpressure_win) is the number of scanned pages before * we try to analyze scanned/reclaimed ratio. So the window is used as a @@ -243,17 +241,12 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg, bool tree, unsigned long scanned, unsigned long reclaimed) { struct vmpressure *vmpr; - bool bypass = false; if (mem_cgroup_disabled()) return; vmpr = memcg_to_vmpressure(memcg); - trace_android_vh_vmpressure(memcg, &bypass); - if (unlikely(bypass)) - return; - /* * Here we only want to account pressure that userland is able to * help us with. For example, suppose that DMA zone is under From 970e02667c9689f2fe6ceccfd80596c4b8a368a4 Mon Sep 17 00:00:00 2001 From: Benedict Wong Date: Thu, 30 Jun 2022 06:42:33 +0000 Subject: [PATCH 048/124] FROMLIST: xfrm: Skip checking of already-verified secpath entries This change fixes a bug where inbound packets to nested IPsec tunnels fails to pass policy checks due to the inner tunnel's policy checks not having a reference to the outer policy/template. This causes the policy check to fail, since the first entries in the secpath correlate to the outer tunnel, while the templates being verified are for the inner tunnel. In order to ensure that the appropriate policy and template context is searchable, the policy checks must be done incrementally between each decryption step. As such, this marks secpath entries as having been successfully matched, skipping them (treating as optional) on subsequent policy checks By skipping the immediate error return in the case where the secpath entry had previously been validated, this change allows secpath entries that matched a policy/template previously, while still requiring that each searched template find a match in the secpath. For security: - All templates must have matching secpath entries - Unchanged by current patch; templates that do not match any secpath entry still return -1. This patch simply allows skipping earlier blocks of verified secpath entries - All entries (except trailing transport mode entries) must have a matching template - Unvalidated entries, including transport-mode entries still return the errored index if it does not match the correct template. Bug: 236423446 Test: Tested against Android Kernel Unit Tests Link: https://lore.kernel.org/netdev/20220824221252.4130836-2-benedictwong@google.com/ [benedictwong: fixed minor style issues] Signed-off-by: Benedict Wong Change-Id: Ic32831cb00151d0de2e465f18ec37d5f7b680e54 --- include/net/xfrm.h | 1 + net/xfrm/xfrm_input.c | 1 + net/xfrm/xfrm_policy.c | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/include/net/xfrm.h b/include/net/xfrm.h index b07e6748f539..db752708b2a5 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -1034,6 +1034,7 @@ struct xfrm_offload { struct sec_path { int len; int olen; + int verified_cnt; struct xfrm_state *xvec[XFRM_MAX_DEPTH]; struct xfrm_offload ovec[XFRM_MAX_OFFLOAD_DEPTH]; diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c index 61e6220ddd5a..098caddabaad 100644 --- a/net/xfrm/xfrm_input.c +++ b/net/xfrm/xfrm_input.c @@ -129,6 +129,7 @@ struct sec_path *secpath_set(struct sk_buff *skb) memset(sp->ovec, 0, sizeof(sp->ovec)); sp->olen = 0; sp->len = 0; + sp->verified_cnt = 0; return sp; } diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 3d0ffd927004..7be637ebfd08 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -3268,6 +3268,13 @@ xfrm_policy_ok(const struct xfrm_tmpl *tmpl, const struct sec_path *sp, int star if (xfrm_state_ok(tmpl, sp->xvec[idx], family)) return ++idx; if (sp->xvec[idx]->props.mode != XFRM_MODE_TRANSPORT) { + if (idx < sp->verified_cnt) { + /* Secpath entry previously verified, consider optional and + * continue searching + */ + continue; + } + if (start == -1) start = -2-idx; break; @@ -3672,6 +3679,9 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, * Order is _important_. Later we will implement * some barriers, but at the moment barriers * are implied between each two transformations. + * Upon success, marks secpath entries as having been + * verified to allow them to be skipped in future policy + * checks (e.g. nested tunnels). */ for (i = xfrm_nr-1, k = 0; i >= 0; i--) { k = xfrm_policy_ok(tpp[i], sp, k, family); @@ -3690,6 +3700,8 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, } xfrm_pols_put(pols, npols); + sp->verified_cnt = k; + return 1; } XFRM_INC_STATS(net, LINUX_MIB_XFRMINPOLBLOCK); From b5bf2997c3438528631ce0e945884927fbe751ae Mon Sep 17 00:00:00 2001 From: Benedict Wong Date: Thu, 21 Jul 2022 06:54:43 +0000 Subject: [PATCH 049/124] FROMLIST: xfrm: Ensure policy checked for nested ESP tunnels This change ensures that all nested XFRM packets have their policy checked before decryption of the next layer, so that policies are verified at each intermediate step of the decryption process. Notably, raw ESP/AH packets do not perform policy checks inherently, whereas all other encapsulated packets (UDP, TCP encapsulated) do policy checks after calling xfrm_input handling in the respective encapsulation layer. This is necessary especially for nested tunnels, as the IP addresses, protocol and ports may all change, thus not matching the previous policies. In order to ensure that packets match the relevant inbound templates, the xfrm_policy_check should be done before handing off to the inner XFRM protocol to decrypt and decapsulate. In order to prevent double-checking packets both here and in the encapsulation layers, this check is currently limited to nested tunnel-mode transforms and checked prior to decapsulation of inner tunnel layers (prior to hitting a nested tunnel's xfrm_input, there is no great way to detect a nested tunnel). This is primarily a performance consideration, as a general blanket check at the end of xfrm_input would suffice, but may result in multiple policy checks. Bug: 236423446 Test: Tested against Android Kernel Unit Tests Link: https://lore.kernel.org/netdev/20220824221252.4130836-3-benedictwong@google.com/ Signed-off-by: Benedict Wong Change-Id: I20c5abf39512d7f6cf438c0921a78a84e281b4e9 --- net/xfrm/xfrm_input.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c index 098caddabaad..9978b41c8d33 100644 --- a/net/xfrm/xfrm_input.c +++ b/net/xfrm/xfrm_input.c @@ -586,6 +586,20 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type) goto drop; } + /* If nested tunnel, check outer states before context is lost. + * Only nested tunnels need to be checked, since IP addresses change + * as a result of the tunnel mode decapsulation. Similarly, this check + * is limited to nested tunnels to avoid performing another policy + * check on non-nested tunnels. On success, this check also updates the + * secpath's verified_cnt variable, skipping future verifications of + * previously-verified secpath entries. + */ + if ((x->outer_mode.flags & XFRM_MODE_FLAG_TUNNEL) && + sp->verified_cnt < sp->len && + !xfrm_policy_check(NULL, XFRM_POLICY_IN, skb, family)) { + goto drop; + } + skb->mark = xfrm_smark_get(skb->mark, x); sp->xvec[sp->len++] = x; From e3b7e41f06a7a4af5c7f4e4d9ed9adf97aa6c01b Mon Sep 17 00:00:00 2001 From: xiaofeng Date: Wed, 24 Aug 2022 19:34:06 +0800 Subject: [PATCH 050/124] ANDROID: vendor_hooks:vendor hook for __alloc_pages_slowpath. add vendor hook in __alloc_pages_slowpath ahead of __alloc_pages_direct_reclaim and warn_alloc. Bug: 243629905 Change-Id: Ieacc6cf79823c0bfacfdeec9afb55ed66f40d0b0 Signed-off-by: xiaofeng (cherry picked from commit 0312e9cd22b100a088ff64ab36b2db2eb9f28b7c) --- drivers/android/vendor_hooks.c | 3 ++- include/trace/hooks/mm.h | 8 ++++++++ mm/page_alloc.c | 11 +++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 5e27095e8b7a..c507e5737cdb 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -408,4 +408,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_memcg_scan_type); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_pidfd_open); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmput); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_early_resume_begin); - +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_reclaim_bypass); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_failure_bypass); diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index a5db2918abbb..9e8f234545b1 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -146,6 +146,14 @@ DECLARE_HOOK(android_vh_mem_cgroup_css_online, DECLARE_HOOK(android_vh_mem_cgroup_css_offline, TP_PROTO(struct cgroup_subsys_state *css, struct mem_cgroup *memcg), TP_ARGS(css, memcg)); +DECLARE_HOOK(android_vh_alloc_pages_reclaim_bypass, + TP_PROTO(gfp_t gfp_mask, int order, int alloc_flags, + int migratetype, struct page **page), + TP_ARGS(gfp_mask, order, alloc_flags, migratetype, page)); +DECLARE_HOOK(android_vh_alloc_pages_failure_bypass, + TP_PROTO(gfp_t gfp_mask, int order, int alloc_flags, + int migratetype, struct page **page), + TP_ARGS(gfp_mask, order, alloc_flags, migratetype, page)); /* macro versions of hooks are no longer required */ #endif /* _TRACE_HOOK_MM_H */ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 8c64f228acf7..209f7aef707d 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5102,6 +5102,12 @@ retry: if (current->flags & PF_MEMALLOC) goto nopage; + trace_android_vh_alloc_pages_reclaim_bypass(gfp_mask, order, + alloc_flags, ac->migratetype, &page); + + if (page) + goto got_pg; + /* Try direct reclaim and then allocating */ page = __alloc_pages_direct_reclaim(gfp_mask, order, alloc_flags, ac, &did_some_progress); @@ -5209,6 +5215,11 @@ nopage: goto retry; } fail: + trace_android_vh_alloc_pages_failure_bypass(gfp_mask, order, + alloc_flags, ac->migratetype, &page); + if (page) + goto got_pg; + warn_alloc(gfp_mask, ac->nodemask, "page allocation failure: order:%u", order); got_pg: From dd04e189dfa3623934dd894e85b1fc6d64fbc3ad Mon Sep 17 00:00:00 2001 From: Woody Lin Date: Tue, 30 Aug 2022 17:34:32 +0800 Subject: [PATCH 051/124] ANDROID: Update the ABI representation 1 symbol(s) added 'int kobject_rename(struct kobject *, const char *)' Bug: 239090823 Signed-off-by: Woody Lin Change-Id: Ifdc8ac7b67a33a94cb3b85f570ddb1a9d1401aaa --- android/abi_gki_aarch64.xml | 6 ++++++ android/abi_gki_aarch64_generic | 1 + 2 files changed, 7 insertions(+) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index ce9870316ebc..631ec84b350a 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -2021,6 +2021,7 @@ + @@ -117007,6 +117008,11 @@ + + + + + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index 956aea9d453f..23ab56e53ad8 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -1195,6 +1195,7 @@ kobject_init kobject_init_and_add kobject_put + kobject_rename kobject_uevent kobject_uevent_env kobj_sysfs_ops From e09aff6074e10262d503418e599f1a18fc047bd8 Mon Sep 17 00:00:00 2001 From: Ziyi Cui Date: Mon, 29 Aug 2022 23:09:23 +0000 Subject: [PATCH 052/124] ANDROID: softirq: Add EXPORT_SYMBOL_GPL for softirq and tasklet The purpose of these symbols are used for getting counter and metrics of long running irq. Currently we only have symbols for irq_handler_entry and irq_handler_exit. Bug: 227809911 Signed-off-by: Ziyi Cui Change-Id: Idf4ccdede5232689b2752283539aee54a5f67866 --- kernel/softirq.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/softirq.c b/kernel/softirq.c index a6da60be62e8..e9455df99569 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -31,6 +31,10 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(irq_handler_entry); EXPORT_TRACEPOINT_SYMBOL_GPL(irq_handler_exit); +EXPORT_TRACEPOINT_SYMBOL_GPL(softirq_entry); +EXPORT_TRACEPOINT_SYMBOL_GPL(softirq_exit); +EXPORT_TRACEPOINT_SYMBOL_GPL(tasklet_entry); +EXPORT_TRACEPOINT_SYMBOL_GPL(tasklet_exit); /* - No shared variables, all the data are CPU local. From c7afbeb17edfbcb7a9cf3b0058b8bb9b492cbf9e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 31 Aug 2022 11:45:30 +0200 Subject: [PATCH 053/124] Revert "ANDROID: mm: export zone_watermark_ok" This reverts commit e909fe79d28d614b390edcef5b13a2f375ec042e. The symbols exported in it were never used by any external modules, so remove the exports as they are not needed. Bug: 203756332 Bug: 140294230 Cc: Sudarshan Rajagopalan Signed-off-by: Greg Kroah-Hartman Change-Id: Ib3315ba129773256398a71ffe4c3acb55075b012 --- mm/mmzone.c | 2 -- mm/page_alloc.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/mm/mmzone.c b/mm/mmzone.c index 1470eea5454a..595400d7dcec 100644 --- a/mm/mmzone.c +++ b/mm/mmzone.c @@ -72,7 +72,6 @@ struct zoneref *__next_zones_zonelist(struct zoneref *z, return z; } -EXPORT_SYMBOL_GPL(__next_zones_zonelist); #ifdef CONFIG_ARCH_HAS_HOLES_MEMORYMODEL bool memmap_valid_within(unsigned long pfn, @@ -133,4 +132,3 @@ enum zone_type gfp_zone(gfp_t flags) VM_BUG_ON((GFP_ZONE_BAD >> bit) & 1); return z; } -EXPORT_SYMBOL_GPL(gfp_zone); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 209f7aef707d..bebdf55d7272 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3999,7 +3999,6 @@ bool zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark, return __zone_watermark_ok(z, order, mark, highest_zoneidx, alloc_flags, zone_page_state(z, NR_FREE_PAGES)); } -EXPORT_SYMBOL_GPL(zone_watermark_ok); static inline bool zone_watermark_fast(struct zone *z, unsigned int order, unsigned long mark, int highest_zoneidx, @@ -4052,7 +4051,6 @@ bool zone_watermark_ok_safe(struct zone *z, unsigned int order, return __zone_watermark_ok(z, order, mark, highest_zoneidx, 0, free_pages); } -EXPORT_SYMBOL_GPL(zone_watermark_ok_safe); #ifdef CONFIG_NUMA static bool zone_allows_reclaim(struct zone *local_zone, struct zone *zone) From 9cfe2646f7f421c6faacc2fd3097845c5d0680c5 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 30 Aug 2022 19:10:52 +0200 Subject: [PATCH 054/124] Revert "ANDROID: vendor_hooks: FPSIMD save/restore by using vendor_hooks" This reverts commit 74555f39924dc4c173b4bec9bd015acfeb895e68. The hook android_vh_is_fpsimd_save is not used by any vendor, so remove it to help with merge issues with future LTS releases. If this is needed by any real user, it can easily be reverted to add it back and then the symbol should be added to the abi list at the same time to prevent it from being removed again later. Bug: 203756332 Bug: 149632552 Cc: Wooyeon Kim Signed-off-by: Greg Kroah-Hartman Change-Id: Idecd20a8791c5e4497f8d2222cc54cc42b2ebdff --- arch/arm64/include/asm/processor.h | 5 +++++ arch/arm64/kernel/process.c | 3 --- drivers/android/vendor_hooks.c | 2 -- include/trace/hooks/fpsimd.h | 27 --------------------------- 4 files changed, 5 insertions(+), 32 deletions(-) delete mode 100644 include/trace/hooks/fpsimd.h diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index abeebb43b3fe..a4867b384ef0 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -149,6 +149,11 @@ struct thread_struct { struct user_fpsimd_state fpsimd_state; } uw; + /* + * Unused now that commit 74555f39924d ("ANDROID: vendor_hooks: FPSIMD + * save/restore by using vendor_hooks") is reverted, but remains to + * preserve the ABI in the android13-5.10 branch. + */ ANDROID_VENDOR_DATA(1); unsigned int fpsimd_cpu; diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 00bff856d496..d98512af85f1 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -44,7 +44,6 @@ #include #include #include -#include #include #include @@ -588,8 +587,6 @@ __notrace_funcgraph struct task_struct *__switch_to(struct task_struct *prev, if (prev->thread.sctlr_user != next->thread.sctlr_user) update_sctlr_el1(next->thread.sctlr_user); - trace_android_vh_is_fpsimd_save(prev, next); - /* the actual thread switch */ last = cpu_switch_to(prev, next); diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index c507e5737cdb..74d2fcf0e2d2 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -100,7 +99,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sk_free); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_nf_conn_alloc); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_nf_conn_free); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_arch_set_freq_scale); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_is_fpsimd_save); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_transaction_init); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_priority_skip); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_binder_set_priority); diff --git a/include/trace/hooks/fpsimd.h b/include/trace/hooks/fpsimd.h deleted file mode 100644 index 1141ebb1a1c6..000000000000 --- a/include/trace/hooks/fpsimd.h +++ /dev/null @@ -1,27 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#undef TRACE_SYSTEM -#define TRACE_SYSTEM fpsimd - -#define TRACE_INCLUDE_PATH trace/hooks - -#if !defined(_TRACE_HOOK_FPSIMD_H) || defined(TRACE_HEADER_MULTI_READ) -#define _TRACE_HOOK_FPSIMD_H - -#include - -#ifdef __GENKSYMS__ -struct task_struct; -#else -/* struct task_struct */ -#include -#endif /* __GENKSYMS__ */ - -DECLARE_HOOK(android_vh_is_fpsimd_save, - TP_PROTO(struct task_struct *prev, struct task_struct *next), - TP_ARGS(prev, next)) - -/* macro versions of hooks are no longer required */ - -#endif /* _TRACE_HOOK_FPSIMD_H */ -/* This part must be outside protection */ -#include From 909d582d3a0bd779d4260c41f276b138014cde99 Mon Sep 17 00:00:00 2001 From: JianMin Liu Date: Wed, 29 Jun 2022 21:13:56 +0800 Subject: [PATCH 055/124] ANDROID: sched: Introducing PELT multiplier The new sysctl sched_pelt_multiplier allows a user to set a clock multiplier x2 or x4 (x1 being the default). This clock multiplier artificially speed-up PELT ramp up/down similarly to a faster half-life. Indeed, if we write PELT as a first order filter: y(t) = G * (1 - exp(t/tau)) Then we can see that multiplying the time by a constant X, is the same as dividing the time constant tau by X. y(t) = G * (1 - exp((t*X)/tau)) y(t) = G * (1 - exp(t/(tau/X))) Tau being half-life*ln(2), multiplying the PELT time is the same as dividing the half-life: - x1: 32ms half-life - x2: 16ms half-life - x4: 8ms half-life Internally, a new clock is created: rq->clock_task_mult. It sits in the clock hierarchy between rq->clock_task and rq->clock_pelt. Bug: 177593580 Bug: 237219700 Change-Id: I67e6ca7994bebea22bf75732ee11d2b10e0d6b7e Suggested-by: Morten Rasmussen Signed-off-by: Vincent Donnefort Signed-off-by: JianMin Liu (cherry picked from commit 4442801a43f36350785023f54fc37abfd36b2145) --- include/linux/sched/sysctl.h | 7 ++++++ kernel/sched/fair.c | 6 +++--- kernel/sched/pelt.c | 42 ++++++++++++++++++++++++++++++++++++ kernel/sched/pelt.h | 11 ++++++++-- kernel/sched/sched.h | 10 +++++++++ kernel/sysctl.c | 9 ++++++++ 6 files changed, 80 insertions(+), 5 deletions(-) diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h index 3c31ba88aca5..581ee79550de 100644 --- a/include/linux/sched/sysctl.h +++ b/include/linux/sched/sysctl.h @@ -92,6 +92,13 @@ int sysctl_numa_balancing(struct ctl_table *table, int write, void *buffer, int sysctl_schedstats(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos); +#ifdef CONFIG_SMP +extern unsigned int sysctl_sched_pelt_multiplier; + +int sched_pelt_multiplier(struct ctl_table *table, int write, void *buffer, + size_t *lenp, loff_t *ppos); +#endif + #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) extern unsigned int sysctl_sched_energy_aware; int sched_energy_aware_handler(struct ctl_table *table, int write, diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index ff561e3763f4..b7a86b611318 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4800,7 +4800,7 @@ static int tg_unthrottle_up(struct task_group *tg, void *data) cfs_rq->throttle_count--; if (!cfs_rq->throttle_count) { - cfs_rq->throttled_clock_task_time += rq_clock_task(rq) - + cfs_rq->throttled_clock_task_time += rq_clock_task_mult(rq) - cfs_rq->throttled_clock_task; /* Add cfs_rq with already running entity in the list */ @@ -4818,7 +4818,7 @@ static int tg_throttle_down(struct task_group *tg, void *data) /* group is entering throttled state, stop time */ if (!cfs_rq->throttle_count) { - cfs_rq->throttled_clock_task = rq_clock_task(rq); + cfs_rq->throttled_clock_task = rq_clock_task_mult(rq); list_del_leaf_cfs_rq(cfs_rq); } cfs_rq->throttle_count++; @@ -5236,7 +5236,7 @@ static void sync_throttle(struct task_group *tg, int cpu) pcfs_rq = tg->parent->cfs_rq[cpu]; cfs_rq->throttle_count = pcfs_rq->throttle_count; - cfs_rq->throttled_clock_task = rq_clock_task(cpu_rq(cpu)); + cfs_rq->throttled_clock_task = rq_clock_task_mult(cpu_rq(cpu)); } /* conditionally throttle active cfs_rq's from put_prev_entity() */ diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c index e15a2fad146e..3e0d42dda717 100644 --- a/kernel/sched/pelt.c +++ b/kernel/sched/pelt.c @@ -509,3 +509,45 @@ int update_irq_load_avg(struct rq *rq, u64 running) return ret; } #endif + +DEFINE_PER_CPU(u64, clock_task_mult); + +unsigned int sysctl_sched_pelt_multiplier = 1; +__read_mostly unsigned int sched_pelt_lshift; + +int sched_pelt_multiplier(struct ctl_table *table, int write, void *buffer, + size_t *lenp, loff_t *ppos) +{ + static DEFINE_MUTEX(mutex); + unsigned int old; + int ret; + + mutex_lock(&mutex); + + old = sysctl_sched_pelt_multiplier; + ret = proc_dointvec(table, write, buffer, lenp, ppos); + if (ret) + goto undo; + if (!write) + goto done; + + switch (sysctl_sched_pelt_multiplier) { + case 1: + fallthrough; + case 2: + fallthrough; + case 4: + WRITE_ONCE(sched_pelt_lshift, + sysctl_sched_pelt_multiplier >> 1); + goto done; + default: + ret = -EINVAL; + } + +undo: + sysctl_sched_pelt_multiplier = old; +done: + mutex_unlock(&mutex); + + return ret; +} diff --git a/kernel/sched/pelt.h b/kernel/sched/pelt.h index 45bf08e22207..3f00596def11 100644 --- a/kernel/sched/pelt.h +++ b/kernel/sched/pelt.h @@ -61,6 +61,8 @@ static inline void cfs_se_util_change(struct sched_avg *avg) WRITE_ONCE(avg->util_est.enqueued, enqueued); } +extern unsigned int sched_pelt_lshift; + /* * The clock_pelt scales the time to reflect the effective amount of * computation done during the running delta time but then sync back to @@ -75,9 +77,13 @@ static inline void cfs_se_util_change(struct sched_avg *avg) */ static inline void update_rq_clock_pelt(struct rq *rq, s64 delta) { + delta <<= READ_ONCE(sched_pelt_lshift); + + per_cpu(clock_task_mult, rq->cpu) += delta; + if (unlikely(is_idle_task(rq->curr))) { /* The rq is idle, we can sync to clock_task */ - rq->clock_pelt = rq_clock_task(rq); + rq->clock_pelt = rq_clock_task_mult(rq); return; } @@ -129,7 +135,8 @@ static inline void update_idle_rq_clock_pelt(struct rq *rq) * rq's clock_task. */ if (util_sum >= divider) - rq->lost_idle_time += rq_clock_task(rq) - rq->clock_pelt; + rq->lost_idle_time += rq_clock_task_mult(rq) - + rq->clock_pelt; } static inline u64 rq_clock_pelt(struct rq *rq) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 317be806dd04..71c2d7c194fd 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1194,6 +1194,16 @@ static inline u64 rq_clock_task(struct rq *rq) return rq->clock_task; } +DECLARE_PER_CPU(u64, clock_task_mult); + +static inline u64 rq_clock_task_mult(struct rq *rq) +{ + lockdep_assert_held(&rq->lock); + assert_clock_updated(rq); + + return per_cpu(clock_task_mult, rq->cpu); +} + /** * By default the decay is the default pelt decay period. * The decay shift can change the decay period in diff --git a/kernel/sysctl.c b/kernel/sysctl.c index e68cc71b9f8f..d053ab4adf4b 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1831,6 +1831,15 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = sched_rr_handler, }, +#ifdef CONFIG_SMP + { + .procname = "sched_pelt_multiplier", + .data = &sysctl_sched_pelt_multiplier, + .maxlen = sizeof(unsigned int), + .mode = 0644, + .proc_handler = sched_pelt_multiplier, + }, +#endif #ifdef CONFIG_UCLAMP_TASK { .procname = "sched_util_clamp_min", From 4e709a85e578d28a2626832c4f2cf5e9031d435c Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Thu, 28 Jul 2022 14:13:33 -0700 Subject: [PATCH 056/124] ANDROID: fix kernelci issue for allnoconfig builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'allnoconfig' builds failed with: kernel/sched/sched.h:1203:50: error: ‘struct rq’ has no member named ‘cpu’ rq->cpu needs to be replaced with cpu_of(rq) for !CONFIG_SMP builds Fixes: 4442801a43f3 ("ANDROID: sched: Introducing PELT multiplier") Signed-off-by: Todd Kjos Change-Id: Iceb439dc3bba27516b5ecd2c18c9835c23e5a39a --- kernel/sched/sched.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 71c2d7c194fd..9255afc79715 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1201,7 +1201,7 @@ static inline u64 rq_clock_task_mult(struct rq *rq) lockdep_assert_held(&rq->lock); assert_clock_updated(rq); - return per_cpu(clock_task_mult, rq->cpu); + return per_cpu(clock_task_mult, cpu_of(rq)); } /** From 7219ca326a8e84df0c88db8aa4eafd793a55527c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 1 Sep 2022 14:52:39 +0200 Subject: [PATCH 057/124] Revert "ANDROID: Sched: Add restricted vendor hooks for scheduler" This reverts most of commit 292f430816f36384634ca1365ccc67c08302dd21. Only a small number of the original hooks in this commit were ever used, so remove all of the unused ones. The hooks removed are: android_rvh_try_to_wake_up android_rvh_try_to_wake_up_success android_rvh_wake_up_new_task android_rvh_new_task_stats android_rvh_flush_task android_rvh_tick_entry android_rvh_schedule android_rvh_sched_cpu_starting android_rvh_sched_cpu_dying android_rvh_account_irq android_rvh_place_entity android_rvh_update_cpu_capacity android_rvh_update_misfit_status If these are needed by any real user, it can easily be reverted to add it back and then the symbols must be added to the abi list at the same time to prevent it from being removed again later. Bug: 203756332 Bug: 173725277 Cc: Shaleen Agrawal Cc: Pavankumar Kondeti Signed-off-by: Greg Kroah-Hartman Change-Id: Icc24ed128fe1034ad663b749caa3bc2e2d0efac0 --- drivers/android/vendor_hooks.c | 13 --------- include/trace/hooks/sched.h | 52 ---------------------------------- kernel/sched/core.c | 15 +--------- kernel/sched/cputime.c | 2 -- kernel/sched/fair.c | 3 -- 5 files changed, 1 insertion(+), 84 deletions(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 74d2fcf0e2d2..3607c500f192 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -160,21 +160,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_preempt_enable); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_irqs_disable); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_irqs_enable); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_task_cpu); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_try_to_wake_up); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_try_to_wake_up_success); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sched_fork); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_wake_up_new_task); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_new_task_stats); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_flush_task); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_tick_entry); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_schedule); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sched_cpu_starting); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_sched_cpu_dying); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_account_irq); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_place_entity); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_build_perf_domains); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_cpu_capacity); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_update_misfit_status); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpu_cgroup_attach); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpu_cgroup_can_attach); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpu_cgroup_online); diff --git a/include/trace/hooks/sched.h b/include/trace/hooks/sched.h index defc23107762..3a8eee2345af 100644 --- a/include/trace/hooks/sched.h +++ b/include/trace/hooks/sched.h @@ -159,66 +159,14 @@ DECLARE_RESTRICTED_HOOK(android_rvh_set_task_cpu, TP_PROTO(struct task_struct *p, unsigned int new_cpu), TP_ARGS(p, new_cpu), 1); -DECLARE_RESTRICTED_HOOK(android_rvh_try_to_wake_up, - TP_PROTO(struct task_struct *p), - TP_ARGS(p), 1); - -DECLARE_RESTRICTED_HOOK(android_rvh_try_to_wake_up_success, - TP_PROTO(struct task_struct *p), - TP_ARGS(p), 1); - DECLARE_RESTRICTED_HOOK(android_rvh_sched_fork, TP_PROTO(struct task_struct *p), TP_ARGS(p), 1); -DECLARE_RESTRICTED_HOOK(android_rvh_wake_up_new_task, - TP_PROTO(struct task_struct *p), - TP_ARGS(p), 1); - -DECLARE_RESTRICTED_HOOK(android_rvh_new_task_stats, - TP_PROTO(struct task_struct *p), - TP_ARGS(p), 1); - -DECLARE_RESTRICTED_HOOK(android_rvh_flush_task, - TP_PROTO(struct task_struct *prev), - TP_ARGS(prev), 1); - -DECLARE_RESTRICTED_HOOK(android_rvh_tick_entry, - TP_PROTO(struct rq *rq), - TP_ARGS(rq), 1); - -DECLARE_RESTRICTED_HOOK(android_rvh_schedule, - TP_PROTO(struct task_struct *prev, struct task_struct *next, struct rq *rq), - TP_ARGS(prev, next, rq), 1); - -DECLARE_RESTRICTED_HOOK(android_rvh_sched_cpu_starting, - TP_PROTO(int cpu), - TP_ARGS(cpu), 1); - -DECLARE_RESTRICTED_HOOK(android_rvh_sched_cpu_dying, - TP_PROTO(int cpu), - TP_ARGS(cpu), 1); - -DECLARE_RESTRICTED_HOOK(android_rvh_account_irq, - TP_PROTO(struct task_struct *curr, int cpu, s64 delta), - TP_ARGS(curr, cpu, delta), 1); - -DECLARE_RESTRICTED_HOOK(android_rvh_place_entity, - TP_PROTO(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial, u64 vruntime), - TP_ARGS(cfs_rq, se, initial, vruntime), 1); - DECLARE_RESTRICTED_HOOK(android_rvh_build_perf_domains, TP_PROTO(bool *eas_check), TP_ARGS(eas_check), 1); -DECLARE_RESTRICTED_HOOK(android_rvh_update_cpu_capacity, - TP_PROTO(int cpu, unsigned long *capacity), - TP_ARGS(cpu, capacity), 1); - -DECLARE_RESTRICTED_HOOK(android_rvh_update_misfit_status, - TP_PROTO(struct task_struct *p, struct rq *rq, bool *need_update), - TP_ARGS(p, rq, need_update), 1); - DECLARE_RESTRICTED_HOOK(android_rvh_cpu_cgroup_attach, TP_PROTO(struct cgroup_taskset *tset), TP_ARGS(tset), 1); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 30e22d525d93..f805a67f877e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3194,8 +3194,6 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) */ smp_cond_load_acquire(&p->on_cpu, !VAL); - trace_android_rvh_try_to_wake_up(p); - cpu = select_task_rq(p, p->wake_cpu, SD_BALANCE_WAKE, wake_flags); if (task_cpu(p) != cpu) { if (p->in_iowait) { @@ -3215,10 +3213,8 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) unlock: raw_spin_unlock_irqrestore(&p->pi_lock, flags); out: - if (success) { - trace_android_rvh_try_to_wake_up_success(p); + if (success) ttwu_stat(p, task_cpu(p), wake_flags); - } preempt_enable(); return success; @@ -3579,8 +3575,6 @@ void wake_up_new_task(struct task_struct *p) struct rq_flags rf; struct rq *rq; - trace_android_rvh_wake_up_new_task(p); - raw_spin_lock_irqsave(&p->pi_lock, rf.flags); p->state = TASK_RUNNING; #ifdef CONFIG_SMP @@ -3599,7 +3593,6 @@ void wake_up_new_task(struct task_struct *p) rq = __task_rq_lock(p, &rf); update_rq_clock(rq); post_init_entity_util_avg(p); - trace_android_rvh_new_task_stats(p); activate_task(rq, p, ENQUEUE_NOCLOCK); trace_sched_wakeup_new(p); @@ -3891,7 +3884,6 @@ static struct rq *finish_task_switch(struct task_struct *prev) * task and put them back on the free list. */ kprobe_flush_task(prev); - trace_android_rvh_flush_task(prev); /* Task is done with its stack. */ put_task_stack(prev); @@ -4247,7 +4239,6 @@ void scheduler_tick(void) rq_lock(rq, &rf); - trace_android_rvh_tick_entry(rq); update_rq_clock(rq); thermal_pressure = arch_scale_thermal_pressure(cpu_of(rq)); update_thermal_load_avg(rq_clock_thermal(rq), rq, thermal_pressure); @@ -4772,7 +4763,6 @@ static void __sched notrace __schedule(bool preempt) clear_tsk_need_resched(prev); clear_preempt_need_resched(); - trace_android_rvh_schedule(prev, next, rq); if (likely(prev != next)) { rq->nr_switches++; /* @@ -7356,7 +7346,6 @@ int sched_cpu_starting(unsigned int cpu) { sched_rq_cpu_starting(cpu); sched_tick_start(cpu); - trace_android_rvh_sched_cpu_starting(cpu); return 0; } @@ -7378,8 +7367,6 @@ int sched_cpu_dying(unsigned int cpu) BUG_ON(rq->nr_running != 1); rq_unlock_irqrestore(rq, &rf); - trace_android_rvh_sched_cpu_dying(cpu); - calc_load_migrate(rq); nohz_balance_exit_idle(rq); hrtick_clear(rq); diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index 7ffe3e2be485..807b948d22c9 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c @@ -73,8 +73,6 @@ void irqtime_account_irq(struct task_struct *curr) irqtime_account_delta(irqtime, delta, CPUTIME_IRQ); else if (in_serving_softirq() && curr != this_cpu_ksoftirqd()) irqtime_account_delta(irqtime, delta, CPUTIME_SOFTIRQ); - - trace_android_rvh_account_irq(curr, cpu, delta); } EXPORT_SYMBOL_GPL(irqtime_account_irq); diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index b7a86b611318..b5601fced9d5 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4109,7 +4109,6 @@ static inline void update_misfit_status(struct task_struct *p, struct rq *rq) { bool need_update = true; - trace_android_rvh_update_misfit_status(p, rq, &need_update); if (!static_branch_unlikely(&sched_asym_cpucapacity) || !need_update) return; @@ -4209,7 +4208,6 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial) /* ensure we never gain time by being placed backwards. */ se->vruntime = max_vruntime(se->vruntime, vruntime); - trace_android_rvh_place_entity(cfs_rq, se, initial, vruntime); } static void check_enqueue_throttle(struct cfs_rq *cfs_rq); @@ -8336,7 +8334,6 @@ static void update_cpu_capacity(struct sched_domain *sd, int cpu) if (!capacity) capacity = 1; - trace_android_rvh_update_cpu_capacity(cpu, &capacity); cpu_rq(cpu)->cpu_capacity = capacity; trace_sched_cpu_capacity_tp(cpu_rq(cpu)); From 3743e36578ceed4d55412a38280d289669d94c59 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 1 Sep 2022 14:58:23 +0200 Subject: [PATCH 058/124] Revert "ANDROID: GKI: signal: Export for __lock_task_sighand" This reverts commit a719abf03114cfc0b9f68937d9cd900d74d65cae. The symbol exported was never used by any external modules, so remove the unneeded export. Bug: 158067689 Bug: 203756332 Cc: Abhilasha Rao Signed-off-by: Greg Kroah-Hartman Change-Id: I13b65fd0620faf08784dabc7130f199dfa5cf053 --- kernel/signal.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/signal.c b/kernel/signal.c index 7814560f8637..6bf3a8f1cd94 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -1400,7 +1400,6 @@ struct sighand_struct *__lock_task_sighand(struct task_struct *tsk, return sighand; } -EXPORT_SYMBOL_GPL(__lock_task_sighand); /* * send signal info to all the members of a group From 9bc5a118ef8acd8454e364ed055eaa9e1120d49b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 1 Sep 2022 15:51:44 +0200 Subject: [PATCH 059/124] Revert "ANDROID: usb: host: export additional xhci symbols for ring management" This reverts commit 6c997d153d7c1e11d51aeb1b7c46002d5daa760b. The symbols exported by it were never used by any external modules, so remove the unneeded exports. Bug: 203756332 Signed-off-by: Greg Kroah-Hartman Change-Id: I338313c0c2ad1ec83f452db910a6ef9b5ee32b7d --- drivers/usb/host/xhci-mem.c | 4 ---- drivers/usb/host/xhci-ring.c | 3 --- 2 files changed, 7 deletions(-) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 4324fd31b2c4..48bbf13e08f6 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1836,7 +1836,6 @@ struct xhci_command *xhci_alloc_command(struct xhci_hcd *xhci, INIT_LIST_HEAD(&command->cmd_list); return command; } -EXPORT_SYMBOL_GPL(xhci_alloc_command); struct xhci_command *xhci_alloc_command_with_ctx(struct xhci_hcd *xhci, bool allocate_completion, gfp_t mem_flags) @@ -1870,7 +1869,6 @@ void xhci_free_command(struct xhci_hcd *xhci, kfree(command->completion); kfree(command); } -EXPORT_SYMBOL_GPL(xhci_free_command); int xhci_alloc_erst(struct xhci_hcd *xhci, struct xhci_ring *evt_ring, @@ -1901,7 +1899,6 @@ int xhci_alloc_erst(struct xhci_hcd *xhci, return 0; } -EXPORT_SYMBOL_GPL(xhci_alloc_erst); void xhci_free_erst(struct xhci_hcd *xhci, struct xhci_erst *erst) { @@ -1915,7 +1912,6 @@ void xhci_free_erst(struct xhci_hcd *xhci, struct xhci_erst *erst) erst->erst_dma_addr); erst->entries = NULL; } -EXPORT_SYMBOL_GPL(xhci_free_erst); static struct xhci_device_context_array *xhci_vendor_alloc_dcbaa( struct xhci_hcd *xhci, gfp_t flags) diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index c85f36ed67d6..b7d5cff93a48 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -79,7 +79,6 @@ dma_addr_t xhci_trb_virt_to_dma(struct xhci_segment *seg, return 0; return seg->dma + (segment_offset * sizeof(*trb)); } -EXPORT_SYMBOL_GPL(xhci_trb_virt_to_dma); static bool trb_is_noop(union xhci_trb *trb) { @@ -312,7 +311,6 @@ void xhci_ring_cmd_db(struct xhci_hcd *xhci) /* Flush PCI posted writes */ readl(&xhci->dba->doorbell[0]); } -EXPORT_SYMBOL_GPL(xhci_ring_cmd_db); static bool xhci_mod_cmd_timer(struct xhci_hcd *xhci, unsigned long delay) { @@ -4412,7 +4410,6 @@ int xhci_queue_stop_endpoint(struct xhci_hcd *xhci, struct xhci_command *cmd, return queue_command(xhci, cmd, 0, 0, 0, trb_slot_id | trb_ep_index | type | trb_suspend, false); } -EXPORT_SYMBOL_GPL(xhci_queue_stop_endpoint); int xhci_queue_reset_ep(struct xhci_hcd *xhci, struct xhci_command *cmd, int slot_id, unsigned int ep_index, From 1dd8074b61d49e5c3bd9f3940363e1e8906035ed Mon Sep 17 00:00:00 2001 From: Hsiu-Chang Chen Date: Tue, 6 Sep 2022 15:25:17 +0800 Subject: [PATCH 060/124] ANDROID: Update the ABI representation 1 symbol(s) added 'int __xa_insert(struct xarray *, unsigned long int, void *, gfp_t)' Bug: 245009352 Signed-off-by: Hsiu-Chang Chen Change-Id: I80dcbc7d4ef9c1429eace307845c67dc0604f8a0 --- android/abi_gki_aarch64.xml | 1423 ++++++++++++++----------------- android/abi_gki_aarch64_generic | 1 + 2 files changed, 652 insertions(+), 772 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index 631ec84b350a..16cecdb1603b 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -339,6 +339,7 @@ + @@ -4068,71 +4069,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -4888,7 +4824,7 @@ - + @@ -7619,43 +7555,43 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -8728,7 +8664,7 @@ - + @@ -10135,9 +10071,6 @@ - - - @@ -11412,15 +11345,15 @@ - + - + - + - + @@ -11626,7 +11559,7 @@ - + @@ -14504,7 +14437,7 @@ - + @@ -20966,7 +20899,7 @@ - + @@ -23333,7 +23266,7 @@ - + @@ -25287,7 +25220,7 @@ - + @@ -32728,7 +32661,7 @@ - + @@ -35471,7 +35404,7 @@ - + @@ -36763,17 +36696,7 @@ - - - - - - - - - - - + @@ -41370,7 +41293,7 @@ - + @@ -42831,7 +42754,6 @@ - @@ -45853,81 +45775,81 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -46118,14 +46040,6 @@ - - - - - - - - @@ -46421,13 +46335,13 @@ - + - + - + @@ -46436,7 +46350,7 @@ - + @@ -50408,7 +50322,7 @@ - + @@ -52921,7 +52835,6 @@ - @@ -54814,24 +54727,24 @@ - + - + - + - + - + - + - + @@ -56227,61 +56140,61 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -59342,15 +59255,15 @@ - + - + - + - + @@ -59693,7 +59606,7 @@ - + @@ -59775,7 +59688,7 @@ - + @@ -63538,7 +63451,7 @@ - + @@ -64241,7 +64154,7 @@ - + @@ -65093,25 +65006,25 @@ - + - + - + - + - + - + - + @@ -67657,7 +67570,7 @@ - + @@ -67684,7 +67597,7 @@ - + @@ -67695,7 +67608,7 @@ - + @@ -68407,7 +68320,7 @@ - + @@ -68420,7 +68333,7 @@ - + @@ -68450,7 +68363,7 @@ - + @@ -68493,7 +68406,7 @@ - + @@ -68520,7 +68433,7 @@ - + @@ -68528,7 +68441,7 @@ - + @@ -68536,7 +68449,7 @@ - + @@ -68549,25 +68462,25 @@ - + - + - + - + - + - + - + @@ -68600,7 +68513,7 @@ - + @@ -68611,7 +68524,7 @@ - + @@ -68624,7 +68537,7 @@ - + @@ -68670,7 +68583,7 @@ - + @@ -68695,15 +68608,15 @@ - + - + - + @@ -68711,7 +68624,7 @@ - + @@ -68797,7 +68710,7 @@ - + @@ -68805,21 +68718,21 @@ - + - + - + - + - + @@ -68856,10 +68769,10 @@ - + - + @@ -68875,7 +68788,7 @@ - + @@ -68902,10 +68815,10 @@ - + - + @@ -68949,7 +68862,7 @@ - + @@ -68962,7 +68875,7 @@ - + @@ -68992,7 +68905,7 @@ - + @@ -69005,7 +68918,7 @@ - + @@ -69041,13 +68954,13 @@ - + - + - + @@ -69108,7 +69021,7 @@ - + @@ -69119,13 +69032,13 @@ - + - + @@ -69133,7 +69046,7 @@ - + @@ -69149,7 +69062,7 @@ - + @@ -69253,7 +69166,7 @@ - + @@ -69402,10 +69315,10 @@ - + - + @@ -69421,27 +69334,27 @@ - + - + - + - + - + - + - + @@ -69457,22 +69370,22 @@ - + - + - + - + - + - + @@ -69496,36 +69409,36 @@ - + - + - + - + - + - + - + - + - + - + @@ -69536,7 +69449,7 @@ - + @@ -69560,96 +69473,96 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -69662,13 +69575,13 @@ - + - + - + @@ -69802,7 +69715,7 @@ - + @@ -72624,15 +72537,15 @@ - + - + - + - + @@ -74231,7 +74144,7 @@ - + @@ -74278,7 +74191,6 @@ - @@ -82834,7 +82746,7 @@ - + @@ -84236,7 +84148,7 @@ - + @@ -84316,22 +84228,22 @@ - + - + - + - + - + - + @@ -89909,7 +89821,7 @@ - + @@ -90306,9 +90218,6 @@ - - - @@ -90439,12 +90348,12 @@ - + - + - + @@ -93708,7 +93617,7 @@ - + @@ -94746,39 +94655,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -94786,7 +94663,7 @@ - + @@ -94794,7 +94671,7 @@ - + @@ -94805,7 +94682,7 @@ - + @@ -94813,7 +94690,7 @@ - + @@ -94830,7 +94707,7 @@ - + @@ -94838,7 +94715,7 @@ - + @@ -94846,7 +94723,7 @@ - + @@ -94860,7 +94737,7 @@ - + @@ -94874,12 +94751,12 @@ - + - + @@ -94893,7 +94770,7 @@ - + @@ -94910,7 +94787,7 @@ - + @@ -94921,7 +94798,7 @@ - + @@ -94938,7 +94815,7 @@ - + @@ -94946,7 +94823,7 @@ - + @@ -94957,7 +94834,7 @@ - + @@ -94968,7 +94845,7 @@ - + @@ -94976,7 +94853,7 @@ - + @@ -95152,13 +95029,13 @@ - + - + @@ -95169,7 +95046,7 @@ - + @@ -95180,7 +95057,7 @@ - + @@ -95188,7 +95065,7 @@ - + @@ -95196,7 +95073,7 @@ - + @@ -95210,7 +95087,7 @@ - + @@ -95218,7 +95095,7 @@ - + @@ -95226,7 +95103,7 @@ - + @@ -95234,7 +95111,7 @@ - + @@ -95242,7 +95119,7 @@ - + @@ -95253,7 +95130,7 @@ - + @@ -95261,7 +95138,7 @@ - + @@ -95275,7 +95152,7 @@ - + @@ -95286,7 +95163,7 @@ - + @@ -95294,7 +95171,7 @@ - + @@ -95302,7 +95179,7 @@ - + @@ -95310,7 +95187,7 @@ - + @@ -95330,7 +95207,7 @@ - + @@ -95344,7 +95221,7 @@ - + @@ -95361,7 +95238,7 @@ - + @@ -95375,7 +95252,7 @@ - + @@ -95389,7 +95266,7 @@ - + @@ -95397,7 +95274,7 @@ - + @@ -95411,7 +95288,7 @@ - + @@ -95422,7 +95299,7 @@ - + @@ -95439,7 +95316,7 @@ - + @@ -95447,7 +95324,7 @@ - + @@ -95455,7 +95332,7 @@ - + @@ -95466,7 +95343,7 @@ - + @@ -95477,7 +95354,7 @@ - + @@ -95485,7 +95362,7 @@ - + @@ -95502,7 +95379,7 @@ - + @@ -95525,7 +95402,7 @@ - + @@ -95533,7 +95410,7 @@ - + @@ -95544,7 +95421,7 @@ - + @@ -95558,18 +95435,18 @@ - + - + - + @@ -95595,7 +95472,7 @@ - + @@ -95606,7 +95483,7 @@ - + @@ -95614,7 +95491,7 @@ - + @@ -95634,7 +95511,7 @@ - + @@ -95645,7 +95522,7 @@ - + @@ -95656,12 +95533,12 @@ - + - + @@ -95669,7 +95546,7 @@ - + @@ -95677,7 +95554,7 @@ - + @@ -95685,7 +95562,7 @@ - + @@ -95693,12 +95570,12 @@ - + - + @@ -95706,7 +95583,7 @@ - + @@ -95714,7 +95591,7 @@ - + @@ -95722,7 +95599,7 @@ - + @@ -95730,7 +95607,7 @@ - + @@ -95738,7 +95615,7 @@ - + @@ -95746,7 +95623,7 @@ - + @@ -95787,7 +95664,7 @@ - + @@ -95801,7 +95678,7 @@ - + @@ -95827,7 +95704,7 @@ - + @@ -95892,7 +95769,7 @@ - + @@ -95903,7 +95780,7 @@ - + @@ -95920,7 +95797,7 @@ - + @@ -95964,7 +95841,7 @@ - + @@ -95975,7 +95852,7 @@ - + @@ -95986,7 +95863,7 @@ - + @@ -96006,7 +95883,7 @@ - + @@ -96014,7 +95891,7 @@ - + @@ -96031,7 +95908,7 @@ - + @@ -96060,7 +95937,7 @@ - + @@ -96077,7 +95954,7 @@ - + @@ -96091,17 +95968,17 @@ - + - + - + @@ -96109,7 +95986,7 @@ - + @@ -96120,7 +95997,7 @@ - + @@ -96128,7 +96005,7 @@ - + @@ -96169,7 +96046,7 @@ - + @@ -96177,7 +96054,7 @@ - + @@ -96185,7 +96062,7 @@ - + @@ -96199,7 +96076,7 @@ - + @@ -96219,7 +96096,7 @@ - + @@ -96227,7 +96104,7 @@ - + @@ -96235,7 +96112,7 @@ - + @@ -96243,12 +96120,12 @@ - + - + @@ -96256,7 +96133,7 @@ - + @@ -96267,7 +96144,7 @@ - + @@ -96275,18 +96152,18 @@ - + - + - - + + @@ -96300,12 +96177,12 @@ - + - + @@ -96313,12 +96190,12 @@ - + - + @@ -96326,12 +96203,12 @@ - + - + @@ -96348,7 +96225,7 @@ - + @@ -96356,7 +96233,7 @@ - + @@ -96364,12 +96241,12 @@ - + - + @@ -96377,7 +96254,7 @@ - + @@ -96385,7 +96262,7 @@ - + @@ -96402,12 +96279,12 @@ - + - + @@ -96433,7 +96310,7 @@ - + @@ -96444,7 +96321,7 @@ - + @@ -96464,7 +96341,7 @@ - + @@ -96487,7 +96364,7 @@ - + @@ -96522,7 +96399,7 @@ - + @@ -96533,7 +96410,7 @@ - + @@ -96547,12 +96424,12 @@ - + - + @@ -96563,7 +96440,7 @@ - + @@ -96577,7 +96454,7 @@ - + @@ -96588,7 +96465,7 @@ - + @@ -96602,7 +96479,7 @@ - + @@ -96616,12 +96493,12 @@ - + - + @@ -96629,7 +96506,7 @@ - + @@ -96643,7 +96520,7 @@ - + @@ -96651,7 +96528,7 @@ - + @@ -96662,7 +96539,7 @@ - + @@ -96679,7 +96556,7 @@ - + @@ -96699,7 +96576,7 @@ - + @@ -96716,7 +96593,7 @@ - + @@ -96727,7 +96604,7 @@ - + @@ -96735,7 +96612,7 @@ - + @@ -96743,7 +96620,7 @@ - + @@ -96751,7 +96628,7 @@ - + @@ -96765,7 +96642,7 @@ - + @@ -96773,7 +96650,7 @@ - + @@ -96784,7 +96661,7 @@ - + @@ -96801,7 +96678,7 @@ - + @@ -96827,7 +96704,7 @@ - + @@ -96838,7 +96715,7 @@ - + @@ -96849,7 +96726,7 @@ - + @@ -97238,11 +97115,6 @@ - - - - - @@ -97581,7 +97453,7 @@ - + @@ -97715,30 +97587,30 @@ - + - + - + - + - + - + - + - + - + @@ -101532,7 +101404,7 @@ - + @@ -104247,7 +104119,7 @@ - + @@ -105545,7 +105417,7 @@ - + @@ -105974,11 +105846,11 @@ - - - - - + + + + + @@ -106423,14 +106295,14 @@ - - - + + + - - - + + + @@ -106639,9 +106511,9 @@ - - - + + + @@ -106699,8 +106571,8 @@ - - + + @@ -106780,9 +106652,9 @@ - - - + + + @@ -107084,12 +106956,12 @@ - - + + - - + + @@ -107109,10 +106981,10 @@ - - - - + + + + @@ -107129,22 +107001,22 @@ - - - - - - - - - - - + + + + + + + + + + + - - - + + + @@ -107153,12 +107025,12 @@ - - - - - - + + + + + + @@ -107168,17 +107040,17 @@ - - - - - + + + + + - - - - + + + + @@ -107226,11 +107098,11 @@ - - - - - + + + + + @@ -107259,9 +107131,9 @@ - - - + + + @@ -107276,15 +107148,15 @@ - - - - + + + + - - - + + + @@ -107332,21 +107204,21 @@ - - - - - - - + + + + + + + - - - - - - + + + + + + @@ -107360,39 +107232,39 @@ - - - + + + - - - - - + + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - - + + + + + + @@ -107476,10 +107348,10 @@ - - - - + + + + @@ -107572,11 +107444,11 @@ - - - - - + + + + + @@ -107584,11 +107456,11 @@ - - - - - + + + + + @@ -107908,47 +107780,47 @@ - + - - + + - + - - + + - + - + - - + + - - + + - - - - - + + + + + @@ -107960,7 +107832,7 @@ - + @@ -107975,9 +107847,9 @@ - + - + @@ -108107,6 +107979,13 @@ + + + + + + + @@ -108309,9 +108188,9 @@ - - - + + + @@ -108407,9 +108286,9 @@ - - - + + + @@ -108515,8 +108394,8 @@ - - + + @@ -114601,14 +114480,14 @@ - - - + + + - - - + + + @@ -114948,8 +114827,8 @@ - - + + @@ -116333,11 +116212,11 @@ - + - - + + @@ -116776,7 +116655,7 @@ - + @@ -116832,7 +116711,7 @@ - + @@ -117034,7 +116913,7 @@ - + @@ -117882,16 +117761,16 @@ - - - - - - + + + + + + - - + + @@ -118888,14 +118767,14 @@ - - - - + + + + - - + + @@ -119677,7 +119556,7 @@ - + @@ -119801,10 +119680,10 @@ - + - + @@ -120748,7 +120627,7 @@ - + @@ -120937,67 +120816,67 @@ - - + + - - - + + + - - - - + + + + - - - - + + + + - - + + - - + + - - + + - - - - + + + + - - + + - - + + - - + + - - + + - - + + - + @@ -121277,10 +121156,10 @@ - - - - + + + + @@ -121423,9 +121302,9 @@ - - - + + + @@ -123200,19 +123079,19 @@ - - - - + + + + - - + + - - - + + + @@ -123351,10 +123230,10 @@ - - - - + + + + @@ -123481,8 +123360,8 @@ - - + + @@ -125376,8 +125255,8 @@ - - + + @@ -125630,8 +125509,8 @@ - - + + @@ -125667,9 +125546,9 @@ - - - + + + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index 23ab56e53ad8..b5b8c15eddbc 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -2666,6 +2666,7 @@ xa_find xa_find_after xa_get_mark + __xa_insert xa_load xa_set_mark xa_store From 23d664773fe7cfae6f2ee8fe37709d8b2ac0a55d Mon Sep 17 00:00:00 2001 From: Daeho Jeong Date: Mon, 20 Jun 2022 10:38:42 -0700 Subject: [PATCH 061/124] BACKPORT: f2fs: introduce memory mode Introduce memory mode to supports "normal" and "low" memory modes. "low" mode is to support low memory devices. Because of the nature of low memory devices, in this mode, f2fs will try to save memory sometimes by sacrificing performance. "normal" mode is the default mode and same as before. Bug: 232003054 Signed-off-by: Daeho Jeong Signed-off-by: Jaegeuk Kim (cherry picked from commit 60f60d1fd86a) Change-Id: I7cb719b18f0002d7af47f7a18e8ec2f4c534bdd9 --- Documentation/filesystems/f2fs.rst | 5 +++++ fs/f2fs/f2fs.h | 13 +++++++++++++ fs/f2fs/super.c | 24 ++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/Documentation/filesystems/f2fs.rst b/Documentation/filesystems/f2fs.rst index 5fda320354a6..b8cdd1fcb83e 100644 --- a/Documentation/filesystems/f2fs.rst +++ b/Documentation/filesystems/f2fs.rst @@ -342,6 +342,11 @@ discard_unit=%s Control discard unit, the argument can be "block", "segment" default, it is helpful for large sized SMR or ZNS devices to reduce memory cost by getting rid of fs metadata supports small discard. +memory=%s Control memory mode. This supports "normal" and "low" modes. + "low" mode is introduced to support low memory devices. + Because of the nature of low memory devices, in this mode, f2fs + will try to save memory sometimes by sacrificing performance. + "normal" mode is the default mode and same as before. ======================== ============================================================ Debugfs Entries diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 552ad16feeac..3c7c2f52b0d1 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -157,6 +157,7 @@ struct f2fs_mount_info { int fsync_mode; /* fsync policy */ int fs_mode; /* fs mode: LFS or ADAPTIVE */ int bggc_mode; /* bggc mode: off, on or sync */ + int memory_mode; /* memory mode */ int discard_unit; /* * discard command's offset/size should * be aligned to this unit: block, @@ -1367,6 +1368,13 @@ enum { DISCARD_UNIT_SECTION, /* basic discard unit is section */ }; +enum { + MEMORY_MODE_NORMAL, /* memory mode for normal devices */ + MEMORY_MODE_LOW, /* memory mode for low memry devices */ +}; + + + static inline int f2fs_test_bit(unsigned int nr, char *addr); static inline void f2fs_set_bit(unsigned int nr, char *addr); static inline void f2fs_clear_bit(unsigned int nr, char *addr); @@ -4423,6 +4431,11 @@ static inline bool f2fs_lfs_mode(struct f2fs_sb_info *sbi) return F2FS_OPTION(sbi).fs_mode == FS_MODE_LFS; } +static inline bool f2fs_low_mem_mode(struct f2fs_sb_info *sbi) +{ + return F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_LOW; +} + static inline bool f2fs_may_compress(struct inode *inode) { if (IS_SWAPFILE(inode) || f2fs_is_pinned_file(inode) || diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 48daa85746f8..4648cb843686 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -160,6 +160,7 @@ enum { Opt_gc_merge, Opt_nogc_merge, Opt_discard_unit, + Opt_memory_mode, Opt_err, }; @@ -237,6 +238,7 @@ static match_table_t f2fs_tokens = { {Opt_gc_merge, "gc_merge"}, {Opt_nogc_merge, "nogc_merge"}, {Opt_discard_unit, "discard_unit=%s"}, + {Opt_memory_mode, "memory=%s"}, {Opt_err, NULL}, }; @@ -1246,6 +1248,22 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) } kfree(name); break; + case Opt_memory_mode: + name = match_strdup(&args[0]); + if (!name) + return -ENOMEM; + if (!strcmp(name, "normal")) { + F2FS_OPTION(sbi).memory_mode = + MEMORY_MODE_NORMAL; + } else if (!strcmp(name, "low")) { + F2FS_OPTION(sbi).memory_mode = + MEMORY_MODE_LOW; + } else { + kfree(name); + return -EINVAL; + } + kfree(name); + break; default: f2fs_err(sbi, "Unrecognized mount option \"%s\" or missing value", p); @@ -2028,6 +2046,11 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root) else if (F2FS_OPTION(sbi).discard_unit == DISCARD_UNIT_SECTION) seq_printf(seq, ",discard_unit=%s", "section"); + if (F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_NORMAL) + seq_printf(seq, ",memory=%s", "normal"); + else if (F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_LOW) + seq_printf(seq, ",memory=%s", "low"); + return 0; } @@ -2050,6 +2073,7 @@ static void default_options(struct f2fs_sb_info *sbi) F2FS_OPTION(sbi).compress_ext_cnt = 0; F2FS_OPTION(sbi).compress_mode = COMPR_MODE_FS; F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON; + F2FS_OPTION(sbi).memory_mode = MEMORY_MODE_NORMAL; sbi->sb->s_flags &= ~SB_INLINECRYPT; From 8ecc3b8d53b19d99e4fdb94b25aadecc9a8d3ecd Mon Sep 17 00:00:00 2001 From: Daeho Jeong Date: Tue, 2 Aug 2022 12:24:37 -0700 Subject: [PATCH 062/124] BACKPORT: f2fs: handle decompress only post processing in softirq Now decompression is being handled in workqueue and it makes read I/O latency non-deterministic, because of the non-deterministic scheduling nature of workqueues. So, I made it handled in softirq context only if possible, not in low memory devices, since this modification will maintain decompresion related memory a little longer. Bug: 232003054 Signed-off-by: Daeho Jeong Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Change-Id: I1a7c642e05c2f8544d475039b733403181de641e (cherry picked from commit 9ef8cd45d7a9) --- fs/f2fs/compress.c | 203 ++++++++++++++++++++++++++++++--------------- fs/f2fs/data.c | 52 ++++++++---- fs/f2fs/f2fs.h | 17 ++-- 3 files changed, 179 insertions(+), 93 deletions(-) diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index e98a0ef71941..1e76c80a3eeb 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -728,14 +728,19 @@ out: return ret; } -void f2fs_decompress_cluster(struct decompress_io_ctx *dic) +static int f2fs_prepare_decomp_mem(struct decompress_io_ctx *dic, + bool pre_alloc); +static void f2fs_release_decomp_mem(struct decompress_io_ctx *dic, + bool bypass_destroy_callback, bool pre_alloc); + +void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task) { struct f2fs_sb_info *sbi = F2FS_I_SB(dic->inode); struct f2fs_inode_info *fi = F2FS_I(dic->inode); const struct f2fs_compress_ops *cops = f2fs_cops[fi->i_compress_algorithm]; + bool bypass_callback = false; int ret; - int i; trace_f2fs_decompress_pages_start(dic->inode, dic->cluster_idx, dic->cluster_size, fi->i_compress_algorithm); @@ -745,41 +750,10 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic) goto out_end_io; } - dic->tpages = page_array_alloc(dic->inode, dic->cluster_size); - if (!dic->tpages) { - ret = -ENOMEM; - goto out_end_io; - } - - for (i = 0; i < dic->cluster_size; i++) { - if (dic->rpages[i]) { - dic->tpages[i] = dic->rpages[i]; - continue; - } - - dic->tpages[i] = f2fs_compress_alloc_page(); - if (!dic->tpages[i]) { - ret = -ENOMEM; - goto out_end_io; - } - } - - if (cops->init_decompress_ctx) { - ret = cops->init_decompress_ctx(dic); - if (ret) - goto out_end_io; - } - - dic->rbuf = f2fs_vmap(dic->tpages, dic->cluster_size); - if (!dic->rbuf) { - ret = -ENOMEM; - goto out_destroy_decompress_ctx; - } - - dic->cbuf = f2fs_vmap(dic->cpages, dic->nr_cpages); - if (!dic->cbuf) { - ret = -ENOMEM; - goto out_vunmap_rbuf; + ret = f2fs_prepare_decomp_mem(dic, false); + if (ret) { + bypass_callback = true; + goto out_release; } dic->clen = le32_to_cpu(dic->cbuf->clen); @@ -787,7 +761,7 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic) if (dic->clen > PAGE_SIZE * dic->nr_cpages - COMPRESS_HEADER_SIZE) { ret = -EFSCORRUPTED; - goto out_vunmap_cbuf; + goto out_release; } ret = cops->decompress_pages(dic); @@ -808,17 +782,13 @@ void f2fs_decompress_cluster(struct decompress_io_ctx *dic) } } -out_vunmap_cbuf: - vm_unmap_ram(dic->cbuf, dic->nr_cpages); -out_vunmap_rbuf: - vm_unmap_ram(dic->rbuf, dic->cluster_size); -out_destroy_decompress_ctx: - if (cops->destroy_decompress_ctx) - cops->destroy_decompress_ctx(dic); +out_release: + f2fs_release_decomp_mem(dic, bypass_callback, false); + out_end_io: trace_f2fs_decompress_pages_end(dic->inode, dic->cluster_idx, dic->clen, ret); - f2fs_decompress_end_io(dic, ret); + f2fs_decompress_end_io(dic, ret, in_task); } /* @@ -828,7 +798,7 @@ out_end_io: * (or in the case of a failure, cleans up without actually decompressing). */ void f2fs_end_read_compressed_page(struct page *page, bool failed, - block_t blkaddr) + block_t blkaddr, bool in_task) { struct decompress_io_ctx *dic = (struct decompress_io_ctx *)page_private(page); @@ -838,12 +808,12 @@ void f2fs_end_read_compressed_page(struct page *page, bool failed, if (failed) WRITE_ONCE(dic->failed, true); - else if (blkaddr) + else if (blkaddr && in_task) f2fs_cache_compressed_page(sbi, page, dic->inode->i_ino, blkaddr); if (atomic_dec_and_test(&dic->remaining_pages)) - f2fs_decompress_cluster(dic); + f2fs_decompress_cluster(dic, in_task); } static bool is_page_in_cluster(struct compress_ctx *cc, pgoff_t index) @@ -1551,16 +1521,85 @@ destroy_out: return err; } -static void f2fs_free_dic(struct decompress_io_ctx *dic); +static inline bool allow_memalloc_for_decomp(struct f2fs_sb_info *sbi, + bool pre_alloc) +{ + return pre_alloc ^ f2fs_low_mem_mode(sbi); +} + +static int f2fs_prepare_decomp_mem(struct decompress_io_ctx *dic, + bool pre_alloc) +{ + const struct f2fs_compress_ops *cops = + f2fs_cops[F2FS_I(dic->inode)->i_compress_algorithm]; + int i; + + if (!allow_memalloc_for_decomp(F2FS_I_SB(dic->inode), pre_alloc)) + return 0; + + dic->tpages = page_array_alloc(dic->inode, dic->cluster_size); + if (!dic->tpages) + return -ENOMEM; + + for (i = 0; i < dic->cluster_size; i++) { + if (dic->rpages[i]) { + dic->tpages[i] = dic->rpages[i]; + continue; + } + + dic->tpages[i] = f2fs_compress_alloc_page(); + if (!dic->tpages[i]) + return -ENOMEM; + } + + dic->rbuf = f2fs_vmap(dic->tpages, dic->cluster_size); + if (!dic->rbuf) + return -ENOMEM; + + dic->cbuf = f2fs_vmap(dic->cpages, dic->nr_cpages); + if (!dic->cbuf) + return -ENOMEM; + + if (cops->init_decompress_ctx) { + int ret = cops->init_decompress_ctx(dic); + + if (ret) + return ret; + } + + return 0; +} + +static void f2fs_release_decomp_mem(struct decompress_io_ctx *dic, + bool bypass_destroy_callback, bool pre_alloc) +{ + const struct f2fs_compress_ops *cops = + f2fs_cops[F2FS_I(dic->inode)->i_compress_algorithm]; + + if (!allow_memalloc_for_decomp(F2FS_I_SB(dic->inode), pre_alloc)) + return; + + if (!bypass_destroy_callback && cops->destroy_decompress_ctx) + cops->destroy_decompress_ctx(dic); + + if (dic->cbuf) + vm_unmap_ram(dic->cbuf, dic->nr_cpages); + + if (dic->rbuf) + vm_unmap_ram(dic->rbuf, dic->cluster_size); +} + +static void f2fs_free_dic(struct decompress_io_ctx *dic, + bool bypass_destroy_callback); struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc) { struct decompress_io_ctx *dic; pgoff_t start_idx = start_idx_of_cluster(cc); - int i; + struct f2fs_sb_info *sbi = F2FS_I_SB(cc->inode); + int i, ret; - dic = f2fs_kmem_cache_alloc(dic_entry_slab, GFP_F2FS_ZERO, - false, F2FS_I_SB(cc->inode)); + dic = f2fs_kmem_cache_alloc(dic_entry_slab, GFP_F2FS_ZERO, false, sbi); if (!dic) return ERR_PTR(-ENOMEM); @@ -1586,32 +1625,43 @@ struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc) dic->nr_rpages = cc->cluster_size; dic->cpages = page_array_alloc(dic->inode, dic->nr_cpages); - if (!dic->cpages) + if (!dic->cpages) { + ret = -ENOMEM; goto out_free; + } for (i = 0; i < dic->nr_cpages; i++) { struct page *page; page = f2fs_compress_alloc_page(); - if (!page) + if (!page) { + ret = -ENOMEM; goto out_free; + } f2fs_set_compressed_page(page, cc->inode, start_idx + i + 1, dic); dic->cpages[i] = page; } + ret = f2fs_prepare_decomp_mem(dic, true); + if (ret) + goto out_free; + return dic; out_free: - f2fs_free_dic(dic); - return ERR_PTR(-ENOMEM); + f2fs_free_dic(dic, true); + return ERR_PTR(ret); } -static void f2fs_free_dic(struct decompress_io_ctx *dic) +static void f2fs_free_dic(struct decompress_io_ctx *dic, + bool bypass_destroy_callback) { int i; + f2fs_release_decomp_mem(dic, bypass_destroy_callback, true); + if (dic->tpages) { for (i = 0; i < dic->cluster_size; i++) { if (dic->rpages[i]) @@ -1636,17 +1686,33 @@ static void f2fs_free_dic(struct decompress_io_ctx *dic) kmem_cache_free(dic_entry_slab, dic); } -static void f2fs_put_dic(struct decompress_io_ctx *dic) +static void f2fs_late_free_dic(struct work_struct *work) { - if (refcount_dec_and_test(&dic->refcnt)) - f2fs_free_dic(dic); + struct decompress_io_ctx *dic = + container_of(work, struct decompress_io_ctx, free_work); + + f2fs_free_dic(dic, false); +} + +static void f2fs_put_dic(struct decompress_io_ctx *dic, bool in_task) +{ + if (refcount_dec_and_test(&dic->refcnt)) { + if (in_task) { + f2fs_free_dic(dic, false); + } else { + INIT_WORK(&dic->free_work, f2fs_late_free_dic); + queue_work(F2FS_I_SB(dic->inode)->post_read_wq, + &dic->free_work); + } + } } /* * Update and unlock the cluster's pagecache pages, and release the reference to * the decompress_io_ctx that was being held for I/O completion. */ -static void __f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed) +static void __f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed, + bool in_task) { int i; @@ -1667,7 +1733,7 @@ static void __f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed) unlock_page(rpage); } - f2fs_put_dic(dic); + f2fs_put_dic(dic, in_task); } static void f2fs_verify_cluster(struct work_struct *work) @@ -1684,14 +1750,15 @@ static void f2fs_verify_cluster(struct work_struct *work) SetPageError(rpage); } - __f2fs_decompress_end_io(dic, false); + __f2fs_decompress_end_io(dic, false, true); } /* * This is called when a compressed cluster has been decompressed * (or failed to be read and/or decompressed). */ -void f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed) +void f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed, + bool in_task) { if (!failed && dic->need_verity) { /* @@ -1703,7 +1770,7 @@ void f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed) INIT_WORK(&dic->verity_work, f2fs_verify_cluster); fsverity_enqueue_verify_work(&dic->verity_work); } else { - __f2fs_decompress_end_io(dic, failed); + __f2fs_decompress_end_io(dic, failed, in_task); } } @@ -1712,12 +1779,12 @@ void f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed) * * This is called when the page is no longer needed and can be freed. */ -void f2fs_put_page_dic(struct page *page) +void f2fs_put_page_dic(struct page *page, bool in_task) { struct decompress_io_ctx *dic = (struct decompress_io_ctx *)page_private(page); - f2fs_put_dic(dic); + f2fs_put_dic(dic, in_task); } /* diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 46a4322401b1..103e7038356f 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -122,7 +122,7 @@ struct bio_post_read_ctx { block_t fs_blkaddr; }; -static void f2fs_finish_read_bio(struct bio *bio) +static void f2fs_finish_read_bio(struct bio *bio, bool in_task) { struct bio_vec *bv; struct bvec_iter_all iter_all; @@ -136,8 +136,9 @@ static void f2fs_finish_read_bio(struct bio *bio) if (f2fs_is_compressed_page(page)) { if (bio->bi_status) - f2fs_end_read_compressed_page(page, true, 0); - f2fs_put_page_dic(page); + f2fs_end_read_compressed_page(page, true, 0, + in_task); + f2fs_put_page_dic(page, in_task); continue; } @@ -194,7 +195,7 @@ static void f2fs_verify_bio(struct work_struct *work) fsverity_verify_bio(bio); } - f2fs_finish_read_bio(bio); + f2fs_finish_read_bio(bio, true); } /* @@ -206,7 +207,7 @@ static void f2fs_verify_bio(struct work_struct *work) * can involve reading verity metadata pages from the file, and these verity * metadata pages may be encrypted and/or compressed. */ -static void f2fs_verify_and_finish_bio(struct bio *bio) +static void f2fs_verify_and_finish_bio(struct bio *bio, bool in_task) { struct bio_post_read_ctx *ctx = bio->bi_private; @@ -214,7 +215,7 @@ static void f2fs_verify_and_finish_bio(struct bio *bio) INIT_WORK(&ctx->work, f2fs_verify_bio); fsverity_enqueue_verify_work(&ctx->work); } else { - f2fs_finish_read_bio(bio); + f2fs_finish_read_bio(bio, in_task); } } @@ -227,7 +228,8 @@ static void f2fs_verify_and_finish_bio(struct bio *bio) * that the bio includes at least one compressed page. The actual decompression * is done on a per-cluster basis, not a per-bio basis. */ -static void f2fs_handle_step_decompress(struct bio_post_read_ctx *ctx) +static void f2fs_handle_step_decompress(struct bio_post_read_ctx *ctx, + bool in_task) { struct bio_vec *bv; struct bvec_iter_all iter_all; @@ -240,7 +242,7 @@ static void f2fs_handle_step_decompress(struct bio_post_read_ctx *ctx) /* PG_error was set if decryption failed. */ if (f2fs_is_compressed_page(page)) f2fs_end_read_compressed_page(page, PageError(page), - blkaddr); + blkaddr, in_task); else all_compressed = false; @@ -265,15 +267,16 @@ static void f2fs_post_read_work(struct work_struct *work) fscrypt_decrypt_bio(ctx->bio); if (ctx->enabled_steps & STEP_DECOMPRESS) - f2fs_handle_step_decompress(ctx); + f2fs_handle_step_decompress(ctx, true); - f2fs_verify_and_finish_bio(ctx->bio); + f2fs_verify_and_finish_bio(ctx->bio, true); } static void f2fs_read_end_io(struct bio *bio) { struct f2fs_sb_info *sbi = F2FS_P_SB(bio_first_page_all(bio)); struct bio_post_read_ctx *ctx; + bool intask = in_task(); iostat_update_and_unbind_ctx(bio, 0); ctx = bio->bi_private; @@ -284,16 +287,29 @@ static void f2fs_read_end_io(struct bio *bio) } if (bio->bi_status) { - f2fs_finish_read_bio(bio); + f2fs_finish_read_bio(bio, intask); return; } - if (ctx && (ctx->enabled_steps & (STEP_DECRYPT | STEP_DECOMPRESS))) { - INIT_WORK(&ctx->work, f2fs_post_read_work); - queue_work(ctx->sbi->post_read_wq, &ctx->work); - } else { - f2fs_verify_and_finish_bio(bio); + if (ctx) { + unsigned int enabled_steps = ctx->enabled_steps & + (STEP_DECRYPT | STEP_DECOMPRESS); + + /* + * If we have only decompression step between decompression and + * decrypt, we don't need post processing for this. + */ + if (enabled_steps == STEP_DECOMPRESS && + !f2fs_low_mem_mode(sbi)) { + f2fs_handle_step_decompress(ctx, intask); + } else if (enabled_steps) { + INIT_WORK(&ctx->work, f2fs_post_read_work); + queue_work(ctx->sbi->post_read_wq, &ctx->work); + return; + } } + + f2fs_verify_and_finish_bio(bio, intask); } static void f2fs_write_end_io(struct bio *bio) @@ -2228,7 +2244,7 @@ skip_reading_dnode: if (f2fs_load_compressed_page(sbi, page, blkaddr)) { if (atomic_dec_and_test(&dic->remaining_pages)) - f2fs_decompress_cluster(dic); + f2fs_decompress_cluster(dic, true); continue; } @@ -2246,7 +2262,7 @@ submit_and_realloc: page->index, for_write); if (IS_ERR(bio)) { ret = PTR_ERR(bio); - f2fs_decompress_end_io(dic, ret); + f2fs_decompress_end_io(dic, ret, true); f2fs_put_dnode(&dn); *bio_ret = NULL; return ret; diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 3c7c2f52b0d1..d2d0a6e17ae3 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1595,6 +1595,7 @@ struct decompress_io_ctx { void *private; /* payload buffer for specified decompression algorithm */ void *private2; /* extra payload buffer */ struct work_struct verity_work; /* work to verify the decompressed pages */ + struct work_struct free_work; /* work for late free this structure itself */ }; #define NULL_CLUSTER ((unsigned int)(~0)) @@ -4185,9 +4186,9 @@ void f2fs_compress_write_end_io(struct bio *bio, struct page *page); bool f2fs_is_compress_backend_ready(struct inode *inode); int f2fs_init_compress_mempool(void); void f2fs_destroy_compress_mempool(void); -void f2fs_decompress_cluster(struct decompress_io_ctx *dic); +void f2fs_decompress_cluster(struct decompress_io_ctx *dic, bool in_task); void f2fs_end_read_compressed_page(struct page *page, bool failed, - block_t blkaddr); + block_t blkaddr, bool in_task); bool f2fs_cluster_is_empty(struct compress_ctx *cc); bool f2fs_cluster_can_merge_page(struct compress_ctx *cc, pgoff_t index); bool f2fs_all_cluster_page_loaded(struct compress_ctx *cc, struct pagevec *pvec, @@ -4206,8 +4207,9 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret, unsigned nr_pages, sector_t *last_block_in_bio, bool is_readahead, bool for_write); struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc); -void f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed); -void f2fs_put_page_dic(struct page *page); +void f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed, + bool in_task); +void f2fs_put_page_dic(struct page *page, bool in_task); unsigned int f2fs_cluster_blocks_are_contiguous(struct dnode_of_data *dn); int f2fs_init_compress_ctx(struct compress_ctx *cc); void f2fs_destroy_compress_ctx(struct compress_ctx *cc, bool reuse); @@ -4253,13 +4255,14 @@ static inline struct page *f2fs_compress_control_page(struct page *page) } static inline int f2fs_init_compress_mempool(void) { return 0; } static inline void f2fs_destroy_compress_mempool(void) { } -static inline void f2fs_decompress_cluster(struct decompress_io_ctx *dic) { } +static inline void f2fs_decompress_cluster(struct decompress_io_ctx *dic, + bool in_task) { } static inline void f2fs_end_read_compressed_page(struct page *page, - bool failed, block_t blkaddr) + bool failed, block_t blkaddr, bool in_task) { WARN_ON_ONCE(1); } -static inline void f2fs_put_page_dic(struct page *page) +static inline void f2fs_put_page_dic(struct page *page, bool in_task) { WARN_ON_ONCE(1); } From 68f703b19f82076aba0c9a1a798b2d6b6537f1df Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Fri, 12 Aug 2022 22:49:50 -0700 Subject: [PATCH 063/124] FROMGIT: f2fs: fix wrong continue condition in GC We should decrease the frozen counter. Cc: stable@vger.kernel.org Fixes: 325163e9892b ("f2fs: add gc_urgent_high_remaining sysfs node") Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim (cherry picked from commit 605b0a778aa2599aa902ae639b8e9937c74b869b https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev) Change-Id: I892f215e778f7d89b9bbf3dfb292ed820944cf6b --- fs/f2fs/gc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 79dc38eacb19..e38beb82f61c 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -93,14 +93,10 @@ static int gc_thread_func(void *data) */ if (sbi->gc_mode == GC_URGENT_HIGH) { spin_lock(&sbi->gc_urgent_high_lock); - if (sbi->gc_urgent_high_limited) { - if (!sbi->gc_urgent_high_remaining) { - sbi->gc_urgent_high_limited = false; - spin_unlock(&sbi->gc_urgent_high_lock); - sbi->gc_mode = GC_NORMAL; - continue; - } - sbi->gc_urgent_high_remaining--; + if (sbi->gc_urgent_high_limited && + !sbi->gc_urgent_high_remaining--) { + sbi->gc_urgent_high_limited = false; + sbi->gc_mode = GC_NORMAL; } spin_unlock(&sbi->gc_urgent_high_lock); } From f18d40369c2afbe325dd06ba0a507499f6687f8a Mon Sep 17 00:00:00 2001 From: Chao Yu Date: Sat, 20 Aug 2022 11:06:00 +0800 Subject: [PATCH 064/124] FROMGIT: f2fs: remove gc_urgent_high_limited for cleanup Remove redundant sbi->gc_urgent_high_limited. Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim (cherry picked from commit 265576181b4afda8c60ae85261f55a8430419884 https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev) Change-Id: Id92efe0343922c0b0fc279332ec102f1d8de8ecc --- fs/f2fs/f2fs.h | 1 - fs/f2fs/gc.c | 8 ++++---- fs/f2fs/sysfs.c | 1 - 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index d2d0a6e17ae3..1c2b5bd44cf2 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1728,7 +1728,6 @@ struct f2fs_sb_info { unsigned int gc_mode; /* current GC state */ unsigned int next_victim_seg[2]; /* next segment in victim section */ spinlock_t gc_urgent_high_lock; - bool gc_urgent_high_limited; /* indicates having limited trial count */ unsigned int gc_urgent_high_remaining; /* remaining trial count for GC_URGENT_HIGH */ /* for skip statistic */ diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index e38beb82f61c..3da5583f9dbb 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -93,10 +93,10 @@ static int gc_thread_func(void *data) */ if (sbi->gc_mode == GC_URGENT_HIGH) { spin_lock(&sbi->gc_urgent_high_lock); - if (sbi->gc_urgent_high_limited && - !sbi->gc_urgent_high_remaining--) { - sbi->gc_urgent_high_limited = false; - sbi->gc_mode = GC_NORMAL; + if (sbi->gc_urgent_high_remaining) { + sbi->gc_urgent_high_remaining--; + if (!sbi->gc_urgent_high_remaining) + sbi->gc_mode = GC_NORMAL; } spin_unlock(&sbi->gc_urgent_high_lock); } diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index f240f5593394..3ccbbee77cff 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -513,7 +513,6 @@ out: if (!strcmp(a->attr.name, "gc_urgent_high_remaining")) { spin_lock(&sbi->gc_urgent_high_lock); - sbi->gc_urgent_high_limited = t != 0; sbi->gc_urgent_high_remaining = t; spin_unlock(&sbi->gc_urgent_high_lock); From 7a046711777024d45eeb48f97b6157b1c8081a6c Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Fri, 19 Aug 2022 15:52:02 -0700 Subject: [PATCH 065/124] FROMGIT: f2fs: flush pending checkpoints when freezing super This avoids -EINVAL when trying to freeze f2fs. Bug: 242127451 Cc: stable@vger.kernel.org Signed-off-by: Jaegeuk Kim Change-Id: Id2939642e3b93b42cf1ca03831d6c5e4e54d57fd (cherry picked from commit a36fe7301268524ffa56ff8a9ad0edec6bd5b85a https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev) --- fs/f2fs/checkpoint.c | 24 ++++++++++++++++++------ fs/f2fs/f2fs.h | 1 + fs/f2fs/super.c | 5 ++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index d93db6d29704..9aae2e6cc981 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -1895,15 +1895,27 @@ int f2fs_start_ckpt_thread(struct f2fs_sb_info *sbi) void f2fs_stop_ckpt_thread(struct f2fs_sb_info *sbi) { struct ckpt_req_control *cprc = &sbi->cprc_info; + struct task_struct *ckpt_task; - if (cprc->f2fs_issue_ckpt) { - struct task_struct *ckpt_task = cprc->f2fs_issue_ckpt; + if (!cprc->f2fs_issue_ckpt) + return; - cprc->f2fs_issue_ckpt = NULL; - kthread_stop(ckpt_task); + ckpt_task = cprc->f2fs_issue_ckpt; + cprc->f2fs_issue_ckpt = NULL; + kthread_stop(ckpt_task); - flush_remained_ckpt_reqs(sbi, NULL); - } + f2fs_flush_ckpt_thread(sbi); +} + +void f2fs_flush_ckpt_thread(struct f2fs_sb_info *sbi) +{ + struct ckpt_req_control *cprc = &sbi->cprc_info; + + flush_remained_ckpt_reqs(sbi, NULL); + + /* Let's wait for the previous dispatched checkpoint. */ + while (atomic_read(&cprc->queued_ckpt)) + io_schedule_timeout(DEFAULT_IO_TIMEOUT); } void f2fs_init_ckpt_req_control(struct f2fs_sb_info *sbi) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 1c2b5bd44cf2..c5e7a34693b8 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3681,6 +3681,7 @@ static inline bool f2fs_need_rand_seg(struct f2fs_sb_info *sbi) * checkpoint.c */ void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io); +void f2fs_flush_ckpt_thread(struct f2fs_sb_info *sbi); struct page *f2fs_grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index); struct page *f2fs_get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index); struct page *f2fs_get_meta_page_retry(struct f2fs_sb_info *sbi, pgoff_t index); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 4648cb843686..22ec463155ff 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1689,9 +1689,8 @@ static int f2fs_freeze(struct super_block *sb) if (is_sbi_flag_set(F2FS_SB(sb), SBI_IS_DIRTY)) return -EINVAL; - /* ensure no checkpoint required */ - if (!llist_empty(&F2FS_SB(sb)->cprc_info.issue_list)) - return -EINVAL; + /* Let's flush checkpoints and stop the thread. */ + f2fs_flush_ckpt_thread(F2FS_SB(sb)); /* to avoid deadlock on f2fs_evict_inode->SB_FREEZE_FS */ set_sbi_flag(F2FS_SB(sb), SBI_IS_FREEZING); From 7af4b3ca302ba827f89c06ce837943e17f5213a6 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Thu, 18 Aug 2022 22:40:09 -0700 Subject: [PATCH 066/124] FROMGIT: f2fs: complete checkpoints during remount Otherwise, pending checkpoints can contribute a race condition to give a quota warning. - Thread - checkpoint thread add checkpoints to the list do_remount() down_write(&sb->s_umount); f2fs_remount() block_operations() down_read_trylock(&sb->s_umount) = 0 up_write(&sb->s_umount); f2fs_quota_sync() dquot_writeback_dquots() WARN_ON_ONCE(!rwsem_is_locked(&sb->s_umount)); Or, do_remount() down_write(&sb->s_umount); f2fs_remount() create a ckpt thread f2fs_enable_checkpoint() adds checkpoints wait for f2fs_sync_fs() trigger another pending checkpoint block_operations() down_read_trylock(&sb->s_umount) = 0 up_write(&sb->s_umount); f2fs_quota_sync() dquot_writeback_dquots() WARN_ON_ONCE(!rwsem_is_locked(&sb->s_umount)); Bug: 242127451 Bug: 215554521 Cc: stable@vger.kernel.org Signed-off-by: Jaegeuk Kim Change-Id: I85926fe14245058e48bac5699a7b760d7700c653 (cherry picked from commit d14393c5bff2f0c163e6bb384618300e30d19754 https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev) --- fs/f2fs/super.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 22ec463155ff..b07d90a7f199 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2193,6 +2193,9 @@ static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi) f2fs_up_write(&sbi->gc_lock); f2fs_sync_fs(sbi->sb, 1); + + /* Let's ensure there's no pending checkpoint anymore */ + f2fs_flush_ckpt_thread(sbi); } static int f2fs_remount(struct super_block *sb, int *flags, char *data) @@ -2359,6 +2362,9 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) f2fs_stop_ckpt_thread(sbi); need_restart_ckpt = true; } else { + /* Flush if the prevous checkpoint, if exists. */ + f2fs_flush_ckpt_thread(sbi); + err = f2fs_start_ckpt_thread(sbi); if (err) { f2fs_err(sbi, From 220890882465d2e6ed353fbe5a2d4a2b99c4c980 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Tue, 23 Aug 2022 10:18:42 -0700 Subject: [PATCH 067/124] FROMGIT: f2fs: increase the limit for reserve_root This patch increases the threshold that limits the reserved root space from 0.2% to 12.5% by using simple shift operation. Typically Android sets 128MB, but if the storage capacity is 32GB, 0.2% which is around 64MB becomes too small. Let's relax it. Bug: 243493735 Cc: stable@vger.kernel.org Reported-by: Aran Dalton Signed-off-by: Jaegeuk Kim Change-Id: Ia76ae8f9dd1c7a5f123a561f081bf5a4a29ac186 (cherry picked from commit cf42f1d7ab33ea2637f3c6b786a76302f719726b https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev) --- fs/f2fs/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index b07d90a7f199..bdea4ec6cebe 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -309,10 +309,10 @@ static void f2fs_destroy_casefold_cache(void) { } static inline void limit_reserve_root(struct f2fs_sb_info *sbi) { - block_t limit = min((sbi->user_block_count << 1) / 1000, + block_t limit = min((sbi->user_block_count >> 3), sbi->user_block_count - sbi->reserved_blocks); - /* limit is 0.2% */ + /* limit is 12.5% */ if (test_opt(sbi, RESERVE_ROOT) && F2FS_OPTION(sbi).root_reserved_blocks > limit) { F2FS_OPTION(sbi).root_reserved_blocks = limit; From 5c6d73ac2c042dabdc3d9d67b98212b1eb5204f8 Mon Sep 17 00:00:00 2001 From: Konstantin Vyshetsky Date: Wed, 20 Apr 2022 17:24:29 -0700 Subject: [PATCH 068/124] BACKPORT: scsi: ufs: core: Increase fDeviceInit poll frequency UFS devices are expected to clear fDeviceInit flag in single digit milliseconds. Current values of 5 to 10 millisecond sleep add to increased latency during the initialization and resume path. This CL lowers the sleep range to 500 to 1000 microseconds. Bug: 236993021 Link: https://lore.kernel.org/r/20220421002429.3136933-1-bvanassche@acm.org Acked-by: Avri Altman Signed-off-by: Konstantin Vyshetsky Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen (cherry picked from commit a4e6496fca3f32e997e8a3b5c44e2a1ae09d018e) Change-Id: I3a9a01853e89ea73ff5e355007db4730fa853ea0 --- drivers/scsi/ufs/ufshcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index b9df2db533d2..45ee1adefc08 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4553,7 +4553,7 @@ static int ufshcd_complete_dev_init(struct ufs_hba *hba) QUERY_FLAG_IDN_FDEVICEINIT, 0, &flag_res); if (!flag_res) break; - usleep_range(5000, 10000); + usleep_range(500, 1000); } while (ktime_before(ktime_get(), timeout)); if (err) { From 3d35c6b91d6d370ca5166efa990588ee43267721 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 11 Aug 2022 16:43:49 -0700 Subject: [PATCH 069/124] UPSTREAM: scsi: ufs: core: Reduce the power mode change timeout The current power mode change timeout (180 s) is so large that it can cause a watchdog timer to fire. Reduce the power mode change timeout to 10 seconds. Link: https://lore.kernel.org/r/20220811234401.1957911-1-bvanassche@acm.org Reviewed-by: Stanley Chu Signed-off-by: Bart Van Assche Signed-off-by: Martin K. Petersen (cherry picked from commit 8f2c96420c6ec3dcb18c8be923e24c6feaa5ccf6) Change-Id: I89a7f925812b6e1c4ca158bd7b22a41323557ec5 Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 45ee1adefc08..9ee325116902 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -8826,6 +8826,8 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, struct scsi_device *sdp; unsigned long flags; int ret, retries; + unsigned long deadline; + int32_t remaining; spin_lock_irqsave(hba->host->host_lock, flags); sdp = hba->sdev_ufs_device; @@ -8858,9 +8860,14 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, * callbacks hence set the RQF_PM flag so that it doesn't resume the * already suspended childs. */ + deadline = jiffies + 10 * HZ; for (retries = 3; retries > 0; --retries) { + ret = -ETIMEDOUT; + remaining = deadline - jiffies; + if (remaining <= 0) + break; ret = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr, - START_STOP_TIMEOUT, 0, 0, RQF_PM, NULL); + remaining / HZ, 0, 0, RQF_PM, NULL); if (!scsi_status_is_check_condition(ret) || !scsi_sense_valid(&sshdr) || sshdr.sense_key != UNIT_ATTENTION) From d451b4eee2469f8bafc6eb8db02728eacd851084 Mon Sep 17 00:00:00 2001 From: John Scheible Date: Thu, 8 Sep 2022 18:00:01 -0700 Subject: [PATCH 070/124] ANDROID: Update the ABI representation Add iommu_dma_enable_best_fit_algo symbol. 1 symbol(s) added 'int iommu_dma_enable_best_fit_algo(struct device *)' Bug: 245799843 Signed-off-by: John Scheible Change-Id: I5cc4d870556b62e43a3a5f717d23a512a138cb17 --- android/abi_gki_aarch64.xml | 822 +++++++++++++++++++------------- android/abi_gki_aarch64_generic | 1 + 2 files changed, 479 insertions(+), 344 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index 16cecdb1603b..fa125a3765ea 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -1910,6 +1910,7 @@ + @@ -4069,6 +4070,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4824,7 +4890,7 @@ - + @@ -7555,7 +7621,7 @@ - + @@ -8664,7 +8730,7 @@ - + @@ -10071,6 +10137,9 @@ + + + @@ -11559,7 +11628,7 @@ - + @@ -14437,7 +14506,7 @@ - + @@ -20899,7 +20968,7 @@ - + @@ -23266,7 +23335,7 @@ - + @@ -25220,7 +25289,7 @@ - + @@ -32661,7 +32730,7 @@ - + @@ -35404,7 +35473,7 @@ - + @@ -36696,7 +36765,17 @@ - + + + + + + + + + + + @@ -41293,7 +41372,7 @@ - + @@ -42754,6 +42833,7 @@ + @@ -46040,6 +46120,14 @@ + + + + + + + + @@ -46335,13 +46423,13 @@ - + - + - + @@ -46350,7 +46438,7 @@ - + @@ -50322,7 +50410,7 @@ - + @@ -52835,6 +52923,7 @@ + @@ -56140,61 +56229,61 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -59606,7 +59695,7 @@ - + @@ -59688,7 +59777,7 @@ - + @@ -63451,7 +63540,7 @@ - + @@ -64154,7 +64243,7 @@ - + @@ -65006,25 +65095,25 @@ - + - + - + - + - + - + - + @@ -67570,7 +67659,7 @@ - + @@ -67597,7 +67686,7 @@ - + @@ -67608,7 +67697,7 @@ - + @@ -68320,7 +68409,7 @@ - + @@ -68333,7 +68422,7 @@ - + @@ -68363,7 +68452,7 @@ - + @@ -68406,7 +68495,7 @@ - + @@ -68433,7 +68522,7 @@ - + @@ -68441,7 +68530,7 @@ - + @@ -68449,7 +68538,7 @@ - + @@ -68462,25 +68551,25 @@ - + - + - + - + - + - + - + @@ -68513,7 +68602,7 @@ - + @@ -68524,7 +68613,7 @@ - + @@ -68537,7 +68626,7 @@ - + @@ -68583,7 +68672,7 @@ - + @@ -68608,15 +68697,15 @@ - + - + - + @@ -68624,7 +68713,7 @@ - + @@ -68710,7 +68799,7 @@ - + @@ -68718,21 +68807,21 @@ - + - + - + - + - + @@ -68769,10 +68858,10 @@ - + - + @@ -68788,7 +68877,7 @@ - + @@ -68815,10 +68904,10 @@ - + - + @@ -68862,7 +68951,7 @@ - + @@ -68875,7 +68964,7 @@ - + @@ -68905,7 +68994,7 @@ - + @@ -68918,7 +69007,7 @@ - + @@ -68954,13 +69043,13 @@ - + - + - + @@ -69021,7 +69110,7 @@ - + @@ -69032,13 +69121,13 @@ - + - + @@ -69046,7 +69135,7 @@ - + @@ -69062,7 +69151,7 @@ - + @@ -69166,7 +69255,7 @@ - + @@ -69315,10 +69404,10 @@ - + - + @@ -69334,27 +69423,27 @@ - + - + - + - + - + - + - + @@ -69370,22 +69459,22 @@ - + - + - + - + - + - + @@ -69409,36 +69498,36 @@ - + - + - + - + - + - + - + - + - + - + @@ -69449,7 +69538,7 @@ - + @@ -69473,96 +69562,96 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -69575,13 +69664,13 @@ - + - + - + @@ -69715,7 +69804,7 @@ - + @@ -74144,7 +74233,7 @@ - + @@ -74191,6 +74280,7 @@ + @@ -82746,7 +82836,7 @@ - + @@ -84148,7 +84238,7 @@ - + @@ -84228,22 +84318,22 @@ - + - + - + - + - + - + @@ -89821,7 +89911,7 @@ - + @@ -90218,6 +90308,9 @@ + + + @@ -93617,7 +93710,7 @@ - + @@ -94655,7 +94748,39 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -94663,7 +94788,7 @@ - + @@ -94671,7 +94796,7 @@ - + @@ -94682,7 +94807,7 @@ - + @@ -94690,7 +94815,7 @@ - + @@ -94707,7 +94832,7 @@ - + @@ -94715,7 +94840,7 @@ - + @@ -94723,7 +94848,7 @@ - + @@ -94737,7 +94862,7 @@ - + @@ -94751,12 +94876,12 @@ - + - + @@ -94770,7 +94895,7 @@ - + @@ -94787,7 +94912,7 @@ - + @@ -94798,7 +94923,7 @@ - + @@ -94815,7 +94940,7 @@ - + @@ -94823,7 +94948,7 @@ - + @@ -94834,7 +94959,7 @@ - + @@ -94845,7 +94970,7 @@ - + @@ -94853,7 +94978,7 @@ - + @@ -95029,13 +95154,13 @@ - + - + @@ -95046,7 +95171,7 @@ - + @@ -95057,7 +95182,7 @@ - + @@ -95065,7 +95190,7 @@ - + @@ -95073,7 +95198,7 @@ - + @@ -95087,7 +95212,7 @@ - + @@ -95095,7 +95220,7 @@ - + @@ -95103,7 +95228,7 @@ - + @@ -95111,7 +95236,7 @@ - + @@ -95119,7 +95244,7 @@ - + @@ -95130,7 +95255,7 @@ - + @@ -95138,7 +95263,7 @@ - + @@ -95152,7 +95277,7 @@ - + @@ -95163,7 +95288,7 @@ - + @@ -95171,7 +95296,7 @@ - + @@ -95179,7 +95304,7 @@ - + @@ -95187,7 +95312,7 @@ - + @@ -95207,7 +95332,7 @@ - + @@ -95221,7 +95346,7 @@ - + @@ -95238,7 +95363,7 @@ - + @@ -95252,7 +95377,7 @@ - + @@ -95266,7 +95391,7 @@ - + @@ -95274,7 +95399,7 @@ - + @@ -95288,7 +95413,7 @@ - + @@ -95299,7 +95424,7 @@ - + @@ -95316,7 +95441,7 @@ - + @@ -95324,7 +95449,7 @@ - + @@ -95332,7 +95457,7 @@ - + @@ -95343,7 +95468,7 @@ - + @@ -95354,7 +95479,7 @@ - + @@ -95362,7 +95487,7 @@ - + @@ -95379,7 +95504,7 @@ - + @@ -95402,7 +95527,7 @@ - + @@ -95410,7 +95535,7 @@ - + @@ -95421,7 +95546,7 @@ - + @@ -95435,18 +95560,18 @@ - + - + - + @@ -95472,7 +95597,7 @@ - + @@ -95483,7 +95608,7 @@ - + @@ -95491,7 +95616,7 @@ - + @@ -95511,7 +95636,7 @@ - + @@ -95522,7 +95647,7 @@ - + @@ -95533,12 +95658,12 @@ - + - + @@ -95546,7 +95671,7 @@ - + @@ -95554,7 +95679,7 @@ - + @@ -95562,7 +95687,7 @@ - + @@ -95570,12 +95695,12 @@ - + - + @@ -95583,7 +95708,7 @@ - + @@ -95591,7 +95716,7 @@ - + @@ -95599,7 +95724,7 @@ - + @@ -95607,7 +95732,7 @@ - + @@ -95615,7 +95740,7 @@ - + @@ -95623,7 +95748,7 @@ - + @@ -95664,7 +95789,7 @@ - + @@ -95678,7 +95803,7 @@ - + @@ -95704,7 +95829,7 @@ - + @@ -95769,7 +95894,7 @@ - + @@ -95780,7 +95905,7 @@ - + @@ -95797,7 +95922,7 @@ - + @@ -95841,7 +95966,7 @@ - + @@ -95852,7 +95977,7 @@ - + @@ -95863,7 +95988,7 @@ - + @@ -95883,7 +96008,7 @@ - + @@ -95891,7 +96016,7 @@ - + @@ -95908,7 +96033,7 @@ - + @@ -95937,7 +96062,7 @@ - + @@ -95954,7 +96079,7 @@ - + @@ -95968,17 +96093,17 @@ - + - + - + @@ -95986,7 +96111,7 @@ - + @@ -95997,7 +96122,7 @@ - + @@ -96005,7 +96130,7 @@ - + @@ -96046,7 +96171,7 @@ - + @@ -96054,7 +96179,7 @@ - + @@ -96062,7 +96187,7 @@ - + @@ -96076,7 +96201,7 @@ - + @@ -96096,7 +96221,7 @@ - + @@ -96104,7 +96229,7 @@ - + @@ -96112,7 +96237,7 @@ - + @@ -96120,12 +96245,12 @@ - + - + @@ -96133,7 +96258,7 @@ - + @@ -96144,7 +96269,7 @@ - + @@ -96152,18 +96277,18 @@ - + - + - - + + @@ -96177,12 +96302,12 @@ - + - + @@ -96190,12 +96315,12 @@ - + - + @@ -96203,12 +96328,12 @@ - + - + @@ -96225,7 +96350,7 @@ - + @@ -96233,7 +96358,7 @@ - + @@ -96241,12 +96366,12 @@ - + - + @@ -96254,7 +96379,7 @@ - + @@ -96262,7 +96387,7 @@ - + @@ -96279,12 +96404,12 @@ - + - + @@ -96310,7 +96435,7 @@ - + @@ -96321,7 +96446,7 @@ - + @@ -96341,7 +96466,7 @@ - + @@ -96364,7 +96489,7 @@ - + @@ -96399,7 +96524,7 @@ - + @@ -96410,7 +96535,7 @@ - + @@ -96424,12 +96549,12 @@ - + - + @@ -96440,7 +96565,7 @@ - + @@ -96454,7 +96579,7 @@ - + @@ -96465,7 +96590,7 @@ - + @@ -96479,7 +96604,7 @@ - + @@ -96493,12 +96618,12 @@ - + - + @@ -96506,7 +96631,7 @@ - + @@ -96520,7 +96645,7 @@ - + @@ -96528,7 +96653,7 @@ - + @@ -96539,7 +96664,7 @@ - + @@ -96556,7 +96681,7 @@ - + @@ -96576,7 +96701,7 @@ - + @@ -96593,7 +96718,7 @@ - + @@ -96604,7 +96729,7 @@ - + @@ -96612,7 +96737,7 @@ - + @@ -96620,7 +96745,7 @@ - + @@ -96628,7 +96753,7 @@ - + @@ -96642,7 +96767,7 @@ - + @@ -96650,7 +96775,7 @@ - + @@ -96661,7 +96786,7 @@ - + @@ -96678,7 +96803,7 @@ - + @@ -96704,7 +96829,7 @@ - + @@ -96715,7 +96840,7 @@ - + @@ -96726,7 +96851,7 @@ - + @@ -97115,6 +97240,11 @@ + + + + + @@ -97453,7 +97583,7 @@ - + @@ -101404,7 +101534,7 @@ - + @@ -104119,7 +104249,7 @@ - + @@ -105417,7 +105547,7 @@ - + @@ -116292,6 +116422,10 @@ + + + + @@ -123616,36 +123750,36 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index b5b8c15eddbc..fbfc15968c6f 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -1092,6 +1092,7 @@ iommu_device_sysfs_remove iommu_device_unlink iommu_device_unregister + iommu_dma_enable_best_fit_algo iommu_domain_alloc iommu_domain_free iommu_fwspec_add_ids From 66047fb43166be89e8116444a948dd29f41fd562 Mon Sep 17 00:00:00 2001 From: Jack Diver Date: Fri, 9 Sep 2022 10:09:28 +0000 Subject: [PATCH 071/124] ANDROID: Update the ABI representation 1 symbol(s) added 'void __bitmap_xor(unsigned long int *, const unsigned long int *, const unsigned long int *, unsigned int)' Bug: 228779790 Signed-off-by: Jack Diver Change-Id: Ia7622941d313214eaf1aaf26aba64e0e149fa7ca --- android/abi_gki_aarch64.xml | 8 ++++++++ android/abi_gki_aarch64_generic | 1 + 2 files changed, 9 insertions(+) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index fa125a3765ea..ac5b15015083 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -23,6 +23,7 @@ + @@ -106038,6 +106039,13 @@ + + + + + + + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index fbfc15968c6f..966896aa05e3 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -78,6 +78,7 @@ __bitmap_set bitmap_to_arr32 __bitmap_weight + __bitmap_xor blk_abort_request blk_alloc_queue blk_check_plugged From aff23090349989a7aa39026fac2e27d5634cf2d4 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 19 Jul 2022 11:09:01 -0700 Subject: [PATCH 072/124] BACKPORT: watchqueue: make sure to serialize 'wqueue->defunct' properly commit 353f7988dd8413c47718f7ca79c030b6fb62cfe5 upstream. When the pipe is closed, we mark the associated watchqueue defunct by calling watch_queue_clear(). However, while that is protected by the watchqueue lock, new watchqueue entries aren't actually added under that lock at all: they use the pipe->rd_wait.lock instead, and looking up that pipe happens without any locking. The watchqueue code uses the RCU read-side section to make sure that the wqueue entry itself hasn't disappeared, but that does not protect the pipe_info in any way. So make sure to actually hold the wqueue lock when posting watch events, properly serializing against the pipe being torn down. Bug: 235277737 Reported-by: Noam Rathaus Cc: Greg KH Cc: David Howells Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Change-Id: I42b0d56021be1d8950c3642ae0acc5cdccadb394 --- kernel/watch_queue.c | 53 +++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c index e3f144d96026..0d9f302a1bbe 100644 --- a/kernel/watch_queue.c +++ b/kernel/watch_queue.c @@ -34,6 +34,27 @@ MODULE_LICENSE("GPL"); #define WATCH_QUEUE_NOTE_SIZE 128 #define WATCH_QUEUE_NOTES_PER_PAGE (PAGE_SIZE / WATCH_QUEUE_NOTE_SIZE) +/* + * This must be called under the RCU read-lock, which makes + * sure that the wqueue still exists. It can then take the lock, + * and check that the wqueue hasn't been destroyed, which in + * turn makes sure that the notification pipe still exists. + */ +static inline bool lock_wqueue(struct watch_queue *wqueue) +{ + spin_lock_bh(&wqueue->lock); + if (unlikely(wqueue->defunct)) { + spin_unlock_bh(&wqueue->lock); + return false; + } + return true; +} + +static inline void unlock_wqueue(struct watch_queue *wqueue) +{ + spin_unlock_bh(&wqueue->lock); +} + static void watch_queue_pipe_buf_release(struct pipe_inode_info *pipe, struct pipe_buffer *buf) { @@ -69,6 +90,10 @@ static const struct pipe_buf_operations watch_queue_pipe_buf_ops = { /* * Post a notification to a watch queue. + * + * Must be called with the RCU lock for reading, and the + * watch_queue lock held, which guarantees that the pipe + * hasn't been released. */ static bool post_one_notification(struct watch_queue *wqueue, struct watch_notification *n) @@ -85,9 +110,6 @@ static bool post_one_notification(struct watch_queue *wqueue, spin_lock_irq(&pipe->rd_wait.lock); - if (wqueue->defunct) - goto out; - mask = pipe->ring_size - 1; head = pipe->head; tail = pipe->tail; @@ -203,7 +225,10 @@ void __post_watch_notification(struct watch_list *wlist, if (security_post_notification(watch->cred, cred, n) < 0) continue; - post_one_notification(wqueue, n); + if (lock_wqueue(wqueue)) { + post_one_notification(wqueue, n); + unlock_wqueue(wqueue);; + } } rcu_read_unlock(); @@ -463,11 +488,12 @@ int add_watch_to_object(struct watch *watch, struct watch_list *wlist) return -EAGAIN; } - spin_lock_bh(&wqueue->lock); - kref_get(&wqueue->usage); - kref_get(&watch->usage); - hlist_add_head(&watch->queue_node, &wqueue->watches); - spin_unlock_bh(&wqueue->lock); + if (lock_wqueue(wqueue)) { + kref_get(&wqueue->usage); + kref_get(&watch->usage); + hlist_add_head(&watch->queue_node, &wqueue->watches); + unlock_wqueue(wqueue); + } hlist_add_head(&watch->list_node, &wlist->watchers); return 0; @@ -521,20 +547,15 @@ found: wqueue = rcu_dereference(watch->queue); - /* We don't need the watch list lock for the next bit as RCU is - * protecting *wqueue from deallocation. - */ - if (wqueue) { + if (lock_wqueue(wqueue)) { post_one_notification(wqueue, &n.watch); - spin_lock_bh(&wqueue->lock); - if (!hlist_unhashed(&watch->queue_node)) { hlist_del_init_rcu(&watch->queue_node); put_watch(watch); } - spin_unlock_bh(&wqueue->lock); + unlock_wqueue(wqueue); } if (wlist->release_watch) { From aa381a5c71469188ea57ff86f511341c66cdf285 Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Wed, 7 Sep 2022 13:25:46 -0700 Subject: [PATCH 073/124] ANDROID: remove CONFIG_TRACEPOINTS from hook definition headers Remove the obsolete use of CONFIG_TRACEPOINTS in hook definition header files. The !CONFIG_TRACEPOINTS case is correctly handled by the included trace header files. Bug: 233047575 Signed-off-by: Todd Kjos Change-Id: I957649bcfef375284f2885cf732ff2960c303837 --- include/trace/hooks/debug.h | 5 ----- include/trace/hooks/gpiolib.h | 4 ---- include/trace/hooks/iommu.h | 8 -------- include/trace/hooks/psi.h | 7 ------- 4 files changed, 24 deletions(-) diff --git a/include/trace/hooks/debug.h b/include/trace/hooks/debug.h index 892c60ac6f34..58ec198ceb6d 100644 --- a/include/trace/hooks/debug.h +++ b/include/trace/hooks/debug.h @@ -9,7 +9,6 @@ #include -#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS) #ifdef __GENKSYMS__ struct pt_regs; #else @@ -20,10 +19,6 @@ struct pt_regs; DECLARE_HOOK(android_vh_ipi_stop, TP_PROTO(struct pt_regs *regs), TP_ARGS(regs)) -#else -#define trace_android_vh_ipi_stop(regs) -#define trace_android_vh_ipi_stop_rcuidle(regs) -#endif #endif /* _TRACE_HOOK_DEBUG_H */ /* This part must be outside protection */ diff --git a/include/trace/hooks/gpiolib.h b/include/trace/hooks/gpiolib.h index 24cb3f54fb82..307fbaa2cae0 100644 --- a/include/trace/hooks/gpiolib.h +++ b/include/trace/hooks/gpiolib.h @@ -10,13 +10,9 @@ #include #include "../drivers/gpio/gpiolib.h" -#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS) DECLARE_HOOK(android_vh_gpio_block_read, TP_PROTO(struct gpio_device *gdev, bool *block_gpio_read), TP_ARGS(gdev, block_gpio_read)); -#else -#define trace_android_vh_gpio_block_read(gdev, block_gpio_read) -#endif #endif /* _TRACE_HOOK_GPIOLIB_H */ /* This part must be outside protection */ diff --git a/include/trace/hooks/iommu.h b/include/trace/hooks/iommu.h index 6c30cb7932fa..c09f1a4bf65a 100644 --- a/include/trace/hooks/iommu.h +++ b/include/trace/hooks/iommu.h @@ -11,7 +11,6 @@ #include -#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS) DECLARE_RESTRICTED_HOOK(android_rvh_iommu_setup_dma_ops, TP_PROTO(struct device *dev, u64 dma_base, u64 size), TP_ARGS(dev, dma_base, size), 1); @@ -23,13 +22,6 @@ DECLARE_HOOK(android_vh_iommu_alloc_iova, DECLARE_HOOK(android_vh_iommu_free_iova, TP_PROTO(dma_addr_t iova, size_t size), TP_ARGS(iova, size)); -#else - -#define trace_android_rvh_iommu_setup_dma_ops(dev, dma_base, size) -#define trace_android_vh_iommu_alloc_iova(dev, iova, size) -#define trace_android_vh_iommu_free_iova(iova, size) - -#endif #endif /* _TRACE_HOOK_IOMMU_H */ diff --git a/include/trace/hooks/psi.h b/include/trace/hooks/psi.h index ffda9543357e..32c7a273c5e2 100644 --- a/include/trace/hooks/psi.h +++ b/include/trace/hooks/psi.h @@ -9,8 +9,6 @@ #include -#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS) - #ifdef __GENKSYMS__ struct psi_group; struct psi_trigger; @@ -26,11 +24,6 @@ DECLARE_HOOK(android_vh_psi_group, TP_PROTO(struct psi_group *group), TP_ARGS(group)); -#else -#define trace_android_vh_psi_event(t) -#define trace_android_vh_psi_group(group) -#endif - #endif /* _TRACE_HOOK_PSI_H */ /* This part must be outside protection */ From d6ab8e3ba2d7f0060959bb607959cd8df5aa7b56 Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Thu, 8 Sep 2022 20:49:23 +0000 Subject: [PATCH 074/124] Revert "ANDROID: arm64: smp: fix Lockdep warning: RCU used illegally from idle CPU." This reverts commit 4af50419dbc04512c2ca6c2085a2bf6b4a397541. Causes a build break for kernel_microdroid_aarch64 builds Change-Id: I385a8e56ae1245bccba4d1b641175e73807da88b Signed-off-by: Todd Kjos --- arch/arm64/kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index fd9c0ce1b645..da66f6ac590b 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -915,7 +915,7 @@ static void do_handle_IPI(int ipinr) break; case IPI_CPU_STOP: - trace_android_vh_ipi_stop_rcuidle(get_irq_regs()); + trace_android_vh_ipi_stop(get_irq_regs()); local_cpu_stop(); break; From 7108d9d0e5f2ff1a531dd36714c68a330ba84823 Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Wed, 31 Aug 2022 15:59:29 -0700 Subject: [PATCH 075/124] ANDROID: remove inclusions from hook definition headers To avoid changing the visibiliy of data types when including hook definition headers remove header file inclusions from the hook definition header files. Instead, the hook definition headers should just have forward declarations that don't require full definition. To provide full definitions of the types for the KMI, the headers that define the types should be included by the source file that instantiates the hooks - normally vendor_hooks.c. Since the KMI is frozen, some of the inclusions are still required to preserve the CRC associated with symbols. Keep these inclusions under #ifdef __GENKSYMS__. This patch results in 17 fewer opaque types in the KMI (80 vs 97). Of the remaining 80 opaque types, 50 are defined in C files (and therefore are truly opaque and cannot be used by vendor modules). That leaves 30 types that still need definition in the KMI. Bug: 233047575 Signed-off-by: Todd Kjos Change-Id: Ibc1173eb4b07fcec21c7abd8e0ab1950b3fb5b34 --- android/abi_gki_aarch64.xml | 6902 ++++++++++++++++++++------- drivers/android/vendor_hooks.c | 22 + include/trace/hooks/binder.h | 14 +- include/trace/hooks/block.h | 9 - include/trace/hooks/cgroup.h | 10 +- include/trace/hooks/cpufreq.h | 9 +- include/trace/hooks/cpuidle.h | 5 - include/trace/hooks/cpuidle_psci.h | 6 +- include/trace/hooks/creds.h | 8 +- include/trace/hooks/debug.h | 5 - include/trace/hooks/dtask.h | 12 +- include/trace/hooks/fault.h | 6 +- include/trace/hooks/fips140.h | 5 - include/trace/hooks/ftrace_dump.h | 5 +- include/trace/hooks/gic_v3.h | 8 +- include/trace/hooks/gpiolib.h | 5 + include/trace/hooks/gup.h | 5 - include/trace/hooks/logbuf.h | 5 - include/trace/hooks/mm.h | 20 +- include/trace/hooks/mmc_core.h | 9 - include/trace/hooks/mpam.h | 6 +- include/trace/hooks/net.h | 14 +- include/trace/hooks/pci.h | 3 + include/trace/hooks/pm_domain.h | 6 +- include/trace/hooks/power.h | 13 +- include/trace/hooks/psi.h | 6 +- include/trace/hooks/remoteproc.h | 5 - include/trace/hooks/rwsem.h | 6 +- include/trace/hooks/sched.h | 16 +- include/trace/hooks/shmem_fs.h | 6 +- include/trace/hooks/signal.h | 6 +- include/trace/hooks/softlockup.h | 6 +- include/trace/hooks/sys.h | 6 +- include/trace/hooks/syscall_check.h | 8 +- include/trace/hooks/thermal.h | 6 +- include/trace/hooks/topology.h | 5 + include/trace/hooks/traps.h | 6 +- include/trace/hooks/ufshcd.h | 9 - include/trace/hooks/usb.h | 8 +- include/trace/hooks/user.h | 6 +- include/trace/hooks/v4l2core.h | 10 +- include/trace/hooks/v4l2mc.h | 8 +- include/trace/hooks/workqueue.h | 6 +- 43 files changed, 5268 insertions(+), 1973 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index ac5b15015083..1b628cab49f8 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -3964,7 +3964,7 @@ - + @@ -4115,16 +4115,16 @@ - + - + - + - + @@ -4219,6 +4219,14 @@ + + + + + + + + @@ -4356,7 +4364,20 @@ - + + + + + + + + + + + + + + @@ -4433,7 +4454,7 @@ - + @@ -4468,7 +4489,7 @@ - + @@ -4891,7 +4912,7 @@ - + @@ -4923,11 +4944,60 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5061,6 +5131,14 @@ + + + + + + + + @@ -5150,6 +5228,7 @@ + @@ -5180,6 +5259,14 @@ + + + + + + + + @@ -5337,9 +5424,12 @@ - + + + + @@ -5403,6 +5493,7 @@ + @@ -5466,6 +5557,7 @@ + @@ -5616,6 +5708,7 @@ + @@ -5762,6 +5855,7 @@ + @@ -6151,6 +6245,7 @@ + @@ -6372,43 +6467,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -6423,6 +6482,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6492,6 +6587,7 @@ + @@ -6912,7 +7008,7 @@ - + @@ -7052,12 +7148,20 @@ + + + + + + + + - + @@ -7310,6 +7414,7 @@ + @@ -7319,6 +7424,23 @@ + + + + + + + + + + + + + + + + + @@ -7585,7 +7707,7 @@ - + @@ -7594,6 +7716,9 @@ + + + @@ -7622,7 +7747,7 @@ - + @@ -7810,6 +7935,12 @@ + + + + + + @@ -8163,6 +8294,17 @@ + + + + + + + + + + + @@ -8290,42 +8432,42 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -8342,7 +8484,19 @@ + + + + + + + + + + + + @@ -8731,7 +8885,7 @@ - + @@ -8789,6 +8943,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -8858,6 +9036,7 @@ + @@ -9017,6 +9196,7 @@ + @@ -9114,7 +9294,62 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9144,7 +9379,7 @@ - + @@ -9320,6 +9555,17 @@ + + + + + + + + + + + @@ -9341,6 +9587,14 @@ + + + + + + + + @@ -9357,7 +9611,7 @@ - + @@ -9617,14 +9871,16 @@ + - + + @@ -9712,7 +9968,23 @@ - + + + + + + + + + + + + + + + + + @@ -9844,7 +10116,7 @@ - + @@ -9856,7 +10128,7 @@ - + @@ -9883,10 +10155,10 @@ - + - + @@ -10717,7 +10989,7 @@ - + @@ -10746,52 +11018,60 @@ - - + - - - - - - - + - + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + @@ -11305,18 +11585,18 @@ - + - + - + - + - + @@ -11356,7 +11636,7 @@ - + @@ -11404,6 +11684,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -11460,7 +11781,7 @@ - + @@ -11567,7 +11888,7 @@ - + @@ -11629,7 +11950,7 @@ - + @@ -11822,7 +12143,7 @@ - + @@ -12207,7 +12528,7 @@ - + @@ -12644,21 +12965,38 @@ - + - + - + - + - + + + + + + + + + + + + + + + + + + @@ -13031,7 +13369,7 @@ - + @@ -13317,6 +13655,7 @@ + @@ -13335,6 +13674,12 @@ + + + + + + @@ -13386,7 +13731,7 @@ - + @@ -13544,6 +13889,14 @@ + + + + + + + + @@ -13699,6 +14052,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -13752,6 +14128,7 @@ + @@ -13784,7 +14161,65 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -14011,6 +14446,12 @@ + + + + + + @@ -14077,7 +14518,7 @@ - + @@ -14459,6 +14900,10 @@ + + + + @@ -14507,7 +14952,7 @@ - + @@ -14673,6 +15118,12 @@ + + + + + + @@ -14752,9 +15203,12 @@ - + + + + @@ -15328,6 +15782,20 @@ + + + + + + + + + + + + + + @@ -15361,7 +15829,7 @@ - + @@ -15401,11 +15869,12 @@ + - + @@ -15587,6 +16056,7 @@ + @@ -15810,7 +16280,7 @@ - + @@ -15828,39 +16298,39 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -16001,6 +16471,8 @@ + + @@ -16221,6 +16693,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -16300,7 +16855,7 @@ - + @@ -16394,7 +16949,7 @@ - + @@ -16790,6 +17345,7 @@ + @@ -17240,7 +17796,194 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -17298,6 +18041,12 @@ + + + + + + @@ -17808,7 +18557,7 @@ - + @@ -17926,6 +18675,7 @@ + @@ -18099,7 +18849,20 @@ - + + + + + + + + + + + + + + @@ -18197,6 +18960,7 @@ + @@ -18768,6 +19532,14 @@ + + + + + + + + @@ -18799,6 +19571,7 @@ + @@ -18841,7 +19614,7 @@ - + @@ -19089,6 +19862,7 @@ + @@ -19416,6 +20190,23 @@ + + + + + + + + + + + + + + + + + @@ -19642,6 +20433,7 @@ + @@ -19888,7 +20680,7 @@ - + @@ -20403,6 +21195,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -20512,7 +21369,7 @@ - + @@ -20661,7 +21518,7 @@ - + @@ -20963,13 +21820,21 @@ + + + + + + + + - + @@ -20989,6 +21854,7 @@ + @@ -21073,6 +21939,7 @@ + @@ -21082,7 +21949,7 @@ - + @@ -21101,6 +21968,7 @@ + @@ -21132,6 +22000,20 @@ + + + + + + + + + + + + + + @@ -21437,6 +22319,7 @@ + @@ -21582,6 +22465,16 @@ + + + + + + + + + + @@ -21653,6 +22546,10 @@ + + + + @@ -22039,6 +22936,9 @@ + + + @@ -22112,6 +23012,12 @@ + + + + + + @@ -22122,6 +23028,7 @@ + @@ -22443,6 +23350,7 @@ + @@ -22515,6 +23423,7 @@ + @@ -22855,7 +23764,7 @@ - + @@ -22908,6 +23817,7 @@ + @@ -23087,6 +23997,7 @@ + @@ -23142,6 +24053,12 @@ + + + + + + @@ -23237,6 +24154,11 @@ + + + + + @@ -23336,7 +24258,7 @@ - + @@ -23942,6 +24864,14 @@ + + + + + + + + @@ -24377,6 +25307,7 @@ + @@ -24387,6 +25318,7 @@ + @@ -25290,7 +26222,7 @@ - + @@ -25346,6 +26278,14 @@ + + + + + + + + @@ -25661,6 +26601,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -25670,6 +26633,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -25771,7 +26775,7 @@ - + @@ -26322,27 +27326,27 @@ - + - + - + - + - + - + - + - + @@ -26424,6 +27428,9 @@ + + + @@ -26544,6 +27551,7 @@ + @@ -26748,6 +27756,12 @@ + + + + + + @@ -26867,7 +27881,7 @@ - + @@ -26918,7 +27932,7 @@ - + @@ -26926,6 +27940,9 @@ + + + @@ -27135,7 +28152,7 @@ - + @@ -27181,7 +28198,7 @@ - + @@ -27292,7 +28309,7 @@ - + @@ -27472,6 +28489,23 @@ + + + + + + + + + + + + + + + + + @@ -27492,7 +28526,7 @@ - + @@ -27505,6 +28539,11 @@ + + + + + @@ -27626,6 +28665,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -28098,11 +29169,12 @@ - + + @@ -28437,6 +29509,12 @@ + + + + + + @@ -28466,12 +29544,12 @@ - + - + @@ -28707,6 +29785,10 @@ + + + + @@ -28787,6 +29869,7 @@ + @@ -28797,7 +29880,7 @@ - + @@ -28954,7 +30037,7 @@ - + @@ -29045,6 +30128,14 @@ + + + + + + + + @@ -29098,6 +30189,7 @@ + @@ -29860,6 +30952,12 @@ + + + + + + @@ -30130,7 +31228,7 @@ - + @@ -30183,6 +31281,7 @@ + @@ -30261,7 +31360,7 @@ - + @@ -30312,6 +31411,12 @@ + + + + + + @@ -30584,6 +31689,10 @@ + + + + @@ -30742,6 +31851,7 @@ + @@ -31208,6 +32318,14 @@ + + + + + + + + @@ -31791,6 +32909,10 @@ + + + + @@ -31906,6 +33028,13 @@ + + + + + + + @@ -32333,7 +33462,7 @@ - + @@ -32344,7 +33473,14 @@ - + + + + + + + + @@ -32480,24 +33616,24 @@ - + - + - + - + - + - + - + @@ -32731,7 +33867,7 @@ - + @@ -32906,7 +34042,7 @@ - + @@ -32944,6 +34080,14 @@ + + + + + + + + @@ -33120,7 +34264,7 @@ - + @@ -33340,6 +34484,7 @@ + @@ -33494,7 +34639,22 @@ + + + + + + + + + + + + + + + @@ -33541,18 +34701,18 @@ - + - + - + - + - + @@ -34118,6 +35278,17 @@ + + + + + + + + + + + @@ -34237,7 +35408,7 @@ - + @@ -34303,7 +35474,7 @@ - + @@ -34659,6 +35830,7 @@ + @@ -34759,13 +35931,13 @@ - + - + - + @@ -34789,7 +35961,7 @@ - + @@ -34807,13 +35979,13 @@ - + - + @@ -34822,7 +35994,7 @@ - + @@ -34831,7 +36003,7 @@ - + @@ -35203,6 +36375,14 @@ + + + + + + + + @@ -35474,7 +36654,7 @@ - + @@ -35753,13 +36933,13 @@ - + - + @@ -35777,7 +36957,7 @@ - + @@ -35871,10 +37051,17 @@ + + + + + + + @@ -35980,6 +37167,7 @@ + @@ -36148,6 +37336,7 @@ + @@ -36791,6 +37980,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -36864,6 +38079,7 @@ + @@ -36886,7 +38102,29 @@ - + + + + + + + + + + + + + + + + + + + + + + + @@ -37067,7 +38305,7 @@ - + @@ -37076,7 +38314,7 @@ - + @@ -37535,7 +38773,23 @@ - + + + + + + + + + + + + + + + + + @@ -37813,7 +39067,7 @@ - + @@ -38369,6 +39623,12 @@ + + + + + + @@ -38379,7 +39639,7 @@ - + @@ -39055,6 +40315,7 @@ + @@ -39085,7 +40346,7 @@ - + @@ -39438,6 +40699,14 @@ + + + + + + + + @@ -39689,9 +40958,15 @@ - + + + + + + + @@ -39907,6 +41182,7 @@ + @@ -40058,6 +41334,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -40146,6 +41470,20 @@ + + + + + + + + + + + + + + @@ -40851,7 +42189,7 @@ - + @@ -40917,6 +42255,7 @@ + @@ -41048,6 +42387,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -41373,7 +42735,7 @@ - + @@ -41850,6 +43212,7 @@ + @@ -41966,7 +43329,7 @@ - + @@ -42015,6 +43378,11 @@ + + + + + @@ -42115,7 +43483,35 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -42469,6 +43865,11 @@ + + + + + @@ -42623,7 +44024,7 @@ - + @@ -42639,6 +44040,7 @@ + @@ -43242,6 +44644,7 @@ + @@ -43744,6 +45147,11 @@ + + + + + @@ -43923,6 +45331,7 @@ + @@ -44134,6 +45543,7 @@ + @@ -44396,6 +45806,12 @@ + + + + + + @@ -44612,6 +46028,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -44644,7 +46098,77 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -44684,7 +46208,7 @@ - + @@ -44833,7 +46357,7 @@ - + @@ -45138,6 +46662,9 @@ + + + @@ -46170,6 +47697,13 @@ + + + + + + + @@ -46272,6 +47806,7 @@ + @@ -46424,13 +47959,13 @@ - + - + - + @@ -46439,7 +47974,7 @@ - + @@ -46453,7 +47988,7 @@ - + @@ -46476,7 +48011,7 @@ - + @@ -46522,7 +48057,7 @@ - + @@ -46617,6 +48152,14 @@ + + + + + + + + @@ -47060,6 +48603,10 @@ + + + + @@ -47134,6 +48681,23 @@ + + + + + + + + + + + + + + + + + @@ -47703,7 +49267,7 @@ - + @@ -47816,6 +49380,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -47907,6 +49503,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -47978,6 +49594,14 @@ + + + + + + + + @@ -47995,7 +49619,32 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -48043,6 +49692,20 @@ + + + + + + + + + + + + + + @@ -48487,6 +50150,7 @@ + @@ -48600,7 +50264,7 @@ - + @@ -48763,6 +50427,12 @@ + + + + + + @@ -49168,12 +50838,34 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -49392,7 +51084,7 @@ - + @@ -49530,6 +51222,7 @@ + @@ -49676,7 +51369,29 @@ - + + + + + + + + + + + + + + + + + + + + + + + @@ -50411,7 +52126,7 @@ - + @@ -50453,30 +52168,30 @@ - + - + - + - + - + - + - + - + - + @@ -50877,6 +52592,7 @@ + @@ -51003,7 +52719,7 @@ - + @@ -51142,6 +52858,7 @@ + @@ -51293,7 +53010,7 @@ - + @@ -51329,6 +53046,7 @@ + @@ -51492,7 +53210,146 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -51678,6 +53535,7 @@ + @@ -52104,6 +53962,11 @@ + + + + + @@ -52112,7 +53975,7 @@ - + @@ -52207,6 +54070,14 @@ + + + + + + + + @@ -52357,6 +54228,15 @@ + + + + + + + + + @@ -52515,7 +54395,7 @@ - + @@ -52548,6 +54428,11 @@ + + + + + @@ -52939,6 +54824,20 @@ + + + + + + + + + + + + + + @@ -53127,6 +55026,14 @@ + + + + + + + + @@ -53251,7 +55158,7 @@ - + @@ -53284,10 +55191,10 @@ - + - + @@ -53312,6 +55219,7 @@ + @@ -53480,7 +55388,7 @@ - + @@ -53587,6 +55495,7 @@ + @@ -53809,7 +55718,7 @@ - + @@ -53981,7 +55890,7 @@ - + @@ -54072,7 +55981,7 @@ - + @@ -54090,6 +55999,7 @@ + @@ -54575,10 +56485,15 @@ - + + + + + + @@ -54604,7 +56519,7 @@ - + @@ -55163,7 +57078,7 @@ - + @@ -55171,6 +57086,7 @@ + @@ -55439,7 +57355,20 @@ - + + + + + + + + + + + + + + @@ -55508,7 +57437,7 @@ - + @@ -56010,7 +57939,7 @@ - + @@ -56072,13 +58001,13 @@ - + - + @@ -56230,61 +58159,61 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -56324,7 +58253,7 @@ - + @@ -56374,6 +58303,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -56416,16 +58365,16 @@ - + - + - + - + @@ -56569,7 +58518,53 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -57517,15 +59512,15 @@ - + - + - + - + @@ -57715,6 +59710,9 @@ + + + @@ -57784,6 +59782,13 @@ + + + + + + + @@ -57852,6 +59857,10 @@ + + + + @@ -57966,6 +59975,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -58211,7 +60246,7 @@ - + @@ -58401,72 +60436,72 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -58509,6 +60544,7 @@ + @@ -58528,6 +60564,13 @@ + + + + + + + @@ -58902,7 +60945,7 @@ - + @@ -58981,6 +61024,12 @@ + + + + + + @@ -59210,6 +61259,20 @@ + + + + + + + + + + + + + + @@ -59266,7 +61329,7 @@ - + @@ -59696,7 +61759,7 @@ - + @@ -59768,6 +61831,15 @@ + + + + + + + + + @@ -59778,7 +61850,7 @@ - + @@ -59880,6 +61952,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -59938,6 +62033,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -60097,7 +62215,7 @@ - + @@ -60138,6 +62256,7 @@ + @@ -60281,7 +62400,7 @@ - + @@ -60310,6 +62429,13 @@ + + + + + + + @@ -60348,13 +62474,13 @@ - + - + @@ -60366,7 +62492,7 @@ - + @@ -60625,7 +62751,7 @@ - + @@ -60745,6 +62871,7 @@ + @@ -60930,12 +63057,12 @@ - + - + - + @@ -61112,6 +63239,17 @@ + + + + + + + + + + + @@ -61244,7 +63382,7 @@ - + @@ -61344,7 +63482,191 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -62087,6 +64409,7 @@ + @@ -62331,7 +64654,7 @@ - + @@ -62403,7 +64726,7 @@ - + @@ -62847,6 +65170,7 @@ + @@ -63238,6 +65562,7 @@ + @@ -63289,7 +65614,7 @@ - + @@ -63302,7 +65627,7 @@ - + @@ -63422,7 +65747,7 @@ - + @@ -63541,7 +65866,7 @@ - + @@ -63559,7 +65884,7 @@ - + @@ -63586,7 +65911,7 @@ - + @@ -63834,16 +66159,27 @@ - + - + - + + + + + + + + + + + + @@ -63977,6 +66313,7 @@ + @@ -64244,7 +66581,7 @@ - + @@ -64489,6 +66826,9 @@ + + + @@ -64616,6 +66956,7 @@ + @@ -64739,6 +67080,7 @@ + @@ -64935,6 +67277,7 @@ + @@ -64962,7 +67305,7 @@ - + @@ -65096,25 +67439,25 @@ - + - + - + - + - + - + - + @@ -65267,6 +67610,7 @@ + @@ -65327,7 +67671,7 @@ - + @@ -65396,15 +67740,15 @@ - + - + - + @@ -65464,7 +67808,7 @@ - + @@ -65639,6 +67983,9 @@ + + + @@ -65902,11 +68249,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -66022,7 +68397,7 @@ - + @@ -66067,6 +68442,7 @@ + @@ -66078,6 +68454,7 @@ + @@ -66207,7 +68584,7 @@ - + @@ -66326,6 +68703,10 @@ + + + + @@ -66581,6 +68962,7 @@ + @@ -66692,7 +69074,7 @@ - + @@ -66833,6 +69215,7 @@ + @@ -66847,6 +69230,7 @@ + @@ -66916,7 +69300,7 @@ - + @@ -66983,59 +69367,65 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + @@ -67058,7 +69448,7 @@ - + @@ -67214,7 +69604,7 @@ - + @@ -67400,7 +69790,7 @@ - + @@ -67660,7 +70050,7 @@ - + @@ -67687,7 +70077,7 @@ - + @@ -67698,7 +70088,7 @@ - + @@ -67749,66 +70139,160 @@ - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - - + - - - - - - - - - - - - - - - - - + - + - + @@ -67825,23 +70309,23 @@ - + - + - + - + - + @@ -67852,15 +70336,15 @@ - + - + - + - + @@ -67877,7 +70361,7 @@ - + @@ -67885,7 +70369,7 @@ - + @@ -67896,12 +70380,12 @@ - + - + @@ -67909,7 +70393,7 @@ - + @@ -67917,7 +70401,7 @@ - + @@ -67925,7 +70409,7 @@ - + @@ -67933,7 +70417,7 @@ - + @@ -67950,7 +70434,7 @@ - + @@ -67967,21 +70451,21 @@ - + - + - + - + - + - + @@ -67992,7 +70476,7 @@ - + @@ -68000,12 +70484,12 @@ - + - + @@ -68013,7 +70497,7 @@ - + @@ -68024,7 +70508,7 @@ - + @@ -68035,7 +70519,7 @@ - + @@ -68046,12 +70530,12 @@ - + - + - + @@ -68059,13 +70543,13 @@ - + - + - + @@ -68073,7 +70557,7 @@ - + @@ -68081,7 +70565,7 @@ - + @@ -68089,7 +70573,7 @@ - + @@ -68097,7 +70581,7 @@ - + @@ -68108,7 +70592,7 @@ - + @@ -68122,7 +70606,7 @@ - + @@ -68130,7 +70614,7 @@ - + @@ -68138,7 +70622,7 @@ - + @@ -68146,7 +70630,7 @@ - + @@ -68172,12 +70656,12 @@ - + - + @@ -68185,23 +70669,23 @@ - + - + - + - + - + - + - + @@ -68209,7 +70693,7 @@ - + @@ -68235,7 +70719,7 @@ - + @@ -68246,7 +70730,7 @@ - + @@ -68254,7 +70738,7 @@ - + @@ -68262,7 +70746,7 @@ - + @@ -68273,7 +70757,7 @@ - + @@ -68281,7 +70765,7 @@ - + @@ -68292,7 +70776,7 @@ - + @@ -68300,7 +70784,7 @@ - + @@ -68311,7 +70795,7 @@ - + @@ -68322,7 +70806,7 @@ - + @@ -68330,7 +70814,7 @@ - + @@ -68350,19 +70834,19 @@ - + - + - + - - + + @@ -68370,7 +70854,7 @@ - + @@ -68378,7 +70862,7 @@ - + @@ -68386,7 +70870,7 @@ - + @@ -68394,7 +70878,7 @@ - + @@ -68405,15 +70889,15 @@ - + - + - + @@ -68421,15 +70905,15 @@ - + - + - + @@ -68437,7 +70921,7 @@ - + @@ -68445,7 +70929,7 @@ - + @@ -68453,10 +70937,10 @@ - + - + @@ -68464,7 +70948,7 @@ - + @@ -68472,7 +70956,7 @@ - + @@ -68483,7 +70967,7 @@ - + @@ -68494,15 +70978,15 @@ - + - + - + @@ -68510,7 +70994,7 @@ - + @@ -68518,31 +71002,31 @@ - + - + - + - + - + - + - + @@ -68550,33 +71034,33 @@ - + - + - + - + - + - + - + - + - + @@ -68590,7 +71074,7 @@ - + @@ -68598,15 +71082,15 @@ - + - + - + @@ -68614,10 +71098,10 @@ - + - + @@ -68625,15 +71109,15 @@ - + - + - + @@ -68644,7 +71128,7 @@ - + @@ -68652,7 +71136,7 @@ - + @@ -68663,7 +71147,7 @@ - + @@ -68671,15 +71155,15 @@ - + - + - + @@ -68693,31 +71177,31 @@ - + - + - + - + - + - + - + - + @@ -68725,7 +71209,7 @@ - + @@ -68736,7 +71220,7 @@ - + @@ -68744,7 +71228,15 @@ - + + + + + + + + + @@ -68752,7 +71244,7 @@ - + @@ -68760,7 +71252,7 @@ - + @@ -68771,7 +71263,7 @@ - + @@ -68779,7 +71271,7 @@ - + @@ -68787,7 +71279,7 @@ - + @@ -68795,37 +71287,37 @@ - + - + - + - + - + - + - + - + - + - + @@ -68833,7 +71325,7 @@ - + @@ -68841,7 +71333,7 @@ - + @@ -68849,23 +71341,23 @@ - + - + - + - + - + @@ -68873,15 +71365,15 @@ - + - + - + @@ -68889,7 +71381,7 @@ - + @@ -68903,15 +71395,15 @@ - + - + - + - + @@ -68919,7 +71411,7 @@ - + @@ -68933,7 +71425,7 @@ - + @@ -68947,15 +71439,15 @@ - + - + - + @@ -68963,9 +71455,9 @@ - + - + @@ -68977,7 +71469,7 @@ - + @@ -68985,7 +71477,7 @@ - + @@ -68993,12 +71485,12 @@ - + - + - + @@ -69006,15 +71498,15 @@ - + - + - + @@ -69034,7 +71526,7 @@ - + @@ -69042,18 +71534,18 @@ - + - + - + - + - + @@ -69061,7 +71553,7 @@ - + @@ -69069,7 +71561,7 @@ - + @@ -69077,7 +71569,7 @@ - + @@ -69091,7 +71583,7 @@ - + @@ -69111,7 +71603,7 @@ - + @@ -69120,26 +71612,26 @@ - + - + - + - + - + - + @@ -69147,15 +71639,15 @@ - + - + - + @@ -69163,7 +71655,7 @@ - + @@ -69174,7 +71666,7 @@ - + @@ -69182,7 +71674,7 @@ - + @@ -69193,7 +71685,7 @@ - + @@ -69204,7 +71696,7 @@ - + @@ -69218,7 +71710,7 @@ - + @@ -69226,7 +71718,7 @@ - + @@ -69243,7 +71735,7 @@ - + @@ -69251,15 +71743,15 @@ - + - + - + @@ -69267,7 +71759,7 @@ - + @@ -69293,12 +71785,12 @@ - + - + @@ -69339,7 +71831,7 @@ - + @@ -69347,7 +71839,7 @@ - + @@ -69355,7 +71847,7 @@ - + @@ -69363,7 +71855,7 @@ - + @@ -69371,15 +71863,15 @@ - + - + - + - + @@ -69387,7 +71879,7 @@ - + @@ -69395,7 +71887,7 @@ - + @@ -69403,18 +71895,18 @@ - + - + - + - + @@ -69422,32 +71914,32 @@ - + - + - + - + - + - + - + - + - + - + @@ -69455,30 +71947,49 @@ - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + @@ -69486,7 +71997,23 @@ - + + + + + + + + + + + + + + + + + @@ -69497,38 +72024,38 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -69537,15 +72064,15 @@ - + - + - + @@ -69553,7 +72080,7 @@ - + @@ -69561,101 +72088,101 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -69663,38 +72190,38 @@ - + - + - + - + - + - + - + - + - + - + @@ -69702,7 +72229,7 @@ - + @@ -69710,7 +72237,7 @@ - + @@ -69718,7 +72245,7 @@ - + @@ -69726,7 +72253,7 @@ - + @@ -69734,7 +72261,7 @@ - + @@ -69742,7 +72269,7 @@ - + @@ -69753,7 +72280,7 @@ - + @@ -69761,7 +72288,7 @@ - + @@ -69771,6 +72298,7 @@ + @@ -69805,7 +72333,7 @@ - + @@ -70089,7 +72617,14 @@ - + + + + + + + + @@ -70231,6 +72766,7 @@ + @@ -70825,6 +73361,7 @@ + @@ -70859,6 +73396,7 @@ + @@ -71213,6 +73751,7 @@ + @@ -71662,6 +74201,7 @@ + @@ -71984,6 +74524,7 @@ + @@ -72165,6 +74706,11 @@ + + + + + @@ -72378,6 +74924,11 @@ + + + + + @@ -72408,10 +74959,12 @@ + + @@ -72519,7 +75072,7 @@ - + @@ -72553,6 +75106,11 @@ + + + + + @@ -72623,6 +75181,7 @@ + @@ -72689,10 +75248,26 @@ - + + + + + + + + + + + + + + + + + + - @@ -72917,7 +75492,7 @@ - + @@ -73027,6 +75602,12 @@ + + + + + + @@ -73402,7 +75983,7 @@ - + @@ -73633,6 +76214,7 @@ + @@ -73880,6 +76462,7 @@ + @@ -74027,6 +76610,7 @@ + @@ -74076,7 +76660,7 @@ - + @@ -74223,7 +76807,7 @@ - + @@ -74234,7 +76818,7 @@ - + @@ -74856,7 +77440,7 @@ - + @@ -75001,6 +77585,7 @@ + @@ -75139,9 +77724,6 @@ - - - @@ -75492,12 +78074,12 @@ - + - + - + @@ -75693,7 +78275,7 @@ - + @@ -75795,7 +78377,7 @@ - + @@ -75815,6 +78397,9 @@ + + + @@ -76569,7 +79154,7 @@ - + @@ -76707,312 +79292,312 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -77321,6 +79906,10 @@ + + + + @@ -77750,6 +80339,7 @@ + @@ -77967,7 +80557,7 @@ - + @@ -78186,6 +80776,12 @@ + + + + + + @@ -78200,6 +80796,7 @@ + @@ -78275,6 +80872,14 @@ + + + + + + + + @@ -78283,6 +80888,7 @@ + @@ -78307,6 +80913,7 @@ + @@ -78396,6 +81003,20 @@ + + + + + + + + + + + + + + @@ -78404,6 +81025,7 @@ + @@ -78438,7 +81060,7 @@ - + @@ -78516,6 +81138,7 @@ + @@ -78823,6 +81446,20 @@ + + + + + + + + + + + + + + @@ -78882,7 +81519,7 @@ - + @@ -78921,6 +81558,12 @@ + + + + + + @@ -79003,10 +81646,10 @@ - + - + @@ -79109,6 +81752,23 @@ + + + + + + + + + + + + + + + + + @@ -79375,7 +82035,7 @@ - + @@ -79710,7 +82370,7 @@ - + @@ -79812,7 +82472,7 @@ - + @@ -79829,7 +82489,7 @@ - + @@ -79891,6 +82551,13 @@ + + + + + + + @@ -79922,6 +82589,7 @@ + @@ -80015,6 +82683,7 @@ + @@ -80186,6 +82855,14 @@ + + + + + + + + @@ -81042,6 +83719,12 @@ + + + + + + @@ -81487,6 +84170,7 @@ + @@ -81575,6 +84259,7 @@ + @@ -81759,6 +84444,10 @@ + + + + @@ -82197,7 +84886,7 @@ - + @@ -82310,7 +84999,7 @@ - + @@ -82400,7 +85089,7 @@ - + @@ -82432,6 +85121,7 @@ + @@ -82801,7 +85491,7 @@ - + @@ -82837,7 +85527,7 @@ - + @@ -82955,9 +85645,6 @@ - - - @@ -83141,6 +85828,7 @@ + @@ -83608,13 +86296,13 @@ - + - + @@ -83712,7 +86400,7 @@ - + @@ -83826,7 +86514,7 @@ - + @@ -83840,7 +86528,7 @@ - + @@ -83962,13 +86650,13 @@ - + - + - + @@ -84016,7 +86704,7 @@ - + @@ -84122,6 +86810,14 @@ + + + + + + + + @@ -84239,7 +86935,7 @@ - + @@ -84319,22 +87015,22 @@ - + - + - + - + - + - + @@ -84481,6 +87177,17 @@ + + + + + + + + + + + @@ -84816,6 +87523,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -84894,7 +87657,7 @@ - + @@ -85120,7 +87883,7 @@ - + @@ -85255,7 +88018,7 @@ - + @@ -85360,7 +88123,7 @@ - + @@ -85572,6 +88335,7 @@ + @@ -85686,6 +88450,7 @@ + @@ -85718,7 +88483,28 @@ + + + + + + + + + + + + + + + + + + + + + @@ -85822,6 +88608,7 @@ + @@ -85965,7 +88752,7 @@ - + @@ -86148,7 +88935,7 @@ - + @@ -86219,6 +89006,17 @@ + + + + + + + + + + + @@ -86756,6 +89554,11 @@ + + + + + @@ -87126,7 +89929,7 @@ - + @@ -87135,7 +89938,7 @@ - + @@ -87531,6 +90334,9 @@ + + + @@ -87695,6 +90501,7 @@ + @@ -87734,6 +90541,7 @@ + @@ -88133,7 +90941,7 @@ - + @@ -88210,7 +91018,7 @@ - + @@ -88220,6 +91028,14 @@ + + + + + + + + @@ -88374,10 +91190,10 @@ - + - + @@ -89220,10 +92036,10 @@ - + - + @@ -89235,7 +92051,7 @@ - + @@ -89393,6 +92209,7 @@ + @@ -89593,6 +92410,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -89618,6 +92455,14 @@ + + + + + + + + @@ -89654,6 +92499,10 @@ + + + + @@ -89675,6 +92524,17 @@ + + + + + + + + + + + @@ -89754,7 +92614,86 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -89912,7 +92851,7 @@ - + @@ -90013,7 +92952,7 @@ - + @@ -90231,7 +93170,44 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -90318,6 +93294,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -90395,7 +93394,7 @@ - + @@ -90893,6 +93892,7 @@ + @@ -91553,6 +94553,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -91678,6 +94707,12 @@ + + + + + + @@ -91862,7 +94897,7 @@ - + @@ -91886,6 +94921,11 @@ + + + + + @@ -92024,7 +95064,7 @@ - + @@ -92295,7 +95335,7 @@ - + @@ -92380,7 +95420,7 @@ - + @@ -92602,6 +95642,11 @@ + + + + + @@ -93711,7 +96756,7 @@ - + @@ -93944,21 +96989,21 @@ - + - + - + - + - + - + @@ -94010,6 +97055,9 @@ + + + @@ -94246,7 +97294,206 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -94254,7 +97501,15 @@ - + + + + + + + + + @@ -94262,7 +97517,7 @@ - + @@ -94270,7 +97525,7 @@ - + @@ -94317,7 +97572,7 @@ - + @@ -94328,7 +97583,7 @@ - + @@ -94348,7 +97603,7 @@ - + @@ -94371,7 +97626,7 @@ - + @@ -94391,26 +97646,26 @@ - + - + - + - + - + @@ -94424,7 +97679,7 @@ - + @@ -94432,7 +97687,7 @@ - + @@ -94452,7 +97707,7 @@ - + @@ -94475,7 +97730,7 @@ - + @@ -94483,7 +97738,7 @@ - + @@ -94491,7 +97746,7 @@ - + @@ -94499,7 +97754,7 @@ - + @@ -94507,7 +97762,7 @@ - + @@ -94533,17 +97788,17 @@ - + - + - + @@ -94551,17 +97806,17 @@ - + - + - + @@ -94578,7 +97833,7 @@ - + @@ -94592,7 +97847,7 @@ - + @@ -94606,7 +97861,7 @@ - + @@ -94635,7 +97890,7 @@ - + @@ -94652,7 +97907,7 @@ - + @@ -94666,7 +97921,7 @@ - + @@ -94680,7 +97935,7 @@ - + @@ -94694,7 +97949,7 @@ - + @@ -94705,7 +97960,7 @@ - + @@ -94719,15 +97974,15 @@ - + - + - + @@ -94735,7 +97990,7 @@ - + @@ -94749,12 +98004,12 @@ - + - + @@ -94762,7 +98017,7 @@ - + @@ -94770,7 +98025,7 @@ - + @@ -94781,7 +98036,7 @@ - + @@ -94789,7 +98044,7 @@ - + @@ -94797,7 +98052,7 @@ - + @@ -94808,7 +98063,7 @@ - + @@ -94816,7 +98071,7 @@ - + @@ -94833,7 +98088,7 @@ - + @@ -94841,7 +98096,7 @@ - + @@ -94849,7 +98104,7 @@ - + @@ -94863,7 +98118,7 @@ - + @@ -94877,14 +98132,14 @@ - + - + - + @@ -94893,10 +98148,10 @@ - + - + @@ -94913,7 +98168,7 @@ - + @@ -94924,7 +98179,7 @@ - + @@ -94935,13 +98190,13 @@ - + - + @@ -94949,7 +98204,7 @@ - + @@ -94960,7 +98215,7 @@ - + @@ -94971,7 +98226,7 @@ - + @@ -94979,7 +98234,7 @@ - + @@ -95155,13 +98410,13 @@ - + - + @@ -95172,7 +98427,7 @@ - + @@ -95180,10 +98435,10 @@ - + - + @@ -95191,7 +98446,7 @@ - + @@ -95199,7 +98454,7 @@ - + @@ -95213,7 +98468,7 @@ - + @@ -95221,7 +98476,7 @@ - + @@ -95229,7 +98484,7 @@ - + @@ -95237,7 +98492,7 @@ - + @@ -95245,7 +98500,7 @@ - + @@ -95256,7 +98511,7 @@ - + @@ -95264,7 +98519,7 @@ - + @@ -95278,7 +98533,7 @@ - + @@ -95289,7 +98544,7 @@ - + @@ -95297,7 +98552,7 @@ - + @@ -95305,7 +98560,7 @@ - + @@ -95313,7 +98568,7 @@ - + @@ -95333,7 +98588,7 @@ - + @@ -95341,13 +98596,13 @@ - + - + @@ -95364,7 +98619,7 @@ - + @@ -95378,7 +98633,7 @@ - + @@ -95392,7 +98647,7 @@ - + @@ -95400,7 +98655,7 @@ - + @@ -95414,7 +98669,7 @@ - + @@ -95425,7 +98680,7 @@ - + @@ -95442,15 +98697,15 @@ - + - + - + @@ -95458,7 +98713,7 @@ - + @@ -95469,7 +98724,7 @@ - + @@ -95480,7 +98735,7 @@ - + @@ -95488,7 +98743,7 @@ - + @@ -95505,7 +98760,7 @@ - + @@ -95528,7 +98783,7 @@ - + @@ -95536,7 +98791,7 @@ - + @@ -95547,7 +98802,7 @@ - + @@ -95561,18 +98816,18 @@ - + - + - + - + @@ -95598,7 +98853,7 @@ - + @@ -95609,7 +98864,7 @@ - + @@ -95617,7 +98872,7 @@ - + @@ -95637,7 +98892,7 @@ - + @@ -95648,7 +98903,7 @@ - + @@ -95659,12 +98914,12 @@ - + - + @@ -95672,7 +98927,7 @@ - + @@ -95680,7 +98935,7 @@ - + @@ -95688,7 +98943,7 @@ - + @@ -95696,12 +98951,12 @@ - + - + @@ -95709,7 +98964,7 @@ - + @@ -95717,7 +98972,7 @@ - + @@ -95725,7 +98980,7 @@ - + @@ -95733,7 +98988,7 @@ - + @@ -95741,7 +98996,7 @@ - + @@ -95749,7 +99004,7 @@ - + @@ -95790,7 +99045,7 @@ - + @@ -95798,13 +99053,13 @@ - + - + @@ -95830,7 +99085,7 @@ - + @@ -95895,7 +99150,7 @@ - + @@ -95906,7 +99161,7 @@ - + @@ -95923,7 +99178,7 @@ - + @@ -95967,9 +99222,9 @@ - + - + @@ -95978,7 +99233,7 @@ - + @@ -95989,7 +99244,7 @@ - + @@ -96009,7 +99264,7 @@ - + @@ -96017,7 +99272,7 @@ - + @@ -96034,7 +99289,7 @@ - + @@ -96063,12 +99318,12 @@ - + - + @@ -96077,10 +99332,10 @@ - + - + @@ -96094,17 +99349,17 @@ - + - + - + @@ -96112,7 +99367,7 @@ - + @@ -96123,7 +99378,7 @@ - + @@ -96131,7 +99386,7 @@ - + @@ -96172,7 +99427,7 @@ - + @@ -96180,7 +99435,7 @@ - + @@ -96188,7 +99443,7 @@ - + @@ -96202,7 +99457,7 @@ - + @@ -96222,7 +99477,7 @@ - + @@ -96230,7 +99485,7 @@ - + @@ -96238,7 +99493,7 @@ - + @@ -96246,12 +99501,12 @@ - + - + @@ -96259,7 +99514,7 @@ - + @@ -96267,10 +99522,10 @@ - + - + @@ -96278,23 +99533,23 @@ - + - + - - + + - + @@ -96303,12 +99558,12 @@ - + - + @@ -96316,12 +99571,12 @@ - + - + @@ -96329,12 +99584,12 @@ - + - + @@ -96351,7 +99606,7 @@ - + @@ -96359,7 +99614,7 @@ - + @@ -96367,12 +99622,12 @@ - + - + @@ -96380,7 +99635,7 @@ - + @@ -96388,9 +99643,9 @@ - + - + @@ -96405,12 +99660,12 @@ - + - + @@ -96436,7 +99691,7 @@ - + @@ -96447,7 +99702,7 @@ - + @@ -96467,7 +99722,7 @@ - + @@ -96490,53 +99745,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -96550,12 +99759,12 @@ - + - + @@ -96566,7 +99775,7 @@ - + @@ -96580,7 +99789,7 @@ - + @@ -96591,7 +99800,7 @@ - + @@ -96605,7 +99814,7 @@ - + @@ -96619,20 +99828,20 @@ - + - + - + - + @@ -96646,7 +99855,7 @@ - + @@ -96654,7 +99863,7 @@ - + @@ -96665,7 +99874,7 @@ - + @@ -96682,7 +99891,7 @@ - + @@ -96702,7 +99911,7 @@ - + @@ -96719,7 +99928,7 @@ - + @@ -96730,7 +99939,7 @@ - + @@ -96738,7 +99947,7 @@ - + @@ -96746,7 +99955,7 @@ - + @@ -96754,7 +99963,7 @@ - + @@ -96768,7 +99977,7 @@ - + @@ -96776,7 +99985,7 @@ - + @@ -96787,7 +99996,7 @@ - + @@ -96804,7 +100013,7 @@ - + @@ -96830,7 +100039,7 @@ - + @@ -96841,7 +100050,7 @@ - + @@ -96852,7 +100061,7 @@ - + @@ -96909,20 +100118,7 @@ - - - - - - - - - - - - - - + @@ -97158,6 +100354,29 @@ + + + + + + + + + + + + + + + + + + + + + + + @@ -97219,7 +100438,7 @@ - + @@ -97238,6 +100457,14 @@ + + + + + + + + @@ -97413,7 +100640,7 @@ - + @@ -97584,7 +100811,7 @@ - + @@ -97616,6 +100843,7 @@ + @@ -98499,6 +101727,7 @@ + @@ -98508,6 +101737,7 @@ + @@ -98709,6 +101939,7 @@ + @@ -98896,7 +102127,7 @@ - + @@ -98952,7 +102183,7 @@ - + @@ -98979,7 +102210,7 @@ - + @@ -99107,24 +102338,25 @@ - + + - + - + - + - + - + - + @@ -99247,84 +102479,84 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -99360,12 +102592,12 @@ - + - + @@ -99504,6 +102736,13 @@ + + + + + + + @@ -100076,6 +103315,9 @@ + + + @@ -100096,7 +103338,7 @@ - + @@ -100390,6 +103632,23 @@ + + + + + + + + + + + + + + + + + @@ -100529,7 +103788,7 @@ - + @@ -100792,10 +104051,10 @@ - + - + @@ -101099,6 +104358,20 @@ + + + + + + + + + + + + + + @@ -101203,7 +104476,7 @@ - + @@ -101342,6 +104615,7 @@ + @@ -101380,6 +104654,7 @@ + @@ -101453,7 +104728,7 @@ - + @@ -101504,7 +104779,7 @@ - + @@ -101535,7 +104810,7 @@ - + @@ -101975,7 +105250,7 @@ - + @@ -102090,6 +105365,7 @@ + @@ -102165,7 +105441,7 @@ - + @@ -102224,6 +105500,7 @@ + @@ -102318,7 +105595,7 @@ - + @@ -102896,6 +106173,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -102952,12 +106255,12 @@ - + - + @@ -103040,6 +106343,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -103254,6 +106649,7 @@ + @@ -103322,7 +106718,7 @@ - + @@ -103380,6 +106776,7 @@ + @@ -103533,6 +106930,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -103796,7 +107219,7 @@ - + @@ -103945,6 +107368,10 @@ + + + + @@ -103970,6 +107397,7 @@ + @@ -104198,6 +107626,7 @@ + @@ -104250,7 +107679,7 @@ - + @@ -104473,6 +107902,7 @@ + @@ -105001,7 +108431,7 @@ - + @@ -105073,7 +108503,7 @@ - + @@ -105094,7 +108524,7 @@ - + @@ -105106,7 +108536,7 @@ - + @@ -105146,6 +108576,23 @@ + + + + + + + + + + + + + + + + + @@ -105204,13 +108651,13 @@ - + - + @@ -105548,7 +108995,7 @@ - + @@ -105703,6 +109150,7 @@ + @@ -105841,6 +109289,7 @@ + @@ -105863,6 +109312,17 @@ + + + + + + + + + + + @@ -107113,101 +110573,93 @@ - - - - - - - - - - - - - + - - - - - - + + + + - - - - - - - - - - - + + + + + - - - + + + + + - - - - + + + + + + + + + + + - - - - - - + + + - - - - - + + + + - - - - - + + + + + + - - - - + + + + + - - - - - - + + + + + - - - - - - + + + + - + + + + + + + + + @@ -107215,40 +110667,48 @@ - - - - - - + + + + + + - - - - + + + + + + - - - - - + + + + - - - - - + + + + + - - - - - - + + + + + + + + + + + + + @@ -107263,15 +110723,15 @@ - - - - + + + + - - - + + + @@ -107286,45 +110746,45 @@ - - - - + + + + - - - + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - + + + + - - - - + + + + @@ -107342,161 +110802,161 @@ - - - - - - - + + + + + + + - - - - - - + + + + + + - - - + + + - - - - + + + + - - - + + + - - - - - + + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - + + + + - - - - - - - - + + + + + + + + - - - + + + - - - - + + + + - - - - + + + + - - - - - - - + + + + + + + - - - - + + + + - - - - - + + + + + @@ -107505,50 +110965,50 @@ - - - - + + + + - - - - + + + + - - - + + + - - - + + + - - - - + + + + - - - - + + + + - - - + + + - - - - - + + + + + @@ -107557,62 +111017,62 @@ - - - - - - - + + + + + + + - - - - + + + + - - - - - - - - + + + + + + + + - - - - - + + + + + - - - + + + - - - - - + + + + + - - - - - - + + + + + + - - - - + + + + @@ -107633,10 +111093,10 @@ - - - - + + + + @@ -107645,17 +111105,17 @@ - - - - - - + + + + + + - - - + + + @@ -107692,76 +111152,76 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + - - - + + + + - - - + + + + + + - - - - - + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -107917,102 +111377,102 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - + - - + + - - - - - - - - - - - + + + + + + + + + + + diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 3607c500f192..8ddb3f6664fc 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -5,6 +5,28 @@ * * Copyright 2020 Google LLC */ +#ifndef __GENKSYMS__ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include <../drivers/net/wireless/intel/ipw2x00/libipw.h> +#include <../fs/mount.h> +#include <../fs/kernfs/kernfs-internal.h> +#include <../kernel/audit.h> +#include <../net/can/af_can.h> +#include <../net/tipc/bearer.h> +#include <../net/xdp/xsk_queue.h> +#include <../security/keys/internal.h> +#endif #define CREATE_TRACE_POINTS #include diff --git a/include/trace/hooks/binder.h b/include/trace/hooks/binder.h index 001780156c5d..c46264c38dde 100644 --- a/include/trace/hooks/binder.h +++ b/include/trace/hooks/binder.h @@ -10,7 +10,6 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct binder_alloc; struct binder_proc; struct binder_thread; @@ -18,18 +17,7 @@ struct binder_transaction; struct task_struct; struct seq_file; struct binder_transaction_data; -#else -/* struct binder_alloc */ -#include <../drivers/android/binder_alloc.h> -/* struct binder_proc, struct binder_thread, struct binder_transaction */ -#include <../drivers/android/binder_internal.h> -/* struct task_struct */ -#include -/* struct seq_file */ -#include -/* struct binder_transaction_data */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_binder_transaction_init, TP_PROTO(struct binder_transaction *t), TP_ARGS(t)); diff --git a/include/trace/hooks/block.h b/include/trace/hooks/block.h index 0828a306ea13..e8bee374f989 100644 --- a/include/trace/hooks/block.h +++ b/include/trace/hooks/block.h @@ -9,18 +9,9 @@ #include -#ifdef __GENKSYMS__ struct blk_mq_tags; struct blk_mq_alloc_data; struct blk_mq_tag_set; -#else -/* struct blk_mq_tags */ -#include <../block/blk-mq-tag.h> -/* struct blk_mq_alloc_data */ -#include <../block/blk-mq.h> -/* struct blk_mq_tag_set */ -#include -#endif /* __GENKSYMS__ */ DECLARE_HOOK(android_vh_blk_alloc_rqs, TP_PROTO(size_t *rq_size, struct blk_mq_tag_set *set, diff --git a/include/trace/hooks/cgroup.h b/include/trace/hooks/cgroup.h index 5546d390cb50..116a2afabf99 100644 --- a/include/trace/hooks/cgroup.h +++ b/include/trace/hooks/cgroup.h @@ -7,18 +7,10 @@ #define _TRACE_HOOK_CGROUP_H #include -#ifdef __GENKSYMS__ struct cgroup_taskset; struct cgroup_subsys; struct task_struct; -#else -/* Including ../kernel/cgroup/cgroup-internal.h breaks builds. */ -struct cgroup_taskset; -/* struct cgroup_subsys */ -#include -/* struct task_struct */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_cgroup_set_task, TP_PROTO(int ret, struct task_struct *task), TP_ARGS(ret, task)); diff --git a/include/trace/hooks/cpufreq.h b/include/trace/hooks/cpufreq.h index 70f90a3ef25c..2739a0f9a547 100644 --- a/include/trace/hooks/cpufreq.h +++ b/include/trace/hooks/cpufreq.h @@ -6,10 +6,15 @@ #if !defined(_TRACE_HOOK_CPUFREQ_H) || defined(TRACE_HEADER_MULTI_READ) #define _TRACE_HOOK_CPUFREQ_H - -#include #include +#ifdef __GENKSYMS__ +#include +#endif + +struct cpufreq_policy; +struct task_struct; + DECLARE_HOOK(android_vh_show_max_freq, TP_PROTO(struct cpufreq_policy *policy, unsigned int *max_freq), TP_ARGS(policy, max_freq)); diff --git a/include/trace/hooks/cpuidle.h b/include/trace/hooks/cpuidle.h index 9addbdf32913..c2ddabe37b00 100644 --- a/include/trace/hooks/cpuidle.h +++ b/include/trace/hooks/cpuidle.h @@ -9,12 +9,7 @@ #include -#ifdef __GENKSYMS__ struct cpuidle_device; -#else -/* struct cpuidle_device */ -#include -#endif /* __GENKSYMS__ */ DECLARE_HOOK(android_vh_cpu_idle_enter, TP_PROTO(int *state, struct cpuidle_device *dev), diff --git a/include/trace/hooks/cpuidle_psci.h b/include/trace/hooks/cpuidle_psci.h index 4881f35712c0..3ca307a3d82b 100644 --- a/include/trace/hooks/cpuidle_psci.h +++ b/include/trace/hooks/cpuidle_psci.h @@ -10,12 +10,8 @@ * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct cpuidle_device; -#else -/* struct cpuidle_device */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_cpuidle_psci_enter, TP_PROTO(struct cpuidle_device *dev, bool s2idle), TP_ARGS(dev, s2idle)); diff --git a/include/trace/hooks/creds.h b/include/trace/hooks/creds.h index 9544ee2e827c..12f92be91c24 100644 --- a/include/trace/hooks/creds.h +++ b/include/trace/hooks/creds.h @@ -10,15 +10,9 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct cred; struct task_struct; -#else -/* struct cred */ -#include -/* struct task_struct */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_commit_creds, TP_PROTO(const struct task_struct *task, const struct cred *new), TP_ARGS(task, new)); diff --git a/include/trace/hooks/debug.h b/include/trace/hooks/debug.h index 58ec198ceb6d..5a20141d742b 100644 --- a/include/trace/hooks/debug.h +++ b/include/trace/hooks/debug.h @@ -9,12 +9,7 @@ #include -#ifdef __GENKSYMS__ struct pt_regs; -#else -/* struct pt_regs */ -#include -#endif /* __GENKSYMS__ */ DECLARE_HOOK(android_vh_ipi_stop, TP_PROTO(struct pt_regs *regs), diff --git a/include/trace/hooks/dtask.h b/include/trace/hooks/dtask.h index be037865cdbc..749dc5b4078b 100644 --- a/include/trace/hooks/dtask.h +++ b/include/trace/hooks/dtask.h @@ -10,21 +10,11 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct mutex; struct rt_mutex; struct rw_semaphore; struct task_struct; -#else -/* struct mutex */ -#include -/* struct rt_mutex */ -#include -/* struct rw_semaphore */ -#include -/* struct task_struct */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_mutex_wait_start, TP_PROTO(struct mutex *lock), TP_ARGS(lock)); diff --git a/include/trace/hooks/fault.h b/include/trace/hooks/fault.h index 920772177bb0..1b6e0b0911f5 100644 --- a/include/trace/hooks/fault.h +++ b/include/trace/hooks/fault.h @@ -10,12 +10,8 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct pt_regs; -#else -/* struct pt_regs */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_RESTRICTED_HOOK(android_rvh_die_kernel_fault, TP_PROTO(struct pt_regs *regs, unsigned int esr, unsigned long addr, const char *msg), TP_ARGS(regs, esr, addr, msg), 1); diff --git a/include/trace/hooks/fips140.h b/include/trace/hooks/fips140.h index 6a777771a6c8..fd4a42c013c7 100644 --- a/include/trace/hooks/fips140.h +++ b/include/trace/hooks/fips140.h @@ -7,12 +7,7 @@ #define _TRACE_HOOK_FIPS140_H #include -#ifdef __GENKSYMS__ struct crypto_aes_ctx; -#else -/* struct crypto_aes_ctx */ -#include -#endif /* __GENKSYMS__ */ /* * These hooks exist only for the benefit of the FIPS140 crypto module, which diff --git a/include/trace/hooks/ftrace_dump.h b/include/trace/hooks/ftrace_dump.h index b63d9c809426..0594e8bee2e2 100644 --- a/include/trace/hooks/ftrace_dump.h +++ b/include/trace/hooks/ftrace_dump.h @@ -6,11 +6,14 @@ #if !defined(_TRACE_HOOK_FTRACE_DUMP_H) || defined(TRACE_HEADER_MULTI_READ) #define _TRACE_HOOK_FTRACE_DUMP_H +#include +#ifdef __GENKSYMS__ #include #include +#endif -#include +struct trace_seq; DECLARE_HOOK(android_vh_ftrace_oops_enter, TP_PROTO(bool *ftrace_check), diff --git a/include/trace/hooks/gic_v3.h b/include/trace/hooks/gic_v3.h index 8db98581eebc..647514f8d7a4 100644 --- a/include/trace/hooks/gic_v3.h +++ b/include/trace/hooks/gic_v3.h @@ -9,15 +9,9 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct cpumask; struct irq_data; -#else -/* struct cpumask */ -#include -/* struct irq_data */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_gic_v3_affinity_init, TP_PROTO(int irq, u32 offset, u64 *affinity), TP_ARGS(irq, offset, affinity)); diff --git a/include/trace/hooks/gpiolib.h b/include/trace/hooks/gpiolib.h index 307fbaa2cae0..20115981de55 100644 --- a/include/trace/hooks/gpiolib.h +++ b/include/trace/hooks/gpiolib.h @@ -8,7 +8,12 @@ #define _TRACE_HOOK_GPIOLIB_H #include + +#ifdef __GENKSYMS__ #include "../drivers/gpio/gpiolib.h" +#endif + +struct gpio_device; DECLARE_HOOK(android_vh_gpio_block_read, TP_PROTO(struct gpio_device *gdev, bool *block_gpio_read), diff --git a/include/trace/hooks/gup.h b/include/trace/hooks/gup.h index 3135cd538a92..47ea47eeede4 100644 --- a/include/trace/hooks/gup.h +++ b/include/trace/hooks/gup.h @@ -7,12 +7,7 @@ #define _TRACE_HOOK_GUP_H #include -#ifdef __GENKSYMS__ struct page; -#else -/* struct page */ -#include -#endif /* __GENKSYMS__ */ DECLARE_HOOK(android_vh_try_grab_compound_head, TP_PROTO(struct page *page, int refs, unsigned int flags, bool *ret), diff --git a/include/trace/hooks/logbuf.h b/include/trace/hooks/logbuf.h index caec0d062476..c5ad3ba85174 100644 --- a/include/trace/hooks/logbuf.h +++ b/include/trace/hooks/logbuf.h @@ -9,13 +9,8 @@ #include -#ifdef __GENKSYMS__ struct printk_record; struct printk_ringbuffer; -#else -/* struct printk_record, struct printk_ringbuffer */ -#include <../kernel/printk/printk_ringbuffer.h> -#endif /* __GENKSYMS__ */ DECLARE_HOOK(android_vh_logbuf, TP_PROTO(struct printk_ringbuffer *rb, struct printk_record *r), diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index 9e8f234545b1..c3113e14e847 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -8,30 +8,20 @@ #define _TRACE_HOOK_MM_H #include - -#include -#include #include #ifdef __GENKSYMS__ +#include +#include +#endif + +struct oom_control; struct cma; struct acr_info; struct compact_control; struct slabinfo; struct cgroup_subsys_state; struct mem_cgroup; -#else -/* struct compact_control */ -#include <../mm/internal.h> -/* struct slabinfo */ -#include <../mm/slab.h> -/* struct cgroup_subsys_state */ -#include -/* struct acr_info */ -#include -/* struct mem_cgroup */ -#include -#endif /* __GENKSYMS__ */ struct cma; struct acr_info; diff --git a/include/trace/hooks/mmc_core.h b/include/trace/hooks/mmc_core.h index 1889cc54a2b3..c59b4accc9fd 100644 --- a/include/trace/hooks/mmc_core.h +++ b/include/trace/hooks/mmc_core.h @@ -9,18 +9,9 @@ #include -#ifdef __GENKSYMS__ struct sdhci_host; struct mmc_card; struct mmc_host; -#else -/* struct sdhci_host */ -#include <../drivers/mmc/host/sdhci.h> -/* struct mmc_card */ -#include -/* struct mmc_host */ -#include -#endif /* __GENKSYMS__ */ DECLARE_HOOK(android_vh_mmc_blk_reset, TP_PROTO(struct mmc_host *host, int err, bool *allow), diff --git a/include/trace/hooks/mpam.h b/include/trace/hooks/mpam.h index f7f5e468bcef..06b96b1309f8 100644 --- a/include/trace/hooks/mpam.h +++ b/include/trace/hooks/mpam.h @@ -10,12 +10,8 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct task_struct; -#else -/* struct task_struct */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_mpam_set, TP_PROTO(struct task_struct *prev, struct task_struct *next), TP_ARGS(prev, next)); diff --git a/include/trace/hooks/net.h b/include/trace/hooks/net.h index 97f15ba6ae3c..4fcd632b2f96 100644 --- a/include/trace/hooks/net.h +++ b/include/trace/hooks/net.h @@ -8,24 +8,12 @@ #define _TRACE_HOOK_NET_VH_H #include -#ifdef __GENKSYMS__ struct packet_type; struct sk_buff; struct list_head; struct nf_conn; struct sock; -#else -/* struct packet_type */ -#include -/* struct sk_buff */ -#include -/* struct list_head */ -#include -/* struct nf_conn */ -#include -/* struct sock */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_ptype_head, TP_PROTO(const struct packet_type *pt, struct list_head *vendor_pt), TP_ARGS(pt, vendor_pt)); diff --git a/include/trace/hooks/pci.h b/include/trace/hooks/pci.h index 00d38980ec49..40255448c83c 100644 --- a/include/trace/hooks/pci.h +++ b/include/trace/hooks/pci.h @@ -6,6 +6,9 @@ #if !defined(_TRACE_HOOK_PCI_H) || defined(TRACE_HEADER_MULTI_READ) #define _TRACE_HOOK_PCI_H #include + +struct pci_dev; + /* * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality diff --git a/include/trace/hooks/pm_domain.h b/include/trace/hooks/pm_domain.h index 1a8ce26ccc3d..eaee85b9c00c 100644 --- a/include/trace/hooks/pm_domain.h +++ b/include/trace/hooks/pm_domain.h @@ -10,12 +10,8 @@ #include -#ifdef __GENKSYMS__ struct generic_pm_domain; -#else -/* struct generic_pm_domain */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_allow_domain_state, TP_PROTO(struct generic_pm_domain *genpd, uint32_t idx, bool *allow), TP_ARGS(genpd, idx, allow)) diff --git a/include/trace/hooks/power.h b/include/trace/hooks/power.h index 3c735b7a5abd..f9b7bbec1531 100644 --- a/include/trace/hooks/power.h +++ b/include/trace/hooks/power.h @@ -10,17 +10,14 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ -enum freq_qos_req_type; + +/* needed for enum freq_qos_req_types */ +#include + struct freq_constraints; struct freq_qos_request; struct task_struct; -#else -/* enum freq_qos_req_type, struct freq_constraints, struct freq_qos_request */ -#include -/* struct task_struct */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_try_to_freeze_todo, TP_PROTO(unsigned int todo, unsigned int elapsed_msecs, bool wq_busy), TP_ARGS(todo, elapsed_msecs, wq_busy)); diff --git a/include/trace/hooks/psi.h b/include/trace/hooks/psi.h index 32c7a273c5e2..deeb3dfbeeb0 100644 --- a/include/trace/hooks/psi.h +++ b/include/trace/hooks/psi.h @@ -9,13 +9,9 @@ #include -#ifdef __GENKSYMS__ struct psi_group; struct psi_trigger; -#else -/* struct psi_group, struct psi_trigger */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_psi_event, TP_PROTO(struct psi_trigger *t), TP_ARGS(t)); diff --git a/include/trace/hooks/remoteproc.h b/include/trace/hooks/remoteproc.h index 4d3311b1fee4..ee0a2f0ea147 100644 --- a/include/trace/hooks/remoteproc.h +++ b/include/trace/hooks/remoteproc.h @@ -9,12 +9,7 @@ #include -#ifdef __GENKSYMS__ struct rproc; -#else -/* struct rproc */ -#include -#endif /* __GENKSYMS__ */ DECLARE_HOOK(android_vh_rproc_recovery, TP_PROTO(struct rproc *rproc), diff --git a/include/trace/hooks/rwsem.h b/include/trace/hooks/rwsem.h index 3d6877f166ed..e3fd21729eee 100644 --- a/include/trace/hooks/rwsem.h +++ b/include/trace/hooks/rwsem.h @@ -9,13 +9,9 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct rw_semaphore; struct rwsem_waiter; -#else -/* struct rw_semaphore, struct rwsem_waiter */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_rwsem_init, TP_PROTO(struct rw_semaphore *sem), TP_ARGS(sem)); diff --git a/include/trace/hooks/sched.h b/include/trace/hooks/sched.h index 3a8eee2345af..4f345029ea09 100644 --- a/include/trace/hooks/sched.h +++ b/include/trace/hooks/sched.h @@ -9,7 +9,6 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct cgroup_taskset; struct cgroup_subsys_state; struct cpufreq_policy; @@ -18,20 +17,7 @@ enum uclamp_id; struct sched_entity; struct task_struct; struct uclamp_se; -#else -/* Including ../kernel/cgroup/cgroup-internal.h breaks builds. */ -struct cgroup_taskset; -/* struct cgroup_subsys_state */ -#include -/* struct cpufreq_policy */ -#include -/* struct em_perf_domain */ -#include -/* enum uclamp_id, struct sched_entity, struct task_struct, struct uclamp_se */ -#include -/* Only defined with CONFIG_UCLAMP_TASK, so declare unconditionally. */ -struct uclamp_se; -#endif /* __GENKSYMS__ */ + DECLARE_RESTRICTED_HOOK(android_rvh_select_task_rq_fair, TP_PROTO(struct task_struct *p, int prev_cpu, int sd_flag, int wake_flags, int *new_cpu), TP_ARGS(p, prev_cpu, sd_flag, wake_flags, new_cpu), 1); diff --git a/include/trace/hooks/shmem_fs.h b/include/trace/hooks/shmem_fs.h index adfd05825928..29c45d1e0571 100644 --- a/include/trace/hooks/shmem_fs.h +++ b/include/trace/hooks/shmem_fs.h @@ -7,12 +7,8 @@ #define _TRACE_HOOK_SHMEM_FS_H #include -#ifdef __GENKSYMS__ struct page; -#else -/* struct page */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_shmem_alloc_page, TP_PROTO(struct page **page), TP_ARGS(page)); diff --git a/include/trace/hooks/signal.h b/include/trace/hooks/signal.h index 04976ed38cc7..6338274f27c4 100644 --- a/include/trace/hooks/signal.h +++ b/include/trace/hooks/signal.h @@ -7,12 +7,8 @@ #define _TRACE_HOOK_SIGNAL_H #include -#ifdef __GENKSYMS__ struct task_struct; -#else -/* struct task_struct */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_do_send_sig_info, TP_PROTO(int sig, struct task_struct *killer, struct task_struct *dst), TP_ARGS(sig, killer, dst)); diff --git a/include/trace/hooks/softlockup.h b/include/trace/hooks/softlockup.h index d90571a3f0fc..d9806aeb5aa8 100644 --- a/include/trace/hooks/softlockup.h +++ b/include/trace/hooks/softlockup.h @@ -10,12 +10,8 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct pt_regs; -#else -/* struct pt_regs */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_watchdog_timer_softlockup, TP_PROTO(int duration, struct pt_regs *regs, bool is_panic), TP_ARGS(duration, regs, is_panic)); diff --git a/include/trace/hooks/sys.h b/include/trace/hooks/sys.h index 819a126ce0ae..a14bd4135410 100644 --- a/include/trace/hooks/sys.h +++ b/include/trace/hooks/sys.h @@ -7,12 +7,8 @@ #define _TRACE_HOOK_SYS_H #include -#ifdef __GENKSYMS__ struct task_struct; -#else -/* struct task_struct */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_syscall_prctl_finished, TP_PROTO(int option, struct task_struct *task), TP_ARGS(option, task)); diff --git a/include/trace/hooks/syscall_check.h b/include/trace/hooks/syscall_check.h index aa563ad1c510..c906ff6b8e7f 100644 --- a/include/trace/hooks/syscall_check.h +++ b/include/trace/hooks/syscall_check.h @@ -10,15 +10,9 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct file; union bpf_attr; -#else -/* struct file */ -#include -/* union bpf_attr */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_check_mmap_file, TP_PROTO(const struct file *file, unsigned long prot, unsigned long flag, unsigned long ret), diff --git a/include/trace/hooks/thermal.h b/include/trace/hooks/thermal.h index e9a9a4ae3e07..97074725fb08 100644 --- a/include/trace/hooks/thermal.h +++ b/include/trace/hooks/thermal.h @@ -10,12 +10,8 @@ #include #include -#ifdef __GENKSYMS__ struct thermal_zone_device; -#else -/* struct thermal_zone_device */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_enable_thermal_genl_check, TP_PROTO(int event, int tz_id, int *enable_thermal_genl), TP_ARGS(event, tz_id, enable_thermal_genl)); diff --git a/include/trace/hooks/topology.h b/include/trace/hooks/topology.h index 5d29893ba477..e924c97ab4d9 100644 --- a/include/trace/hooks/topology.h +++ b/include/trace/hooks/topology.h @@ -8,7 +8,12 @@ #define _TRACE_HOOK_TOPOLOGY_H #include + +#ifdef __GENKSYMS__ #include +#endif + +struct cpumask; DECLARE_HOOK(android_vh_arch_set_freq_scale, TP_PROTO(const struct cpumask *cpus, unsigned long freq, diff --git a/include/trace/hooks/traps.h b/include/trace/hooks/traps.h index 6b9b986f7a30..f0ede1e69b15 100644 --- a/include/trace/hooks/traps.h +++ b/include/trace/hooks/traps.h @@ -10,12 +10,8 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct pt_regs; -#else -/* struct pt_regs */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_RESTRICTED_HOOK(android_rvh_do_undefinstr, TP_PROTO(struct pt_regs *regs, bool user), TP_ARGS(regs, user), diff --git a/include/trace/hooks/ufshcd.h b/include/trace/hooks/ufshcd.h index 32a7f98da4c1..ad2c067f02c4 100644 --- a/include/trace/hooks/ufshcd.h +++ b/include/trace/hooks/ufshcd.h @@ -9,20 +9,11 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct ufs_hba; struct ufshcd_lrb; struct uic_command; struct request; struct scsi_device; -#else -/* struct ufs_hba, struct ufshcd_lrb, struct uic_command */ -#include <../drivers/scsi/ufs/ufshcd.h> -/* struct request */ -#include -/* struct scsi_device */ -#include -#endif /* __GENKSYMS__ */ DECLARE_HOOK(android_vh_ufs_fill_prdt, TP_PROTO(struct ufs_hba *hba, struct ufshcd_lrb *lrbp, diff --git a/include/trace/hooks/usb.h b/include/trace/hooks/usb.h index f4d5ff04b6b8..3a22a2971c24 100644 --- a/include/trace/hooks/usb.h +++ b/include/trace/hooks/usb.h @@ -5,8 +5,14 @@ #define TRACE_INCLUDE_PATH trace/hooks #if !defined(_TRACE_HOOK_USB_H) || defined(TRACE_HEADER_MULTI_READ) #define _TRACE_HOOK_USB_H -#include #include + +#ifdef __GENKSYMS__ +#include +#endif + +struct usb_device; + /* * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality diff --git a/include/trace/hooks/user.h b/include/trace/hooks/user.h index 6a39785a52e1..1a41c12edd58 100644 --- a/include/trace/hooks/user.h +++ b/include/trace/hooks/user.h @@ -7,12 +7,8 @@ #define _TRACE_HOOK_USER_H #include -#ifdef __GENKSYMS__ struct user_struct; -#else -/* struct user_struct */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_alloc_uid, TP_PROTO(struct user_struct *user), TP_ARGS(user)); diff --git a/include/trace/hooks/v4l2core.h b/include/trace/hooks/v4l2core.h index 3dec47042a86..e209621cd66c 100644 --- a/include/trace/hooks/v4l2core.h +++ b/include/trace/hooks/v4l2core.h @@ -9,7 +9,6 @@ #include -#ifdef __GENKSYMS__ struct v4l2_subdev; struct v4l2_subdev_pad_config; struct v4l2_subdev_format; @@ -17,14 +16,7 @@ struct v4l2_subdev_frame_interval; struct v4l2_subdev_selection; struct v4l2_fmtdesc; struct v4l2_format; -#else -/* struct v4l2_subdev, struct v4l2_subdev_pad_config */ -#include -/* struct v4l2_subdev_format, struct v4l2_subdev_frame_interval, struct v4l2_subdev_selection */ -#include -/* struct v4l2_fmtdesc, struct v4l2_format */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_clear_reserved_fmt_fields, TP_PROTO(struct v4l2_format *fmt, int *ret), TP_ARGS(fmt, ret)); diff --git a/include/trace/hooks/v4l2mc.h b/include/trace/hooks/v4l2mc.h index 332a3a09680d..cafc74f14e9b 100644 --- a/include/trace/hooks/v4l2mc.h +++ b/include/trace/hooks/v4l2mc.h @@ -9,15 +9,9 @@ #include -#ifdef __GENKSYMS__ struct media_link; struct media_link_desc; -#else -/* struct media_link */ -#include -/* struct media_link_desc */ -#include -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_media_device_setup_link, TP_PROTO(struct media_link *link, struct media_link_desc *linkd, int *ret), TP_ARGS(link, linkd, ret)); diff --git a/include/trace/hooks/workqueue.h b/include/trace/hooks/workqueue.h index 3d6d0d61040d..284b3ff86fa8 100644 --- a/include/trace/hooks/workqueue.h +++ b/include/trace/hooks/workqueue.h @@ -10,12 +10,8 @@ * Following tracepoints are not exported in tracefs and provide a * mechanism for vendor modules to hook and extend functionality */ -#ifdef __GENKSYMS__ struct worker; -#else -/* struct worker */ -#include <../kernel/workqueue_internal.h> -#endif /* __GENKSYMS__ */ + DECLARE_HOOK(android_vh_create_worker, TP_PROTO(struct worker *worker, struct workqueue_attrs *attrs), TP_ARGS(worker, attrs)); From ee742bccf646e249fbcc4d635ee71649ff915205 Mon Sep 17 00:00:00 2001 From: Ziyi Cui Date: Thu, 25 Aug 2022 17:55:19 +0000 Subject: [PATCH 076/124] ANDROID: power: fix vendor hook in suspend.c Fix the position of the trace point. Bug: 241946090 Fixes: 737a5314c9f3 ("ANDROID: power: Add vendor hook for suspend") Signed-off-by: Ziyi Cui Change-Id: I8bf231ee35e0c0ebcb35722f4c527ab61116901e --- kernel/power/suspend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 731e79844739..e4c5dcf91033 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -440,7 +440,6 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) BUG_ON(!irqs_disabled()); system_state = SYSTEM_SUSPEND; - trace_android_vh_early_resume_begin(NULL); error = syscore_suspend(); if (!error) { *wakeup = pm_wakeup_pending(); @@ -450,6 +449,7 @@ static int suspend_enter(suspend_state_t state, bool *wakeup) error = suspend_ops->enter(state); trace_suspend_resume(TPS("machine_suspend"), state, false); + trace_android_vh_early_resume_begin(NULL); } else if (*wakeup) { error = -EBUSY; } From 790fa51f7bd2f9e464a845bb0caabe1bf0f7fde8 Mon Sep 17 00:00:00 2001 From: Sean Christopherson Date: Fri, 11 Mar 2022 03:27:41 +0000 Subject: [PATCH 077/124] BACKPORT: KVM: x86: avoid calling x86 emulator without a decoded instruction commit fee060cd52d69c114b62d1a2948ea9648b5131f9 upstream. Whenever x86_decode_emulated_instruction() detects a breakpoint, it returns the value that kvm_vcpu_check_breakpoint() writes into its pass-by-reference second argument. Unfortunately this is completely bogus because the expected outcome of x86_decode_emulated_instruction is an EMULATION_* value. Then, if kvm_vcpu_check_breakpoint() does "*r = 0" (corresponding to a KVM_EXIT_DEBUG userspace exit), it is misunderstood as EMULATION_OK and x86_emulate_instruction() is called without having decoded the instruction. This causes various havoc from running with a stale emulation context. The fix is to move the call to kvm_vcpu_check_breakpoint() where it was before commit 4aa2691dcbd3 ("KVM: x86: Factor out x86 instruction emulation with decoding") introduced x86_decode_emulated_instruction(). The other caller of the function does not need breakpoint checks, because it is invoked as part of a vmexit and the processor has already checked those before executing the instruction that #GP'd. This fixes CVE-2022-1852. Bug: 235183128 Reported-by: Qiuhao Li Reported-by: Gaoning Pan Reported-by: Yongkang Jia Fixes: 4aa2691dcbd3 ("KVM: x86: Factor out x86 instruction emulation with decoding") Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson Message-Id: <20220311032801.3467418-2-seanjc@google.com> [Rewrote commit message according to Qiuhao's report, since a patch already existed to fix the bug. - Paolo] Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Change-Id: I3acbb7fc23566c4108f15960c420384af52c2703 --- arch/x86/kvm/x86.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a5d6d79b023b..0ecdb3a81f95 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -7289,7 +7289,7 @@ int kvm_skip_emulated_instruction(struct kvm_vcpu *vcpu) } EXPORT_SYMBOL_GPL(kvm_skip_emulated_instruction); -static bool kvm_vcpu_check_breakpoint(struct kvm_vcpu *vcpu, int *r) +static bool kvm_vcpu_check_code_breakpoint(struct kvm_vcpu *vcpu, int *r) { if (unlikely(vcpu->guest_debug & KVM_GUESTDBG_USE_HW_BP) && (vcpu->arch.guest_debug_dr7 & DR7_BP_EN_MASK)) { @@ -7358,25 +7358,23 @@ static bool is_vmware_backdoor_opcode(struct x86_emulate_ctxt *ctxt) } /* - * Decode to be emulated instruction. Return EMULATION_OK if success. + * Decode an instruction for emulation. The caller is responsible for handling + * code breakpoints. Note, manually detecting code breakpoints is unnecessary + * (and wrong) when emulating on an intercepted fault-like exception[*], as + * code breakpoints have higher priority and thus have already been done by + * hardware. + * + * [*] Except #MC, which is higher priority, but KVM should never emulate in + * response to a machine check. */ int x86_decode_emulated_instruction(struct kvm_vcpu *vcpu, int emulation_type, void *insn, int insn_len) { - int r = EMULATION_OK; struct x86_emulate_ctxt *ctxt = vcpu->arch.emulate_ctxt; + int r; init_emulate_ctxt(vcpu); - /* - * We will reenter on the same instruction since we do not set - * complete_userspace_io. This does not handle watchpoints yet, - * those would be handled in the emulate_ops. - */ - if (!(emulation_type & EMULTYPE_SKIP) && - kvm_vcpu_check_breakpoint(vcpu, &r)) - return r; - ctxt->ud = emulation_type & EMULTYPE_TRAP_UD; r = x86_decode_insn(ctxt, insn, insn_len); @@ -7411,6 +7409,15 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, if (!(emulation_type & EMULTYPE_NO_DECODE)) { kvm_clear_exception_queue(vcpu); + /* + * Return immediately if RIP hits a code breakpoint, such #DBs + * are fault-like and are higher priority than any faults on + * the code fetch itself. + */ + if (!(emulation_type & EMULTYPE_SKIP) && + kvm_vcpu_check_code_breakpoint(vcpu, &r)) + return r; + r = x86_decode_emulated_instruction(vcpu, emulation_type, insn, insn_len); if (r != EMULATION_OK) { From b5fe8c470e8528e85aba5471218ef9fb656ec6aa Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 26 May 2022 07:34:52 +0100 Subject: [PATCH 078/124] BACKPORT: pipe: Fix missing lock in pipe_resize_ring() commit 189b0ddc245139af81198d1a3637cac74f96e13a upstream. pipe_resize_ring() needs to take the pipe->rd_wait.lock spinlock to prevent post_one_notification() from trying to insert into the ring whilst the ring is being replaced. The occupancy check must be done after the lock is taken, and the lock must be taken after the new ring is allocated. The bug can lead to an oops looking something like: BUG: KASAN: use-after-free in post_one_notification.isra.0+0x62e/0x840 Read of size 4 at addr ffff88801cc72a70 by task poc/27196 ... Call Trace: post_one_notification.isra.0+0x62e/0x840 __post_watch_notification+0x3b7/0x650 key_create_or_update+0xb8b/0xd20 __do_sys_add_key+0x175/0x340 __x64_sys_add_key+0xbe/0x140 do_syscall_64+0x5c/0xc0 entry_SYSCALL_64_after_hwframe+0x44/0xae Reported by Selim Enes Karaduman @Enesdex working with Trend Micro Zero Day Initiative. Bug: 244395411 Fixes: c73be61cede5 ("pipe: Add general notification queue support") Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-17291 Signed-off-by: David Howells Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Change-Id: I129164eb9dba557d5a4370f4eca124b9916774a6 --- fs/pipe.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/fs/pipe.c b/fs/pipe.c index 9f2ca1b1c17a..434b0a274468 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -1244,30 +1244,33 @@ unsigned int round_pipe_size(unsigned long size) /* * Resize the pipe ring to a number of slots. + * + * Note the pipe can be reduced in capacity, but only if the current + * occupancy doesn't exceed nr_slots; if it does, EBUSY will be + * returned instead. */ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots) { struct pipe_buffer *bufs; unsigned int head, tail, mask, n; - /* - * We can shrink the pipe, if arg is greater than the ring occupancy. - * Since we don't expect a lot of shrink+grow operations, just free and - * allocate again like we would do for growing. If the pipe currently - * contains more buffers than arg, then return busy. - */ - mask = pipe->ring_size - 1; - head = pipe->head; - tail = pipe->tail; - n = pipe_occupancy(pipe->head, pipe->tail); - if (nr_slots < n) - return -EBUSY; - bufs = kcalloc(nr_slots, sizeof(*bufs), GFP_KERNEL_ACCOUNT | __GFP_NOWARN); if (unlikely(!bufs)) return -ENOMEM; + spin_lock_irq(&pipe->rd_wait.lock); + mask = pipe->ring_size - 1; + head = pipe->head; + tail = pipe->tail; + + n = pipe_occupancy(head, tail); + if (nr_slots < n) { + spin_unlock_irq(&pipe->rd_wait.lock); + kfree(bufs); + return -EBUSY; + } + /* * The pipe array wraps around, so just start the new one at zero * and adjust the indices. @@ -1299,6 +1302,8 @@ int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots) pipe->tail = tail; pipe->head = head; + spin_unlock_irq(&pipe->rd_wait.lock); + /* This might have made more room for writers */ wake_up_interruptible(&pipe->wr_wait); return 0; From 952141fb9237ec54cda66e04622725daae29d273 Mon Sep 17 00:00:00 2001 From: Sarthak Kukreti Date: Tue, 31 May 2022 15:56:40 -0400 Subject: [PATCH 079/124] BACKPORT: dm verity: set DM_TARGET_IMMUTABLE feature flag commit 4caae58406f8ceb741603eee460d79bacca9b1b5 upstream. The device-mapper framework provides a mechanism to mark targets as immutable (and hence fail table reloads that try to change the target type). Add the DM_TARGET_IMMUTABLE flag to the dm-verity target's feature flags to prevent switching the verity target with a different target type. Bug: 234475629 Fixes: a4ffc152198e ("dm: add verity target") Cc: stable@vger.kernel.org Signed-off-by: Sarthak Kukreti Reviewed-by: Kees Cook Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Change-Id: Iaeec7fa3be98a646062439e4551f84242dacfb45 --- drivers/md/dm-verity-target.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index 9d5c6dd5b756..2c355b58d078 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -1252,6 +1252,7 @@ bad: static struct target_type verity_target = { .name = "verity", .version = {1, 7, 0}, + .features = DM_TARGET_IMMUTABLE, .module = THIS_MODULE, .ctr = verity_ctr, .dtr = verity_dtr, From d1b29856cad674e59a182e45983ed1abf4f5489d Mon Sep 17 00:00:00 2001 From: Soukjin Bae Date: Tue, 13 Sep 2022 07:51:58 +0900 Subject: [PATCH 080/124] ANDROID: net: export symbol for tracepoint_consume_skb Need to use the tracepoint_consume_skb symbol at module driver Bug: 244504166 Link: https://lore.kernel.org/lkml/20220617200021.02ad8ffc@kernel.org/T Signed-off-by: Soukjin Bae Change-Id: Icffa3e7d2045156691a7711c5f19b309f8356261 --- net/core/net-traces.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/core/net-traces.c b/net/core/net-traces.c index 465362a9b55d..42f242394135 100644 --- a/net/core/net-traces.c +++ b/net/core/net-traces.c @@ -54,6 +54,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(neigh_event_send_dead); EXPORT_TRACEPOINT_SYMBOL_GPL(neigh_cleanup_and_release); EXPORT_TRACEPOINT_SYMBOL_GPL(kfree_skb); +EXPORT_TRACEPOINT_SYMBOL_GPL(consume_skb); EXPORT_TRACEPOINT_SYMBOL_GPL(napi_poll); From 185f60f2bbabcda5dc7e10a241016cba20b6e949 Mon Sep 17 00:00:00 2001 From: Robin Peng Date: Thu, 15 Sep 2022 09:20:23 +0800 Subject: [PATCH 081/124] ANDROID: add forward declaration vm_unmapped_area_info aosp/2215503 remove inclusions from hook definition headers and build breakage detected on pixel device. include/trace/hooks/mm.h:80:40: error: declaration of 'struct vm_unmapped_area_info' will not be visible outside of this function Fix this by adding struct vm_unmapped_area_info forward declaration. Fixes: 7108d9d0e5f2 ("ANDROID: remove inclusions from hook definition headers") Bug: 233047575 Signed-off-by: Robin Peng Change-Id: I8989ba78977a26e13c79f9efb156bf8317c1010e --- include/trace/hooks/mm.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/trace/hooks/mm.h b/include/trace/hooks/mm.h index c3113e14e847..263b867d453c 100644 --- a/include/trace/hooks/mm.h +++ b/include/trace/hooks/mm.h @@ -24,6 +24,7 @@ struct cgroup_subsys_state; struct mem_cgroup; struct cma; struct acr_info; +struct vm_unmapped_area_info; DECLARE_RESTRICTED_HOOK(android_rvh_set_skip_swapcache_flags, TP_PROTO(gfp_t *flags), From 6140082c11069782cb83f26f7ef9fb65292e4938 Mon Sep 17 00:00:00 2001 From: Cheng-Yi Chiang Date: Wed, 18 Nov 2020 12:38:52 +0800 Subject: [PATCH 082/124] UPSTREAM: ASoC: hdmi-codec: Get ELD in before reporting plugged event In plugged callback, ELD should be updated from display driver so that user space can query information from ELD immediately after receiving jack plugged event. When jack is unplugged, clear ELD buffer so that user space does not get obsolete information of unplugged HDMI. Bug: 239396464 Change-Id: I2245de6e6f7dbc64863267db864dafdd3af95747 Signed-off-by: Cheng-Yi Chiang Link: https://lore.kernel.org/r/20201118043852.1338877-1-cychiang@chromium.org Signed-off-by: Mark Brown Signed-off-by: Sugar Zhang (cherry picked from commit 25ce4f2b3593fa6bba70ddabbd2ee297b262784f) --- sound/soc/codecs/hdmi-codec.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 403d4c6a49a8..e8410b2433de 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -692,10 +692,16 @@ static void plugged_cb(struct device *dev, bool plugged) { struct hdmi_codec_priv *hcp = dev_get_drvdata(dev); - if (plugged) + if (plugged) { + if (hcp->hcd.ops->get_eld) { + hcp->hcd.ops->get_eld(dev->parent, hcp->hcd.data, + hcp->eld, sizeof(hcp->eld)); + } hdmi_codec_jack_report(hcp, SND_JACK_LINEOUT); - else + } else { hdmi_codec_jack_report(hcp, 0); + memset(hcp->eld, 0, sizeof(hcp->eld)); + } } static int hdmi_codec_set_jack(struct snd_soc_component *component, From f5a1cb7fd6e41462c939d59da37f120da2a6c375 Mon Sep 17 00:00:00 2001 From: Shengjiu Wang Date: Thu, 26 Nov 2020 14:36:48 +0800 Subject: [PATCH 083/124] UPSTREAM: ASoC: hdmi-codec: Add RX support HDMI interface can also be used as receiver, this patch is to add such support. The most difference compare with TX is that RX don't need to get edid information. Bug: 239396464 Change-Id: Ib5f9f347cd50abe95fa9c8a4856bd1a91117ca67 Signed-off-by: Shengjiu Wang Link: https://lore.kernel.org/r/1606372608-2329-1-git-send-email-shengjiu.wang@nxp.com Signed-off-by: Mark Brown Signed-off-by: Sugar Zhang (cherry picked from commit 144f836646989783cb018d00fa69f3f8dab58349) --- sound/soc/codecs/hdmi-codec.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index e8410b2433de..d5fcc4db8284 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -282,6 +282,7 @@ struct hdmi_codec_priv { static const struct snd_soc_dapm_widget hdmi_widgets[] = { SND_SOC_DAPM_OUTPUT("TX"), + SND_SOC_DAPM_OUTPUT("RX"), }; enum { @@ -389,6 +390,7 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); + bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; int ret = 0; mutex_lock(&hcp->lock); @@ -404,7 +406,7 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, goto err; } - if (hcp->hcd.ops->get_eld) { + if (tx && hcp->hcd.ops->get_eld) { ret = hcp->hcd.ops->get_eld(dai->dev->parent, hcp->hcd.data, hcp->eld, sizeof(hcp->eld)); if (ret) @@ -660,14 +662,20 @@ static int hdmi_dai_probe(struct snd_soc_dai *dai) { struct snd_soc_dapm_context *dapm; struct hdmi_codec_daifmt *daifmt; - struct snd_soc_dapm_route route = { - .sink = "TX", - .source = dai->driver->playback.stream_name, + struct snd_soc_dapm_route route[] = { + { + .sink = "TX", + .source = dai->driver->playback.stream_name, + }, + { + .sink = dai->driver->capture.stream_name, + .source = "RX", + }, }; int ret; dapm = snd_soc_component_get_dapm(dai->component); - ret = snd_soc_dapm_add_routes(dapm, &route, 1); + ret = snd_soc_dapm_add_routes(dapm, route, 2); if (ret) return ret; @@ -757,6 +765,14 @@ static const struct snd_soc_dai_driver hdmi_i2s_dai = { .formats = I2S_FORMATS, .sig_bits = 24, }, + .capture = { + .stream_name = "Capture", + .channels_min = 2, + .channels_max = 8, + .rates = HDMI_RATES, + .formats = I2S_FORMATS, + .sig_bits = 24, + }, .ops = &hdmi_codec_i2s_dai_ops, .pcm_new = hdmi_codec_pcm_new, }; @@ -773,6 +789,13 @@ static const struct snd_soc_dai_driver hdmi_spdif_dai = { .rates = HDMI_RATES, .formats = SPDIF_FORMATS, }, + .capture = { + .stream_name = "Capture", + .channels_min = 2, + .channels_max = 2, + .rates = HDMI_RATES, + .formats = SPDIF_FORMATS, + }, .ops = &hdmi_codec_spdif_dai_ops, .pcm_new = hdmi_codec_pcm_new, }; From c584eb99bb43ec13aab379702206edd27f8d8ca4 Mon Sep 17 00:00:00 2001 From: Stephan Gerhold Date: Thu, 7 Jan 2021 17:51:31 +0100 Subject: [PATCH 084/124] UPSTREAM: ASoC: hdmi-codec: Fix return value in hdmi_codec_set_jack() Sound is broken on the DragonBoard 410c (apq8016_sbc) since 5.10: hdmi-audio-codec hdmi-audio-codec.1.auto: ASoC: error at snd_soc_component_set_jack on hdmi-audio-codec.1.auto: -95 qcom-apq8016-sbc 7702000.sound: Failed to set jack: -95 ADV7533: ASoC: error at snd_soc_link_init on ADV7533: -95 hdmi-audio-codec hdmi-audio-codec.1.auto: ASoC: error at snd_soc_component_set_jack on hdmi-audio-codec.1.auto: -95 qcom-apq8016-sbc: probe of 7702000.sound failed with error -95 This happens because apq8016_sbc calls snd_soc_component_set_jack() on all codec DAIs and attempts to ignore failures with return code -ENOTSUPP. -ENOTSUPP is also excluded from error logging in soc_component_ret(). However, hdmi_codec_set_jack() returns -E*OP*NOTSUPP if jack detection is not supported, which is not handled in apq8016_sbc and soc_component_ret(). Make it return -ENOTSUPP instead to fix sound and silence the errors. Bug: 239396464 Change-Id: Id38ce1cdfc80daaac7d77212cecd29dd6fa4e877 Cc: Cheng-Yi Chiang Cc: Srinivas Kandagatla Fixes: 55c5cc63ab32 ("ASoC: hdmi-codec: Use set_jack ops to set jack") Signed-off-by: Stephan Gerhold Acked-by: Nicolin Chen Link: https://lore.kernel.org/r/20210107165131.2535-1-stephan@gerhold.net Signed-off-by: Mark Brown (cherry picked from commit 2a0435df963f996ca870a2ef1cbf1773dc0ea25a) Signed-off-by: Sugar Zhang --- sound/soc/codecs/hdmi-codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index d5fcc4db8284..0f3ac22f2cf8 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -717,7 +717,7 @@ static int hdmi_codec_set_jack(struct snd_soc_component *component, void *data) { struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); - int ret = -EOPNOTSUPP; + int ret = -ENOTSUPP; if (hcp->hcd.ops->hook_plugged_cb) { hcp->jack = jack; From a7633aa2d93d5fb87f14b6757c9c5a5e70350123 Mon Sep 17 00:00:00 2001 From: Sia Jee Heng Date: Thu, 4 Feb 2021 09:42:55 +0800 Subject: [PATCH 085/124] UPSTREAM: ASoC: codec: hdmi-codec: Support IEC958 encoded PCM format Existing hdmi-codec driver only support standard pcm format. Support of IEC958 encoded format pass from ALSA IEC958 plugin is needed so that the IEC958 encoded data can be streamed to the HDMI chip. Bug: 239396464 Change-Id: I01516e34605e380995b5312273035a0d000d36f1 Signed-off-by: Sia Jee Heng Link: https://lore.kernel.org/r/20210204014258.10197-2-jee.heng.sia@intel.com Signed-off-by: Mark Brown Signed-off-by: Sugar Zhang (cherry picked from commit 28785f548d18e6d52785a1172e5c176784ce74cd) --- include/sound/hdmi-codec.h | 5 +++++ sound/soc/codecs/hdmi-codec.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h index b55970859a13..4b3a1d374b90 100644 --- a/include/sound/hdmi-codec.h +++ b/include/sound/hdmi-codec.h @@ -34,6 +34,11 @@ struct hdmi_codec_daifmt { unsigned int frame_clk_inv:1; unsigned int bit_clk_master:1; unsigned int frame_clk_master:1; + /* bit_fmt could be standard PCM format or + * IEC958 encoded format. ALSA IEC958 plugin will pass + * IEC958_SUBFRAME format to the underneath driver. + */ + snd_pcm_format_t bit_fmt; }; /* diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 0f3ac22f2cf8..422539f933de 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -489,6 +489,7 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, hp.sample_rate = params_rate(params); hp.channels = params_channels(params); + cf->bit_fmt = params_format(params); return hcp->hcd.ops->hw_params(dai->dev->parent, hcp->hcd.data, cf, &hp); } @@ -617,7 +618,8 @@ static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = { SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S20_3BE |\ SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_3BE |\ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S24_BE |\ - SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE) + SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE |\ + SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE) static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai) From 004a44b9138aaf167d8d7be5df8f7fb292a73352 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 12 Mar 2021 12:22:33 -0600 Subject: [PATCH 086/124] UPSTREAM: ASoC: hdmi-codec: remove useless initialization Fix cppcheck warning: sound/soc/codecs/hdmi-codec.c:745:5: style: Redundant initialization for 'cf'. The initialized value is overwritten before it is read. [redundantInitialization] cf = dai->playback_dma_data; ^ sound/soc/codecs/hdmi-codec.c:738:31: note: cf is initialized struct hdmi_codec_daifmt *cf = dai->playback_dma_data; ^ sound/soc/codecs/hdmi-codec.c:745:5: note: cf is overwritten cf = dai->playback_dma_data; ^ Bug: 239396464 Change-Id: Ia903635862e043207929827afcaeb531e6344283 Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20210312182246.5153-11-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sugar Zhang (cherry picked from commit 3c011ef344cddd15be0a9b2256f7886f6b5eeec5) --- sound/soc/codecs/hdmi-codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 422539f933de..83e74ddccf59 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -735,7 +735,7 @@ static int hdmi_codec_set_jack(struct snd_soc_component *component, static int hdmi_dai_spdif_probe(struct snd_soc_dai *dai) { - struct hdmi_codec_daifmt *cf = dai->playback_dma_data; + struct hdmi_codec_daifmt *cf; int ret; ret = hdmi_dai_probe(dai); From 6cc06d03bff9aee9006166f597d5174fd7722db2 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 12 Mar 2021 12:22:34 -0600 Subject: [PATCH 087/124] UPSTREAM: ASoC: hdmi-codec: remove unused spk_mask member fix cppcheck warning: sound/soc/codecs/hdmi-codec.c:25:16: style: struct member 'hdmi_codec_channel_map_table::spk_mask' is never used. [unusedStructMember] unsigned long spk_mask; /* speaker position bit mask */ ^ Bug: 239396464 Change-Id: I235b7757db88bfbd059ad0f9795908fbfbb1cfdb Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20210312182246.5153-12-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sugar Zhang (cherry picked from commit 9ad869fee5c598d914fa5cf8fb26f5e106e90956) --- sound/soc/codecs/hdmi-codec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 83e74ddccf59..1567ba196ab9 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -22,7 +22,6 @@ struct hdmi_codec_channel_map_table { unsigned char map; /* ALSA API channel map position */ - unsigned long spk_mask; /* speaker position bit mask */ }; /* From 92c209708ae171a955c29e07d10e9cf951c30ec5 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Tue, 25 May 2021 15:23:43 +0200 Subject: [PATCH 088/124] UPSTREAM: ALSA: doc: Clarify IEC958 controls iface The doc currently mentions that the IEC958 Playback Default should be exposed on the PCM iface, and the Playback Mask on the mixer iface. It's a bit confusing to advise to have two related controls on two separate ifaces, and it looks like the drivers that currently expose those controls use any combination of the mixer and PCM ifaces. Let's try to clarify the situation a bit, and encourage to at least have the controls on the same iface. Bug: 239396464 Change-Id: Ie0fb033564972f74154c378c644c581dc4d06dfa Signed-off-by: Maxime Ripard Reviewed-by: Takashi Iwai Link: https://lore.kernel.org/r/20210525132354.297468-2-maxime@cerno.tech Signed-off-by: Sugar Zhang (cherry picked from commit aa7899537a4ec63ac3d58c9ece945c2750d22168) --- .../sound/kernel-api/writing-an-alsa-driver.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Documentation/sound/kernel-api/writing-an-alsa-driver.rst b/Documentation/sound/kernel-api/writing-an-alsa-driver.rst index 73bbd59afc33..690c5238f904 100644 --- a/Documentation/sound/kernel-api/writing-an-alsa-driver.rst +++ b/Documentation/sound/kernel-api/writing-an-alsa-driver.rst @@ -3508,14 +3508,15 @@ field must be set, though). “IEC958 Playback Con Mask” is used to return the bit-mask for the IEC958 status bits of consumer mode. Similarly, “IEC958 Playback Pro Mask” -returns the bitmask for professional mode. They are read-only controls, -and are defined as MIXER controls (iface = -``SNDRV_CTL_ELEM_IFACE_MIXER``). +returns the bitmask for professional mode. They are read-only controls. Meanwhile, “IEC958 Playback Default” control is defined for getting and -setting the current default IEC958 bits. Note that this one is usually -defined as a PCM control (iface = ``SNDRV_CTL_ELEM_IFACE_PCM``), -although in some places it's defined as a MIXER control. +setting the current default IEC958 bits. + +Due to historical reasons, both variants of the Playback Mask and the +Playback Default controls can be implemented on either a +``SNDRV_CTL_ELEM_IFACE_PCM`` or a ``SNDRV_CTL_ELEM_IFACE_MIXER`` iface. +Drivers should expose the mask and default on the same iface though. In addition, you can define the control switches to enable/disable or to set the raw bit mode. The implementation will depend on the chip, but From 8de9ae8605ff355e2991370eff904669f96e4307 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Tue, 25 May 2021 15:23:44 +0200 Subject: [PATCH 089/124] UPSTREAM: ALSA: iec958: Split status creation and fill In some situations, like a codec probe, we need to provide an IEC status default but don't have access to the sampling rate and width yet since no stream has been configured yet. Each and every driver has its own default, whereas the core iec958 code also has some buried in the snd_pcm_create_iec958_consumer functions. Let's split these functions in two to provide a default that doesn't rely on the sampling rate and width, and another function to fill them when available. Bug: 239396464 Change-Id: I277899145367b219b337bc796f2faee8c4917082 Signed-off-by: Maxime Ripard Reviewed-by: Takashi Iwai Link: https://lore.kernel.org/r/20210525132354.297468-3-maxime@cerno.tech Signed-off-by: Sugar Zhang (cherry picked from commit 9eafc11f921b8cb7d7e28ab1fdcf6b92fcbcb0be) --- include/sound/pcm_iec958.h | 8 ++ sound/core/pcm_iec958.c | 176 ++++++++++++++++++++++++++++--------- 2 files changed, 141 insertions(+), 43 deletions(-) diff --git a/include/sound/pcm_iec958.h b/include/sound/pcm_iec958.h index 0939aa45e2fe..64e84441cde1 100644 --- a/include/sound/pcm_iec958.h +++ b/include/sound/pcm_iec958.h @@ -4,6 +4,14 @@ #include +int snd_pcm_create_iec958_consumer_default(u8 *cs, size_t len); + +int snd_pcm_fill_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, + size_t len); + +int snd_pcm_fill_iec958_consumer_hw_params(struct snd_pcm_hw_params *params, + u8 *cs, size_t len); + int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, size_t len); diff --git a/sound/core/pcm_iec958.c b/sound/core/pcm_iec958.c index f9a211cc1f2c..7a1b816f67cc 100644 --- a/sound/core/pcm_iec958.c +++ b/sound/core/pcm_iec958.c @@ -9,41 +9,85 @@ #include #include -static int create_iec958_consumer(uint rate, uint sample_width, - u8 *cs, size_t len) +/** + * snd_pcm_create_iec958_consumer_default - create default consumer format IEC958 channel status + * @cs: channel status buffer, at least four bytes + * @len: length of channel status buffer + * + * Create the consumer format channel status data in @cs of maximum size + * @len. When relevant, the configuration-dependant bits will be set as + * unspecified. + * + * Drivers should then call einter snd_pcm_fill_iec958_consumer() or + * snd_pcm_fill_iec958_consumer_hw_params() to replace these unspecified + * bits by their actual values. + * + * Drivers may wish to tweak the contents of the buffer after creation. + * + * Returns: length of buffer, or negative error code if something failed. + */ +int snd_pcm_create_iec958_consumer_default(u8 *cs, size_t len) { - unsigned int fs, ws; - if (len < 4) return -EINVAL; - switch (rate) { - case 32000: - fs = IEC958_AES3_CON_FS_32000; - break; - case 44100: - fs = IEC958_AES3_CON_FS_44100; - break; - case 48000: - fs = IEC958_AES3_CON_FS_48000; - break; - case 88200: - fs = IEC958_AES3_CON_FS_88200; - break; - case 96000: - fs = IEC958_AES3_CON_FS_96000; - break; - case 176400: - fs = IEC958_AES3_CON_FS_176400; - break; - case 192000: - fs = IEC958_AES3_CON_FS_192000; - break; - default: + memset(cs, 0, len); + + cs[0] = IEC958_AES0_CON_NOT_COPYRIGHT | IEC958_AES0_CON_EMPHASIS_NONE; + cs[1] = IEC958_AES1_CON_GENERAL; + cs[2] = IEC958_AES2_CON_SOURCE_UNSPEC | IEC958_AES2_CON_CHANNEL_UNSPEC; + cs[3] = IEC958_AES3_CON_CLOCK_1000PPM | IEC958_AES3_CON_FS_NOTID; + + if (len > 4) + cs[4] = IEC958_AES4_CON_WORDLEN_NOTID; + + return len; +} +EXPORT_SYMBOL_GPL(snd_pcm_create_iec958_consumer_default); + +static int fill_iec958_consumer(uint rate, uint sample_width, + u8 *cs, size_t len) +{ + if (len < 4) return -EINVAL; + + if ((cs[3] & IEC958_AES3_CON_FS) == IEC958_AES3_CON_FS_NOTID) { + unsigned int fs; + + switch (rate) { + case 32000: + fs = IEC958_AES3_CON_FS_32000; + break; + case 44100: + fs = IEC958_AES3_CON_FS_44100; + break; + case 48000: + fs = IEC958_AES3_CON_FS_48000; + break; + case 88200: + fs = IEC958_AES3_CON_FS_88200; + break; + case 96000: + fs = IEC958_AES3_CON_FS_96000; + break; + case 176400: + fs = IEC958_AES3_CON_FS_176400; + break; + case 192000: + fs = IEC958_AES3_CON_FS_192000; + break; + default: + return -EINVAL; + } + + cs[3] &= ~IEC958_AES3_CON_FS; + cs[3] |= fs; } - if (len > 4) { + if (len > 4 && + (cs[4] & IEC958_AES4_CON_WORDLEN) == IEC958_AES4_CON_WORDLEN_NOTID) { + unsigned int ws; + switch (sample_width) { case 16: ws = IEC958_AES4_CON_WORDLEN_20_16; @@ -64,21 +108,58 @@ static int create_iec958_consumer(uint rate, uint sample_width, default: return -EINVAL; } + + cs[4] &= ~IEC958_AES4_CON_WORDLEN; + cs[4] |= ws; } - memset(cs, 0, len); - - cs[0] = IEC958_AES0_CON_NOT_COPYRIGHT | IEC958_AES0_CON_EMPHASIS_NONE; - cs[1] = IEC958_AES1_CON_GENERAL; - cs[2] = IEC958_AES2_CON_SOURCE_UNSPEC | IEC958_AES2_CON_CHANNEL_UNSPEC; - cs[3] = IEC958_AES3_CON_CLOCK_1000PPM | fs; - - if (len > 4) - cs[4] = ws; - return len; } +/** + * snd_pcm_fill_iec958_consumer - Fill consumer format IEC958 channel status + * @runtime: pcm runtime structure with ->rate filled in + * @cs: channel status buffer, at least four bytes + * @len: length of channel status buffer + * + * Fill the unspecified bits in an IEC958 status bits array using the + * parameters of the PCM runtime @runtime. + * + * Drivers may wish to tweak the contents of the buffer after its been + * filled. + * + * Returns: length of buffer, or negative error code if something failed. + */ +int snd_pcm_fill_iec958_consumer(struct snd_pcm_runtime *runtime, + u8 *cs, size_t len) +{ + return fill_iec958_consumer(runtime->rate, + snd_pcm_format_width(runtime->format), + cs, len); +} +EXPORT_SYMBOL_GPL(snd_pcm_fill_iec958_consumer); + +/** + * snd_pcm_fill_iec958_consumer_hw_params - Fill consumer format IEC958 channel status + * @params: the hw_params instance for extracting rate and sample format + * @cs: channel status buffer, at least four bytes + * @len: length of channel status buffer + * + * Fill the unspecified bits in an IEC958 status bits array using the + * parameters of the PCM hardware parameters @params. + * + * Drivers may wish to tweak the contents of the buffer after its been + * filled.. + * + * Returns: length of buffer, or negative error code if something failed. + */ +int snd_pcm_fill_iec958_consumer_hw_params(struct snd_pcm_hw_params *params, + u8 *cs, size_t len) +{ + return fill_iec958_consumer(params_rate(params), params_width(params), cs, len); +} +EXPORT_SYMBOL_GPL(snd_pcm_fill_iec958_consumer_hw_params); + /** * snd_pcm_create_iec958_consumer - create consumer format IEC958 channel status * @runtime: pcm runtime structure with ->rate filled in @@ -95,9 +176,13 @@ static int create_iec958_consumer(uint rate, uint sample_width, int snd_pcm_create_iec958_consumer(struct snd_pcm_runtime *runtime, u8 *cs, size_t len) { - return create_iec958_consumer(runtime->rate, - snd_pcm_format_width(runtime->format), - cs, len); + int ret; + + ret = snd_pcm_create_iec958_consumer_default(cs, len); + if (ret < 0) + return ret; + + return snd_pcm_fill_iec958_consumer(runtime, cs, len); } EXPORT_SYMBOL(snd_pcm_create_iec958_consumer); @@ -117,7 +202,12 @@ EXPORT_SYMBOL(snd_pcm_create_iec958_consumer); int snd_pcm_create_iec958_consumer_hw_params(struct snd_pcm_hw_params *params, u8 *cs, size_t len) { - return create_iec958_consumer(params_rate(params), params_width(params), - cs, len); + int ret; + + ret = snd_pcm_create_iec958_consumer_default(cs, len); + if (ret < 0) + return ret; + + return fill_iec958_consumer(params_rate(params), params_width(params), cs, len); } EXPORT_SYMBOL(snd_pcm_create_iec958_consumer_hw_params); From 9e9d26699dbce100121481676e14acf44d50ddaa Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Tue, 25 May 2021 15:23:45 +0200 Subject: [PATCH 090/124] UPSTREAM: ASoC: hdmi-codec: Rework to support more controls We're going to add more controls to support the IEC958 output, so let's rework the control registration a bit to support more of them. Bug: 239396464 Change-Id: Ia8c0bf8c997638b5a121ae7356fa1eb27746036f Signed-off-by: Maxime Ripard Acked-by: Mark Brown Link: https://lore.kernel.org/r/20210525132354.297468-4-maxime@cerno.tech Signed-off-by: Sugar Zhang (cherry picked from commit 366b45b974481bea9603843d308aded519aab7dc) --- sound/soc/codecs/hdmi-codec.c | 41 ++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 1567ba196ab9..65bde6f0ea1c 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -620,21 +620,23 @@ static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = { SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE |\ SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE) +struct snd_kcontrol_new hdmi_codec_controls[] = { + { + .access = (SNDRV_CTL_ELEM_ACCESS_READ | + SNDRV_CTL_ELEM_ACCESS_VOLATILE), + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = "ELD", + .info = hdmi_eld_ctl_info, + .get = hdmi_eld_ctl_get, + }, +}; + static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd, struct snd_soc_dai *dai) { struct snd_soc_dai_driver *drv = dai->driver; struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); - struct snd_kcontrol *kctl; - struct snd_kcontrol_new hdmi_eld_ctl = { - .access = SNDRV_CTL_ELEM_ACCESS_READ | - SNDRV_CTL_ELEM_ACCESS_VOLATILE, - .iface = SNDRV_CTL_ELEM_IFACE_PCM, - .name = "ELD", - .info = hdmi_eld_ctl_info, - .get = hdmi_eld_ctl_get, - .device = rtd->pcm->device, - }; + unsigned int i; int ret; ret = snd_pcm_add_chmap_ctls(rtd->pcm, SNDRV_PCM_STREAM_PLAYBACK, @@ -651,12 +653,21 @@ static int hdmi_codec_pcm_new(struct snd_soc_pcm_runtime *rtd, hcp->chmap_info->chmap = hdmi_codec_stereo_chmaps; hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; - /* add ELD ctl with the device number corresponding to the PCM stream */ - kctl = snd_ctl_new1(&hdmi_eld_ctl, dai->component); - if (!kctl) - return -ENOMEM; + for (i = 0; i < ARRAY_SIZE(hdmi_codec_controls); i++) { + struct snd_kcontrol *kctl; - return snd_ctl_add(rtd->card->snd_card, kctl); + /* add ELD ctl with the device number corresponding to the PCM stream */ + kctl = snd_ctl_new1(&hdmi_codec_controls[i], dai->component); + if (!kctl) + return -ENOMEM; + + kctl->id.device = rtd->pcm->device; + ret = snd_ctl_add(rtd->card->snd_card, kctl); + if (ret < 0) + return ret; + } + + return 0; } static int hdmi_dai_probe(struct snd_soc_dai *dai) From 21e97dfa193b49b56a65db92c0a1ca531abe0f20 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Tue, 25 May 2021 15:23:46 +0200 Subject: [PATCH 091/124] UPSTREAM: ASoC: hdmi-codec: Add iec958 controls The IEC958 status bits can be exposed and modified by the userspace through dedicated ALSA controls. This patch implements those controls for the hdmi-codec driver. It relies on a default value being setup at probe time that can later be overridden by the control put. The hw_params callback is then called with a buffer filled with the proper bits for the current parameters being passed on so the underlying driver can just reuse those bits as is. Bug: 239396464 Change-Id: I99f37b7e74655687e73a75ba19fd2de8041f8646 Signed-off-by: Maxime Ripard Acked-by: Mark Brown Link: https://lore.kernel.org/r/20210525132354.297468-5-maxime@cerno.tech Signed-off-by: Sugar Zhang (cherry picked from commit 7a8e1d44211e16eb394b7b9e0b236ee1503a3ad3) --- sound/soc/codecs/hdmi-codec.c | 66 +++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 65bde6f0ea1c..a0834b784814 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -277,6 +277,7 @@ struct hdmi_codec_priv { bool busy; struct snd_soc_jack *jack; unsigned int jack_status; + u8 iec_status[5]; }; static const struct snd_soc_dapm_widget hdmi_widgets[] = { @@ -385,6 +386,47 @@ static int hdmi_codec_chmap_ctl_get(struct snd_kcontrol *kcontrol, return 0; } +static int hdmi_codec_iec958_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; + uinfo->count = 1; + return 0; +} + +static int hdmi_codec_iec958_default_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); + + memcpy(ucontrol->value.iec958.status, hcp->iec_status, + sizeof(hcp->iec_status)); + + return 0; +} + +static int hdmi_codec_iec958_default_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component); + + memcpy(hcp->iec_status, ucontrol->value.iec958.status, + sizeof(hcp->iec_status)); + + return 0; +} + +static int hdmi_codec_iec958_mask_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + memset(ucontrol->value.iec958.status, 0xff, + sizeof_field(struct hdmi_codec_priv, iec_status)); + + return 0; +} + static int hdmi_codec_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { @@ -459,8 +501,9 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, params_width(params), params_rate(params), params_channels(params)); - ret = snd_pcm_create_iec958_consumer_hw_params(params, hp.iec.status, - sizeof(hp.iec.status)); + memcpy(hp.iec.status, hcp->iec_status, sizeof(hp.iec.status)); + ret = snd_pcm_fill_iec958_consumer_hw_params(params, hp.iec.status, + sizeof(hp.iec.status)); if (ret < 0) { dev_err(dai->dev, "Creating IEC958 channel status failed %d\n", ret); @@ -621,6 +664,20 @@ static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = { SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE) struct snd_kcontrol_new hdmi_codec_controls[] = { + { + .access = SNDRV_CTL_ELEM_ACCESS_READ, + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, MASK), + .info = hdmi_codec_iec958_info, + .get = hdmi_codec_iec958_mask_get, + }, + { + .iface = SNDRV_CTL_ELEM_IFACE_PCM, + .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT), + .info = hdmi_codec_iec958_info, + .get = hdmi_codec_iec958_default_get, + .put = hdmi_codec_iec958_default_put, + }, { .access = (SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE), @@ -873,6 +930,11 @@ static int hdmi_codec_probe(struct platform_device *pdev) hcp->hcd = *hcd; mutex_init(&hcp->lock); + ret = snd_pcm_create_iec958_consumer_default(hcp->iec_status, + sizeof(hcp->iec_status)); + if (ret < 0) + return ret; + daidrv = devm_kcalloc(dev, dai_count, sizeof(*daidrv), GFP_KERNEL); if (!daidrv) return -ENOMEM; From 46a21348d6142240a27c8a48b105c12029174fc6 Mon Sep 17 00:00:00 2001 From: Maxime Ripard Date: Tue, 25 May 2021 15:23:47 +0200 Subject: [PATCH 092/124] UPSTREAM: ASoC: hdmi-codec: Add a prepare hook The IEC958 status bit is usually set by the userspace after hw_params has been called, so in order to use whatever is set by the userspace, we need to implement the prepare hook. Let's add it to the hdmi_codec_ops, and mandate that either prepare or hw_params is implemented. Bug: 239396464 Change-Id: I06ccde5d8185955bb60783b597f0205811460968 Signed-off-by: Maxime Ripard Acked-by: Mark Brown Link: https://lore.kernel.org/r/20210525132354.297468-6-maxime@cerno.tech Signed-off-by: Sugar Zhang (cherry picked from commit 2fef64eec23a0840c97977b16dd8919afaffa876) --- include/sound/hdmi-codec.h | 12 +++- sound/soc/codecs/hdmi-codec.c | 110 +++++++++++++++++++++++++++------- 2 files changed, 98 insertions(+), 24 deletions(-) diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h index 4b3a1d374b90..4fc733c8c570 100644 --- a/include/sound/hdmi-codec.h +++ b/include/sound/hdmi-codec.h @@ -65,12 +65,22 @@ struct hdmi_codec_ops { /* * Configures HDMI-encoder for audio stream. - * Mandatory + * Having either prepare or hw_params is mandatory. */ int (*hw_params)(struct device *dev, void *data, struct hdmi_codec_daifmt *fmt, struct hdmi_codec_params *hparms); + /* + * Configures HDMI-encoder for audio stream. Can be called + * multiple times for each setup. + * + * Having either prepare or hw_params is mandatory. + */ + int (*prepare)(struct device *dev, void *data, + struct hdmi_codec_daifmt *fmt, + struct hdmi_codec_params *hparms); + /* * Shuts down the audio stream. * Mandatory diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index a0834b784814..a67c92032e11 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -481,6 +481,42 @@ static void hdmi_codec_shutdown(struct snd_pcm_substream *substream, mutex_unlock(&hcp->lock); } +static int hdmi_codec_fill_codec_params(struct snd_soc_dai *dai, + unsigned int sample_width, + unsigned int sample_rate, + unsigned int channels, + struct hdmi_codec_params *hp) +{ + struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); + int idx; + + /* Select a channel allocation that matches with ELD and pcm channels */ + idx = hdmi_codec_get_ch_alloc_table_idx(hcp, channels); + if (idx < 0) { + dev_err(dai->dev, "Not able to map channels to speakers (%d)\n", + idx); + hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; + return idx; + } + + memset(hp, 0, sizeof(*hp)); + + hdmi_audio_infoframe_init(&hp->cea); + hp->cea.channels = channels; + hp->cea.coding_type = HDMI_AUDIO_CODING_TYPE_STREAM; + hp->cea.sample_size = HDMI_AUDIO_SAMPLE_SIZE_STREAM; + hp->cea.sample_frequency = HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM; + hp->cea.channel_allocation = hdmi_codec_channel_alloc[idx].ca_id; + + hp->sample_width = sample_width; + hp->sample_rate = sample_rate; + hp->channels = channels; + + hcp->chmap_idx = hdmi_codec_channel_alloc[idx].ca_id; + + return 0; +} + static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) @@ -495,12 +531,23 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, .dig_subframe = { 0 }, } }; - int ret, idx; + int ret; + + if (!hcp->hcd.ops->hw_params) + return 0; dev_dbg(dai->dev, "%s() width %d rate %d channels %d\n", __func__, params_width(params), params_rate(params), params_channels(params)); + ret = hdmi_codec_fill_codec_params(dai, + params_width(params), + params_rate(params), + params_channels(params), + &hp); + if (ret < 0) + return ret; + memcpy(hp.iec.status, hcp->iec_status, sizeof(hp.iec.status)); ret = snd_pcm_fill_iec958_consumer_hw_params(params, hp.iec.status, sizeof(hp.iec.status)); @@ -510,32 +557,47 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, return ret; } - hdmi_audio_infoframe_init(&hp.cea); - hp.cea.channels = params_channels(params); - hp.cea.coding_type = HDMI_AUDIO_CODING_TYPE_STREAM; - hp.cea.sample_size = HDMI_AUDIO_SAMPLE_SIZE_STREAM; - hp.cea.sample_frequency = HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM; - - /* Select a channel allocation that matches with ELD and pcm channels */ - idx = hdmi_codec_get_ch_alloc_table_idx(hcp, hp.cea.channels); - if (idx < 0) { - dev_err(dai->dev, "Not able to map channels to speakers (%d)\n", - idx); - hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN; - return idx; - } - hp.cea.channel_allocation = hdmi_codec_channel_alloc[idx].ca_id; - hcp->chmap_idx = hdmi_codec_channel_alloc[idx].ca_id; - - hp.sample_width = params_width(params); - hp.sample_rate = params_rate(params); - hp.channels = params_channels(params); - cf->bit_fmt = params_format(params); return hcp->hcd.ops->hw_params(dai->dev->parent, hcp->hcd.data, cf, &hp); } +static int hdmi_codec_prepare(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai); + struct hdmi_codec_daifmt *cf = dai->playback_dma_data; + struct snd_pcm_runtime *runtime = substream->runtime; + unsigned int channels = runtime->channels; + unsigned int width = snd_pcm_format_width(runtime->format); + unsigned int rate = runtime->rate; + struct hdmi_codec_params hp; + int ret; + + if (!hcp->hcd.ops->prepare) + return 0; + + dev_dbg(dai->dev, "%s() width %d rate %d channels %d\n", __func__, + width, rate, channels); + + ret = hdmi_codec_fill_codec_params(dai, width, rate, channels, &hp); + if (ret < 0) + return ret; + + memcpy(hp.iec.status, hcp->iec_status, sizeof(hp.iec.status)); + ret = snd_pcm_fill_iec958_consumer(runtime, hp.iec.status, + sizeof(hp.iec.status)); + if (ret < 0) { + dev_err(dai->dev, "Creating IEC958 channel status failed %d\n", + ret); + return ret; + } + + cf->bit_fmt = runtime->format; + return hcp->hcd.ops->prepare(dai->dev->parent, hcp->hcd.data, + cf, &hp); +} + static int hdmi_codec_i2s_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { @@ -627,6 +689,7 @@ static const struct snd_soc_dai_ops hdmi_codec_i2s_dai_ops = { .startup = hdmi_codec_startup, .shutdown = hdmi_codec_shutdown, .hw_params = hdmi_codec_hw_params, + .prepare = hdmi_codec_prepare, .set_fmt = hdmi_codec_i2s_set_fmt, .mute_stream = hdmi_codec_mute, }; @@ -917,7 +980,8 @@ static int hdmi_codec_probe(struct platform_device *pdev) } dai_count = hcd->i2s + hcd->spdif; - if (dai_count < 1 || !hcd->ops || !hcd->ops->hw_params || + if (dai_count < 1 || !hcd->ops || + (!hcd->ops->hw_params && !hcd->ops->prepare) || !hcd->ops->audio_shutdown) { dev_err(dev, "%s: Invalid parameters\n", __func__); return -EINVAL; From 32934b542c3d01951279eb79b9beaa3ede4d12a8 Mon Sep 17 00:00:00 2001 From: Jiapeng Chong Date: Wed, 16 Jun 2021 13:55:41 +0800 Subject: [PATCH 093/124] UPSTREAM: ASoC: hdmi-codec: make hdmi_codec_controls static This symbol is not used outside of hdmi-codec.c, so marks it static. Fix the following sparse warning: sound/soc/codecs/hdmi-codec.c:750:25: warning: symbol 'hdmi_codec_controls' was not declared. Should it be static? Bug: 239396464 Change-Id: I6569284ef557fee683afb9031e5cc1b5684a1c30 Reported-by: Abaci Robot Signed-off-by: Jiapeng Chong Link: https://lore.kernel.org/r/1623822941-3077-1-git-send-email-jiapeng.chong@linux.alibaba.com Signed-off-by: Mark Brown Signed-off-by: Sugar Zhang (cherry picked from commit e99d7c69fd4c18e7319f8aab8e252b12130796bf) --- sound/soc/codecs/hdmi-codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index a67c92032e11..d0fb04ae372c 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -726,7 +726,7 @@ static const struct snd_soc_dai_ops hdmi_codec_spdif_dai_ops = { SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE |\ SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE) -struct snd_kcontrol_new hdmi_codec_controls[] = { +static struct snd_kcontrol_new hdmi_codec_controls[] = { { .access = SNDRV_CTL_ELEM_ACCESS_READ, .iface = SNDRV_CTL_ELEM_IFACE_PCM, From f68d040c318f8022628d89e794b78326b352a9fe Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 16 Sep 2022 06:37:59 -0700 Subject: [PATCH 094/124] FROMLIST: scsi: ufs: Fix deadlocks between power management and error handler The following deadlocks have been observed on multiple test setups: * ufshcd_wl_suspend() is waiting for blk_execute_rq() to complete while it holds host_sem. * ufshcd_eh_host_reset_handler() invokes ufshcd_err_handler() and the latter function tries to obtain host_sem. This is a deadlock because blk_execute_rq() can't execute SCSI commands while the host is in the SHOST_RECOVERY state and because the error handler cannot make progress either. * ufshcd_wl_runtime_resume() is waiting for blk_execute_rq() to finish while it holds host_sem. * ufshcd_eh_host_reset_handler() invokes ufshcd_err_handler() and the latter function calls pm_runtime_resume(). This is a deadlock because of the same reason as the previous scenario. Fix both deadlocks by not obtaining host_sem from the power management code paths. Removing the host_sem locking from the power management code is safe because the ufshcd_err_handler() is already serialized against SCSI command execution. Cc: dh0421.hwang@samsung.com Cc: Asutosh Das Fixes: b294ff3e3449 ("scsi: ufs: core: Enable power management for wlun") Signed-off-by: Bart Van Assche Bug: 240498410 Bug: 246990788 Bug: 247073231 Bug: 247081382 Bug: 247082093 Link: https://lore.kernel.org/linux-scsi/ Signed-off-by: Bart Van Assche Change-Id: Ifb9b429ba89ff6d8a133d96a172eaefc09d85955 --- drivers/scsi/ufs/ufshcd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9ee325116902..fb62a8210075 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -9337,16 +9337,13 @@ static int ufshcd_wl_suspend(struct device *dev) ktime_t start = ktime_get(); hba = shost_priv(sdev->host); - down(&hba->host_sem); if (pm_runtime_suspended(dev)) goto out; ret = __ufshcd_wl_suspend(hba, UFS_SYSTEM_PM); - if (ret) { + if (ret) dev_err(&sdev->sdev_gendev, "%s failed: %d\n", __func__, ret); - up(&hba->host_sem); - } out: if (!ret) @@ -9379,7 +9376,6 @@ out: hba->curr_dev_pwr_mode, hba->uic_link_state); if (!ret) hba->is_sys_suspended = false; - up(&hba->host_sem); return ret; } #endif From dd18c291f9a958a1e285ce0e84ec6b5879fe10ab Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 10 Jan 2022 03:15:27 +0900 Subject: [PATCH 095/124] BACKPORT: UPSTREAM: kbuild: rename cmd_{bzip2,lzma,lzo,lz4,xzkern,zstd22} GZIP-compressed files end with 4 byte data that represents the size of the original input. The decompressors (the self-extracting kernel) exploit it to know the vmlinux size beforehand. To mimic the GZIP's trailer, Kbuild provides cmd_{bzip2,lzma,lzo,lz4,xzkern,zstd22}. Unfortunately these macros are used everywhere despite the appended size data is only useful for the decompressors. There is no guarantee that such hand-crafted trailers are safely ignored. In fact, the kernel refuses compressed initramdfs with the garbage data. That is why usr/Makefile overrides size_append to make it no-op. To limit the use of such broken compressed files, this commit renames the existing macros as follows: cmd_bzip2 --> cmd_bzip2_with_size cmd_lzma --> cmd_lzma_with_size cmd_lzo --> cmd_lzo_with_size cmd_lz4 --> cmd_lz4_with_size cmd_xzkern --> cmd_xzkern_with_size cmd_zstd22 --> cmd_zstd22_with_size To keep the decompressors working, I updated the following Makefiles accordingly: arch/arm/boot/compressed/Makefile arch/h8300/boot/compressed/Makefile arch/mips/boot/compressed/Makefile arch/parisc/boot/compressed/Makefile arch/s390/boot/compressed/Makefile arch/sh/boot/compressed/Makefile arch/x86/boot/compressed/Makefile I reused the current macro names for the normal usecases; they produce the compressed data in the proper format. I did not touch the following: arch/arc/boot/Makefile arch/arm64/boot/Makefile arch/csky/boot/Makefile arch/mips/boot/Makefile arch/riscv/boot/Makefile arch/sh/boot/Makefile kernel/Makefile This means those Makefiles will stop appending the size data. I dropped the 'override size_append' hack from usr/Makefile. Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier Bug: 135791357 (cherry picked from commit 7ce7e984ab2b218d6e92d5165629022fe2daf9ee https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master) Change-Id: I3524909ef3daab85f7d22afdebc2e5bbfd5e5cf3 [szuweilin: Resolved the conflict about non-existing zstd22 in arch/s390/boot/compressed/Makefile] Signed-off-by: SzuWei Lin --- arch/arm/boot/compressed/Makefile | 8 +++---- arch/h8300/boot/compressed/Makefile | 4 +++- arch/mips/boot/compressed/Makefile | 12 +++++------ arch/parisc/boot/compressed/Makefile | 10 ++++----- arch/s390/boot/compressed/Makefile | 10 ++++----- arch/sh/boot/compressed/Makefile | 8 +++---- arch/x86/boot/compressed/Makefile | 12 +++++------ scripts/Makefile.lib | 31 +++++++++++++++++++++------- usr/Makefile | 5 ----- 9 files changed, 57 insertions(+), 43 deletions(-) diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile index 175213d7a1aa..37c3036cd468 100644 --- a/arch/arm/boot/compressed/Makefile +++ b/arch/arm/boot/compressed/Makefile @@ -76,10 +76,10 @@ CPPFLAGS_vmlinux.lds += -DTEXT_OFFSET="$(TEXT_OFFSET)" CPPFLAGS_vmlinux.lds += -DMALLOC_SIZE="$(MALLOC_SIZE)" compress-$(CONFIG_KERNEL_GZIP) = gzip -compress-$(CONFIG_KERNEL_LZO) = lzo -compress-$(CONFIG_KERNEL_LZMA) = lzma -compress-$(CONFIG_KERNEL_XZ) = xzkern -compress-$(CONFIG_KERNEL_LZ4) = lz4 +compress-$(CONFIG_KERNEL_LZO) = lzo_with_size +compress-$(CONFIG_KERNEL_LZMA) = lzma_with_size +compress-$(CONFIG_KERNEL_XZ) = xzkern_with_size +compress-$(CONFIG_KERNEL_LZ4) = lz4_with_size libfdt_objs := fdt_rw.o fdt_ro.o fdt_wip.o fdt.o diff --git a/arch/h8300/boot/compressed/Makefile b/arch/h8300/boot/compressed/Makefile index 5942793f77a0..6ab2fa5ba105 100644 --- a/arch/h8300/boot/compressed/Makefile +++ b/arch/h8300/boot/compressed/Makefile @@ -30,9 +30,11 @@ $(obj)/vmlinux.bin: vmlinux FORCE suffix-$(CONFIG_KERNEL_GZIP) := gzip suffix-$(CONFIG_KERNEL_LZO) := lzo +compress-$(CONFIG_KERNEL_GZIP) := gzip +compress-$(CONFIG_KERNEL_LZO) := lzo_with_size $(obj)/vmlinux.bin.$(suffix-y): $(obj)/vmlinux.bin FORCE - $(call if_changed,$(suffix-y)) + $(call if_changed,$(compress-y)) LDFLAGS_piggy.o := -r --format binary --oformat elf32-h8300-linux -T OBJCOPYFLAGS := -O binary diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile index eae0fad30f27..69eda7ab110a 100644 --- a/arch/mips/boot/compressed/Makefile +++ b/arch/mips/boot/compressed/Makefile @@ -71,12 +71,12 @@ $(obj)/vmlinux.bin: $(KBUILD_IMAGE) FORCE $(call if_changed,objcopy) tool_$(CONFIG_KERNEL_GZIP) = gzip -tool_$(CONFIG_KERNEL_BZIP2) = bzip2 -tool_$(CONFIG_KERNEL_LZ4) = lz4 -tool_$(CONFIG_KERNEL_LZMA) = lzma -tool_$(CONFIG_KERNEL_LZO) = lzo -tool_$(CONFIG_KERNEL_XZ) = xzkern -tool_$(CONFIG_KERNEL_ZSTD) = zstd22 +tool_$(CONFIG_KERNEL_BZIP2) = bzip2_with_size +tool_$(CONFIG_KERNEL_LZ4) = lz4_with_size +tool_$(CONFIG_KERNEL_LZMA) = lzma_with_size +tool_$(CONFIG_KERNEL_LZO) = lzo_with_size +tool_$(CONFIG_KERNEL_XZ) = xzkern_with_size +tool_$(CONFIG_KERNEL_ZSTD) = zstd22_with_size targets += vmlinux.bin.z $(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE diff --git a/arch/parisc/boot/compressed/Makefile b/arch/parisc/boot/compressed/Makefile index dff453687530..c09300a6ba98 100644 --- a/arch/parisc/boot/compressed/Makefile +++ b/arch/parisc/boot/compressed/Makefile @@ -73,15 +73,15 @@ suffix-$(CONFIG_KERNEL_XZ) := xz $(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) $(call if_changed,gzip) $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) - $(call if_changed,bzip2) + $(call if_changed,bzip2_with_size) $(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) - $(call if_changed,lz4) + $(call if_changed,lz4_with_size) $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) - $(call if_changed,lzma) + $(call if_changed,lzma_with_size) $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) - $(call if_changed,lzo) + $(call if_changed,lzo_with_size) $(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) - $(call if_changed,xzkern) + $(call if_changed,xzkern_with_size) LDFLAGS_piggy.o := -r --format binary --oformat $(LD_BFD) -T $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.$(suffix-y) diff --git a/arch/s390/boot/compressed/Makefile b/arch/s390/boot/compressed/Makefile index b235ed95a3d8..0e4b585885f0 100644 --- a/arch/s390/boot/compressed/Makefile +++ b/arch/s390/boot/compressed/Makefile @@ -49,15 +49,15 @@ suffix-$(CONFIG_KERNEL_XZ) := .xz $(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE $(call if_changed,gzip) $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE - $(call if_changed,bzip2) + $(call if_changed,bzip2_with_size) $(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE - $(call if_changed,lz4) + $(call if_changed,lz4_with_size) $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE - $(call if_changed,lzma) + $(call if_changed,lzma_with_size) $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE - $(call if_changed,lzo) + $(call if_changed,lzo_with_size) $(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE - $(call if_changed,xzkern) + $(call if_changed,xzkern_with_size) OBJCOPYFLAGS_piggy.o := -I binary -O elf64-s390 -B s390:64-bit --rename-section .data=.vmlinux.bin.compressed $(obj)/piggy.o: $(obj)/vmlinux.bin$(suffix-y) FORCE diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile index 589d2d8a573d..0525d8abdf45 100644 --- a/arch/sh/boot/compressed/Makefile +++ b/arch/sh/boot/compressed/Makefile @@ -58,13 +58,13 @@ vmlinux.bin.all-y := $(obj)/vmlinux.bin $(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE $(call if_changed,gzip) $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE - $(call if_changed,bzip2) + $(call if_changed,bzip2_with_size) $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE - $(call if_changed,lzma) + $(call if_changed,lzma_with_size) $(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE - $(call if_changed,xzkern) + $(call if_changed,xzkern_with_size) $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE - $(call if_changed,lzo) + $(call if_changed,lzo_with_size) OBJCOPYFLAGS += -R .empty_zero_page diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index bf91e0a36d77..57820a9763df 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -125,17 +125,17 @@ vmlinux.bin.all-$(CONFIG_X86_NEED_RELOCS) += $(obj)/vmlinux.relocs $(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE $(call if_changed,gzip) $(obj)/vmlinux.bin.bz2: $(vmlinux.bin.all-y) FORCE - $(call if_changed,bzip2) + $(call if_changed,bzip2_with_size) $(obj)/vmlinux.bin.lzma: $(vmlinux.bin.all-y) FORCE - $(call if_changed,lzma) + $(call if_changed,lzma_with_size) $(obj)/vmlinux.bin.xz: $(vmlinux.bin.all-y) FORCE - $(call if_changed,xzkern) + $(call if_changed,xzkern_with_size) $(obj)/vmlinux.bin.lzo: $(vmlinux.bin.all-y) FORCE - $(call if_changed,lzo) + $(call if_changed,lzo_with_size) $(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE - $(call if_changed,lz4) + $(call if_changed,lz4_with_size) $(obj)/vmlinux.bin.zst: $(vmlinux.bin.all-y) FORCE - $(call if_changed,zstd22) + $(call if_changed,zstd22_with_size) suffix-$(CONFIG_KERNEL_GZIP) := gz suffix-$(CONFIG_KERNEL_BZIP2) := bz2 diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 28f73e4355b1..33aaad005caa 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -401,20 +401,31 @@ printf "%08x\n" $$dec_size | \ ) quiet_cmd_bzip2 = BZIP2 $@ - cmd_bzip2 = { cat $(real-prereqs) | $(KBZIP2) -9; $(size_append); } > $@ + cmd_bzip2 = cat $(real-prereqs) | $(KBZIP2) -9 > $@ + +quiet_cmd_bzip2_with_size = BZIP2 $@ + cmd_bzip2_with_size = { cat $(real-prereqs) | $(KBZIP2) -9; $(size_append); } > $@ # Lzma # --------------------------------------------------------------------------- quiet_cmd_lzma = LZMA $@ - cmd_lzma = { cat $(real-prereqs) | $(LZMA) -9; $(size_append); } > $@ + cmd_lzma = cat $(real-prereqs) | $(LZMA) -9 > $@ + +quiet_cmd_lzma_with_size = LZMA $@ + cmd_lzma_with_size = { cat $(real-prereqs) | $(LZMA) -9; $(size_append); } > $@ quiet_cmd_lzo = LZO $@ - cmd_lzo = { cat $(real-prereqs) | $(KLZOP) -9; $(size_append); } > $@ + cmd_lzo = cat $(real-prereqs) | $(KLZOP) -9 > $@ + +quiet_cmd_lzo_with_size = LZO $@ + cmd_lzo_with_size = { cat $(real-prereqs) | $(KLZOP) -9; $(size_append); } > $@ quiet_cmd_lz4 = LZ4 $@ - cmd_lz4 = { cat $(real-prereqs) | \ - $(LZ4) -l -12 --favor-decSpeed stdin stdout; \ + cmd_lz4 = cat $(real-prereqs) | $(LZ4) -l -12 --favor-decSpeed stdin stdout > $@ + +quiet_cmd_lz4_with_size = LZ4 $@ + cmd_lz4_with_size = { cat $(real-prereqs) | $(LZ4) -l -12 --favor-decSpeed stdin stdout; \ $(size_append); } > $@ # U-Boot mkimage @@ -457,7 +468,10 @@ quiet_cmd_uimage = UIMAGE $@ # big dictionary would increase the memory usage too much in the multi-call # decompression mode. A BCJ filter isn't used either. quiet_cmd_xzkern = XZKERN $@ - cmd_xzkern = { cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh; \ + cmd_xzkern = cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh > $@ + +quiet_cmd_xzkern_with_size = XZKERN $@ + cmd_xzkern_with_size = { cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh; \ $(size_append); } > $@ quiet_cmd_xzmisc = XZMISC $@ @@ -483,7 +497,10 @@ quiet_cmd_zstd = ZSTD $@ cmd_zstd = { cat $(real-prereqs) | $(ZSTD) -19; $(size_append); } > $@ quiet_cmd_zstd22 = ZSTD22 $@ - cmd_zstd22 = { cat $(real-prereqs) | $(ZSTD) -22 --ultra; $(size_append); } > $@ + cmd_zstd22 = cat $(real-prereqs) | $(ZSTD) -22 --ultra > $@ + +quiet_cmd_zstd22_with_size = ZSTD22 $@ + cmd_zstd22_with_size = { cat $(real-prereqs) | $(ZSTD) -22 --ultra; $(size_append); } > $@ # ASM offsets # --------------------------------------------------------------------------- diff --git a/usr/Makefile b/usr/Makefile index b1a81a40eab1..7b89c0175a3a 100644 --- a/usr/Makefile +++ b/usr/Makefile @@ -3,11 +3,6 @@ # kbuild file for usr/ - including initramfs image # -# cmd_bzip2, cmd_lzma, cmd_lzo, cmd_lz4 from scripts/Makefile.lib appends the -# size at the end of the compressed file, which unfortunately does not work -# with unpack_to_rootfs(). Make size_append no-op. -override size_append := : - compress-y := shipped compress-$(CONFIG_INITRAMFS_COMPRESSION_GZIP) := gzip compress-$(CONFIG_INITRAMFS_COMPRESSION_BZIP2) := bzip2 From 1d61c5b5a06a3a19c2cfcb84f7a907827875c829 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 19 Sep 2022 15:20:43 -0700 Subject: [PATCH 096/124] Revert "FROMLIST: scsi: ufs: Fix deadlocks between power management and error handler" This reverts commit f68d040c318f8022628d89e794b78326b352a9fe. Patch "scsi: ufs: core: Reduce the power mode change timeout" caused a spike in the number of UFS suspend timeouts. Hence revert that change and also later UFS driver changes. Bug: b/246990788 Change-Id: Ic20594727d47dc6d9af9a320d64bd7011112e789 Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index fb62a8210075..9ee325116902 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -9337,13 +9337,16 @@ static int ufshcd_wl_suspend(struct device *dev) ktime_t start = ktime_get(); hba = shost_priv(sdev->host); + down(&hba->host_sem); if (pm_runtime_suspended(dev)) goto out; ret = __ufshcd_wl_suspend(hba, UFS_SYSTEM_PM); - if (ret) + if (ret) { dev_err(&sdev->sdev_gendev, "%s failed: %d\n", __func__, ret); + up(&hba->host_sem); + } out: if (!ret) @@ -9376,6 +9379,7 @@ out: hba->curr_dev_pwr_mode, hba->uic_link_state); if (!ret) hba->is_sys_suspended = false; + up(&hba->host_sem); return ret; } #endif From 0cf7d9ce9f839d9e268e4073753dfb2cdb9eb704 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 19 Sep 2022 15:20:50 -0700 Subject: [PATCH 097/124] Revert "UPSTREAM: scsi: ufs: core: Reduce the power mode change timeout" This reverts commit 3d35c6b91d6d370ca5166efa990588ee43267721. Patch "scsi: ufs: core: Reduce the power mode change timeout" caused a spike in the number of UFS suspend timeouts. Hence revert that change and also later UFS driver changes. Bug: b/246990788 Change-Id: I5aae929f0598020dc5e7c440946eb0d2101b07cc Signed-off-by: Bart Van Assche --- drivers/scsi/ufs/ufshcd.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9ee325116902..45ee1adefc08 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -8826,8 +8826,6 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, struct scsi_device *sdp; unsigned long flags; int ret, retries; - unsigned long deadline; - int32_t remaining; spin_lock_irqsave(hba->host->host_lock, flags); sdp = hba->sdev_ufs_device; @@ -8860,14 +8858,9 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, * callbacks hence set the RQF_PM flag so that it doesn't resume the * already suspended childs. */ - deadline = jiffies + 10 * HZ; for (retries = 3; retries > 0; --retries) { - ret = -ETIMEDOUT; - remaining = deadline - jiffies; - if (remaining <= 0) - break; ret = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr, - remaining / HZ, 0, 0, RQF_PM, NULL); + START_STOP_TIMEOUT, 0, 0, RQF_PM, NULL); if (!scsi_status_is_check_condition(ret) || !scsi_sense_valid(&sshdr) || sshdr.sense_key != UNIT_ATTENTION) From 5625e355a9c41837357efdeb6ac7bc07ddef122b Mon Sep 17 00:00:00 2001 From: Tadeusz Struk Date: Tue, 13 Sep 2022 10:56:54 -0700 Subject: [PATCH 098/124] ANDROID: incfs: Add check for ATTR_KILL_SUID and ATTR_MODE in incfs_setattr Add an explicite check for ATTR_KILL_SUID and ATTR_MODE in incfs_setattr. Both of these attributes can not be set at the same time, otherwise notify_change() function will check it and invoke BUG(), crashing the system. Bug: 243394930 Signed-off-by: Tadeusz Struk Change-Id: I91080d68efbd62f1441e20a5c02feef3d1b06e4e --- fs/incfs/vfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/incfs/vfs.c b/fs/incfs/vfs.c index e97b843a4da5..7d349ee73bc3 100644 --- a/fs/incfs/vfs.c +++ b/fs/incfs/vfs.c @@ -1592,6 +1592,10 @@ static int incfs_setattr(struct dentry *dentry, struct iattr *ia) if (ia->ia_valid & ATTR_SIZE) return -EINVAL; + if ((ia->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID)) && + (ia->ia_valid & ATTR_MODE)) + return -EINVAL; + if (!di) return -EINVAL; backing_dentry = di->backing_path.dentry; From d25aa0dbae2a9ab2f1b117a164ea935c584cb01e Mon Sep 17 00:00:00 2001 From: Weichao Guo Date: Wed, 7 Sep 2022 10:38:48 +0800 Subject: [PATCH 099/124] FROMLIST: f2fs: let FI_OPU_WRITE override FADVISE_COLD_BIT Cold files may be fragmented due to SSR, defragment is needed as sequential reads are dominant scenarios of these files. FI_OPU_WRITE should override FADVISE_COLD_BIT to avoid defragment fails. Bug: 246903585 Signed-off-by: Weichao Guo Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Weichao Guo Link: https://lore.kernel.org/all/YxlTQ3H+PPKcvpyc@google.com/T/ Change-Id: I52ab86a15ec275772c5356bfc985803bbdde4408 --- fs/f2fs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 103e7038356f..75446c54624b 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2549,7 +2549,7 @@ bool f2fs_should_update_inplace(struct inode *inode, struct f2fs_io_info *fio) return true; /* if this is cold file, we should overwrite to avoid fragmentation */ - if (file_is_cold(inode)) + if (file_is_cold(inode) && !is_inode_flag_set(inode, FI_OPU_WRITE)) return true; return check_inplace_update_policy(inode, fio); From 7b87b9ddb4ef0308c8bd4c862a720001ef5ced79 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Thu, 15 Sep 2022 11:39:30 -0700 Subject: [PATCH 100/124] ANDROID: kleaf: Explicit list of ABI files. In BUILD.bazel, explicitly list abi_definition, kmi_symbol_list, and additional_kmi_symbol_lists. This avoids using the glob expression which may accidentally match editor backup files. Bug: 246344503 Test: TH Change-Id: I3cd494dee47b68a0fe7c3c80dd379b5af6b060fe Signed-off-by: Yifan Hong --- BUILD.bazel | 28 +++++++++++++++++++++++----- build.config.gki.aarch64 | 3 +-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 885571722c52..f780ffd87460 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -19,8 +19,26 @@ package( load("//build/kernel/kleaf:common_kernels.bzl", "define_common_kernels") -# This uses android/abi_gki_aarch64* in kmi_configs. If the list of -# glob(["android/abi_gki_aarch64*"]) differs from -# KMI_SYMBOL_LIST + ADDITIONAL_KMI_SYMBOL_LISTS in build.config.gki.aarch64, -# or TRIM_NONLISTED_KMI changes, override kmi_configs here. -define_common_kernels() +_aarch64_additional_kmi_symbol_lists = [ + # keep sorted + "android/abi_gki_aarch64_core", + "android/abi_gki_aarch64_db845c", + "android/abi_gki_aarch64_fips140", + "android/abi_gki_aarch64_generic", + "android/abi_gki_aarch64_hikey960", + "android/abi_gki_aarch64_virtual_device", +] + +define_common_kernels(target_configs = { + # Sync with build.config.gki.aarch64 + "kernel_aarch64": { + "kmi_symbol_list": "android/abi_gki_aarch64", + "additional_kmi_symbol_lists": _aarch64_additional_kmi_symbol_lists, + "abi_definition": "android/abi_gki_aarch64.xml", + }, + "kernel_aarch64_debug": { + "kmi_symbol_list": "android/abi_gki_aarch64", + "additional_kmi_symbol_lists": _aarch64_additional_kmi_symbol_lists, + "abi_definition": "android/abi_gki_aarch64.xml", + }, +}) diff --git a/build.config.gki.aarch64 b/build.config.gki.aarch64 index 479bed504395..45f1caeb3ff6 100644 --- a/build.config.gki.aarch64 +++ b/build.config.gki.aarch64 @@ -7,9 +7,8 @@ Image.lz4 Image.gz " +# Sync with BUILD.bazel ABI_DEFINITION=android/abi_gki_aarch64.xml -# Update BUILD.bazel, define_common_kernels() if the list differs from -# android/abi_gki_aarch64* in the filesystem. KMI_SYMBOL_LIST=android/abi_gki_aarch64 ADDITIONAL_KMI_SYMBOL_LISTS=" android/abi_gki_aarch64_core From aec8f79a0fc6da7662842a4f77cc4c40df0bcf10 Mon Sep 17 00:00:00 2001 From: Amit Pundir Date: Wed, 21 Sep 2022 21:08:55 +0530 Subject: [PATCH 101/124] ANDROID: GKI: db845c: Update symbols list and ABI android13-5.10 is broken on Dragonboard 845c because of recently added snd_pcm_* symbols. So updated the symbols list by running: "BUILD_CONFIG=common/build.config.db845c \ KMI_SYMBOL_LIST_ADD_ONLY=1 build/build_abi.sh -s" And the abi_gki_aarch64 ABI by running: "BUILD_CONFIG=common/build.config.gki.aarch64 \ ABI_DEFINITION=abi_gki_aarch64.xml KMI_SYMBOL_LIST_ADD_ONLY=1 \ build/build_abi.sh --update --print-report" ======================================================== ABI DIFFERENCES HAVE BEEN DETECTED! 3 symbol(s) added 'int snd_pcm_create_iec958_consumer_default(u8 *, size_t)' 'int snd_pcm_fill_iec958_consumer(struct snd_pcm_runtime *, u8 *, size_t)' 'int snd_pcm_fill_iec958_consumer_hw_params(struct snd_pcm_hw_params *, u8 *, size_t)' ======================================================== Bug: 146449535 Fixes: 8de9ae8605ff ("UPSTREAM: ALSA: iec958: Split status creation and fill") Signed-off-by: Amit Pundir Change-Id: I0ae0be501faea03f67feb9358b8e44f70571f2df --- android/abi_gki_aarch64.xml | 202 ++++++++++++++++++--------------- android/abi_gki_aarch64_db845c | 94 +++++++-------- 2 files changed, 158 insertions(+), 138 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index 1b628cab49f8..24fb6b9a3465 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -3001,7 +3001,10 @@ + + + @@ -9968,23 +9971,7 @@ - - - - - - - - - - - - - - - - - + @@ -45147,11 +45134,6 @@ - - - - - @@ -77724,6 +77706,9 @@ + + + @@ -85645,6 +85630,9 @@ + + + @@ -100118,7 +100106,20 @@ - + + + + + + + + + + + + + + @@ -110904,25 +110905,25 @@ - - - - + + + + - - - - - - - - + + + + + + + + - - - + + + @@ -110982,21 +110983,21 @@ - - - + + + - - - - + + + + - - - - + + + + @@ -111017,13 +111018,13 @@ - - - - - - - + + + + + + + @@ -111032,14 +111033,14 @@ - - - - - - - - + + + + + + + + @@ -111424,9 +111425,9 @@ - - - + + + @@ -111436,15 +111437,15 @@ - - - + + + - + - + @@ -125515,10 +125516,27 @@ - - - - + + + + + + + + + + + + + + + + + + + + + @@ -127218,36 +127236,36 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + diff --git a/android/abi_gki_aarch64_db845c b/android/abi_gki_aarch64_db845c index 69be1905a229..ec944e48a1b9 100644 --- a/android/abi_gki_aarch64_db845c +++ b/android/abi_gki_aarch64_db845c @@ -54,7 +54,6 @@ cpumask_next cpu_number __cpu_online_mask - crc32_le debugfs_create_dir debugfs_create_file debugfs_create_u32 @@ -185,7 +184,6 @@ free_irq generic_handle_irq get_device - get_random_bytes gic_nonsecure_priorities gpiochip_add_data_with_key gpiochip_add_pin_range @@ -419,7 +417,6 @@ preempt_schedule_notrace prepare_to_wait_event printk - pskb_expand_head put_device __put_task_struct qcom_smem_state_register @@ -505,7 +502,6 @@ simple_read_from_buffer single_open single_release - skb_clone skb_dequeue skb_pull skb_push @@ -553,6 +549,7 @@ strlen strncmp strncpy + strnlen strpbrk strsep __sw_hweight32 @@ -655,9 +652,11 @@ cfg80211_vendor_cmd_reply cpu_latency_qos_add_request cpu_latency_qos_remove_request + crc32_le device_get_mac_address device_set_wakeup_enable firmware_request_nowarn + get_random_bytes guid_gen idr_for_each ieee80211_alloc_hw_nm @@ -710,11 +709,13 @@ init_uts_ns __kfifo_alloc __kfifo_free + ktime_get_with_offset __local_bh_enable_ip memmove __nla_parse nla_put param_ops_ulong + pskb_expand_head regulatory_hint rfc1042_header skb_copy @@ -751,44 +752,6 @@ devm_clk_bulk_get_optional iommu_map -# required by ax88179_178a.ko - eth_platform_get_mac_address - ethtool_op_get_link - ethtool_op_get_ts_info - eth_validate_addr - generic_mii_ioctl - mii_ethtool_get_link_ksettings - mii_ethtool_gset - mii_ethtool_set_link_ksettings - mii_nway_restart - netdev_err - netdev_info - netdev_warn - netif_carrier_on - usb_deregister - usbnet_disconnect - usbnet_get_endpoints - usbnet_get_msglevel - usbnet_get_stats64 - usbnet_link_change - usbnet_nway_reset - usbnet_open - usbnet_probe - usbnet_read_cmd - usbnet_read_cmd_nopm - usbnet_resume - usbnet_set_msglevel - usbnet_skb_return - usbnet_start_xmit - usbnet_stop - usbnet_suspend - usbnet_tx_timeout - usbnet_update_max_qlen - usbnet_write_cmd - usbnet_write_cmd_async - usbnet_write_cmd_nopm - usb_register_driver - # required by bam_dma.ko dma_async_device_register dma_async_device_unregister @@ -1303,9 +1266,6 @@ usb_put_hcd usb_remove_hcd -# required by pdr_interface.ko - strnlen - # required by phy-qcom-qmp.ko of_clk_get_by_name __of_reset_control_get @@ -1489,6 +1449,7 @@ refcount_dec_and_mutex_lock release_sock sk_alloc + skb_clone skb_copy_bits skb_copy_datagram_iter skb_free_datagram @@ -1577,7 +1538,9 @@ snd_ctl_add snd_ctl_new1 snd_pcm_add_chmap_ctls - snd_pcm_create_iec958_consumer_hw_params + snd_pcm_create_iec958_consumer_default + snd_pcm_fill_iec958_consumer + snd_pcm_fill_iec958_consumer_hw_params snd_pcm_hw_constraint_eld # required by snd-soc-qcom-common.ko @@ -1701,3 +1664,42 @@ # required by wcd934x.ko mfd_add_devices mfd_remove_devices + +# preserved by --additions-only + eth_platform_get_mac_address + ethtool_op_get_link + ethtool_op_get_ts_info + eth_validate_addr + generic_mii_ioctl + mii_ethtool_get_link_ksettings + mii_ethtool_gset + mii_ethtool_set_link_ksettings + mii_nway_restart + netdev_err + netdev_info + netdev_warn + netif_carrier_on + snd_pcm_create_iec958_consumer_hw_params + usb_deregister + usbnet_disconnect + usbnet_get_endpoints + usbnet_get_msglevel + usbnet_get_stats64 + usbnet_link_change + usbnet_nway_reset + usbnet_open + usbnet_probe + usbnet_read_cmd + usbnet_read_cmd_nopm + usbnet_resume + usbnet_set_msglevel + usbnet_skb_return + usbnet_start_xmit + usbnet_stop + usbnet_suspend + usbnet_tx_timeout + usbnet_update_max_qlen + usbnet_write_cmd + usbnet_write_cmd_async + usbnet_write_cmd_nopm + usb_register_driver From af4d4153ca0cda390521ff612061750bfdec9424 Mon Sep 17 00:00:00 2001 From: Hongyu Jin Date: Fri, 1 Apr 2022 19:55:27 +0800 Subject: [PATCH 102/124] BACKPORT: erofs: fix use-after-free of on-stack io[] The root cause is the race as follows: Thread #1 Thread #2(irq ctx) z_erofs_runqueue() struct z_erofs_decompressqueue io_A[]; submit bio A z_erofs_decompress_kickoff(,,1) z_erofs_decompressqueue_endio(bio A) z_erofs_decompress_kickoff(,,-1) spin_lock_irqsave() atomic_add_return() io_wait_event() -> pending_bios is already 0 [end of function] wake_up_locked(io_A[]) // crash Referenced backtrace in kernel 5.4: [ 10.129422] Unable to handle kernel paging request at virtual address eb0454a4 [ 10.364157] CPU: 0 PID: 709 Comm: getprop Tainted: G WC O 5.4.147-ab09225 #1 [ 11.556325] [] (__wake_up_common) from [] (__wake_up_locked+0x40/0x48) [ 11.565487] [] (__wake_up_locked) from [] (z_erofs_vle_unzip_kickoff+0x6c/0xc0) [ 11.575438] [] (z_erofs_vle_unzip_kickoff) from [] (z_erofs_vle_read_endio+0x16c/0x17c) [ 11.586082] [] (z_erofs_vle_read_endio) from [] (clone_endio+0xb4/0x1d0) [ 11.595428] [] (clone_endio) from [] (blk_update_request+0x150/0x4dc) [ 11.604516] [] (blk_update_request) from [] (mmc_blk_cqe_complete_rq+0x144/0x15c) [ 11.614640] [] (mmc_blk_cqe_complete_rq) from [] (blk_done_softirq+0xb0/0xcc) [ 11.624419] [] (blk_done_softirq) from [] (__do_softirq+0x184/0x56c) [ 11.633419] [] (__do_softirq) from [] (irq_exit+0xd4/0x138) [ 11.641640] [] (irq_exit) from [] (__handle_domain_irq+0x94/0xd0) [ 11.650381] [] (__handle_domain_irq) from [] (gic_handle_irq+0x50/0xd4) [ 11.659641] [] (gic_handle_irq) from [] (__irq_svc+0x70/0xb0) Bug: 246657836 Change-Id: Ieebf1c5abb48723538d05a5e65b5179a382dab3f (cherry picked from commit 60b30050116c0351b90154044345c1b53ae1f323) [Hongyu: Resolved minor conflict in fs/erofs/zdata.c ] Signed-off-by: Hongyu Jin Reviewed-by: Gao Xiang Reviewed-by: Chao Yu Link: https://lore.kernel.org/r/20220401115527.4935-1-hongyu.jin.cn@gmail.com Signed-off-by: Gao Xiang --- fs/erofs/zdata.c | 12 ++++-------- fs/erofs/zdata.h | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index 03a3dafc82f3..bff7bf2f7586 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -770,12 +770,9 @@ static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io, /* wake up the caller thread for sync decompression */ if (sync) { - unsigned long flags; - - spin_lock_irqsave(&io->u.wait.lock, flags); if (!atomic_add_return(bios, &io->pending_bios)) - wake_up_locked(&io->u.wait); - spin_unlock_irqrestore(&io->u.wait.lock, flags); + complete(&io->u.done); + return; } @@ -1186,7 +1183,7 @@ jobqueue_init(struct super_block *sb, } else { fg_out: q = fgq; - init_waitqueue_head(&fgq->u.wait); + init_completion(&fgq->u.done); atomic_set(&fgq->pending_bios, 0); } q->sb = sb; @@ -1360,8 +1357,7 @@ static void z_erofs_runqueue(struct super_block *sb, return; /* wait until all bios are completed */ - io_wait_event(io[JQ_SUBMIT].u.wait, - !atomic_read(&io[JQ_SUBMIT].pending_bios)); + wait_for_completion_io(&io[JQ_SUBMIT].u.done); /* handle synchronous decompress queue in the caller context */ z_erofs_decompress_queue(&io[JQ_SUBMIT], pagepool); diff --git a/fs/erofs/zdata.h b/fs/erofs/zdata.h index 4a69515dea75..5e9a0eb54c89 100644 --- a/fs/erofs/zdata.h +++ b/fs/erofs/zdata.h @@ -89,7 +89,7 @@ struct z_erofs_decompressqueue { z_erofs_next_pcluster_t head; union { - wait_queue_head_t wait; + struct completion done; struct work_struct work; } u; }; From 3dc6e416a159a0bf3336e4c3469531fbbd128146 Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Wed, 21 Sep 2022 20:34:48 +0000 Subject: [PATCH 103/124] ANDROID: force struct blk_mq_alloc_data to be defined in KMI There were 3 remaining types directly referenced by vendor hooks that were not fully-defined in the KMI: struct blk_mq_alloc_data is defined in block/blk-mq.h, however libabigail is not finding its definition based on the instantiation of the hooks, so force it to be defined by defining a dummy exported symbol. Since blk_mq_alloc_data is defined in a subsystem-private header, create a new vendor_hooks.c file in block/ to define the dummy symbol. Bug: 233047575 Bug: 248263460 Signed-off-by: Todd Kjos Change-Id: I6419caba1c6a159b7a64b9d28e983d753393af86 --- BUILD.bazel | 1 + android/abi_gki_aarch64_type_visibility | 4 ++++ block/Makefile | 1 + block/vendor_hooks.c | 24 ++++++++++++++++++++++++ build.config.gki.aarch64 | 1 + drivers/android/vendor_hooks.c | 3 --- 6 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 android/abi_gki_aarch64_type_visibility create mode 100644 block/vendor_hooks.c diff --git a/BUILD.bazel b/BUILD.bazel index f780ffd87460..8a7f131ba6e7 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -26,6 +26,7 @@ _aarch64_additional_kmi_symbol_lists = [ "android/abi_gki_aarch64_fips140", "android/abi_gki_aarch64_generic", "android/abi_gki_aarch64_hikey960", + "android/abi_gki_aarch64_type_visibility", "android/abi_gki_aarch64_virtual_device", ] diff --git a/android/abi_gki_aarch64_type_visibility b/android/abi_gki_aarch64_type_visibility new file mode 100644 index 000000000000..4f826b7b1f87 --- /dev/null +++ b/android/abi_gki_aarch64_type_visibility @@ -0,0 +1,4 @@ +[abi_symbol_list] + +# for type visibility + GKI_struct_blk_mq_alloc_data diff --git a/block/Makefile b/block/Makefile index af3d044abaf1..05daaf8282a1 100644 --- a/block/Makefile +++ b/block/Makefile @@ -39,3 +39,4 @@ obj-$(CONFIG_BLK_SED_OPAL) += sed-opal.o obj-$(CONFIG_BLK_PM) += blk-pm.o obj-$(CONFIG_BLK_INLINE_ENCRYPTION) += keyslot-manager.o blk-crypto.o obj-$(CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK) += blk-crypto-fallback.o +obj-$(CONFIG_ANDROID_VENDOR_HOOKS) += vendor_hooks.o diff --git a/block/vendor_hooks.c b/block/vendor_hooks.c new file mode 100644 index 000000000000..db033b9e2835 --- /dev/null +++ b/block/vendor_hooks.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* vendor_hook.c + * + * Copyright 2022 Google LLC + */ +#include "blk.h" +#include "blk-mq-tag.h" +#include "blk-mq.h" +#include + +#define CREATE_TRACE_POINTS +#include +#include +#include + +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_blk_alloc_rqs); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_blk_rq_ctx_init); + +/* + * For type visibility + */ +const struct blk_mq_alloc_data *GKI_struct_blk_mq_alloc_data; +EXPORT_SYMBOL_GPL(GKI_struct_blk_mq_alloc_data); + diff --git a/build.config.gki.aarch64 b/build.config.gki.aarch64 index 45f1caeb3ff6..dde70d69dd33 100644 --- a/build.config.gki.aarch64 +++ b/build.config.gki.aarch64 @@ -11,6 +11,7 @@ Image.gz ABI_DEFINITION=android/abi_gki_aarch64.xml KMI_SYMBOL_LIST=android/abi_gki_aarch64 ADDITIONAL_KMI_SYMBOL_LISTS=" +android/abi_gki_aarch64_type_visibility android/abi_gki_aarch64_core android/abi_gki_aarch64_fips140 android/abi_gki_aarch64_generic diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 8ddb3f6664fc..d313d85eb576 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -62,7 +62,6 @@ #include #include #include -#include #include #include #include @@ -270,8 +269,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_selinux_avc_insert); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_selinux_avc_node_delete); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_selinux_avc_node_replace); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_selinux_avc_lookup); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_blk_alloc_rqs); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_blk_rq_ctx_init); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_commit_creds); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_exit_creds); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_override_creds); From f8136944246662cdc7992765f89434049b546fb0 Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Wed, 21 Sep 2022 22:31:07 +0000 Subject: [PATCH 104/124] ANDROID: force struct cgroup_taskset to be defined in KMI struct cgroup_taskset is defined in kernel/cgroup/cgroup-internal.h, however libabigail is not finding its definition based on the instantiation of the hooks, so force it to be defined by defining a dummy exported symbol. Since cgroup_taskset is defined in a subsystem-private header, create a new vendor_hooks.c file in kernel/cgroup to define the dummy symbol. Update the XML with the new type definitions Bug: 233047575 Signed-off-by: Todd Kjos Change-Id: I7a2bf2a722bf5aec0c702f215d572cc8e5336f9a --- android/abi_gki_aarch64.xml | 250 +++++++++++++----------- android/abi_gki_aarch64_type_visibility | 1 + drivers/android/vendor_hooks.c | 7 +- kernel/cgroup/Makefile | 1 + kernel/cgroup/vendor_hooks.c | 37 ++++ 5 files changed, 174 insertions(+), 122 deletions(-) create mode 100644 kernel/cgroup/vendor_hooks.c diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index 24fb6b9a3465..aa802204073f 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -3716,6 +3716,8 @@ + + @@ -4222,14 +4224,6 @@ - - - - - - - - @@ -8888,7 +8882,7 @@ - + @@ -12473,6 +12467,7 @@ + @@ -13014,7 +13009,29 @@ - + + + + + + + + + + + + + + + + + + + + + + + @@ -15068,6 +15085,7 @@ + @@ -26209,7 +26227,7 @@ - + @@ -29784,6 +29802,7 @@ + @@ -45473,6 +45492,7 @@ + @@ -49601,32 +49621,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -72008,36 +72003,36 @@ - + - + - + - + - + - + - + - + - + - + @@ -72048,7 +72043,7 @@ - + @@ -72072,96 +72067,96 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -73495,7 +73490,26 @@ - + + + + + + + + + + + + + + + + + + + + @@ -76800,7 +76814,7 @@ - + @@ -99577,7 +99591,7 @@ - + @@ -99594,7 +99608,7 @@ - + @@ -99602,7 +99616,7 @@ - + @@ -99610,12 +99624,12 @@ - + - + @@ -99623,7 +99637,7 @@ - + @@ -99631,7 +99645,7 @@ - + @@ -99648,12 +99662,12 @@ - + - + @@ -99679,7 +99693,7 @@ - + @@ -99690,7 +99704,7 @@ - + @@ -99710,7 +99724,7 @@ - + @@ -99733,7 +99747,7 @@ - + @@ -99747,12 +99761,12 @@ - + - + @@ -99763,7 +99777,7 @@ - + @@ -99777,7 +99791,7 @@ - + @@ -99788,7 +99802,7 @@ - + @@ -99802,7 +99816,7 @@ - + @@ -99816,12 +99830,12 @@ - + - + @@ -99829,7 +99843,7 @@ - + @@ -99843,7 +99857,7 @@ - + @@ -99851,7 +99865,7 @@ - + @@ -99862,7 +99876,7 @@ - + @@ -99879,7 +99893,7 @@ - + @@ -99899,7 +99913,7 @@ - + @@ -99916,7 +99930,7 @@ - + @@ -99927,7 +99941,7 @@ - + @@ -99935,7 +99949,7 @@ - + @@ -99943,7 +99957,7 @@ - + @@ -99951,7 +99965,7 @@ - + @@ -99965,7 +99979,7 @@ - + @@ -99973,7 +99987,7 @@ - + @@ -99984,7 +99998,7 @@ - + @@ -100001,7 +100015,7 @@ - + @@ -107680,7 +107694,7 @@ - + @@ -109402,6 +109416,8 @@ + + diff --git a/android/abi_gki_aarch64_type_visibility b/android/abi_gki_aarch64_type_visibility index 4f826b7b1f87..8a98e59ea81b 100644 --- a/android/abi_gki_aarch64_type_visibility +++ b/android/abi_gki_aarch64_type_visibility @@ -2,3 +2,4 @@ # for type visibility GKI_struct_blk_mq_alloc_data + GKI_struct_cgroup_taskset diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index d313d85eb576..7966f96c1834 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -62,7 +62,9 @@ #include #include #include +#ifdef __GENKSYMS__ #include +#endif #include #include #include @@ -104,7 +106,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_select_task_rq_fair); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_select_task_rq_rt); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_select_task_rq_dl); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_select_fallback_rq); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_refrigerator); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_scheduler_tick); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_enqueue_task); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_dequeue_task); @@ -249,8 +250,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_uclamp_eff_get); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_uclamp_task_util); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_uclamp_rq_util_with); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpufreq_transition); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_set_task); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cgroup_force_kthread_migration); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_syscall_prctl_finished); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_create_worker); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_check_preempt_tick); @@ -315,7 +314,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_swappiness); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_shrink_slab_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_event); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_group); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpuset_fork); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_set_cpus_allowed_comm); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sched_setaffinity_early); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_free_task); @@ -333,7 +331,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_selinux_is_initialized); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_tune_inactive_ratio); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_update_topology_flags_workfn); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_of_i2c_get_board_info); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_attach); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mm_dirty_limits); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_oom_check_panic); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_check_uninterruptible_tasks); diff --git a/kernel/cgroup/Makefile b/kernel/cgroup/Makefile index 5d7a76bfbbb7..c8bc5cbe1d45 100644 --- a/kernel/cgroup/Makefile +++ b/kernel/cgroup/Makefile @@ -6,3 +6,4 @@ obj-$(CONFIG_CGROUP_PIDS) += pids.o obj-$(CONFIG_CGROUP_RDMA) += rdma.o obj-$(CONFIG_CPUSETS) += cpuset.o obj-$(CONFIG_CGROUP_DEBUG) += debug.o +obj-$(CONFIG_ANDROID_VENDOR_HOOKS) += vendor_hooks.o diff --git a/kernel/cgroup/vendor_hooks.c b/kernel/cgroup/vendor_hooks.c new file mode 100644 index 000000000000..95f7e3410d7d --- /dev/null +++ b/kernel/cgroup/vendor_hooks.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* vendor_hook.c + * + * Android Vendor Hook Support + * + * Copyright 2022 Google LLC + */ +#ifndef __GENKSYMS__ +#include "cgroup-internal.h" +#else +/* + * Needed to preserve CRC for cgroup-related hooks + */ +#include +#include <../drivers/gpio/gpiolib.h> +#endif + +#define CREATE_TRACE_POINTS +#include +#include +#include + +/* + * Export tracepoints that act as a bare tracehook (ie: have no trace event + * associated with them) to allow external modules to probe them. + */ +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_set_task); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cpuset_fork); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_cgroup_force_kthread_migration); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_refrigerator); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cgroup_attach); + +/* + * For type visibility + */ +const struct cgroup_taskset *GKI_struct_cgroup_taskset; +EXPORT_SYMBOL_GPL(GKI_struct_cgroup_taskset); From 8483cc3a75a2ec9c646551737db5bb42b6362468 Mon Sep 17 00:00:00 2001 From: Bowgo Tsai Date: Thu, 22 Sep 2022 17:24:36 +0800 Subject: [PATCH 105/124] ANDROID: Enable BUILD_GKI_CERTIFICATION_TOOLS for x86_64 GKI The tools are required to certify a x86_64 GKI boot.img. Bug: 241497048 Test: BUILD_CONFIG=common/build.config.gki.x86_64 build/build.sh Signed-off-by: Bowgo Tsai Change-Id: I0a34b9c8376cdfd77fb9b58b1b50ac734696672f (cherry picked from commit 35b34f288013b85fffee79525c711a6d1f49753e) --- build.config.gki.x86_64 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.config.gki.x86_64 b/build.config.gki.x86_64 index 7ecd1dfe7dcb..3d81fea6aacb 100644 --- a/build.config.gki.x86_64 +++ b/build.config.gki.x86_64 @@ -5,5 +5,7 @@ BUILD_SYSTEM_DLKM=1 MODULES_LIST=${ROOT_DIR}/${KERNEL_DIR}/android/gki_system_dlkm_modules +BUILD_GKI_CERTIFICATION_TOOLS=1 + BUILD_GKI_ARTIFACTS=1 BUILD_GKI_BOOT_IMG_SIZE=67108864 From 494e7075c95df7c664a6eb8aa97ca89e9661a2b6 Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Mon, 15 Aug 2022 10:12:59 -0700 Subject: [PATCH 106/124] ANDROID: fuse-bpf: readddir postfilter fixes Test: fuse_test passes, with appropriate user code directories can be hidden Bug: 219958836 Signed-off-by: Paul Lawrence Change-Id: Ia77d4bf9e63d0dd4535e53e9e07c3216fd4b8430 --- fs/fuse/backing.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/fs/fuse/backing.c b/fs/fuse/backing.c index b536fd9e99b7..49b848e4462d 100644 --- a/fs/fuse/backing.c +++ b/fs/fuse/backing.c @@ -23,6 +23,9 @@ struct fuse_bpf_aio_req { static struct kmem_cache *fuse_bpf_aio_request_cachep; +static void fuse_stat_to_attr(struct fuse_conn *fc, struct inode *inode, + struct kstat *stat, struct fuse_attr *attr); + static void fuse_file_accessed(struct file *dst_file, struct file *src_file) { struct inode *dst_inode; @@ -181,8 +184,10 @@ void *fuse_open_finalize(struct fuse_bpf_args *fa, struct fuse_file *ff = file->private_data; struct fuse_open_out *foo = fa->out_args[0].value; - if (ff) + if (ff) { ff->fh = foo->fh; + ff->nodeid = get_fuse_inode(inode)->nodeid; + } return 0; } @@ -1153,6 +1158,9 @@ int fuse_lookup_backing(struct fuse_bpf_args *fa, struct inode *dir, struct dentry *dir_backing_entry = dir_fuse_entry->backing_path.dentry; struct inode *dir_backing_inode = dir_backing_entry->d_inode; struct dentry *backing_entry; + struct fuse_entry_out *feo = (void *)fa->out_args[0].value; + struct kstat stat; + int err; /* TODO this will not handle lookups over mount points */ inode_lock_nested(dir_backing_inode, I_MUTEX_PARENT); @@ -1165,10 +1173,21 @@ int fuse_lookup_backing(struct fuse_bpf_args *fa, struct inode *dir, fuse_entry->backing_path = (struct path) { .dentry = backing_entry, - .mnt = dir_fuse_entry->backing_path.mnt, + .mnt = mntget(dir_fuse_entry->backing_path.mnt), }; - mntget(fuse_entry->backing_path.mnt); + if (d_is_negative(backing_entry)) + return 0; + + err = vfs_getattr(&fuse_entry->backing_path, &stat, + STATX_BASIC_STATS, 0); + if (err) { + path_put_init(&fuse_entry->backing_path); + return err; + } + + fuse_stat_to_attr(get_fuse_conn(dir), + backing_entry->d_inode, &stat, &feo->attr); return 0; } From 1bd5344779e7d607fecdb47a2536d676fa0330ab Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Wed, 31 Aug 2022 14:41:11 -0700 Subject: [PATCH 107/124] ANDROID: fuse-bpf: Add test for lookup postfilter Test: fuse_test passes Bug: 219958836 Signed-off-by: Paul Lawrence Change-Id: I04a68af274ecf823a96e2f0ead49f56d2f1c1452 --- .../selftests/filesystems/fuse/fuse_test.c | 60 ++++++++++++++++++- .../selftests/filesystems/fuse/test_bpf.c | 13 ++++ 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/filesystems/fuse/fuse_test.c b/tools/testing/selftests/filesystems/fuse/fuse_test.c index 58a0dd587fec..ffc960aa6315 100644 --- a/tools/testing/selftests/filesystems/fuse/fuse_test.c +++ b/tools/testing/selftests/filesystems/fuse/fuse_test.c @@ -1911,6 +1911,63 @@ out: return result; } +static int bpf_test_lookup_postfilter(const char *mount_dir) +{ + const char *file1_name = "file1"; + const char *file2_name = "file2"; + int result = TEST_FAILURE; + int bpf_fd = -1; + int src_fd = -1; + int fuse_dev = -1; + int file_fd = -1; + int pid = -1; + int status; + + TEST(file_fd = s_creat(s_path(s(ft_src), s(file1_name)), 0777), + file_fd != -1); + TESTSYSCALL(close(file_fd)); + TEST(file_fd = s_creat(s_path(s(ft_src), s(file2_name)), 0777), + file_fd != -1); + TESTSYSCALL(close(file_fd)); + file_fd = -1; + TESTEQUAL(install_elf_bpf("test_bpf.bpf", "test_lookup_postfilter", + &bpf_fd, NULL, NULL), 0); + TEST(src_fd = open(ft_src, O_DIRECTORY | O_RDONLY | O_CLOEXEC), + src_fd != -1); + TESTEQUAL(mount_fuse(mount_dir, bpf_fd, src_fd, &fuse_dev), 0); + FUSE_ACTION + int fd = -1; + + TESTEQUAL(s_open(s_path(s(mount_dir), s(file1_name)), O_RDONLY), + -1); + TESTEQUAL(errno, ENOENT); + TEST(fd = s_open(s_path(s(mount_dir), s(file2_name)), O_RDONLY), + fd != -1); + TESTSYSCALL(close(fd)); + FUSE_DAEMON + struct fuse_entry_out *feo; + struct fuse_entry_bpf_out *febo; + + TESTFUSELOOKUP(file1_name, FUSE_POSTFILTER); + TESTFUSEOUTERROR(-ENOENT); + TESTFUSELOOKUP(file2_name, FUSE_POSTFILTER); + feo = (struct fuse_entry_out *) (bytes_in + + sizeof(struct fuse_in_header) + strlen(file2_name) + 1); + febo = (struct fuse_entry_bpf_out *) ((char *)feo + + sizeof(*feo)); + TESTFUSEOUT2(fuse_entry_out, *feo, fuse_entry_bpf_out, *febo); + FUSE_DONE + + result = TEST_SUCCESS; +out: + close(file_fd); + close(fuse_dev); + umount(mount_dir); + close(src_fd); + close(bpf_fd); + return result; +} + static int parse_options(int argc, char *const *argv) { signed char c; @@ -2017,7 +2074,8 @@ int main(int argc, char *argv[]) MAKE_TEST(bpf_test_lseek), MAKE_TEST(bpf_test_readdirplus_not_overriding_backing), MAKE_TEST(bpf_test_no_readdirplus_without_nodeid), - MAKE_TEST(bpf_test_revalidate_handle_backing_fd) + MAKE_TEST(bpf_test_revalidate_handle_backing_fd), + MAKE_TEST(bpf_test_lookup_postfilter), }; #undef MAKE_TEST diff --git a/tools/testing/selftests/filesystems/fuse/test_bpf.c b/tools/testing/selftests/filesystems/fuse/test_bpf.c index 472a02aef5b5..b47445735ab6 100644 --- a/tools/testing/selftests/filesystems/fuse/test_bpf.c +++ b/tools/testing/selftests/filesystems/fuse/test_bpf.c @@ -524,3 +524,16 @@ int readdirplus_test(struct fuse_bpf_args *fa) } return FUSE_BPF_BACKING; } + +SEC("test_lookup_postfilter") +int lookuppostfilter_test(struct fuse_bpf_args *fa) +{ + switch(fa->opcode) { + case FUSE_LOOKUP | FUSE_PREFILTER: + return FUSE_BPF_BACKING | FUSE_BPF_POST_FILTER; + case FUSE_LOOKUP | FUSE_POSTFILTER: + return FUSE_BPF_USER_FILTER; + default: + return FUSE_BPF_BACKING; + } +} From 1856a68952a90a34d459f55d06f84f2177601ca6 Mon Sep 17 00:00:00 2001 From: Hsiu-Chang Chen Date: Fri, 23 Sep 2022 14:40:39 +0800 Subject: [PATCH 108/124] ANDROID: Update the ABI representation 2 symbol(s) added 'struct user_namespace init_user_ns' 'bool ns_capable_noaudit(struct user_namespace *, int)' Bug: 234311675 Signed-off-by: Hsiu-Chang Chen Change-Id: I78851c0ada381095bbac338a331bcd2cc2cd8cde --- android/abi_gki_aarch64.xml | 192 +++++++++++++++++--------------- android/abi_gki_aarch64_generic | 2 + 2 files changed, 102 insertions(+), 92 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index aa802204073f..8e649b4467c9 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -2272,6 +2272,7 @@ + @@ -3891,6 +3892,7 @@ + @@ -5421,7 +5423,7 @@ - + @@ -8882,7 +8884,7 @@ - + @@ -16954,7 +16956,7 @@ - + @@ -26227,7 +26229,7 @@ - + @@ -71872,7 +71874,15 @@ - + + + + + + + + + @@ -71883,14 +71893,6 @@ - - - - - - - - @@ -72003,36 +72005,36 @@ - + - + - + - + - + - + - + - + - + - + @@ -72043,7 +72045,7 @@ - + @@ -72067,96 +72069,96 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -76814,7 +76816,7 @@ - + @@ -99591,7 +99593,7 @@ - + @@ -99608,7 +99610,7 @@ - + @@ -99616,7 +99618,7 @@ - + @@ -99624,12 +99626,12 @@ - + - + @@ -99637,7 +99639,7 @@ - + @@ -99645,7 +99647,7 @@ - + @@ -99662,12 +99664,12 @@ - + - + @@ -99693,7 +99695,7 @@ - + @@ -99704,7 +99706,7 @@ - + @@ -99724,7 +99726,7 @@ - + @@ -99747,7 +99749,7 @@ - + @@ -99761,12 +99763,12 @@ - + - + @@ -99777,7 +99779,7 @@ - + @@ -99791,7 +99793,7 @@ - + @@ -99802,7 +99804,7 @@ - + @@ -99816,7 +99818,7 @@ - + @@ -99830,12 +99832,12 @@ - + - + @@ -99843,7 +99845,7 @@ - + @@ -99857,7 +99859,7 @@ - + @@ -99865,7 +99867,7 @@ - + @@ -99876,7 +99878,7 @@ - + @@ -99893,7 +99895,7 @@ - + @@ -99913,7 +99915,7 @@ - + @@ -99930,7 +99932,7 @@ - + @@ -99941,7 +99943,7 @@ - + @@ -99949,7 +99951,7 @@ - + @@ -99957,7 +99959,7 @@ - + @@ -99965,7 +99967,7 @@ - + @@ -99979,7 +99981,7 @@ - + @@ -99987,7 +99989,7 @@ - + @@ -99998,7 +100000,7 @@ - + @@ -100015,7 +100017,7 @@ - + @@ -107694,7 +107696,7 @@ - + @@ -119667,6 +119669,7 @@ + @@ -121729,6 +121732,11 @@ + + + + + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index 966896aa05e3..ad0af06c1cd6 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -1052,6 +1052,7 @@ __init_swait_queue_head init_task init_timer_key + init_user_ns init_wait_entry __init_waitqueue_head input_alloc_absinfo @@ -1375,6 +1376,7 @@ nr_cpu_ids nr_irqs ns_capable + ns_capable_noaudit nsec_to_clock_t ns_to_timespec64 __num_online_cpus From 7b19b0064b9bc52f5bd09b253d0d3003eb13d70d Mon Sep 17 00:00:00 2001 From: Jianqun Xu Date: Fri, 5 Mar 2021 16:06:58 +0800 Subject: [PATCH 109/124] UPSTREAM: kernel/irq: export irq_gc_set_wake Module driver may use irq_gc_set_wake. Bug: 194515348 Change-Id: I52f43e1dff15d987532395e5151e65419b5904b2 Signed-off-by: Jianqun Xu Acked-by: Marc Zyngier Link: https://lore.kernel.org/r/20210305080658.2422114-1-jay.xu@rock-chips.com Signed-off-by: Linus Walleij (cherry picked from commit 024c79520ff5f8cfb9666cdb877af30c554c540f) Signed-off-by: Kever Yang --- kernel/irq/generic-chip.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c index e2999a070a99..79cb6d063b80 100644 --- a/kernel/irq/generic-chip.c +++ b/kernel/irq/generic-chip.c @@ -200,6 +200,7 @@ int irq_gc_set_wake(struct irq_data *d, unsigned int on) irq_gc_unlock(gc); return 0; } +EXPORT_SYMBOL_GPL(irq_gc_set_wake); static u32 irq_readl_be(void __iomem *addr) { From 7a6ea55aa01ad68460ef10b47abedef555b0a4a1 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 27 Sep 2022 14:04:37 +0200 Subject: [PATCH 110/124] Revert "ANDROID: workqueue: add vendor hook for wq lockup information" This reverts commit 34f087452f27d1f07a6f8a214fdeb83846e9e670. The hook android_vh_wq_lockup_pool is not used by any vendor, so remove it to help with merge issues with future LTS releases. If this is needed by any real user, it can easily be reverted to add it back and then the symbol should be added to the abi list at the same time to prevent it from being removed again later. Bug: 203756332 Bug: 169374262 Cc: Sangmoon Kim Signed-off-by: Greg Kroah-Hartman Change-Id: I84eb7e1abc535a4efecd2b6071ef6d25fa2c1e2e --- drivers/android/vendor_hooks.c | 2 -- include/trace/hooks/wqlockup.h | 21 --------------------- kernel/workqueue.c | 2 -- 3 files changed, 25 deletions(-) delete mode 100644 include/trace/hooks/wqlockup.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 7966f96c1834..9d54e5a7d6d1 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -148,7 +147,6 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_cpu_idle_exit); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mpam_set); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_find_busiest_group); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gic_resume); -EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_wq_lockup_pool); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_ipi_stop); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sysrq_crash); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dump_throttled_rt_tasks); diff --git a/include/trace/hooks/wqlockup.h b/include/trace/hooks/wqlockup.h deleted file mode 100644 index 2572ebf5eff4..000000000000 --- a/include/trace/hooks/wqlockup.h +++ /dev/null @@ -1,21 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#undef TRACE_SYSTEM -#define TRACE_SYSTEM wqlockup -#define TRACE_INCLUDE_PATH trace/hooks - -#if !defined(_TRACE_HOOK_WQLOCKUP_H) || defined(TRACE_HEADER_MULTI_READ) -#define _TRACE_HOOK_WQLOCKUP_H -#include -/* - * Following tracepoints are not exported in tracefs and provide a - * mechanism for vendor modules to hook and extend functionality - */ -DECLARE_HOOK(android_vh_wq_lockup_pool, - TP_PROTO(int cpu, unsigned long pool_ts), - TP_ARGS(cpu, pool_ts)); - -/* macro versions of hooks are no longer required */ - -#endif /* _TRACE_HOOK_WQLOCKUP_H */ -/* This part must be outside protection */ -#include diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 9334aef949f5..d89b24db809f 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -54,7 +54,6 @@ #include "workqueue_internal.h" -#include #include /* events/workqueue.h uses default TRACE_INCLUDE_PATH */ #undef TRACE_INCLUDE_PATH @@ -5845,7 +5844,6 @@ static void wq_watchdog_timer_fn(struct timer_list *unused) pr_cont_pool_info(pool); pr_cont(" stuck for %us!\n", jiffies_to_msecs(now - pool_ts) / 1000); - trace_android_vh_wq_lockup_pool(pool->cpu, pool_ts); } } From 14e1028389b8641d034d0d6978cc1e7e0e58d54b Mon Sep 17 00:00:00 2001 From: John Stultz Date: Mon, 8 Aug 2022 16:56:00 +0000 Subject: [PATCH 111/124] ANDROID: sched: Fix off-by-one with cpupri MAX_RT_PRIO evaluation This patch addresses an issue seen where SCHED_FIFO prio 99 tasks were being woken up on a cpu where a long-running softirq was executing, and the RT task was not being migrated, causing long (10+ms wakeup latencies). Prior to upstream commit 934fc3314b39 ("sched/cpupri: Remap CPUPRI_NORMAL to MAX_RT_PRIO-1") the task->prio -> cpupri mapping is a little ackward. For RT tasks, its calculated as: cpupri = MAX_RT_PRIO - prio + 1; See: https://android.googlesource.com/kernel/common/+/refs/heads/android13-5.10/kernel/sched/cpupri.c#39 This is added ontop of the also ackward detail that the task->prio is inverted (RT prio99 -> 0), means the cpupri mapping for RT tasks goes from 2->101. This makes it easy to evaluate the cpupri incorrectly. Which it turns out happened In commit 3adfd8e344ac ("ANDROID: sched: avoid placing RT threads on cores handling softirqs"): https://android.googlesource.com/kernel/common/+/3adfd8e344ac32845eb3c15743f90a7e3b49dcf3%5E%21/ With the lines: int task_pri = convert_prio(p->prio); bool drop_nopreempts = task_pri <= MAX_RT_PRIO; Where the added logic to decide to migrate a rt task off of a cpu depended on this drop_nopreempts being true. This works properly for rt tasks from prio 99 to 1, but for the case of task->prio == 0 (userland rt prio 99 tasks) it breaks, as the cpupri will be MAX_RT_PRIO - 0 + 1, which then gets checked as <= MAX_RT_PRIO. This prevents the cpu from being dropped from the scheduling set and prevents the rt user prio 99 task from migrating, which results in high priority rt tasks being left on cpus where long running softirqs are executing, causing long latencies. This patch fixes the off by one by changing the evaulation to MAX_RT_PRIO + 1, so that user-prio 99 tasks will also be migrated if appropriate. Luckilly this odd cpupri mapping has been fixed upstream, making this patch no longer necessary in 5.15 and newer kernels. Fixes: 3adfd8e344ac ("ANDROID: sched: avoid placing RT threads on cores handling softirqs") Signed-off-by: John Stultz Change-Id: Ia2db7cd461eb4c90f5850b791de1ae95582f7530 --- kernel/sched/cpupri.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/cpupri.c b/kernel/sched/cpupri.c index 450a724b4542..2896860c8333 100644 --- a/kernel/sched/cpupri.c +++ b/kernel/sched/cpupri.c @@ -150,7 +150,7 @@ int cpupri_find_fitness(struct cpupri *cp, struct task_struct *p, { int task_pri = convert_prio(p->prio); int idx, cpu; - bool drop_nopreempts = task_pri <= MAX_RT_PRIO; + bool drop_nopreempts = task_pri <= MAX_RT_PRIO + 1; BUG_ON(task_pri >= CPUPRI_NR_PRIORITIES); From d91e7b80d89a382a32d16eaefdf548e3d37436ff Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Thu, 29 Sep 2022 03:57:37 +0000 Subject: [PATCH 112/124] ANDROID: Update the ABI representation 1 symbol(s) added 'void drm_atomic_bridge_chain_disable(struct drm_bridge *, struct drm_atomic_state *)' Bug: 233709537 Signed-off-by: Leo Chen Change-Id: I1e3e5c41f3c32404dc25c1f69f447efb3cbafb5d --- android/abi_gki_aarch64.xml | 248 ++++++++++++++++---------------- android/abi_gki_aarch64_generic | 2 + 2 files changed, 129 insertions(+), 121 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index 8e649b4467c9..9ef5c780fb9e 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -1197,6 +1197,7 @@ + @@ -5423,7 +5424,7 @@ - + @@ -13295,72 +13296,72 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -16956,7 +16957,7 @@ - + @@ -67103,69 +67104,69 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -68535,12 +68536,12 @@ - + - + - + @@ -71874,15 +71875,7 @@ - - - - - - - - - + @@ -71893,6 +71886,14 @@ + + + + + + + + @@ -73750,45 +73751,45 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -84666,15 +84667,15 @@ - + - + - + - + @@ -111916,10 +111917,10 @@ - - - - + + + + @@ -112859,16 +112860,16 @@ - - + + - - + + - - + + @@ -114217,7 +114218,7 @@ - + @@ -114397,16 +114398,16 @@ - - + + - - + + @@ -116187,8 +116188,8 @@ - - + + @@ -116237,6 +116238,11 @@ + + + + + @@ -118051,16 +118057,16 @@ - - + + - - + + - - + + @@ -121371,11 +121377,11 @@ - - - - - + + + + + @@ -123549,17 +123555,17 @@ - - - - - + + + + + - - - - + + + + @@ -126703,12 +126709,12 @@ - - - + + + - - + + @@ -128997,8 +129003,8 @@ - - + + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index ad0af06c1cd6..51f6c19865a1 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -629,6 +629,7 @@ drm_add_modes_noedid drm_atomic_add_affected_connectors drm_atomic_add_affected_planes + drm_atomic_bridge_chain_disable drm_atomic_commit drm_atomic_get_connector_state drm_atomic_get_crtc_state @@ -964,6 +965,7 @@ gpiod_get_raw_value_cansleep gpiod_get_value gpiod_get_value_cansleep + gpiod_set_debounce gpiod_set_raw_value gpiod_set_raw_value_cansleep gpiod_set_value From 9fafd34f1d7088338612338cb98b4a3010645433 Mon Sep 17 00:00:00 2001 From: Jeongik Cha Date: Mon, 4 Jul 2022 17:43:54 +0900 Subject: [PATCH 113/124] UPSTREAM: wifi: mac80211_hwsim: fix race condition in pending packet commit 4ee186fa7e40ae06ebbfbad77e249e3746e14114 upstream. A pending packet uses a cookie as an unique key, but it can be duplicated because it didn't use atomic operators. And also, a pending packet can be null in hwsim_tx_info_frame_received_nl due to race condition with mac80211_hwsim_stop. For this, * Use an atomic type and operator for a cookie * Add a lock around the loop for pending packets Signed-off-by: Jeongik Cha Link: https://lore.kernel.org/r/20220704084354.3556326-1-jeongik@google.com Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman (cherry picked from commit eb8fc4277b628ac81db806c130a500dd48a9e524) Signed-off-by: Carlos Llamas Bug: 236994625 Change-Id: Ic6613c8869a51b5de303e40406f023af689b9d64 --- drivers/net/wireless/mac80211_hwsim.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 6911e588e578..85fc2b6aa45c 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -597,7 +597,7 @@ struct mac80211_hwsim_data { bool ps_poll_pending; struct dentry *debugfs; - uintptr_t pending_cookie; + atomic64_t pending_cookie; struct sk_buff_head pending; /* packets pending */ /* * Only radios in the same group can communicate together (the @@ -1204,7 +1204,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw, int i; struct hwsim_tx_rate tx_attempts[IEEE80211_TX_MAX_RATES]; struct hwsim_tx_rate_flag tx_attempts_flags[IEEE80211_TX_MAX_RATES]; - uintptr_t cookie; + u64 cookie; if (data->ps != PS_DISABLED) hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); @@ -1273,8 +1273,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw, goto nla_put_failure; /* We create a cookie to identify this skb */ - data->pending_cookie++; - cookie = data->pending_cookie; + cookie = (u64)atomic64_inc_return(&data->pending_cookie); info->rate_driver_data[0] = (void *)cookie; if (nla_put_u64_64bit(skb, HWSIM_ATTR_COOKIE, cookie, HWSIM_ATTR_PAD)) goto nla_put_failure; @@ -3511,6 +3510,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2, const u8 *src; unsigned int hwsim_flags; int i; + unsigned long flags; bool found = false; if (!info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER] || @@ -3538,18 +3538,20 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2, } /* look for the skb matching the cookie passed back from user */ + spin_lock_irqsave(&data2->pending.lock, flags); skb_queue_walk_safe(&data2->pending, skb, tmp) { u64 skb_cookie; txi = IEEE80211_SKB_CB(skb); - skb_cookie = (u64)(uintptr_t)txi->rate_driver_data[0]; + skb_cookie = (u64)txi->rate_driver_data[0]; if (skb_cookie == ret_skb_cookie) { - skb_unlink(skb, &data2->pending); + __skb_unlink(skb, &data2->pending); found = true; break; } } + spin_unlock_irqrestore(&data2->pending.lock, flags); /* not found */ if (!found) From 80c59100dade6805d807181102a01b369955a0d9 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 11 Jul 2022 13:14:24 +0200 Subject: [PATCH 114/124] UPSTREAM: wifi: mac80211_hwsim: add back erroneously removed cast commit 58b6259d820d63c2adf1c7541b54cce5a2ae6073 upstream. The robots report that we're now casting to a differently sized integer, which is correct, and the previous patch had erroneously removed it. Reported-by: kernel test robot Fixes: 4ee186fa7e40 ("wifi: mac80211_hwsim: fix race condition in pending packet") Signed-off-by: Johannes Berg Cc: Jeongik Cha Signed-off-by: Greg Kroah-Hartman (cherry picked from commit d400222f49599423862010f0c7f6fee142be72d7) Signed-off-by: Carlos Llamas Bug: 236994625 Change-Id: I4b5cfa77c47d4d03b46600f0b543e27340c228c0 --- drivers/net/wireless/mac80211_hwsim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 85fc2b6aa45c..9ca6497c6bf9 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -3543,7 +3543,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2, u64 skb_cookie; txi = IEEE80211_SKB_CB(skb); - skb_cookie = (u64)txi->rate_driver_data[0]; + skb_cookie = (u64)(uintptr_t)txi->rate_driver_data[0]; if (skb_cookie == ret_skb_cookie) { __skb_unlink(skb, &data2->pending); From 9c24cb8704b15761290390010a211e8ea1eebe22 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 13 Jul 2022 21:16:45 +0200 Subject: [PATCH 115/124] UPSTREAM: wifi: mac80211_hwsim: use 32-bit skb cookie commit cc5250cdb43d444061412df7fae72d2b4acbdf97 upstream. We won't really have enough skbs to need a 64-bit cookie, and on 32-bit platforms storing the 64-bit cookie into the void *rate_driver_data doesn't work anyway. Switch back to using just a 32-bit cookie and uintptr_t for the type to avoid compiler warnings about all this. Fixes: 4ee186fa7e40 ("wifi: mac80211_hwsim: fix race condition in pending packet") Signed-off-by: Johannes Berg Cc: Jeongik Cha Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 6dece5ad6e1e7d8c2bacfae606dc6f18a18c51e0) Signed-off-by: Carlos Llamas Bug: 236994625 Change-Id: I81b075297ec2248f706aebc914cd5e2783665bbc --- drivers/net/wireless/mac80211_hwsim.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 9ca6497c6bf9..9157257925e1 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -597,7 +597,7 @@ struct mac80211_hwsim_data { bool ps_poll_pending; struct dentry *debugfs; - atomic64_t pending_cookie; + atomic_t pending_cookie; struct sk_buff_head pending; /* packets pending */ /* * Only radios in the same group can communicate together (the @@ -1204,7 +1204,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw, int i; struct hwsim_tx_rate tx_attempts[IEEE80211_TX_MAX_RATES]; struct hwsim_tx_rate_flag tx_attempts_flags[IEEE80211_TX_MAX_RATES]; - u64 cookie; + uintptr_t cookie; if (data->ps != PS_DISABLED) hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); @@ -1273,7 +1273,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw, goto nla_put_failure; /* We create a cookie to identify this skb */ - cookie = (u64)atomic64_inc_return(&data->pending_cookie); + cookie = atomic_inc_return(&data->pending_cookie); info->rate_driver_data[0] = (void *)cookie; if (nla_put_u64_64bit(skb, HWSIM_ATTR_COOKIE, cookie, HWSIM_ATTR_PAD)) goto nla_put_failure; @@ -3540,10 +3540,10 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2, /* look for the skb matching the cookie passed back from user */ spin_lock_irqsave(&data2->pending.lock, flags); skb_queue_walk_safe(&data2->pending, skb, tmp) { - u64 skb_cookie; + uintptr_t skb_cookie; txi = IEEE80211_SKB_CB(skb); - skb_cookie = (u64)(uintptr_t)txi->rate_driver_data[0]; + skb_cookie = (uintptr_t)txi->rate_driver_data[0]; if (skb_cookie == ret_skb_cookie) { __skb_unlink(skb, &data2->pending); From 5495c19c30eab29208c5209bb019c280064c057e Mon Sep 17 00:00:00 2001 From: Oleg Matcovschi Date: Wed, 28 Sep 2022 15:47:05 -0700 Subject: [PATCH 116/124] ANDROID: Update the ABI symbol list and xml 1 symbol(s) added 'bool drm_mode_parse_command_line_for_connector(const char *, const struct drm_connector *, struct drm_cmdline_mode *)' Bug: 197774385 Signed-off-by: Oleg Matcovschi Signed-off-by: Will McVicker Change-Id: If1686604cc37be5698b4a80f574ad1c907d80137 --- android/abi_gki_aarch64.xml | 250 ++++++++++++++++---------------- android/abi_gki_aarch64_generic | 1 + 2 files changed, 130 insertions(+), 121 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index 9ef5c780fb9e..d590d27623ce 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -1418,6 +1418,7 @@ + @@ -4912,7 +4913,7 @@ - + @@ -8885,7 +8886,7 @@ - + @@ -15836,6 +15837,7 @@ + @@ -26230,7 +26232,7 @@ - + @@ -61739,7 +61741,7 @@ - + @@ -61830,7 +61832,7 @@ - + @@ -71896,27 +71898,27 @@ - + - + - + - + - + - + - + @@ -71932,22 +71934,22 @@ - + - + - + - + - + - + @@ -72006,36 +72008,36 @@ - + - + - + - + - + - + - + - + - + - + @@ -72046,7 +72048,7 @@ - + @@ -72070,96 +72072,96 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -76817,7 +76819,7 @@ - + @@ -86940,7 +86942,7 @@ - + @@ -87020,22 +87022,22 @@ - + - + - + - + - + - + @@ -99482,7 +99484,7 @@ - + @@ -99490,7 +99492,7 @@ - + @@ -99498,7 +99500,7 @@ - + @@ -99506,12 +99508,12 @@ - + - + @@ -99519,7 +99521,7 @@ - + @@ -99530,7 +99532,7 @@ - + @@ -99538,18 +99540,18 @@ - + - + - - + + @@ -99563,12 +99565,12 @@ - + - + @@ -99576,12 +99578,12 @@ - + - + @@ -99589,12 +99591,12 @@ - + - + @@ -99611,7 +99613,7 @@ - + @@ -99619,7 +99621,7 @@ - + @@ -99627,12 +99629,12 @@ - + - + @@ -99640,7 +99642,7 @@ - + @@ -99648,7 +99650,7 @@ - + @@ -99665,12 +99667,12 @@ - + - + @@ -99696,7 +99698,7 @@ - + @@ -99707,7 +99709,7 @@ - + @@ -99727,7 +99729,7 @@ - + @@ -99750,7 +99752,7 @@ - + @@ -99764,12 +99766,12 @@ - + - + @@ -99780,7 +99782,7 @@ - + @@ -99794,7 +99796,7 @@ - + @@ -99805,7 +99807,7 @@ - + @@ -99819,7 +99821,7 @@ - + @@ -99833,12 +99835,12 @@ - + - + @@ -99846,7 +99848,7 @@ - + @@ -99860,7 +99862,7 @@ - + @@ -99868,7 +99870,7 @@ - + @@ -99879,7 +99881,7 @@ - + @@ -99896,7 +99898,7 @@ - + @@ -99916,7 +99918,7 @@ - + @@ -99933,7 +99935,7 @@ - + @@ -99944,7 +99946,7 @@ - + @@ -99952,7 +99954,7 @@ - + @@ -99960,7 +99962,7 @@ - + @@ -99968,7 +99970,7 @@ - + @@ -99982,7 +99984,7 @@ - + @@ -99990,7 +99992,7 @@ - + @@ -100001,7 +100003,7 @@ - + @@ -100018,7 +100020,7 @@ - + @@ -104828,7 +104830,7 @@ - + @@ -107697,7 +107699,7 @@ - + @@ -117364,6 +117366,12 @@ + + + + + + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index 51f6c19865a1..cc974608cece 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -755,6 +755,7 @@ drm_mode_object_find drm_mode_object_get drm_mode_object_put + drm_mode_parse_command_line_for_connector drm_mode_probed_add drm_modeset_acquire_fini drm_modeset_acquire_init From 8015dd49c00e036b214801b34a727b7c98aa84e3 Mon Sep 17 00:00:00 2001 From: Elliot Berman Date: Tue, 20 Sep 2022 12:06:58 -0700 Subject: [PATCH 117/124] FROMGIT: KVM: arm64: Ignore kvm-arm.mode if !is_hyp_mode_available() Ignore kvm-arm.mode if !is_hyp_mode_available(). Specifically, we want to avoid switching kvm_mode to KVM_MODE_PROTECTED if hypervisor mode is not available. This prevents "Protected KVM" cpu capability being reported when Linux is booting in EL1 and would not have KVM enabled. Reasonably though, we should warn if the command line is requesting a KVM mode at all if KVM isn't actually available. Allow "kvm-arm.mode=none" to skip the warning since this would disable KVM anyway. Signed-off-by: Elliot Berman Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20220920190658.2880184-1-quic_eberman@quicinc.com Bug: 249052880 (cherry picked from commit b2a4d007c347b4cb4c60f7512733c3f8300a129c https://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git next) Change-Id: I196649fc00537e563a1fab0a22bf23c5b7abe00d Signed-off-by: Elliot Berman --- arch/arm64/kvm/arm.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 86cbee644a39..8e22c300752c 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -2286,6 +2286,16 @@ static int __init early_kvm_mode_cfg(char *arg) if (!arg) return -EINVAL; + if (strcmp(arg, "none") == 0) { + kvm_mode = KVM_MODE_NONE; + return 0; + } + + if (!is_hyp_mode_available()) { + pr_warn_once("KVM is not available. Ignoring kvm-arm.mode\n"); + return 0; + } + if (strcmp(arg, "protected") == 0) { if (!is_kernel_in_hyp_mode()) kvm_mode = KVM_MODE_PROTECTED; @@ -2300,11 +2310,6 @@ static int __init early_kvm_mode_cfg(char *arg) return 0; } - if (strcmp(arg, "none") == 0) { - kvm_mode = KVM_MODE_NONE; - return 0; - } - return -EINVAL; } early_param("kvm-arm.mode", early_kvm_mode_cfg); From ab9c52146ff66b4e14f0d3c2dc6014212db235c0 Mon Sep 17 00:00:00 2001 From: Rick Yiu Date: Thu, 22 Sep 2022 07:18:33 +0000 Subject: [PATCH 118/124] ANDROID: cgroup: Add vendor hook for rebuild_root_domains_bypass Vendor could decide to bypass this function. Bug: 238390134 Change-Id: Ia6bc71c7569d21da9ae226e5d8739f97b9ca1a4f Signed-off-by: Rick Yiu --- drivers/android/vendor_hooks.c | 1 + include/trace/hooks/sched.h | 4 ++++ kernel/cgroup/cpuset.c | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 9d54e5a7d6d1..73efd5503d2f 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -409,3 +409,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmput); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_early_resume_begin); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_reclaim_bypass); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_failure_bypass); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rebuild_root_domains_bypass); diff --git a/include/trace/hooks/sched.h b/include/trace/hooks/sched.h index 4f345029ea09..bb84a6c428ad 100644 --- a/include/trace/hooks/sched.h +++ b/include/trace/hooks/sched.h @@ -392,6 +392,10 @@ DECLARE_HOOK(android_vh_pidfd_open, DECLARE_HOOK(android_vh_mmput, TP_PROTO(void *unused), TP_ARGS(unused)); + +DECLARE_HOOK(android_vh_rebuild_root_domains_bypass, + TP_PROTO(bool cpuhp_tasks_frozen, bool *bypass), + TP_ARGS(cpuhp_tasks_frozen, bypass)); /* macro versions of hooks are no longer required */ #endif /* _TRACE_HOOK_SCHED_H */ diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 3a0204d880db..76440c9e545b 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -941,6 +941,12 @@ static void rebuild_root_domains(void) { struct cpuset *cs = NULL; struct cgroup_subsys_state *pos_css; + bool bypass = false; + + trace_android_vh_rebuild_root_domains_bypass(cpuhp_tasks_frozen, &bypass); + + if (bypass) + return; lockdep_assert_held(&cpuset_mutex); lockdep_assert_cpus_held(); From e56825d04840d2c577a033544782c7cd8abacad9 Mon Sep 17 00:00:00 2001 From: Fuad Tabba Date: Wed, 28 Sep 2022 11:24:05 +0100 Subject: [PATCH 119/124] ANDROID: KVM: arm64: Initialize ptr auth in protected mode Ensure that pointer authentication is initialized when the vcpu is initialized as well, and not only when the vcpu is reset. Bug: 249192647 Signed-off-by: Fuad Tabba Change-Id: Ida39a3ee5e6b4b0d3255bfef95601890afd80709 --- arch/arm64/kvm/hyp/nvhe/pkvm.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c index 9b2e303dd124..50717a46e735 100644 --- a/arch/arm64/kvm/hyp/nvhe/pkvm.c +++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c @@ -414,6 +414,15 @@ static int set_host_vcpus(struct shadow_vcpu_state *shadow_vcpus, int nr_vcpus, return 0; } +static int init_ptrauth(struct kvm_vcpu *shadow_vcpu) +{ + int ret = 0; + if (test_bit(KVM_ARM_VCPU_PTRAUTH_ADDRESS, shadow_vcpu->arch.features) || + test_bit(KVM_ARM_VCPU_PTRAUTH_GENERIC, shadow_vcpu->arch.features)) + ret = kvm_vcpu_enable_ptrauth(shadow_vcpu); + return ret; +} + static int init_shadow_structs(struct kvm *kvm, struct kvm_shadow_vm *vm, struct kvm_vcpu **vcpu_array, int nr_vcpus) { @@ -438,6 +447,10 @@ static int init_shadow_structs(struct kvm *kvm, struct kvm_shadow_vm *vm, if (ret) return ret; + ret = init_ptrauth(shadow_vcpu); + if (ret) + return ret; + if (test_bit(KVM_ARM_VCPU_SVE, shadow_vcpu->arch.features)) { size_t sve_state_size; void *sve_state; @@ -851,14 +864,7 @@ void pkvm_reset_vcpu(struct kvm_vcpu *vcpu) WARN_ON(!reset_state->reset); - if (test_bit(KVM_ARM_VCPU_PTRAUTH_ADDRESS, vcpu->arch.features) || - test_bit(KVM_ARM_VCPU_PTRAUTH_GENERIC, vcpu->arch.features)) { - /* - * This call should not fail since we've already checked for - * feature support on initialization. - */ - WARN_ON(kvm_vcpu_enable_ptrauth(vcpu)); - } + init_ptrauth(vcpu); /* Reset core registers */ memset(vcpu_gp_regs(vcpu), 0, sizeof(*vcpu_gp_regs(vcpu))); From cd9914280a17bdae03e7e655e2dbf8f2ea67277d Mon Sep 17 00:00:00 2001 From: Duoming Zhou Date: Wed, 4 May 2022 13:58:47 +0800 Subject: [PATCH 120/124] BACKPORT: NFC: netlink: fix sleep in atomic bug when firmware download timeout commit 4071bf121d59944d5cd2238de0642f3d7995a997 upstream. There are sleep in atomic bug that could cause kernel panic during firmware download process. The root cause is that nlmsg_new with GFP_KERNEL parameter is called in fw_dnld_timeout which is a timer handler. The call trace is shown below: BUG: sleeping function called from invalid context at include/linux/sched/mm.h:265 Call Trace: kmem_cache_alloc_node __alloc_skb nfc_genl_fw_download_done call_timer_fn __run_timers.part.0 run_timer_softirq __do_softirq ... The nlmsg_new with GFP_KERNEL parameter may sleep during memory allocation process, and the timer handler is run as the result of a "software interrupt" that should not call any other function that could sleep. This patch changes allocation mode of netlink message from GFP_KERNEL to GFP_ATOMIC in order to prevent sleep in atomic bug. The GFP_ATOMIC flag makes memory allocation operation could be used in atomic context. Bug: 245675148 Fixes: 9674da8759df ("NFC: Add firmware upload netlink command") Fixes: 9ea7187c53f6 ("NFC: netlink: Rename CMD_FW_UPLOAD to CMD_FW_DOWNLOAD") Signed-off-by: Duoming Zhou Reviewed-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20220504055847.38026-1-duoming@zju.edu.cn Signed-off-by: Paolo Abeni Signed-off-by: Greg Kroah-Hartman Signed-off-by: Lee Jones Change-Id: I510b617174c0575cc6f438b2edf44f0262f9c09c --- net/nfc/netlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index 78acc4e9ac93..b8939ebaa6d3 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -1244,7 +1244,7 @@ int nfc_genl_fw_download_done(struct nfc_dev *dev, const char *firmware_name, struct sk_buff *msg; void *hdr; - msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_ATOMIC); if (!msg) return -ENOMEM; @@ -1260,7 +1260,7 @@ int nfc_genl_fw_download_done(struct nfc_dev *dev, const char *firmware_name, genlmsg_end(msg, hdr); - genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_KERNEL); + genlmsg_multicast(&nfc_genl_family, msg, 0, 0, GFP_ATOMIC); return 0; From 92fc848ef5480edc74d72099bfa4b9dc77c2b6f9 Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Fri, 23 Sep 2022 10:48:51 -0700 Subject: [PATCH 121/124] ANDROID: fuse-bpf: Add ability to run ranges of tests to fuse_test Test: run various range options Signed-off-by: Paul Lawrence Bug: 248576331 Change-Id: I75bfa9b499b974250d4d3e375537de1807268c47 --- .../selftests/filesystems/fuse/fuse_test.c | 127 ++++++++++++------ .../filesystems/fuse/test_framework.h | 1 - 2 files changed, 84 insertions(+), 44 deletions(-) diff --git a/tools/testing/selftests/filesystems/fuse/fuse_test.c b/tools/testing/selftests/filesystems/fuse/fuse_test.c index ffc960aa6315..9fe5bfd286be 100644 --- a/tools/testing/selftests/filesystems/fuse/fuse_test.c +++ b/tools/testing/selftests/filesystems/fuse/fuse_test.c @@ -1968,7 +1968,50 @@ out: return result; } -static int parse_options(int argc, char *const *argv) +static void parse_range(const char *ranges, bool *run_test, size_t tests) +{ + size_t i; + char *range; + + for (i = 0; i < tests; ++i) + run_test[i] = false; + + range = strtok(optarg, ","); + while (range) { + char *dash = strchr(range, '-'); + + if (dash) { + size_t start = 1, end = tests; + char *end_ptr; + + if (dash > range) { + start = strtol(range, &end_ptr, 10); + if (*end_ptr != '-' || start <= 0 || start > tests) + ksft_exit_fail_msg("Bad range\n"); + } + + if (dash[1]) { + end = strtol(dash + 1, &end_ptr, 10); + if (*end_ptr || end <= start || end > tests) + ksft_exit_fail_msg("Bad range\n"); + } + + for (i = start; i <= end; ++i) + run_test[i - 1] = true; + } else { + char *end; + long value = strtol(range, &end, 10); + + if (*end || value <= 0 || value > tests) + ksft_exit_fail_msg("Bad range\n"); + run_test[value - 1] = true; + } + range = strtok(NULL, ","); + } +} + +static int parse_options(int argc, char *const *argv, bool *run_test, + size_t tests) { signed char c; @@ -1979,7 +2022,7 @@ static int parse_options(int argc, char *const *argv) break; case 't': - test_options.test = strtol(optarg, NULL, 10); + parse_range(optarg, run_test, tests); break; case 'v': @@ -1998,7 +2041,8 @@ struct test_case { const char *name; }; -static void run_one_test(const char *mount_dir, struct test_case *test_case) +static void run_one_test(const char *mount_dir, + const struct test_case *test_case) { ksft_print_msg("Running %s\n", test_case->name); if (test_case->pfunc(mount_dir) == TEST_SUCCESS) @@ -2014,37 +2058,11 @@ int main(int argc, char *argv[]) int i; int fd, count; - if (parse_options(argc, argv)) - ksft_exit_fail_msg("Bad options\n"); - - // Seed randomness pool for testing on QEMU - // NOTE - this abuses the concept of randomness - do *not* ever do this - // on a machine for production use - the device will think it has good - // randomness when it does not. - fd = open("/dev/urandom", O_WRONLY | O_CLOEXEC); - count = 4096; - for (int i = 0; i < 128; ++i) - ioctl(fd, RNDADDTOENTCNT, &count); - close(fd); - - ksft_print_header(); - - if (geteuid() != 0) - ksft_print_msg("Not a root, might fail to mount.\n"); - - if (tracing_on() != TEST_SUCCESS) - ksft_exit_fail_msg("Can't turn on tracing\n"); - - src_dir = setup_mount_dir(ft_src); - mount_dir = setup_mount_dir(ft_dst); - if (src_dir == NULL || mount_dir == NULL) - ksft_exit_fail_msg("Can't create a mount dir\n"); - #define MAKE_TEST(test) \ { \ test, #test \ } - struct test_case cases[] = { + const struct test_case cases[] = { MAKE_TEST(basic_test), MAKE_TEST(bpf_test_real), MAKE_TEST(bpf_test_partial), @@ -2079,23 +2097,46 @@ int main(int argc, char *argv[]) }; #undef MAKE_TEST - if (test_options.test) { - if (test_options.test <= 0 || - test_options.test > ARRAY_SIZE(cases)) - ksft_exit_fail_msg("Invalid test\n"); + bool run_test[ARRAY_SIZE(cases)]; - ksft_set_plan(1); - delete_dir_tree(mount_dir, false); - delete_dir_tree(src_dir, false); - run_one_test(mount_dir, &cases[test_options.test - 1]); - } else { - ksft_set_plan(ARRAY_SIZE(cases)); - for (i = 0; i < ARRAY_SIZE(cases); ++i) { + for (int i = 0; i < ARRAY_SIZE(cases); ++i) + run_test[i] = true; + + if (parse_options(argc, argv, run_test, ARRAY_SIZE(cases))) + ksft_exit_fail_msg("Bad options\n"); + + // Seed randomness pool for testing on QEMU + // NOTE - this abuses the concept of randomness - do *not* ever do this + // on a machine for production use - the device will think it has good + // randomness when it does not. + fd = open("/dev/urandom", O_WRONLY | O_CLOEXEC); + count = 4096; + for (int i = 0; i < 128; ++i) + ioctl(fd, RNDADDTOENTCNT, &count); + close(fd); + + ksft_print_header(); + + if (geteuid() != 0) + ksft_print_msg("Not a root, might fail to mount.\n"); + + if (tracing_on() != TEST_SUCCESS) + ksft_exit_fail_msg("Can't turn on tracing\n"); + + src_dir = setup_mount_dir(ft_src); + mount_dir = setup_mount_dir(ft_dst); + if (src_dir == NULL || mount_dir == NULL) + ksft_exit_fail_msg("Can't create a mount dir\n"); + + ksft_set_plan(ARRAY_SIZE(run_test)); + + for (i = 0; i < ARRAY_SIZE(run_test); ++i) + if (run_test[i]) { delete_dir_tree(mount_dir, false); delete_dir_tree(src_dir, false); run_one_test(mount_dir, &cases[i]); - } - } + } else + ksft_cnt.ksft_xskip++; umount2(mount_dir, MNT_FORCE); delete_dir_tree(mount_dir, true); diff --git a/tools/testing/selftests/filesystems/fuse/test_framework.h b/tools/testing/selftests/filesystems/fuse/test_framework.h index 945f141e9a66..7e832e901d50 100644 --- a/tools/testing/selftests/filesystems/fuse/test_framework.h +++ b/tools/testing/selftests/filesystems/fuse/test_framework.h @@ -40,7 +40,6 @@ static int test_case_fail; struct _test_options { int file; - int test; bool verbose; }; From 9bc66fe57c42cf7580b4b3ed9f6369884aef1d32 Mon Sep 17 00:00:00 2001 From: Paul Lawrence Date: Mon, 3 Oct 2022 09:56:21 -0700 Subject: [PATCH 122/124] ANDROID: fuse-bpf: set error_in to ENOENT in negative lookup Bug: 250617797 Test: fuse-test passes, app installs Signed-off-by: Paul Lawrence Change-Id: I44544f8989d0ddf00a98eaddce5751df6598130f --- fs/fuse/backing.c | 4 +++- tools/testing/selftests/filesystems/fuse/fuse_test.c | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/fs/fuse/backing.c b/fs/fuse/backing.c index 49b848e4462d..9f78384b021f 100644 --- a/fs/fuse/backing.c +++ b/fs/fuse/backing.c @@ -1176,8 +1176,10 @@ int fuse_lookup_backing(struct fuse_bpf_args *fa, struct inode *dir, .mnt = mntget(dir_fuse_entry->backing_path.mnt), }; - if (d_is_negative(backing_entry)) + if (d_is_negative(backing_entry)) { + fa->error_in = -ENOENT; return 0; + } err = vfs_getattr(&fuse_entry->backing_path, &stat, STATX_BASIC_STATS, 0); diff --git a/tools/testing/selftests/filesystems/fuse/fuse_test.c b/tools/testing/selftests/filesystems/fuse/fuse_test.c index 9fe5bfd286be..461b79656973 100644 --- a/tools/testing/selftests/filesystems/fuse/fuse_test.c +++ b/tools/testing/selftests/filesystems/fuse/fuse_test.c @@ -1915,6 +1915,7 @@ static int bpf_test_lookup_postfilter(const char *mount_dir) { const char *file1_name = "file1"; const char *file2_name = "file2"; + const char *file3_name = "file3"; int result = TEST_FAILURE; int bpf_fd = -1; int src_fd = -1; @@ -1944,18 +1945,27 @@ static int bpf_test_lookup_postfilter(const char *mount_dir) TEST(fd = s_open(s_path(s(mount_dir), s(file2_name)), O_RDONLY), fd != -1); TESTSYSCALL(close(fd)); + TESTEQUAL(s_open(s_path(s(mount_dir), s(file3_name)), O_RDONLY), + -1); FUSE_DAEMON + struct fuse_in_header *in_header = + (struct fuse_in_header *)bytes_in; struct fuse_entry_out *feo; struct fuse_entry_bpf_out *febo; TESTFUSELOOKUP(file1_name, FUSE_POSTFILTER); TESTFUSEOUTERROR(-ENOENT); + TESTFUSELOOKUP(file2_name, FUSE_POSTFILTER); feo = (struct fuse_entry_out *) (bytes_in + sizeof(struct fuse_in_header) + strlen(file2_name) + 1); febo = (struct fuse_entry_bpf_out *) ((char *)feo + sizeof(*feo)); TESTFUSEOUT2(fuse_entry_out, *feo, fuse_entry_bpf_out, *febo); + + TESTFUSELOOKUP(file3_name, FUSE_POSTFILTER); + TESTEQUAL(in_header->error_in, -ENOENT); + TESTFUSEOUTERROR(-ENOENT); FUSE_DONE result = TEST_SUCCESS; From b6a23be181a16e9161853b373d7bad8b2c135fbf Mon Sep 17 00:00:00 2001 From: Todd Kjos Date: Tue, 4 Oct 2022 20:52:53 +0000 Subject: [PATCH 123/124] ANDROID: Fix for kernelci !CONFIG_SMP break-breaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ab9c52146ff6 ("ANDROID: cgroup: Add vendor hook for rebuild_root_domains_bypass") introduced a hook that declared a parameter whose name collided with a global variable. If !CONFIG_SMP, this global variable is instead a compile-time constant which causes this error: include/linux/cpu.h:101:28: error: expected ‘;’, ‘,’ or ‘)’ before numeric constant Fixes: ab9c52146ff6 ("ANDROID: cgroup: Add vendor hook for rebuild_root_domains_bypass") Signed-off-by: Todd Kjos Change-Id: I7831c5067be2ee548e8f6885eec99ab9085414fa --- include/trace/hooks/sched.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/trace/hooks/sched.h b/include/trace/hooks/sched.h index bb84a6c428ad..4233384f6ff8 100644 --- a/include/trace/hooks/sched.h +++ b/include/trace/hooks/sched.h @@ -394,8 +394,8 @@ DECLARE_HOOK(android_vh_mmput, TP_ARGS(unused)); DECLARE_HOOK(android_vh_rebuild_root_domains_bypass, - TP_PROTO(bool cpuhp_tasks_frozen, bool *bypass), - TP_ARGS(cpuhp_tasks_frozen, bypass)); + TP_PROTO(bool tasks_frozen, bool *bypass), + TP_ARGS(tasks_frozen, bypass)); /* macro versions of hooks are no longer required */ #endif /* _TRACE_HOOK_SCHED_H */ From 800870b6d4ce9f44d667cb53ff41b6632e2472e1 Mon Sep 17 00:00:00 2001 From: Ziyi Cui Date: Tue, 4 Oct 2022 18:57:00 +0000 Subject: [PATCH 124/124] ANDROID: Update the ABI representation 2 function symbol(s) added 'int __traceiter_android_vh_early_resume_begin(void *, void *)' 'int __traceiter_android_vh_resume_end(void *, void *)' 2 variable symbol(s) added 'struct tracepoint __tracepoint_android_vh_early_resume_begin' 'struct tracepoint __tracepoint_android_vh_resume_end' Bug: 241946090 Signed-off-by: Ziyi Cui Change-Id: Ie131055ec01e31a7b72ccb997215c67f71ce6bdc --- android/abi_gki_aarch64.xml | 258 +++++++++++++++++--------------- android/abi_gki_aarch64_generic | 4 + 2 files changed, 141 insertions(+), 121 deletions(-) diff --git a/android/abi_gki_aarch64.xml b/android/abi_gki_aarch64.xml index d590d27623ce..bc974a4a06e5 100644 --- a/android/abi_gki_aarch64.xml +++ b/android/abi_gki_aarch64.xml @@ -260,6 +260,7 @@ + @@ -273,6 +274,7 @@ + @@ -3782,6 +3784,7 @@ + @@ -3795,6 +3798,7 @@ + @@ -4913,7 +4917,7 @@ - + @@ -8886,7 +8890,7 @@ - + @@ -26232,7 +26236,7 @@ - + @@ -61741,7 +61745,7 @@ - + @@ -61832,7 +61836,7 @@ - + @@ -71898,27 +71902,27 @@ - + - + - + - + - + - + - + @@ -71934,22 +71938,22 @@ - + - + - + - + - + - + @@ -72008,36 +72012,36 @@ - + - + - + - + - + - + - + - + - + - + @@ -72048,7 +72052,7 @@ - + @@ -72072,96 +72076,96 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -76819,7 +76823,7 @@ - + @@ -86942,7 +86946,7 @@ - + @@ -87022,22 +87026,22 @@ - + - + - + - + - + - + @@ -99484,7 +99488,7 @@ - + @@ -99492,7 +99496,7 @@ - + @@ -99500,7 +99504,7 @@ - + @@ -99508,12 +99512,12 @@ - + - + @@ -99521,7 +99525,7 @@ - + @@ -99532,7 +99536,7 @@ - + @@ -99540,18 +99544,18 @@ - + - + - - + + @@ -99565,12 +99569,12 @@ - + - + @@ -99578,12 +99582,12 @@ - + - + @@ -99591,12 +99595,12 @@ - + - + @@ -99613,7 +99617,7 @@ - + @@ -99621,7 +99625,7 @@ - + @@ -99629,12 +99633,12 @@ - + - + @@ -99642,7 +99646,7 @@ - + @@ -99650,7 +99654,7 @@ - + @@ -99667,12 +99671,12 @@ - + - + @@ -99698,7 +99702,7 @@ - + @@ -99709,7 +99713,7 @@ - + @@ -99729,7 +99733,7 @@ - + @@ -99752,7 +99756,7 @@ - + @@ -99766,12 +99770,12 @@ - + - + @@ -99782,7 +99786,7 @@ - + @@ -99796,7 +99800,7 @@ - + @@ -99807,7 +99811,7 @@ - + @@ -99821,7 +99825,7 @@ - + @@ -99835,12 +99839,12 @@ - + - + @@ -99848,7 +99852,7 @@ - + @@ -99862,7 +99866,7 @@ - + @@ -99870,7 +99874,7 @@ - + @@ -99881,7 +99885,7 @@ - + @@ -99898,7 +99902,7 @@ - + @@ -99918,7 +99922,7 @@ - + @@ -99935,7 +99939,7 @@ - + @@ -99946,7 +99950,7 @@ - + @@ -99954,7 +99958,7 @@ - + @@ -99962,7 +99966,7 @@ - + @@ -99970,7 +99974,7 @@ - + @@ -99984,7 +99988,7 @@ - + @@ -99992,7 +99996,7 @@ - + @@ -100003,7 +100007,7 @@ - + @@ -100020,7 +100024,7 @@ - + @@ -104830,7 +104834,7 @@ - + @@ -107699,7 +107703,7 @@ - + @@ -110974,6 +110978,11 @@ + + + + + @@ -111054,6 +111063,11 @@ + + + + + @@ -111453,6 +111467,7 @@ + @@ -111466,6 +111481,7 @@ + diff --git a/android/abi_gki_aarch64_generic b/android/abi_gki_aarch64_generic index cc974608cece..a7069c587ab7 100644 --- a/android/abi_gki_aarch64_generic +++ b/android/abi_gki_aarch64_generic @@ -2244,6 +2244,7 @@ __traceiter_android_vh_cpu_idle_exit __traceiter_android_vh_dump_throttled_rt_tasks __traceiter_android_vh_dup_task_struct + __traceiter_android_vh_early_resume_begin __traceiter_android_vh_enable_thermal_genl_check __traceiter_android_vh_ep_create_wakeup_source __traceiter_android_vh_get_user_pages @@ -2256,6 +2257,7 @@ __traceiter_android_vh_of_i2c_get_board_info __traceiter_android_vh_pagecache_get_page __traceiter_android_vh_pin_user_pages + __traceiter_android_vh_resume_end __traceiter_android_vh_rmqueue __traceiter_android_vh_sched_setaffinity_early __traceiter_android_vh_scheduler_tick @@ -2358,6 +2360,7 @@ __tracepoint_android_vh_cpu_idle_exit __tracepoint_android_vh_dump_throttled_rt_tasks __tracepoint_android_vh_dup_task_struct + __tracepoint_android_vh_early_resume_begin __tracepoint_android_vh_enable_thermal_genl_check __tracepoint_android_vh_ep_create_wakeup_source __tracepoint_android_vh_get_user_pages @@ -2370,6 +2373,7 @@ __tracepoint_android_vh_of_i2c_get_board_info __tracepoint_android_vh_pagecache_get_page __tracepoint_android_vh_pin_user_pages + __tracepoint_android_vh_resume_end __tracepoint_android_vh_rmqueue __tracepoint_android_vh_sched_setaffinity_early __tracepoint_android_vh_scheduler_tick