[Android] OfficerJimLahey:
Hi,

This has been a long story, but in an attempt to properly patch ashmem.h from QuadRooter (have previously been using a 3.0 kernel which stores ashmem.h in a different location, and the CAF patch against QuadRooter although was straightforward, the ashmem vulnerability is still there), I have figured it was time to try my hand at the experimental (for my device) 3.4 CAF kernel.

After getting in the remaining 3.4 point releases, I tried a ROM build. I found and fixed (so far) a few errors, but there is one I cannot wrap my head around. My device (HTC Doubleshot) uses the QCom display-legacy project. In the process of switching kernels, the kernel source for ion.h has been changed to msm_ion.h. So IONAlloc (in QCom display-legacy) was still pointing to the old file. The build stopped due to the ion.h not being found. I identified and changed the include detail in IONAlloc, but now I have declaration troubles.

IONAlloc is appropriately calling msm_ion.h:

jim@sunnyvale ~/B/R/o/carbon-mt4gs> cat hardware/qcom/display-legacy/libgralloc/ionalloc.h |grep msm_ion.h
#include <linux/msm_ion.h>

Once in the kernel header location, the definition remains:

jim@sunnyvale ~/B/R/o/carbon-mt4gs> ls -l out/target/product/doubleshot/obj/KERNEL_OBJ/usr/include/linux/msm_ion.h
-rw-r--r-- 1 jim jim 5217 Aug 14 14:29 out/target/product/doubleshot/obj/KERNEL_OBJ/usr/include/linux/msm_ion.h

jim@sunnyvale ~/B/R/o/carbon-mt4gs> cat out/target/product/doubleshot/obj/KERNEL_OBJ/usr/include/linux/msm_ion.h |grep ION_SECURE
ION_HEAP_ID_RESERVED = 31 /** Bit reserved for ION_SECURE flag */
#define ION_SECURE ION_FLAG_SECURE

Display-Legacy is calling the kernel headers:

jim@sunnyvale ~/B/R/o/carbon-mt4gs> cat hardware/qcom/display-legacy/common.mk |grep include
common_includes := hardware/qcom/display-legacy/libgralloc
common_includes += hardware/qcom/display-legacy/libgenlock
common_includes += hardware/qcom/display-legacy/liboverlay
common_includes += hardware/qcom/display-legacy/libcopybit
common_includes += hardware/qcom/display-legacy/libqdutils
common_includes += hardware/qcom/display-legacy/libhwcomposer
common_includes += $(TARGET_OUT_HEADERS)/pp/inc
kernel_includes :=
kernel_includes += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include

This all means that the file is being picked up, as I am not receiving a lost file error. Instead, I am getting a lot of missed declarations.

The given errors:

target thumb C++: libmemalloc <= hardware/qcom/display-legacy/libgralloc/ionalloc.cpp
target thumb C++: libmemalloc <= hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp
target thumb C++: libmemalloc <= hardware/qcom/display-legacy/libgralloc/pmemalloc.cpp
target thumb C++: libqdutils <= hardware/qcom/display-legacy/libqdutils/profiler.cpp
hardware/qcom/display-legacy/libgralloc/ionalloc.cpp: In member function 'virtual int gralloc::IonAlloc::alloc_buffer(gralloc::alloc_data&)':
hardware/qcom/display-legacy/libgralloc/ionalloc.cpp:121:23: error: 'ION_SECURE' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/ionalloc.cpp: In member function 'virtual int gralloc::IonAlloc::clean_buffer(void*, size_t, int, int)':
hardware/qcom/display-legacy/libgralloc/ionalloc.cpp:232:22: error: 'ION_IOC_CLEAN_INV_CACHES' was not declared in this scope
build/core/binary.mk:432: recipe for target '/home/jim/Build/ROMS/oven/carbon-mt4gs/out/target/product/doubleshot/obj/SHARED_LIBRARIES/libmemalloc_intermediates/ionalloc.o' failed
make: *** [/home/jim/Build/ROMS/oven/carbon-mt4gs/out/target/product/doubleshot/obj/SHARED_LIBRARIES/libmemalloc_intermediates/ionalloc.o] Error 1
make: *** Waiting for unfinished jobs....
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp: In member function 'virtual int gralloc::IonController::allocate(gralloc::alloc_data&, int, int)':
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:136:30: error: 'ION_SF_HEAP_ID' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:136:44: error: 'ION_HEAP' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:139:30: error: 'ION_SYSTEM_HEAP_ID' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:139:48: error: 'ION_HEAP' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:144:30: error: 'ION_IOMMU_HEAP_ID' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:144:47: error: 'ION_HEAP' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:147:30: error: 'ION_CP_MM_HEAP_ID' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:147:47: error: 'ION_HEAP' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:150:30: error: 'ION_CP_WB_HEAP_ID' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:150:47: error: 'ION_HEAP' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:153:30: error: 'ION_CAMERA_HEAP_ID' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:153:48: error: 'ION_HEAP' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:156:21: error: 'ION_SECURE' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:168:29: error: 'ION_SF_HEAP_ID' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:168:43: error: 'ION_HEAP' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:168:56: error: 'ION_IOMMU_HEAP_ID' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:175:43: error: 'ION_SYSTEM_HEAP_ID' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:178:49: error: 'ION_HEAP' was not declared in this scope
hardware/qcom/display-legacy/libgralloc/alloc_controller.cpp:187:23: error: 'ION_SECURE' was not declared in this scope
build/core/binary.mk:432: recipe for target '/home/jim/Build/ROMS/oven/carbon-mt4gs/out/target/product/doubleshot/obj/SHARED_LIBRARIES/libmemalloc_intermediates/alloc_controller.o' failed
make: *** [/home/jim/Build/ROMS/oven/carbon-mt4gs/out/target/product/doubleshot/obj/SHARED_LIBRARIES/libmemalloc_intermediates/alloc_controller.o] Error 1

It is my understanding that if something is defined, it has already been declared. So in the case of ION_SECURE, I should not see that error pop up. Is there anything I could be missing? Thank you.