ANDROID: vendor_hooks: add vendor hook for dma_heap_buffer_alloc

Add android_vh_dmabuf_heap_flags_validation vh for
heap flags with vendor valid check.

Bug: 241733930
Signed-off-by: davidwang <davidwang@realtek.com>
Change-Id: I5c1c111b8231a05f733bc56bda34bc408e708554
This commit is contained in:
davidwang
2022-08-08 16:57:01 +08:00
committed by Todd Kjos
parent 47351f748e
commit fc9630b3cb
3 changed files with 15 additions and 1 deletions

View File

@@ -370,6 +370,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alter_mutex_list_add);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_unlock_slowpath);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_wake_finish);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dma_buf_release);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dmabuf_heap_flags_validation);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_pass_input_event);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_check_status);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_blk_alloc_rqs);

View File

@@ -20,6 +20,8 @@
#include <linux/dma-heap.h>
#include <uapi/linux/dma-heap.h>
#include <trace/hooks/dmabuf.h>
#define DEVNAME "dma_heap"
#define NUM_HEAP_MINORS 128
@@ -80,10 +82,15 @@ struct dma_buf *dma_heap_buffer_alloc(struct dma_heap *heap, size_t len,
unsigned int fd_flags,
unsigned int heap_flags)
{
bool vh_valid = false;
trace_android_vh_dmabuf_heap_flags_validation(heap,
len, fd_flags, heap_flags, &vh_valid);
if (fd_flags & ~DMA_HEAP_VALID_FD_FLAGS)
return ERR_PTR(-EINVAL);
if (heap_flags & ~DMA_HEAP_VALID_HEAP_FLAGS)
if (heap_flags & ~DMA_HEAP_VALID_HEAP_FLAGS && !vh_valid)
return ERR_PTR(-EINVAL);
/*
* Allocations from all heaps have to begin

View File

@@ -16,6 +16,12 @@
DECLARE_HOOK(android_vh_dma_buf_release,
TP_PROTO(struct dma_buf *data),
TP_ARGS(data));
struct dma_heap;
DECLARE_HOOK(android_vh_dmabuf_heap_flags_validation,
TP_PROTO(struct dma_heap *heap, size_t len,
unsigned int fd_flags, unsigned int heap_flags, bool *skip),
TP_ARGS(heap, len, fd_flags, heap_flags, skip));
#endif /* _TRACE_HOOK_DMABUF_H */
/* This part must be outside protection */
#include <trace/define_trace.h>