hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/android/binder_alloc.h
....@@ -1,15 +1,6 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * Copyright (C) 2017 Google, Inc.
3
- *
4
- * This software is licensed under the terms of the GNU General Public
5
- * License version 2, as published by the Free Software Foundation, and
6
- * may be copied, distributed, and modified under those terms.
7
- *
8
- * This program is distributed in the hope that it will be useful,
9
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- * GNU General Public License for more details.
12
- *
134 */
145
156 #ifndef _LINUX_BINDER_ALLOC_H
....@@ -32,8 +23,11 @@
3223 * @entry: entry alloc->buffers
3324 * @rb_node: node for allocated_buffers/free_buffers rb trees
3425 * @free: %true if buffer is free
26
+ * @clear_on_free: %true if buffer must be zeroed after use
3527 * @allow_user_free: %true if user is allowed to free buffer
3628 * @async_transaction: %true if buffer is in use for an async txn
29
+ * @oneway_spam_suspect: %true if total async allocate size just exceed
30
+ * spamming detect threshold
3731 * @debug_id: unique ID for debugging
3832 * @transaction: pointer to associated struct binder_transaction
3933 * @target_node: struct binder_node associated with this buffer
....@@ -50,9 +44,11 @@
5044 struct rb_node rb_node; /* free entry by size or allocated entry */
5145 /* by address */
5246 unsigned free:1;
47
+ unsigned clear_on_free:1;
5348 unsigned allow_user_free:1;
5449 unsigned async_transaction:1;
55
- unsigned debug_id:29;
50
+ unsigned oneway_spam_suspect:1;
51
+ unsigned debug_id:27;
5652
5753 struct binder_transaction *transaction;
5854
....@@ -94,6 +90,8 @@
9490 * @buffer_size: size of address space specified via mmap
9591 * @pid: pid for associated binder_proc (invariant after init)
9692 * @pages_high: high watermark of offset in @pages
93
+ * @oneway_spam_detected: %true if oneway spam detection fired, clear that
94
+ * flag once the async buffer has returned to a healthy state
9795 *
9896 * Bookkeeping structure for per-proc address space management for binder
9997 * buffers. It is normally initialized during binder_init() and binder_mmap()
....@@ -114,6 +112,7 @@
114112 uint32_t buffer_free;
115113 int pid;
116114 size_t pages_high;
115
+ bool oneway_spam_detected;
117116 };
118117
119118 #ifdef CONFIG_ANDROID_BINDER_IPC_SELFTEST
....@@ -132,6 +131,7 @@
132131 int pid);
133132 extern void binder_alloc_init(struct binder_alloc *alloc);
134133 extern int binder_alloc_shrinker_init(void);
134
+extern void binder_alloc_shrinker_exit(void);
135135 extern void binder_alloc_vma_close(struct binder_alloc *alloc);
136136 extern struct binder_buffer *
137137 binder_alloc_prepare_to_free(struct binder_alloc *alloc,
....@@ -171,17 +171,17 @@
171171 const void __user *from,
172172 size_t bytes);
173173
174
-void binder_alloc_copy_to_buffer(struct binder_alloc *alloc,
175
- struct binder_buffer *buffer,
176
- binder_size_t buffer_offset,
177
- void *src,
178
- size_t bytes);
174
+int binder_alloc_copy_to_buffer(struct binder_alloc *alloc,
175
+ struct binder_buffer *buffer,
176
+ binder_size_t buffer_offset,
177
+ void *src,
178
+ size_t bytes);
179179
180
-void binder_alloc_copy_from_buffer(struct binder_alloc *alloc,
181
- void *dest,
182
- struct binder_buffer *buffer,
183
- binder_size_t buffer_offset,
184
- size_t bytes);
180
+int binder_alloc_copy_from_buffer(struct binder_alloc *alloc,
181
+ void *dest,
182
+ struct binder_buffer *buffer,
183
+ binder_size_t buffer_offset,
184
+ size_t bytes);
185185
186186 #endif /* _LINUX_BINDER_ALLOC_H */
187187