Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7e700ee authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: crypto: Add support for map and unmap ioctls"

parents 97bd099d a540a07e
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
* QCEDEV (QTI Crypto Engine Device)

[Root level node]
Crypto Engine
============
Required properties:
  - compatible : should be "qcom,qcedev"
  - reg : should contain crypto, BAM register map.
@@ -23,6 +26,19 @@ Optional properties:
  - qcom,smmu-s1-enable : Boolean flag to enable SMMU stage 1 translation.
  - iommus : A list of phandle and IOMMU specifier pairs that describe the IOMMU master interfaces of the device.


[Second level nodes]
Context banks
=============
Required properties:
  - compatible : should be "qcom,qcedev,context-bank"
  - iommus : A phandle parsed by smmu driver. Number of entries will vary across targets.

Optional properties:
  - label - string describing iommu domain usage.
  - virtual-addr : start of virtual address pool.
  - virtual-size : size of virtual address pool.

Example:

	qcom,qcedev@fd440000 {
@@ -42,4 +58,15 @@ Example:
				<56 512 0 0>,
				<56 512 3936000 393600>,
		qcom,ce-opp-freq = <100000000>;

		qcom_cedev_ns_cb {
			compatible = "qcom,qcedev,context-bank";
			label = "ns_context";
			iommus = <&anoc2_smmu 0x1878>,
				<&anoc2_smmu 0x1879>,
				<&anoc2_smmu 0x187c>,
				<&anoc2_smmu 0x187f>;
			virtual-addr = <0x60000000>;
			virtual-size = <0x00200000>;
		};
	};
+22 −0
Original line number Diff line number Diff line
@@ -2570,9 +2570,31 @@
			 <&clock_gcc GCC_CE1_AXI_CLK>;
		qcom,ce-opp-freq = <171430000>;
		qcom,request-bw-before-clk;

		qcom,smmu-s1-enable;
		iommus = <&apps_smmu 0x706 0x1>,
			 <&apps_smmu 0x716 0x1>;

		qcom_cedev_ns_cb {
			compatible = "qcom,qcedev,context-bank";
			label = "ns_context";
			iommus = <&apps_smmu 0x712 0>,
			       <&apps_smmu 0x71f 0>;
			virtual-addr = <0x60000000>;
			virtual-size = <0x40000000>;
		};

		qcom_cedev_s_cb {
			compatible = "qcom,qcedev,context-bank";
			label = "secure_context";
			iommus = <&apps_smmu 0x713 0>,
			       <&apps_smmu 0x71c 0>,
			       <&apps_smmu 0x71d 0>,
			       <&apps_smmu 0x71e 0>;
			virtual-addr = <0x60200000>;
			virtual-size = <0x40000000>;
			qcom,secure-context-bank;
		};
	};

	qcom_msmhdcp: qcom,msm_hdcp {
+1 −0
Original line number Diff line number Diff line
obj-$(CONFIG_CRYPTO_DEV_QCOM_MSM_QCE) += qce50.o
obj-$(CONFIG_CRYPTO_DEV_QCEDEV) += qcedev.o
obj-$(CONFIG_CRYPTO_DEV_QCEDEV) += qcedev_smmu.o
obj-$(CONFIG_CRYPTO_DEV_QCRYPTO) += qcrypto.o
obj-$(CONFIG_CRYPTO_DEV_OTA_CRYPTO) += ota_crypto.o
obj-$(CONFIG_CRYPTO_DEV_QCOM_ICE) += ice.o
+114 −1
Original line number Diff line number Diff line
/*
 * QTI CE 32-bit compatibility syscall for 64-bit systems
 *
 * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
 * Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -254,6 +254,75 @@ static int compat_put_qcedev_cipher_op_req(
	return err;
}

static int compat_xfer_qcedev_map_buf_req(
			struct compat_qcedev_map_buf_req __user *data32,
			struct qcedev_map_buf_req __user *data, bool to_get)
{
	int rc = 0, i = 0, fd = -1;
	uint32_t fd_size, fd_offset, num_fds, buf_vaddr;

	if (to_get) {
		/* copy from compat struct */
		for (i = 0; i < QCEDEV_MAX_BUFFERS; i++) {
			rc |= get_user(fd, &data32->fd[i]);
			rc |= put_user(fd, &data->fd[i]);
			rc |= get_user(fd_size, &data32->fd_size[i]);
			rc |= put_user(fd_size, &data->fd_size[i]);
			rc |= get_user(fd_offset, &data32->fd_offset[i]);
			rc |= put_user(fd_offset, &data->fd_offset[i]);
			rc |= get_user(buf_vaddr, &data32->buf_vaddr[i]);
			rc |= put_user(buf_vaddr, &data->buf_vaddr[i]);
		}

		rc |= get_user(num_fds, &data32->num_fds);
		rc |= put_user(num_fds, &data->num_fds);
	} else {
		/* copy to compat struct */
		for (i = 0; i < QCEDEV_MAX_BUFFERS; i++) {
			rc |= get_user(fd, &data->fd[i]);
			rc |= put_user(fd, &data32->fd[i]);
			rc |= get_user(fd_size, &data->fd_size[i]);
			rc |= put_user(fd_size, &data32->fd_size[i]);
			rc |= get_user(fd_offset, &data->fd_offset[i]);
			rc |= put_user(fd_offset, &data32->fd_offset[i]);
			rc |= get_user(buf_vaddr, &data->buf_vaddr[i]);
			rc |= put_user(buf_vaddr, &data32->buf_vaddr[i]);
		}
		rc |= get_user(num_fds, &data->num_fds);
		rc |= put_user(num_fds, &data32->num_fds);
	}

	return rc;
}

static int compat_xfer_qcedev_unmap_buf_req(
			struct compat_qcedev_unmap_buf_req __user *data32,
			struct qcedev_unmap_buf_req __user *data, bool to_get)
{
	int i = 0, rc = 0, fd = -1;
	uint32_t num_fds;

	if (to_get) {
		/* copy from compat struct */
		for (i = 0; i < QCEDEV_MAX_BUFFERS; i++) {
			rc |= get_user(fd, &data32->fd[i]);
			rc |= put_user(fd, &data->fd[i]);
		}
		rc |= get_user(num_fds, &data32->num_fds);
		rc |= put_user(num_fds, &data->num_fds);
	} else {
		/* copy to compat struct */
		for (i = 0; i < QCEDEV_MAX_BUFFERS; i++) {
			rc |= get_user(fd, &data->fd[i]);
			rc |= put_user(fd, &data32->fd[i]);
		}
		rc |= get_user(num_fds, &data->num_fds);
		rc |= put_user(num_fds, &data32->num_fds);
	}
	return rc;
}


static int compat_get_qcedev_sha_op_req(
		struct compat_qcedev_sha_op_req __user *data32,
		struct qcedev_sha_op_req __user *data)
@@ -359,6 +428,10 @@ static unsigned int convert_cmd(unsigned int cmd)
		return QCEDEV_IOCTL_GET_SHA_REQ;
	case COMPAT_QCEDEV_IOCTL_GET_CMAC_REQ:
		return QCEDEV_IOCTL_GET_CMAC_REQ;
	case COMPAT_QCEDEV_IOCTL_MAP_BUF_REQ:
		return QCEDEV_IOCTL_MAP_BUF_REQ;
	case COMPAT_QCEDEV_IOCTL_UNMAP_BUF_REQ:
		return QCEDEV_IOCTL_UNMAP_BUF_REQ;
	default:
		return cmd;
	}
@@ -412,6 +485,46 @@ long compat_qcedev_ioctl(struct file *file,
		err = compat_put_qcedev_sha_op_req(data32, data);
		return ret ? ret : err;
	}
	case COMPAT_QCEDEV_IOCTL_MAP_BUF_REQ: {
		struct compat_qcedev_map_buf_req __user *data32;
		struct qcedev_map_buf_req __user *data;
		int err;

		data32 = compat_ptr(arg);
		data = compat_alloc_user_space(sizeof(*data));
		if (!data)
			return -EINVAL;

		err = compat_xfer_qcedev_map_buf_req(data32, data, true);
		if (err)
			return err;

		ret = qcedev_ioctl(file, convert_cmd(cmd), (unsigned long)data);
		err = compat_xfer_qcedev_map_buf_req(data32, data, false);
		return ret ? ret : err;

		break;
	}
	case COMPAT_QCEDEV_IOCTL_UNMAP_BUF_REQ: {
		struct compat_qcedev_unmap_buf_req __user *data32;
		struct qcedev_unmap_buf_req __user *data;
		int err;

		data32 = compat_ptr(arg);
		data = compat_alloc_user_space(sizeof(*data));
		if (!data)
			return -EINVAL;

		err = compat_xfer_qcedev_unmap_buf_req(data32, data, true);
		if (err)
			return err;

		ret = qcedev_ioctl(file, convert_cmd(cmd), (unsigned long)data);
		err = compat_xfer_qcedev_unmap_buf_req(data32, data, false);
		return ret ? ret : err;

		break;
	}
	default:
		return -ENOIOCTLCMD;
	}
+31 −1
Original line number Diff line number Diff line
@@ -151,6 +151,33 @@ struct compat_qcedev_sha_op_req {
	enum qcedev_sha_alg_enum		alg;
};

/**
 * struct compact_qcedev_map_buf_req - Holds the mapping request information
 * fd (IN):            Array of fds.
 * num_fds (IN):       Number of fds in fd[].
 * fd_size (IN):       Array of sizes corresponding to each fd in fd[].
 * fd_offset (IN):     Array of offset corresponding to each fd in fd[].
 * vaddr (OUT):        Array of mapped virtual address corresponding to
 *                     each fd in fd[].
 */
struct compat_qcedev_map_buf_req {
	compat_long_t	fd[QCEDEV_MAX_BUFFERS];
	compat_ulong_t	num_fds;
	compat_ulong_t	fd_size[QCEDEV_MAX_BUFFERS];
	compat_ulong_t	fd_offset[QCEDEV_MAX_BUFFERS];
	compat_u64      buf_vaddr[QCEDEV_MAX_BUFFERS];
};

/**
 * struct compat_qcedev_unmap_buf_req - Holds the hashing request information
 * fd (IN):	       Array of fds to unmap
 * num_fds (IN):       Number of fds in fd[].
 */
struct	compat_qcedev_unmap_buf_req {
	compat_long_t	fd[QCEDEV_MAX_BUFFERS];
	compat_ulong_t	num_fds;
};

struct file;
extern long compat_qcedev_ioctl(struct file *file,
			unsigned int cmd, unsigned long arg);
@@ -173,6 +200,9 @@ extern long compat_qcedev_ioctl(struct file *file,
	_IO(QCEDEV_IOC_MAGIC, 8)
#define COMPAT_QCEDEV_IOCTL_GET_CMAC_REQ	\
	_IOWR(QCEDEV_IOC_MAGIC, 9, struct compat_qcedev_sha_op_req)

#define COMPAT_QCEDEV_IOCTL_MAP_BUF_REQ	\
	_IOWR(QCEDEV_IOC_MAGIC, 10, struct compat_qcedev_map_buf_req)
#define COMPAT_QCEDEV_IOCTL_UNMAP_BUF_REQ \
	_IOWR(QCEDEV_IOC_MAGIC, 11, struct compat_qcedev_unmap_buf_req)
#endif /* CONFIG_COMPAT */
#endif /* _UAPI_COMPAT_QCEDEV__H */
Loading