1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */
2*4882a593Smuzhiyun #ifndef _LINUX_IO_URING_H
3*4882a593Smuzhiyun #define _LINUX_IO_URING_H
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun #include <linux/sched.h>
6*4882a593Smuzhiyun #include <linux/xarray.h>
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun #ifdef __GENKSYMS__
9*4882a593Smuzhiyun /*
10*4882a593Smuzhiyun * ANDROID ABI HACK
11*4882a593Smuzhiyun *
12*4882a593Smuzhiyun * In the 5.10.162 release, the io_uring code was synced with the version
13*4882a593Smuzhiyun * that is in the 5.15.y kernel tree in order to resolve a huge number of
14*4882a593Smuzhiyun * potential, and known, problems with the codebase. This makes for a more
15*4882a593Smuzhiyun * secure and easier-to-update-and-maintain 5.10.y kernel tree, so this is
16*4882a593Smuzhiyun * a great thing, however this caused some issues when it comes to the
17*4882a593Smuzhiyun * Android KABI preservation and checking tools.
18*4882a593Smuzhiyun *
19*4882a593Smuzhiyun * A number of the io_uring structures get used in other core kernel
20*4882a593Smuzhiyun * structures, only as "opaque" pointers, so there is not any real ABI
21*4882a593Smuzhiyun * breakage. But, due to the visibility of the structures going away, the
22*4882a593Smuzhiyun * CRC values of many scheduler variables and functions were changed.
23*4882a593Smuzhiyun *
24*4882a593Smuzhiyun * In order to preserve the CRC values, to prevent all device kernels to be
25*4882a593Smuzhiyun * forced to rebuild for no reason whatsoever from a functional point of
26*4882a593Smuzhiyun * view, we need to keep around the "old" io_uring structures for the CRC
27*4882a593Smuzhiyun * calculation only. This is done by the following definitions of struct
28*4882a593Smuzhiyun * io_identity and struct io_uring_task which will only be visible when the
29*4882a593Smuzhiyun * CRC calculation build happens, not in any functional kernel build.
30*4882a593Smuzhiyun *
31*4882a593Smuzhiyun * Yes, this all is a horrible hack, and these really are not the true
32*4882a593Smuzhiyun * structures that any code uses, but so life is in the world of stable
33*4882a593Smuzhiyun * apis...
34*4882a593Smuzhiyun * The real structures are in io_uring/io_uring.c, see the ones there if
35*4882a593Smuzhiyun * you need to touch or do anything with it.
36*4882a593Smuzhiyun *
37*4882a593Smuzhiyun * NEVER touch these structure definitions, they are fake and not valid code.
38*4882a593Smuzhiyun */
39*4882a593Smuzhiyun struct io_identity {
40*4882a593Smuzhiyun struct files_struct *files;
41*4882a593Smuzhiyun struct mm_struct *mm;
42*4882a593Smuzhiyun #ifdef CONFIG_BLK_CGROUP
43*4882a593Smuzhiyun struct cgroup_subsys_state *blkcg_css;
44*4882a593Smuzhiyun #endif
45*4882a593Smuzhiyun const struct cred *creds;
46*4882a593Smuzhiyun struct nsproxy *nsproxy;
47*4882a593Smuzhiyun struct fs_struct *fs;
48*4882a593Smuzhiyun unsigned long fsize;
49*4882a593Smuzhiyun #ifdef CONFIG_AUDIT
50*4882a593Smuzhiyun kuid_t loginuid;
51*4882a593Smuzhiyun unsigned int sessionid;
52*4882a593Smuzhiyun #endif
53*4882a593Smuzhiyun refcount_t count;
54*4882a593Smuzhiyun };
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun struct io_uring_task {
57*4882a593Smuzhiyun /* submission side */
58*4882a593Smuzhiyun struct xarray xa;
59*4882a593Smuzhiyun struct wait_queue_head wait;
60*4882a593Smuzhiyun struct file *last;
61*4882a593Smuzhiyun struct percpu_counter inflight;
62*4882a593Smuzhiyun struct io_identity __identity;
63*4882a593Smuzhiyun struct io_identity *identity;
64*4882a593Smuzhiyun atomic_t in_idle;
65*4882a593Smuzhiyun bool sqpoll;
66*4882a593Smuzhiyun };
67*4882a593Smuzhiyun #endif /* ANDROID ABI HACK */
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun
70*4882a593Smuzhiyun #if defined(CONFIG_IO_URING)
71*4882a593Smuzhiyun struct sock *io_uring_get_socket(struct file *file);
72*4882a593Smuzhiyun void __io_uring_cancel(bool cancel_all);
73*4882a593Smuzhiyun void __io_uring_free(struct task_struct *tsk);
74*4882a593Smuzhiyun
io_uring_files_cancel(void)75*4882a593Smuzhiyun static inline void io_uring_files_cancel(void)
76*4882a593Smuzhiyun {
77*4882a593Smuzhiyun if (current->io_uring)
78*4882a593Smuzhiyun __io_uring_cancel(false);
79*4882a593Smuzhiyun }
io_uring_task_cancel(void)80*4882a593Smuzhiyun static inline void io_uring_task_cancel(void)
81*4882a593Smuzhiyun {
82*4882a593Smuzhiyun if (current->io_uring)
83*4882a593Smuzhiyun __io_uring_cancel(true);
84*4882a593Smuzhiyun }
io_uring_free(struct task_struct * tsk)85*4882a593Smuzhiyun static inline void io_uring_free(struct task_struct *tsk)
86*4882a593Smuzhiyun {
87*4882a593Smuzhiyun if (tsk->io_uring)
88*4882a593Smuzhiyun __io_uring_free(tsk);
89*4882a593Smuzhiyun }
90*4882a593Smuzhiyun #else
io_uring_get_socket(struct file * file)91*4882a593Smuzhiyun static inline struct sock *io_uring_get_socket(struct file *file)
92*4882a593Smuzhiyun {
93*4882a593Smuzhiyun return NULL;
94*4882a593Smuzhiyun }
io_uring_task_cancel(void)95*4882a593Smuzhiyun static inline void io_uring_task_cancel(void)
96*4882a593Smuzhiyun {
97*4882a593Smuzhiyun }
io_uring_files_cancel(void)98*4882a593Smuzhiyun static inline void io_uring_files_cancel(void)
99*4882a593Smuzhiyun {
100*4882a593Smuzhiyun }
io_uring_free(struct task_struct * tsk)101*4882a593Smuzhiyun static inline void io_uring_free(struct task_struct *tsk)
102*4882a593Smuzhiyun {
103*4882a593Smuzhiyun }
104*4882a593Smuzhiyun #endif
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun #endif
107