github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/sys/linux/dev_bifrost.txt (about)

     1  # Copyright 2021 syzkaller project authors. All rights reserved.
     2  # Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  # The source file of mali bifrost ioctl can be found in ChromeOS source tree:
     5  # https://chromium.googlesource.com/chromiumos/third_party/kernel/+/chromeos-4.19/drivers/gpu/arm/bifrost/mali_kbase_ioctl.h
     6  
     7  # Not upstream, generated on:
     8  # https://chromium.googlesource.com/chromiumos/third_party/kernel d2a8a1eb8b86
     9  meta noextract
    10  
    11  include <asm/page.h>
    12  include <drivers/gpu/arm/bifrost/mali_kbase_debug.h>
    13  include <drivers/gpu/arm/bifrost/mali_kbase_hwcnt_reader.h>
    14  include <drivers/gpu/arm/bifrost/mali_kbase_ioctl.h>
    15  include <drivers/gpu/arm/bifrost/mali_base_kernel.h>
    16  include <uapi/linux/fcntl.h>
    17  
    18  resource fd_bifrost[fd]
    19  resource gpu_addr[int64]: BASEP_MEM_INVALID_HANDLE, BASEP_MEM_WRITE_ALLOC_PAGES_HANDLE
    20  resource user_addr[int64]: -1
    21  resource fd_fence[fd]
    22  resource fd_hwcnt[fd]
    23  
    24  openat$bifrost(fd const[AT_FDCWD], file ptr[in, string["/dev/bifrost"]], flags flags[open_flags], mode const[0]) fd_bifrost
    25  # Device name on Android
    26  openat$mali(fd const[AT_FDCWD], file ptr[in, string["/dev/mali0"]], flags flags[open_flags], mode const[0]) fd_bifrost
    27  
    28  mmap$bifrost(addr const[0], len len[addr], prot flags[mmap_prot], flags flags[mmap_flags], fd fd_bifrost, offset fileoff) user_addr
    29  _ = __NR_mmap2
    30  
    31  ioctl$KBASE_IOCTL_JOB_SUBMIT(fd fd_bifrost, cmd const[KBASE_IOCTL_JOB_SUBMIT], arg ptr[in, kbase_ioctl_job_submit])
    32  ioctl$KBASE_IOCTL_POST_TERM(fd fd_bifrost, cmd const[KBASE_IOCTL_POST_TERM], arg const[0])
    33  ioctl$KBASE_IOCTL_SOFT_EVENT_UPDATE(fd fd_bifrost, cmd const[KBASE_IOCTL_SOFT_EVENT_UPDATE], arg ptr[in, kbase_ioctl_soft_event_update])
    34  ioctl$KBASE_IOCTL_VERSION_CHECK(fd fd_bifrost, cmd const[KBASE_IOCTL_VERSION_CHECK], arg ptr[inout, kbase_ioctl_version_check])
    35  ioctl$KBASE_IOCTL_SET_FLAGS(fd fd_bifrost, cmd const[KBASE_IOCTL_SET_FLAGS], arg ptr[in, kbase_ioctl_set_flags])
    36  ioctl$KBASE_IOCTL_GET_GPUPROPS(fd fd_bifrost, cmd const[KBASE_IOCTL_GET_GPUPROPS], arg ptr[inout, kbase_ioctl_get_gpuprops])
    37  ioctl$KBASE_IOCTL_MEM_ALLOC(fd fd_bifrost, cmd const[KBASE_IOCTL_MEM_ALLOC], arg ptr[inout, kbase_ioctl_mem_alloc])
    38  ioctl$KBASE_IOCTL_MEM_QUERY(fd fd_bifrost, cmd const[KBASE_IOCTL_MEM_QUERY], arg ptr[inout, kbase_ioctl_mem_query])
    39  ioctl$KBASE_IOCTL_MEM_FREE(fd fd_bifrost, cmd const[KBASE_IOCTL_MEM_FREE], arg ptr[in, kbase_ioctl_mem_free])
    40  ioctl$KBASE_IOCTL_HWCNT_READER_SETUP(fd fd_bifrost, cmd const[KBASE_IOCTL_HWCNT_READER_SETUP], arg ptr[in, kbase_ioctl_hwcnt_reader_setup]) fd_hwcnt
    41  ioctl$KBASE_IOCTL_HWCNT_ENABLE(fd fd_bifrost, cmd const[KBASE_IOCTL_HWCNT_ENABLE], arg ptr[in, kbase_ioctl_hwcnt_enable])
    42  ioctl$KBASE_IOCTL_HWCNT_DUMP(fd fd_bifrost, cmd const[KBASE_IOCTL_HWCNT_DUMP], arg const[0])
    43  ioctl$KBASE_IOCTL_HWCNT_CLEAR(fd fd_bifrost, cmd const[KBASE_IOCTL_HWCNT_CLEAR], arg const[0])
    44  ioctl$KBASE_IOCTL_HWCNT_SET(fd fd_bifrost, cmd const[KBASE_IOCTL_HWCNT_SET], arg ptr[inout, kbase_ioctl_hwcnt_values])
    45  ioctl$KBASE_IOCTL_DISJOINT_QUERY(fd fd_bifrost, cmd const[KBASE_IOCTL_DISJOINT_QUERY], arg ptr[out, kbase_ioctl_disjoint_query])
    46  ioctl$KBASE_IOCTL_GET_DDK_VERSION(fd fd_bifrost, cmd const[KBASE_IOCTL_GET_DDK_VERSION], arg ptr[inout, kbase_ioctl_get_ddk_version])
    47  ioctl$KBASE_IOCTL_MEM_JIT_INIT_10_2(fd fd_bifrost, cmd const[KBASE_IOCTL_MEM_JIT_INIT_10_2], arg ptr[in, kbase_ioctl_mem_jit_init_10_2])
    48  ioctl$KBASE_IOCTL_MEM_JIT_INIT_11_5(fd fd_bifrost, cmd const[KBASE_IOCTL_MEM_JIT_INIT_11_5], arg ptr[in, kbase_ioctl_mem_jit_init_11_5])
    49  ioctl$KBASE_IOCTL_MEM_JIT_INIT(fd fd_bifrost, cmd const[KBASE_IOCTL_MEM_JIT_INIT], arg ptr[in, kbase_ioctl_mem_jit_init])
    50  ioctl$KBASE_IOCTL_MEM_SYNC(fd fd_bifrost, cmd const[KBASE_IOCTL_MEM_SYNC], arg ptr[in, kbase_ioctl_mem_sync])
    51  ioctl$KBASE_IOCTL_MEM_FIND_CPU_OFFSET(fd fd_bifrost, cmd const[KBASE_IOCTL_MEM_FIND_CPU_OFFSET], arg ptr[inout, kbase_ioctl_mem_find_cpu_offset])
    52  ioctl$KBASE_IOCTL_GET_CONTEXT_ID(fd fd_bifrost, cmd const[KBASE_IOCTL_GET_CONTEXT_ID], arg ptr[out, kbase_ioctl_get_context_id])
    53  ioctl$KBASE_IOCTL_TLSTREAM_ACQUIRE(fd fd_bifrost, cmd const[KBASE_IOCTL_TLSTREAM_ACQUIRE], arg ptr[in, kbase_ioctl_tlstream_acquire])
    54  ioctl$KBASE_IOCTL_TLSTREAM_FLUSH(fd fd_bifrost, cmd const[KBASE_IOCTL_TLSTREAM_FLUSH], arg const[0])
    55  ioctl$KBASE_IOCTL_MEM_COMMIT(fd fd_bifrost, cmd const[KBASE_IOCTL_MEM_COMMIT], arg ptr[in, kbase_ioctl_mem_commit])
    56  ioctl$KBASE_IOCTL_MEM_ALIAS(fd fd_bifrost, cmd const[KBASE_IOCTL_MEM_ALIAS], arg ptr[inout, kbase_ioctl_mem_alias])
    57  ioctl$KBASE_IOCTL_MEM_IMPORT(fd fd_bifrost, cmd const[KBASE_IOCTL_MEM_IMPORT], arg ptr[inout, kbase_ioctl_mem_import])
    58  ioctl$KBASE_IOCTL_MEM_FLAGS_CHANGE(fd fd_bifrost, cmd const[KBASE_IOCTL_MEM_FLAGS_CHANGE], arg ptr[in, kbase_ioctl_mem_flags_change])
    59  ioctl$KBASE_IOCTL_STREAM_CREATE(fd fd_bifrost, cmd const[KBASE_IOCTL_STREAM_CREATE], arg ptr[in, kbase_ioctl_stream_create]) fd_fence
    60  ioctl$KBASE_IOCTL_FENCE_VALIDATE(fd fd_bifrost, cmd const[KBASE_IOCTL_FENCE_VALIDATE], arg ptr[in, kbase_ioctl_fence_validate])
    61  ioctl$KBASE_IOCTL_MEM_PROFILE_ADD(fd fd_bifrost, cmd const[KBASE_IOCTL_MEM_PROFILE_ADD], arg ptr[in, kbase_ioctl_mem_profile_add])
    62  ioctl$KBASE_IOCTL_STICKY_RESOURCE_MAP(fd fd_bifrost, cmd const[KBASE_IOCTL_STICKY_RESOURCE_MAP], arg ptr[in, kbase_ioctl_sticky_resource_map])
    63  ioctl$KBASE_IOCTL_STICKY_RESOURCE_UNMAP(fd fd_bifrost, cmd const[KBASE_IOCTL_STICKY_RESOURCE_UNMAP], arg ptr[in, kbase_ioctl_sticky_resource_unmap])
    64  ioctl$KBASE_IOCTL_MEM_FIND_GPU_START_AND_OFFSET(fd fd_bifrost, cmd const[KBASE_IOCTL_MEM_FIND_GPU_START_AND_OFFSET], arg ptr[inout, kbase_ioctl_mem_find_gpu_start_and_offset])
    65  ioctl$KBASE_IOCTL_MEM_EXEC_INIT(fd fd_bifrost, cmd const[KBASE_IOCTL_MEM_EXEC_INIT], arg ptr[in, kbase_ioctl_mem_exec_init])
    66  ioctl$KBASE_IOCTL_GET_CPU_GPU_TIMEINFO(fd fd_bifrost, cmd const[KBASE_IOCTL_GET_CPU_GPU_TIMEINFO], arg ptr[inout, kbase_ioctl_get_cpu_gpu_timeinfo])
    67  
    68  ioctl$KBASE_HWCNT_READER_GET_HWVER(fd fd_hwcnt, cmd const[KBASE_HWCNT_READER_GET_HWVER], arg const[0])
    69  ioctl$KBASE_HWCNT_READER_GET_BUFFER_SIZE(fd fd_hwcnt, cmd const[KBASE_HWCNT_READER_GET_BUFFER_SIZE], arg const[0])
    70  ioctl$KBASE_HWCNT_READER_DUMP(fd fd_hwcnt, cmd const[KBASE_HWCNT_READER_DUMP], arg const[0])
    71  ioctl$KBASE_HWCNT_READER_CLEAR(fd fd_hwcnt, cmd const[KBASE_HWCNT_READER_CLEAR], arg const[0])
    72  ioctl$KBASE_HWCNT_READER_GET_BUFFER(fd fd_hwcnt, cmd const[KBASE_HWCNT_READER_GET_BUFFER], arg ptr[out, kbase_hwcnt_reader_metadata])
    73  ioctl$KBASE_HWCNT_READER_PUT_BUFFER(fd fd_hwcnt, cmd const[KBASE_HWCNT_READER_PUT_BUFFER], arg ptr[in, kbase_hwcnt_reader_metadata])
    74  ioctl$KBASE_HWCNT_READER_SET_INTERVAL(fd fd_hwcnt, cmd const[KBASE_HWCNT_READER_SET_INTERVAL], arg intptr)
    75  ioctl$KBASE_HWCNT_READER_ENABLE_EVENT(fd fd_hwcnt, cmd const[KBASE_HWCNT_READER_ENABLE_EVENT], arg const[0])
    76  ioctl$KBASE_HWCNT_READER_DISABLE_EVENT(fd fd_hwcnt, cmd const[KBASE_HWCNT_READER_DISABLE_EVENT], arg const[0])
    77  ioctl$KBASE_HWCNT_READER_GET_API_VERSION(fd fd_hwcnt, cmd const[KBASE_HWCNT_READER_GET_API_VERSION], arg const[0])
    78  
    79  type base_atom_id int8
    80  
    81  base_jd_atom_v2 {
    82  	jc		int64
    83  	udata		base_jd_udata
    84  	extres_list	int64
    85  	nr_extres	int16
    86  	compat_core_req	int16
    87  	pre_dep		array[base_dependency, 2]
    88  	atom_number	base_atom_id
    89  	prio		flags[base_jd_prio, int8]
    90  	device_nr	int8
    91  	jobslot		int8
    92  	core_req	flags[base_jd_core_req, int32]
    93  	renderpass_id	int8
    94  	padding		array[const[0, int8], 7]
    95  }
    96  
    97  base_dependency {
    98  	atom_id		base_atom_id
    99  	dependency_type	flags[base_jd_dep_type, int8]
   100  }
   101  
   102  base_jd_udata {
   103  	blob	array[int64, 2]
   104  }
   105  
   106  kbase_ioctl_job_submit {
   107  	addr		ptr64[out, array[base_jd_atom_v2]]
   108  	nr_atoms	len[addr, int32]
   109  # sizeof(base_jd_atom_v2)
   110  	stride		const[56, int32]
   111  }
   112  
   113  kbase_ioctl_soft_event_update {
   114  	event		gpu_addr
   115  	new_status	int32
   116  	flags		const[0, int32]
   117  }
   118  
   119  kbase_ioctl_version_check {
   120  	major	int16
   121  	minor	int16
   122  }
   123  
   124  kbase_ioctl_set_flags {
   125  	create_flags	flags[basep_context_create_kernel_flags, int32]
   126  }
   127  
   128  kbase_ioctl_get_gpuprops {
   129  	buffer	ptr64[out, array[int8]]
   130  	size	len[buffer, int32]
   131  	flags	const[0, int32]
   132  }
   133  
   134  kbase_ioctl_mem_alloc {
   135  	va_pages	int64
   136  	commit_pages	int64
   137  	extent		int64
   138  	flags		flags[base_mem_alloc_flags, int64]
   139  	out_flags	int64	(out_overlay)
   140  	gpu_va		gpu_addr
   141  }
   142  
   143  kbase_ioctl_mem_query {
   144  	gpu_addr	gpu_addr
   145  	query		flags[kbase_ioctl_mem_query_flags, int64]
   146  	value		int64	(out_overlay)
   147  }
   148  
   149  kbase_ioctl_mem_free {
   150  	gpu_addr	gpu_addr
   151  }
   152  
   153  kbase_ioctl_hwcnt_reader_setup {
   154  	buffer_count	int32
   155  	jm_bm		int32
   156  	shader_bm	int32
   157  	tiler_bm	int32
   158  	mmu_l2_bm	int32
   159  }
   160  
   161  kbase_ioctl_hwcnt_enable {
   162  	dump_buffer	gpu_addr
   163  	jm_bm		int32
   164  	shader_bm	int32
   165  	tiler_bm	int32
   166  	mmu_l2_bm	int32
   167  }
   168  
   169  kbase_ioctl_hwcnt_values {
   170  	data	ptr64[out, array[int8]]
   171  	size	len[data, int32]
   172  	padding	const[0, int32]
   173  }
   174  
   175  kbase_ioctl_disjoint_query {
   176  	counter	int32
   177  }
   178  
   179  kbase_ioctl_get_ddk_version {
   180  	version_buffer	ptr64[out, array[int8]]
   181  	size		len[version_buffer, int32]
   182  	padding		const[0, int32]
   183  }
   184  
   185  kbase_ioctl_mem_jit_init_10_2 {
   186  	va_pages	int64
   187  }
   188  
   189  kbase_ioctl_mem_jit_init_11_5 {
   190  	va_pages	int64
   191  	max_allocations	int8
   192  	trim_level	int8
   193  	group_id	int8
   194  	padding		array[const[0, int8], 5]
   195  }
   196  
   197  kbase_ioctl_mem_jit_init {
   198  	va_pages	int64
   199  	max_allocations	int8
   200  	trim_level	int8
   201  	group_id	int8
   202  	padding		array[const[0, int8], 5]
   203  	phys_pages	int64
   204  }
   205  
   206  kbase_ioctl_mem_sync {
   207  	handle		gpu_addr
   208  	user_addr	user_addr
   209  	size		int64
   210  	type		flags[base_syncset_op_flags, int8]
   211  	padding		array[const[0, int8], 7]
   212  }
   213  
   214  kbase_ioctl_mem_find_cpu_offset {
   215  	gpu_addr	gpu_addr
   216  	cpu_addr	user_addr
   217  	size		int64
   218  	offset		int64	(out_overlay)
   219  }
   220  
   221  kbase_ioctl_get_context_id {
   222  	id	int32
   223  }
   224  
   225  kbase_ioctl_tlstream_acquire {
   226  	flags	int32
   227  }
   228  
   229  kbase_ioctl_mem_commit {
   230  	gpu_addr	gpu_addr
   231  	pages		int64
   232  }
   233  
   234  kbase_ioctl_mem_alias {
   235  	flags		flags[base_mem_alloc_flags, int64]
   236  	stride		int64
   237  	nents		len[aliasing_info, int64]
   238  	aliasing_info	ptr64[in, array[base_mem_aliasing_info]]
   239  
   240  	out_flags	int64	(out_overlay)
   241  	gpu_va		gpu_addr
   242  	va_pages	int64
   243  }
   244  
   245  base_mem_aliasing_info {
   246  	handle	gpu_addr
   247  	offset	int64
   248  	length	int64
   249  }
   250  
   251  kbase_ioctl_mem_import {
   252  	flags		flags[base_mem_alloc_flags, int64]
   253  	phandle		int64
   254  	type		flags[base_mem_import_type, int32]
   255  	padding		const[0, int32]
   256  
   257  	out_flags	int64	(out_overlay)
   258  	gpu_va		gpu_addr
   259  	va_pages	int64
   260  }
   261  
   262  kbase_ioctl_mem_flags_change {
   263  	gpu_va	gpu_addr
   264  	flags	flags[base_mem_alloc_flags, int64]
   265  	mask	int64
   266  }
   267  
   268  kbase_ioctl_stream_create {
   269  	name	array[int8, 32]
   270  }
   271  
   272  kbase_ioctl_fence_validate {
   273  	fd	fd_fence
   274  }
   275  
   276  kbase_ioctl_mem_profile_add {
   277  	buffer	ptr64[in, array[int8]]
   278  	len	len[buffer, int32]
   279  	padding	const[0, int32]
   280  }
   281  
   282  kbase_ioctl_sticky_resource_map {
   283  	count	len[address, int64]
   284  	address	ptr64[in, array[int64]]
   285  }
   286  
   287  kbase_ioctl_sticky_resource_unmap {
   288  	count	len[address, int64]
   289  	address	ptr64[in, array[int64]]
   290  }
   291  
   292  kbase_ioctl_mem_find_gpu_start_and_offset {
   293  	gpu_addr	gpu_addr
   294  	size		int64
   295  	start		gpu_addr	(out_overlay)
   296  	offset		int64
   297  }
   298  
   299  kbase_ioctl_mem_exec_init {
   300  	va_pages	int64
   301  }
   302  
   303  kbase_ioctl_get_cpu_gpu_timeinfo {
   304  	request_flags	flags[base_timerequest_allowed_flags, int32]
   305  	paddings	array[const[0, int8], 7]
   306  	sec		int64	(out_overlay)
   307  	nsec		int32
   308  	padding		int32
   309  	timestamp	int64
   310  	cycle_counter	int64
   311  }
   312  
   313  kbase_hwcnt_reader_metadata {
   314  	timestamp	int64
   315  	event_id	int32
   316  	buffer_idx	int32
   317  }
   318  
   319  base_jd_dep_type = BASE_JD_DEP_TYPE_INVALID, BASE_JD_DEP_TYPE_DATA, BASE_JD_DEP_TYPE_ORDER
   320  base_jd_prio = BASE_JD_PRIO_MEDIUM, BASE_JD_PRIO_HIGH, BASE_JD_PRIO_LOW
   321  base_jd_core_req = BASE_JD_REQ_DEP, BASE_JD_REQ_FS, BASE_JD_REQ_CS, BASE_JD_REQ_T, BASE_JD_REQ_CF, BASE_JD_REQ_V, BASE_JD_REQ_FS_AFBC, BASE_JD_REQ_EVENT_COALESCE, BASE_JD_REQ_COHERENT_GROUP, BASE_JD_REQ_PERMON, BASE_JD_REQ_EXTERNAL_RESOURCES, BASE_JD_REQ_SOFT_JOB, BASE_JD_REQ_ONLY_COMPUTE, BASE_JD_REQ_SPECIFIC_COHERENT_GROUP, BASE_JD_REQ_EVENT_ONLY_ON_FAILURE, BASE_JD_REQ_SKIP_CACHE_START, BASE_JD_REQ_SKIP_CACHE_END, BASE_JD_REQ_JOB_SLOT, BASE_JD_REQ_START_RENDERPASS, BASE_JD_REQ_END_RENDERPASS
   322  kbase_ioctl_mem_query_flags = KBASE_MEM_QUERY_COMMIT_SIZE, KBASE_MEM_QUERY_VA_SIZE, KBASE_MEM_QUERY_FLAGS
   323  base_syncset_op_flags = BASE_SYNCSET_OP_MSYNC, BASE_SYNCSET_OP_CSYNC
   324  # 0x400000-0x2000000 are individual bits of BASE_MEM_GROUP_ID_MASK
   325  base_mem_alloc_flags = BASE_MEM_PROT_CPU_RD, BASE_MEM_PROT_CPU_WR, BASE_MEM_PROT_GPU_RD, BASE_MEM_PROT_GPU_WR, BASE_MEM_PROT_GPU_EX, BASEP_MEM_PERMANENT_KERNEL_MAPPING, BASE_MEM_GPU_VA_SAME_4GB_PAGE, BASEP_MEM_NO_USER_FREE, BASE_MEM_RESERVED_BIT_8, BASE_MEM_GROW_ON_GPF, BASE_MEM_COHERENT_SYSTEM, BASE_MEM_COHERENT_LOCAL, BASE_MEM_CACHED_CPU, BASE_MEM_SAME_VA, BASE_MEM_NEED_MMAP, BASE_MEM_COHERENT_SYSTEM_REQUIRED, BASE_MEM_PROTECTED, BASE_MEM_DONT_NEED, BASE_MEM_IMPORT_SHARED, BASE_MEM_RESERVED_BIT_19, BASE_MEM_TILER_ALIGN_TOP_EXTENT_MAX_PAGES, BASE_MEM_TILER_ALIGN_TOP, BASE_MEM_UNCACHED_GPU, 0x400000, 0x800000, 0x1000000, 0x2000000, BASE_MEM_IMPORT_SYNC_ON_MAP_UNMAP, BASE_MEM_FLAG_MAP_FIXED
   326  base_mem_import_type = BASE_MEM_IMPORT_TYPE_INVALID, BASE_MEM_IMPORT_TYPE_UMM, BASE_MEM_IMPORT_TYPE_USER_BUFFER
   327  # 0x08-0x20 are individual bits of BASEP_CONTEXT_MMU_GROUP_ID_MASK
   328  basep_context_create_kernel_flags = BASE_CONTEXT_SYSTEM_MONITOR_SUBMIT_DISABLED, 0x8, 0x10, 0x20, 0x40
   329  base_timerequest_allowed_flags = BASE_TIMEINFO_MONOTONIC_FLAG, BASE_TIMEINFO_TIMESTAMP_FLAG, BASE_TIMEINFO_CYCLE_COUNTER_FLAG, BASE_TIMEINFO_KERNEL_SOURCE_FLAG, BASE_TIMEINFO_USER_SOURCE_FLAG