Revert commits that break compatibility with the FP2 kernel
This reverts two commits related to Ion that introduce conflicts between
headers in the FP2 kernel and Ion shipped in the framework. Keep using
the old codepaths instead.
Revert "Fix compilation on 3.18 kernel for ionbuf"
This reverts commit 8cc7e1bc9f9bd8ded668f2be153327b99378c8c9.
Revert "Handle new Ion"
This reverts commit 4b7f2871635ce1b75495287dc7b7744c8aae6574.
Issue: FP2P-164
Change-Id: I53f014f96ed240026e8ec1b66d64b5f447a86910
diff --git a/oem-recovery/Android.mk b/oem-recovery/Android.mk
index abad64a..4a34669 100644
--- a/oem-recovery/Android.mk
+++ b/oem-recovery/Android.mk
@@ -20,10 +20,7 @@
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_STATIC_LIBRARIES += libedify libotautil libz
-LOCAL_C_INCLUDES := bootable/recovery \
- system/core/libion/include \
- system/core/libion/kernel-headers
-
+LOCAL_C_INCLUDES := bootable/recovery
LOCAL_SRC_FILES := gpt-utils.cpp dec.cpp oem-updater.cpp
LOCAL_CFLAGS := -Wall
LOCAL_NOSANITIZE := cfi
@@ -34,16 +31,12 @@
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
endif
-LOCAL_SHARED_LIBRARIES += libion
LOCAL_MODULE := librecovery_updater_msm
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
-LOCAL_C_INCLUDES := bootable/recovery \
- system/core/libion/include \
- system/core/libion/kernel-headers
-
+LOCAL_C_INCLUDES := bootable/recovery
LOCAL_SRC_FILES := gpt-utils.cpp
LOCAL_CFLAGS := -Wall
ifeq ($(TARGET_HAS_GENERIC_KERNEL_HEADERS),true)
@@ -52,7 +45,7 @@
LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include
LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr
endif
-LOCAL_SHARED_LIBRARIES += liblog libcutils libz libion
+LOCAL_SHARED_LIBRARIES += liblog libcutils libz
LOCAL_MODULE := librecovery_updater_msm
LOCAL_COPY_HEADERS_TO := gpt-utils/inc
LOCAL_COPY_HEADERS := gpt-utils.h
diff --git a/oem-recovery/dec.cpp b/oem-recovery/dec.cpp
index 0956727..9d2fd90 100644
--- a/oem-recovery/dec.cpp
+++ b/oem-recovery/dec.cpp
@@ -42,11 +42,6 @@
#include <linux/qseecom.h>
#include <linux/msm_ion.h>
-#if TARGET_ION_ABI_VERSION >= 2
-#include <ion/ion.h>
-#endif
-#include <linux/dma-buf.h>
-
/* Service IDs */
#define SCM_SVC_SSD 0x07
@@ -105,106 +100,9 @@
uint32_t buffer_len;
int ion_fd;
int ifd_data_fd;
-#ifndef TARGET_ION_ABI_VERSION
struct ion_handle_data ion_alloc_handle;
-#endif
};
-#if TARGET_ION_ABI_VERSION >= 2
-/* uses the new version of ION */
-
-static int ion_memalloc(struct ion_buf_handle *handle, uint32_t size, uint32_t heap)
-{
-
- int32_t ret = 0;
- unsigned char *v_addr;
- int32_t ion_fd = -1;
- int32_t map_fd = -1;
- int retry = 0;
- uint32_t len = (size + 4095) & (~4095);
- uint32_t align = 4096;
- uint32_t flags = 0;
- struct dma_buf_sync buf_sync;
- unsigned int heap_id = ION_HEAP(heap);
- ion_fd = ion_open();
- if (ion_fd < 0) {
- fprintf(stderr, "Cannot open ION device (%s)\n", strerror(errno));
- return -1;
- }
-
- ret = ion_alloc_fd(ion_fd, len, align, ION_HEAP(heap_id), flags, &map_fd);
- if (ret) {
- fprintf(stderr, "ion_alloc_fd for heap failed", strerror(errno));
- ret = -1;
- goto alloc_fail;
- }
- v_addr = (unsigned char *)mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, map_fd, 0);
- if (v_addr == MAP_FAILED) {
- fprintf(stderr, "Ion memory map failed (%s)\n", strerror(errno));
- ret = -1;
- goto map_fail;
- }
-
- handle->ion_fd = ion_fd;
- handle->ifd_data_fd = map_fd;
- handle->buffer = v_addr;
- handle->buffer_len = size;
-
- buf_sync.flags = DMA_BUF_SYNC_START | DMA_BUF_SYNC_RW;
- ret = ioctl(map_fd, DMA_BUF_IOCTL_SYNC, &buf_sync);
- if (ret) {
- fprintf(stderr, "ION buffer allocation failed (%s)\n", strerror(errno));
- ret = -1;
- goto sync_fail;
- }
- return ret;
-
-sync_fail:
- if (v_addr) {
- munmap(v_addr, len);
- handle->buffer = NULL;
- }
-map_fail:
- if (map_fd >= 0 ) {
- ion_close(map_fd);
- handle->ifd_data_fd = -1;
- }
-alloc_fail:
- if (ion_fd >= 0 ) {
- ion_close(ion_fd);
- handle->ion_fd = -1;
- }
- return ret;
-}
-
-static int ion_memfree(struct ion_buf_handle *handle)
-{
- struct dma_buf_sync buf_sync;
- uint32_t len = (handle->buffer_len + 4095) & (~4095);
- int ret = 0;
-
- buf_sync.flags = DMA_BUF_SYNC_END | DMA_BUF_SYNC_RW;
- ret = ioctl(handle->ifd_data_fd, DMA_BUF_IOCTL_SYNC, &buf_sync);
- if (ret) {
- fprintf(stderr, "ioctl failed (%s)\n", strerror(errno));
- }
- if (handle->buffer) {
- munmap(handle->buffer, len);
- handle->buffer = NULL;
- }
- if (handle->ifd_data_fd >= 0 ) {
- ion_close(handle->ifd_data_fd);
- handle->ifd_data_fd= -1;
- }
- if (handle->ion_fd >= 0 ) {
- ion_close(handle->ion_fd);
- handle->ion_fd = -1;
- }
- return ret;
-}
-
-#endif
-#ifndef TARGET_ION_ABI_VERSION
static int
ion_memalloc(struct ion_buf_handle *buf, uint32_t size, uint32_t heap)
{
@@ -319,21 +217,6 @@
return rc;
}
-#endif
-
-
-static int ion_buffer_clean_inval_stub(struct ion_buf_handle *buf)
-{
-
- int ret = 0;
- #ifndef TARGET_ION_ABI_VERSION
- ret = ion_buffer_clean_inval(buf, ION_IOC_CLEAN_INV_CACHES);
- #else
- fprintf(stderr,"ION_IOC_INV_CACHES not defines");
- #endif
- return ret;
-
-}
static int is_encrypted(int smcmod_fd, struct ion_buf_handle *buf,
uint32_t len, uint32_t *ctx_id, uint32_t *end_offset)
@@ -466,12 +349,9 @@
fsize = ftell(file);
fseek(file, 0, SEEK_SET);
-
- #ifdef ION_IOC_INV_CACHES
ret = ion_memalloc(&ionbuf, fsize, ION_PIL1_HEAP_ID);
if (ret)
goto exit;
- #endif
if (ionbuf.buffer == NULL) {
goto exit;
@@ -483,9 +363,10 @@
ret = -errno;
goto exit;
}
- ret = ion_buffer_clean_inval_stub(&ionbuf);
+
+ ret = ion_buffer_clean_inval(&ionbuf, ION_IOC_CLEAN_INV_CACHES);
if (ret < 0)
- goto exit;
+ goto exit;
ret = ioctl(qseecom_fd, QSEECOM_IOCTL_PERF_ENABLE_REQ);
if (ret < 0)
@@ -500,12 +381,13 @@
ret = decrypt(smcmod_fd, &ionbuf, fsize, md_ctx, offset);
if (ret < 0)
goto exit;
- ret = ion_buffer_clean_inval_stub(&ionbuf);
- if (ret < 0)
- goto exit;
+
+ ion_buffer_clean_inval(&ionbuf, ION_IOC_INV_CACHES);
+
ret = save_file(dst_file, ionbuf.buffer + offset, fsize - offset);
if (ret < 0)
goto exit;
+
fprintf(stdout, "decrypting done!\n");
}