xtest: sdp: remove ION support
The ION allocator is deprecated and not present in recent kernels.
Remove the code that uses it.
Tested on QEMUv8 with CFG_SECURE_DATA_PATH=n. Enabling SDP will
require a bit more work (use a toolchain with kernel headers recent
enough to have <linux/dma-heap.h>, and probably a few more things to
enable the SDP heap in the kernel), that is out of scope for this
commit.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
diff --git a/host/xtest/aes_perf.c b/host/xtest/aes_perf.c
index 3fdac60..70f2187 100644
--- a/host/xtest/aes_perf.c
+++ b/host/xtest/aes_perf.c
@@ -31,8 +31,6 @@
static int output_sdp_fd;
static const char *heap_name = DEFAULT_HEAP_NAME;
-
-static int ion_heap = DEFAULT_HEAP_TYPE;
#endif /* CFG_SECURE_DATA_PATH */
/*
@@ -192,7 +190,7 @@
fprintf(stderr, " [-l LOOP] [-m MODE] [-n LOOP] [-r|--no-inited] [-s SIZE]");
fprintf(stderr, " [-v [-v]] [-w SEC]");
#ifdef CFG_SECURE_DATA_PATH
- fprintf(stderr, " [--sdp [-Id|-Ir|-IR] [-Od|-Or|-OR] [--ion-heap ID]]");
+ fprintf(stderr, " [--sdp [-Id|-Ir|-IR] [-Od|-Or|-OR]]");
#endif
fprintf(stderr, "\n");
fprintf(stderr, "AES performance testing tool for OP-TEE\n");
@@ -216,9 +214,6 @@
#ifdef CFG_SECURE_DATA_PATH
fprintf(stderr, "Secure data path specific options:\n");
fprintf(stderr, " --sdp Run the AES test in the scope fo a Secure Data Path test TA\n");
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0)
- fprintf(stderr, " --ion-heap ID Set ION heap ID where to allocate secure buffers [%d]\n", ion_heap);
-#endif
fprintf(stderr, " --heap-name NAME Set heap name where to allocate secure buffers [%s]\n", heap_name);
fprintf(stderr, " -I... AES input test buffer management:\n");
fprintf(stderr, " -Id allocate a non secure buffer (default)\n");
@@ -259,7 +254,7 @@
allocate_shm(&in_shm, sz);
#ifdef CFG_SECURE_DATA_PATH
else {
- input_sdp_fd = allocate_buffer(sz, heap_name, ion_heap, verbosity);
+ input_sdp_fd = allocate_buffer(sz, heap_name, verbosity);
if (input_buffer == BUFFER_SECURE_PREREGISTERED) {
register_shm(&in_shm, input_sdp_fd);
close(input_sdp_fd);
@@ -274,7 +269,7 @@
allocate_shm(&out_shm, sz);
#ifdef CFG_SECURE_DATA_PATH
else {
- output_sdp_fd = allocate_buffer(sz, heap_name, ion_heap, verbosity);
+ output_sdp_fd = allocate_buffer(sz, heap_name, verbosity);
if (output_buffer == BUFFER_SECURE_PREREGISTERED) {
register_shm(&out_shm, output_sdp_fd);
close(output_sdp_fd);
@@ -647,11 +642,6 @@
} else if (!strcmp(argv[i], "--heap-name")) {
NEXT_ARG(i);
heap_name = argv[i];
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0)
- } else if (!strcmp(argv[i], "--ion-heap")) {
- NEXT_ARG(i);
- ion_heap = atoi(argv[i]);
-#endif
#endif // CFG_SECURE_DATA_PATH
} else if (!strcmp(argv[i], "-u")) {
NEXT_ARG(i);
diff --git a/host/xtest/include/uapi/linux/ion.h b/host/xtest/include/uapi/linux/ion.h
deleted file mode 100644
index 075e149..0000000
--- a/host/xtest/include/uapi/linux/ion.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * drivers/staging/android/uapi/ion.h
- *
- * Copyright (C) 2011 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-#ifndef _UAPI_LINUX_ION_H
-#define _UAPI_LINUX_ION_H
-
-#include <linux/ioctl.h>
-#include <linux/types.h>
-
-/**
- * enum ion_heap_types - list of all possible types of heaps
- * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc
- * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc
- * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved
- * carveout heap, allocations are physically
- * contiguous
- * @ION_HEAP_TYPE_DMA: memory allocated via DMA API
- * @ION_HEAP_TYPE_UNMAPPED: memory not intended to be mapped into the
- * linux address space unless for debug cases
- * @ION_NUM_HEAPS: helper for iterating over heaps, a bit mask
- * is used to identify the heaps, so only 32
- * total heap types are supported
- */
-enum ion_heap_type {
- ION_HEAP_TYPE_SYSTEM,
- ION_HEAP_TYPE_SYSTEM_CONTIG,
- ION_HEAP_TYPE_CARVEOUT,
- ION_HEAP_TYPE_CHUNK,
- ION_HEAP_TYPE_DMA,
- ION_HEAP_TYPE_UNMAPPED,
- ION_HEAP_TYPE_CUSTOM, /*
- * must be last so device specific heaps always
- * are at the end of this enum
- */
-};
-
-#define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8)
-
-/**
- * allocation flags - the lower 16 bits are used by core ion, the upper 16
- * bits are reserved for use by the heaps themselves.
- */
-
-/*
- * mappings of this buffer should be cached, ion will do cache maintenance
- * when the buffer is mapped for dma
- */
-#define ION_FLAG_CACHED 1
-
-/*
- * mappings of this buffer will created at mmap time, if this is set
- * caches must be managed manually
- */
-#define ION_FLAG_CACHED_NEEDS_SYNC 2
-
-/**
- * DOC: Ion Userspace API
- *
- * create a client by opening /dev/ion
- * most operations handled via following ioctls
- *
- */
-
-/**
- * struct ion_allocation_data - metadata passed from userspace for allocations
- * @len: size of the allocation
- * @heap_id_mask: mask of heap ids to allocate from
- * @flags: flags passed to heap
- * @handle: pointer that will be populated with a cookie to use to
- * refer to this allocation
- *
- * Provided by userspace as an argument to the ioctl
- */
-struct ion_allocation_data {
- __u64 len;
- __u32 heap_id_mask;
- __u32 flags;
- __u32 fd;
- __u32 unused;
-};
-
-#define MAX_HEAP_NAME 32
-
-/**
- * struct ion_heap_data - data about a heap
- * @name - first 32 characters of the heap name
- * @type - heap type
- * @heap_id - heap id for the heap
- */
-struct ion_heap_data {
- char name[MAX_HEAP_NAME];
- __u32 type;
- __u32 heap_id;
- __u32 reserved0;
- __u32 reserved1;
- __u32 reserved2;
-};
-
-/**
- * struct ion_heap_query - collection of data about all heaps
- * @cnt - total number of heaps to be copied
- * @heaps - buffer to copy heap data
- */
-struct ion_heap_query {
- __u32 cnt; /* Total number of heaps to be copied */
- __u32 reserved0; /* align to 64bits */
- __u64 heaps; /* buffer to be populated */
- __u32 reserved1;
- __u32 reserved2;
-};
-
-#define ION_IOC_MAGIC 'I'
-
-/**
- * DOC: ION_IOC_ALLOC - allocate memory
- *
- * Takes an ion_allocation_data struct and returns it with the handle field
- * populated with the opaque handle for the allocation.
- */
-#define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \
- struct ion_allocation_data)
-
-/**
- * DOC: ION_IOC_FREE - free memory
- *
- * Takes an ion_handle_data struct and frees the handle.
- */
-#define ION_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, struct ion_handle_data)
-
-/**
- * DOC: ION_IOC_SHARE - creates a file descriptor to use to share an allocation
- *
- * Takes an ion_fd_data struct with the handle field populated with a valid
- * opaque handle. Returns the struct with the fd field set to a file
- * descriptor open in the current address space. This file descriptor
- * can then be passed to another process. The corresponding opaque handle can
- * be retrieved via ION_IOC_IMPORT.
- */
-#define ION_IOC_SHARE _IOWR(ION_IOC_MAGIC, 4, struct ion_fd_data)
-
-/**
- * DOC: ION_IOC_HEAP_QUERY - information about available heaps
- *
- * Takes an ion_heap_query structure and populates information about
- * available Ion heaps.
- */
-#define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, \
- struct ion_heap_query)
-
-#endif /* _UAPI_LINUX_ION_H */
diff --git a/host/xtest/include/uapi/linux/ion_old.h b/host/xtest/include/uapi/linux/ion_old.h
deleted file mode 100644
index 58166a5..0000000
--- a/host/xtest/include/uapi/linux/ion_old.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * drivers/staging/android/uapi/ion.h (This is the ION Uapi prior kernel 4.12)
- *
- * Copyright (C) 2011 Google, Inc.
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
-
-#ifndef _UAPI_LINUX_ION_OLD_H
-#define _UAPI_LINUX_ION_OLD_H
-
-/* All ION resources are prefixed ION0_ to ditinguish from companion new API */
-
-#include <linux/ioctl.h>
-#include <linux/types.h>
-
-typedef int ion0_user_handle_t;
-
-/**
- * struct ion0_allocation_data - metadata passed from userspace for allocations
- * @len: size of the allocation
- * @align: required alignment of the allocation
- * @heap_id_mask: mask of heap ids to allocate from
- * @flags: flags passed to heap
- * @handle: pointer that will be populated with a cookie to use to
- * refer to this allocation
- *
- * Provided by userspace as an argument to the ioctl
- */
-struct ion0_allocation_data {
- size_t len;
- size_t align;
- unsigned int heap_id_mask;
- unsigned int flags;
- ion0_user_handle_t handle;
-};
-
-/**
- * struct ion0_fd_data - metadata passed to/from userspace for a handle/fd pair
- * @handle: a handle
- * @fd: a file descriptor representing that handle
- *
- * For ION_IOC_SHARE or ION_IOC_MAP userspace populates the handle field with
- * the handle returned from ion alloc, and the kernel returns the file
- * descriptor to share or map in the fd field. For ION_IOC_IMPORT, userspace
- * provides the file descriptor and the kernel returns the handle.
- */
-struct ion0_fd_data {
- ion0_user_handle_t handle;
- int fd;
-};
-
-/**
- * struct ion0_handle_data - a handle passed to/from the kernel
- * @handle: a handle
- */
-struct ion0_handle_data {
- ion0_user_handle_t handle;
-};
-
-/**
- * struct ion0_custom_data - metadata passed to/from userspace for a custom ioctl
- * @cmd: the custom ioctl function to call
- * @arg: additional data to pass to the custom ioctl, typically a user
- * pointer to a predefined structure
- *
- * This works just like the regular cmd and arg fields of an ioctl.
- */
-struct ion0_custom_data {
- unsigned int cmd;
- unsigned long arg;
-};
-
-/**
- * DOC: ION_IOC_ALLOC - allocate memory
- *
- * Takes an ion_allocation_data struct and returns it with the handle field
- * populated with the opaque handle for the allocation.
- */
-#define ION0_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \
- struct ion0_allocation_data)
-/**
- * DOC: ION_IOC_FREE - free memory
- *
- * Takes an ion_handle_data struct and frees the handle.
- */
-#define ION0_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, struct ion0_handle_data)
-
-/**
- * DOC: ION_IOC_MAP - get a file descriptor to mmap
- *
- * Takes an ion0_fd_data struct with the handle field populated with a valid
- * opaque handle. Returns the struct with the fd field set to a file
- * descriptor open in the current address space. This file descriptor
- * can then be used as an argument to mmap.
- */
-#define ION0_IOC_MAP _IOWR(ION_IOC_MAGIC, 2, struct ion0_fd_data)
-
-/**
- * DOC: ION_IOC_SHARE - creates a file descriptor to use to share an allocation
- *
- * Takes an ion_fd_data struct with the handle field populated with a valid
- * opaque handle. Returns the struct with the fd field set to a file
- * descriptor open in the current address space. This file descriptor
- * can then be passed to another process. The corresponding opaque handle can
- * be retrieved via ION_IOC_IMPORT.
- */
-#define ION0_IOC_SHARE _IOWR(ION_IOC_MAGIC, 4, struct ion0_fd_data)
-
-/**
- * DOC: ION_IOC_IMPORT - imports a shared file descriptor
- *
- * Takes an ion0_fd_data struct with the fd field populated with a valid file
- * descriptor obtained from ION_IOC_SHARE and returns the struct with the handle
- * filed set to the corresponding opaque handle.
- */
-#define ION0_IOC_IMPORT _IOWR(ION_IOC_MAGIC, 5, struct ion0_fd_data)
-
-/**
- * DOC: ION_IOC_SYNC - syncs a shared file descriptors to memory
- *
- * Deprecated in favor of using the dma_buf api's correctly (syncing
- * will happen automatically when the buffer is mapped to a device).
- * If necessary should be used after touching a cached buffer from the cpu,
- * this will make the buffer in memory coherent.
- */
-#define ION0_IOC_SYNC _IOWR(ION_IOC_MAGIC, 7, struct ion0_fd_data)
-
-/**
- * DOC: ION_IOC_CUSTOM - call architecture specific ion ioctl
- *
- * Takes the argument of the architecture specific ioctl to call and
- * passes appropriate userdata for that ioctl
- */
-#define ION0_IOC_CUSTOM _IOWR(ION_IOC_MAGIC, 6, struct ion0_custom_data)
-
-#endif /* _UAPI_LINUX_ION_OLD_H */
diff --git a/host/xtest/regression_1000.c b/host/xtest/regression_1000.c
index de32c41..8570949 100644
--- a/host/xtest/regression_1000.c
+++ b/host/xtest/regression_1000.c
@@ -17,7 +17,9 @@
#include <pta_invoke_tests.h>
#include <pta_secstor_ta_mgmt.h>
#include <pthread.h>
+#ifdef CFG_SECURE_DATA_PATH
#include <sdp_basic.h>
+#endif
#include <signed_hdr.h>
#include <stdio.h>
#include <stdlib.h>
@@ -1266,30 +1268,30 @@
test = TEST_NS_TO_TA;
Do_ADBG_BeginSubCase(c, "SDP: NonSecure client invokes a SDP TA");
- ret = sdp_basic_test(test, size, loop, heap_name, DEFAULT_HEAP_TYPE, rnd_offset, 0);
+ ret = sdp_basic_test(test, size, loop, heap_name, rnd_offset, 0);
ADBG_EXPECT(c, 0, ret);
Do_ADBG_EndSubCase(c, "SDP: NonSecure client invokes a SDP TA");
test = TEST_TA_TO_TA;
Do_ADBG_BeginSubCase(c, "SDP: SDP TA invokes a SDP TA");
- ret = sdp_basic_test(test, size, loop, heap_name, DEFAULT_HEAP_TYPE, rnd_offset, 0);
+ ret = sdp_basic_test(test, size, loop, heap_name, rnd_offset, 0);
ADBG_EXPECT(c, 0, ret);
Do_ADBG_EndSubCase(c, "SDP: SDP TA invokes a SDP TA");
test = TEST_TA_TO_PTA;
Do_ADBG_BeginSubCase(c, "SDP: SDP TA invokes a test pTA (invoke_tests.pta)");
- ret = sdp_basic_test(test, size, loop, heap_name, DEFAULT_HEAP_TYPE, rnd_offset, 0);
+ ret = sdp_basic_test(test, size, loop, heap_name, rnd_offset, 0);
ADBG_EXPECT(c, 0, ret);
Do_ADBG_EndSubCase(c, "SDP: SDP TA invokes a test pTA (invoke_tests.pta)");
test = TEST_NS_TO_PTA;
Do_ADBG_BeginSubCase(c, "SDP: NSec CA invokes a test pTA (invoke_tests.pta) (should fail)");
- ret = sdp_basic_test(test, size, loop, heap_name, DEFAULT_HEAP_TYPE, rnd_offset, 0);
+ ret = sdp_basic_test(test, size, loop, heap_name, rnd_offset, 0);
ADBG_EXPECT(c, 1, ret);
Do_ADBG_EndSubCase(c, "SDP: NSec CA invokes a test pTA (invoke_tests.pta) (should fail)");
Do_ADBG_BeginSubCase(c, "SDP: Invoke TA with out of bounds SDP memref");
- ret = sdp_out_of_bounds_memref_test(size, heap_name, DEFAULT_HEAP_TYPE, 0);
+ ret = sdp_out_of_bounds_memref_test(size, heap_name, 0);
ADBG_EXPECT(c, 0, ret);
Do_ADBG_EndSubCase(c, NULL);
}
diff --git a/host/xtest/sdp_basic.c b/host/xtest/sdp_basic.c
index 16241c4..c8abd51 100644
--- a/host/xtest/sdp_basic.c
+++ b/host/xtest/sdp_basic.c
@@ -56,100 +56,6 @@
TEEC_Session sess;
};
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0))
-/*
- * Old ION API to allocate and export a buffer
- */
-static int allocate_ion_buffer_old_api(size_t size, int heap_type_id, int ion)
-{
- struct ion0_allocation_data alloc_data = { };
- struct ion0_handle_data hdl_data = { };
- struct ion0_fd_data fd_data = { };
- int fd = -1;
-
- alloc_data.len = size;
- alloc_data.align = 0;
- alloc_data.flags = 0;
- alloc_data.heap_id_mask = 1 << heap_type_id;
- if (ioctl(ion, ION0_IOC_ALLOC, &alloc_data) == -1) {
- fprintf(stderr, "Error: old ION allocate API failed\n");
- return fd;
- }
-
- fd_data.handle = alloc_data.handle;
- if (ioctl(ion, ION0_IOC_SHARE, &fd_data) != -1)
- fd = fd_data.fd;
- else
- fprintf(stderr, "Error: old ION share API failed\n");
-
- hdl_data.handle = alloc_data.handle;
- (void)ioctl(ion, ION0_IOC_FREE, &hdl_data);
-
- return fd;
-}
-
-int allocate_ion_buffer(size_t size, const char *heap_name, int heap_type_id, int verbosity)
-{
- struct ion_heap_query query_data = { };
- struct ion_heap_data heap_data[32] = { };
- struct ion_allocation_data alloc_data = { };
- int ion = 0;
- int fd = -1;
- unsigned int idx = 0;
-
- ion = open("/dev/ion", O_RDWR);
- if (ion < 0) {
- fprintf(stderr, "Error: failed to open /dev/ion\n");
- verbose("Seems no ION heap is available.\n");
- verbose("To test ION allocation you can enable\n");
- verbose("CONFIG_ION and CONFIG_ION_DUMMY in your\n");
- verbose("linux kernel configuration.\n");
- return fd;
- }
-
- if (heap_type_id < 0)
- heap_type_id = DEFAULT_HEAP_TYPE;
-
- if (ioctl(ion, ION_IOC_HEAP_QUERY, &query_data) < 0) {
- fprintf(stderr, "Error: failed to query the number of heaps\n");
- goto out;
- }
-
- query_data.heaps = (__u64)(unsigned long)&heap_data;
- if (ioctl(ion, ION_IOC_HEAP_QUERY, &query_data) < 0) {
- fprintf(stderr, "Info: can't query heaps data, try old API\n");
- fd = allocate_ion_buffer_old_api(size, heap_type_id, ion);
- goto out;
- }
-
- for (idx = 0; idx < query_data.cnt; idx++)
- if ((heap_data[idx].type == (unsigned int)heap_type_id) &&
- (strcmp(heap_data[idx].name, heap_name) == 0))
- break;
- if (idx == query_data.cnt) {
- fprintf(stderr, "Error: target heap type %d not found\n",
- heap_type_id);
- goto out;
- }
-
- verbose("Allocate in ION heap '%s' (type=%u, id=%u)\n",
- heap_data[idx].name, heap_data[idx].type,
- heap_data[idx].heap_id);
-
- alloc_data.len = size;
- alloc_data.flags = 0;
- alloc_data.heap_id_mask = 1 << heap_data[idx].heap_id;
- if (ioctl(ion, ION_IOC_ALLOC, &alloc_data) < 0) {
- fprintf(stderr, "Error: failed to allocate in target heap\n");
- goto out;
- }
-
- fd = alloc_data.fd;
-out:
- close(ion);
- return fd;
-}
-#else // LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
int allocate_dma_buffer(size_t size, const char *heap_name, int verbosity)
{
const char *default_dev = DEFAULT_HEAP_NAME;
@@ -183,7 +89,6 @@
close(fd_mem_sec);
return fd;
}
-#endif
static void finalize_tee_ctx(struct tee_ctx *ctx)
{
@@ -464,7 +369,7 @@
int sdp_basic_test(enum test_target_ta ta, size_t size, size_t loop,
- const char *heap_name, int ion_heap, int rnd_offset, int verbosity)
+ const char *heap_name, int rnd_offset, int verbosity)
{
struct tee_ctx *ctx = NULL;
unsigned char *test_buf = NULL;
@@ -492,10 +397,10 @@
goto bail1;
}
- fd = allocate_buffer(sdp_size, heap_name, ion_heap, verbosity);
+ fd = allocate_buffer(sdp_size, heap_name, verbosity);
if (fd < 0) {
- verbose("Failed to allocate SDP buffer (%zu bytes) in %s heap %d: %d\n",
- sdp_size, heap_name, ion_heap, fd);
+ verbose("Failed to allocate SDP buffer (%zu bytes) in %s: %d\n",
+ sdp_size, heap_name, fd);
goto bail1;
}
@@ -607,7 +512,8 @@
return 1;
}
-int sdp_out_of_bounds_memref_test(size_t size, const char *heap_name, int ion_heap, int verbosity)
+int sdp_out_of_bounds_memref_test(size_t size, const char *heap_name,
+ int verbosity)
{
struct tee_ctx ctx = { };
int err = 0;
@@ -619,10 +525,10 @@
if (create_tee_ctx(&ctx, TEST_NS_TO_TA))
return -1;
- fd = allocate_buffer(size, heap_name, ion_heap, verbosity);
+ fd = allocate_buffer(size, heap_name, verbosity);
if (fd < 0) {
- verbose("SDP alloc failed (%zu bytes) in %s heap %d: %d\n",
- size, heap_name, ion_heap, fd);
+ verbose("SDP alloc failed (%zu bytes) in %s: %d\n",
+ size, heap_name, fd);
err = 1;
goto bail;
}
@@ -684,7 +590,7 @@
#define _TO_STR(x) #x
#define TO_STR(x) _TO_STR(x)
-static void usage(const char *progname, size_t size, int loop, const char *heap_name, int ion_heap)
+static void usage(const char *progname, size_t size, int loop, const char *heap_name)
{
fprintf(stderr, "Usage: %s [OPTION]\n", progname);
fprintf(stderr,
@@ -698,11 +604,6 @@
fprintf(stderr, " -v Be verbose\n");
fprintf(stderr, " -s SIZE SDP buffer byte size [%zu]\n", size);
fprintf(stderr, " -n LOOP Test loop iterations [%u]\n", loop);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0)
- fprintf(stderr, " --heap ID Target heap ID [%d]\n", ion_heap);
-#else
- (void)ion_heap;
-#endif
fprintf(stderr, " --heap-name NAME Target heap name [%s]\n", heap_name);
fprintf(stderr, " --no-offset No random offset [0 255] in buffer\n");
}
@@ -728,7 +629,6 @@
{
size_t test_size = 5000;
size_t test_loop = 1000;
- int ion_heap = DEFAULT_HEAP_TYPE;
const char *heap_name = DEFAULT_HEAP_NAME;
int rnd_offset = 1;
int verbosity = 1;
@@ -738,7 +638,7 @@
/* Parse command line */
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
- usage(argv[0], test_size, test_loop, heap_name, ion_heap);
+ usage(argv[0], test_size, test_loop, heap_name);
return 0;
}
}
@@ -751,11 +651,6 @@
} else if (!strcmp(argv[i], "-n")) {
NEXT_ARG(i);
test_loop = atoi(argv[i]);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 11, 0)
- } else if (!strcmp(argv[i], "--ion-heap")) {
- NEXT_ARG(i);
- ion_heap = atoi(argv[i]);
-#endif
} else if (!strcmp(argv[i], "--heap-name")) {
NEXT_ARG(i);
heap_name = argv[i];
@@ -764,38 +659,38 @@
} else {
fprintf(stderr, "%s: invalid argument: %s\n",
argv[0], argv[i]);
- usage(argv[0], test_size, test_loop, heap_name, ion_heap);
+ usage(argv[0], test_size, test_loop, heap_name);
return 1;
}
}
verbose("\nSecure Data Path basic access: "
"NS invokes SDP TA\n");
- err = sdp_basic_test(TEST_NS_TO_TA, test_size, test_loop, heap_name, ion_heap,
+ err = sdp_basic_test(TEST_NS_TO_TA, test_size, test_loop, heap_name,
rnd_offset, verbosity);
CHECK_RESULT(err, 0, return 1);
verbose("\nSecure Data Path basic access: "
"SDP TA invokes SDP TA\n");
- err = sdp_basic_test(TEST_TA_TO_TA, test_size, test_loop, heap_name, ion_heap,
+ err = sdp_basic_test(TEST_TA_TO_TA, test_size, test_loop, heap_name,
rnd_offset, verbosity);
CHECK_RESULT(err, 0, return 1);
verbose("\nSecure Data Path basic access: "
"SDP TA invokes SDP pTA\n");
- err = sdp_basic_test(TEST_TA_TO_PTA, test_size, test_loop, heap_name, ion_heap,
+ err = sdp_basic_test(TEST_TA_TO_PTA, test_size, test_loop, heap_name,
rnd_offset, verbosity);
CHECK_RESULT(err, 0, return 1);
verbose("\nSecure Data Path basic access: "
"NS invokes SDP pTA (shall fail)\n");
- err = sdp_basic_test(TEST_NS_TO_PTA, test_size, test_loop, heap_name, ion_heap,
+ err = sdp_basic_test(TEST_NS_TO_PTA, test_size, test_loop, heap_name,
rnd_offset, verbosity);
CHECK_RESULT(err, 1, return 1);
verbose("\nSecure Data Path basic access: "
"Invoke TA with out of bounds buffer references\n");
- err = sdp_out_of_bounds_memref_test(test_size, heap_name, ion_heap, verbosity);
+ err = sdp_out_of_bounds_memref_test(test_size, heap_name, verbosity);
CHECK_RESULT(err, 0, return 1);
return 0;
diff --git a/host/xtest/sdp_basic.h b/host/xtest/sdp_basic.h
index 64c9203..268d861 100644
--- a/host/xtest/sdp_basic.h
+++ b/host/xtest/sdp_basic.h
@@ -9,16 +9,8 @@
#include <linux/dma-buf.h>
#include <linux/version.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
#include <linux/dma-heap.h>
-#define DEFAULT_HEAP_TYPE 0
#define DEFAULT_HEAP_NAME "/dev/dma_heap/sdp"
-#else
-#include "include/uapi/linux/ion.h"
-#include "include/uapi/linux/ion_old.h"
-#define DEFAULT_HEAP_TYPE ION_HEAP_TYPE_UNMAPPED
-#define DEFAULT_HEAP_NAME "unmapped"
-#endif
#include "ta_sdp_basic.h"
@@ -29,25 +21,17 @@
TEST_TA_TO_PTA,
};
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 11, 0)
int allocate_dma_buffer(size_t size, const char *heap_name, int verbosity);
-static inline int allocate_buffer(size_t size, const char *heap_name, int heap_id, int verbosity)
+static inline int allocate_buffer(size_t size, const char *heap_name,
+ int verbosity)
{
- (void)heap_id;
-
return allocate_dma_buffer(size, heap_name, verbosity);
}
-#else
-int allocate_ion_buffer(size_t size, const char *heap_name, int heap_id, int verbosity);
-static inline int allocate_buffer(size_t size, const char *heap_name, int heap_id, int verbosity)
-{
- return allocate_ion_buffer(size, heap_name, heap_id, verbosity);
-}
-#endif
int sdp_basic_test(enum test_target_ta ta,
- size_t size, size_t loop, const char *heap_name, int ion_heap,
+ size_t size, size_t loop, const char *heap_name,
int rnd_offset, int verbosity);
-int sdp_out_of_bounds_memref_test(size_t size, const char *heap_name, int ion_heap, int verbosity);
+int sdp_out_of_bounds_memref_test(size_t size, const char *heap_name,
+ int verbosity);
#endif /* XTEST_SDP_BASIC_H */