Преглед на файлове

Merge 026f1690e32eb97854ced1358119fb1504d0b5bc on remote branch

Change-Id: Ib8e452216ec3237acf7c2a74486bf9bb4d32bb45
Linux Build Service Account преди 1 година
родител
ревизия
a0ffe024e5
променени са 16 файла, в които са добавени 149 реда и са изтрити 25 реда
  1. 4 3
      Android.mk
  2. 2 0
      BUILD.bazel
  3. 1 1
      Kbuild
  4. 21 0
      build/niobe.bzl
  5. 7 1
      build/sun.bzl
  6. 6 1
      crypto-qti/ota_crypto.c
  7. 9 3
      crypto-qti/qce50.c
  8. 5 0
      crypto-qti/qcedev.c
  9. 49 8
      crypto-qti/qcrypto.c
  10. 0 1
      hdcp/hdcp_main.h
  11. 5 0
      qrng/msm_rng.c
  12. 20 5
      qseecom/qseecom.c
  13. 9 0
      smcinvoke/smcinvoke.c
  14. 5 0
      smmu-proxy/qti-smmu-proxy-common.c
  15. 1 1
      smmu-proxy/qti-smmu-proxy-pvm.c
  16. 5 1
      tz_log/tz_log.c

+ 4 - 3
Android.mk

@@ -30,7 +30,9 @@ LOCAL_MODULE_DDK_BUILD := true
 KBUILD_OPTIONS := SSG_ROOT=$(SEC_KERNEL_DIR)
 KBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM)
 
-###################################################
+CONDITIONAL_FLAGS := $(ENABLE_SECUREMSM_QTEE_DLKM) $(ENABLE_SECUREMSM_DLKM)
+
+ifneq (0, $(words $(filter true, $(CONDITIONAL_FLAGS))))
 include $(CLEAR_VARS)
 # For incremental compilation
 LOCAL_SRC_FILES           := $(SSG_SRC_FILES)
@@ -39,8 +41,7 @@ LOCAL_MODULE_STEM         := Module.symvers
 LOCAL_MODULE_KBUILD_NAME  := Module.symvers
 LOCAL_MODULE_PATH         := $(KERNEL_MODULES_OUT)
 include $(DLKM_DIR)/Build_external_kernelmodule.mk
-###################################################
-###################################################
+endif
 
 ifeq ($(ENABLE_SECUREMSM_QTEE_DLKM), true)
 include $(CLEAR_VARS)

+ 2 - 0
BUILD.bazel

@@ -76,7 +76,9 @@ ddk_headers(
 load(":build/pineapple.bzl", "define_pineapple")
 load(":build/blair.bzl", "define_blair")
 load(":build/sun.bzl", "define_sun")
+load(":build/niobe.bzl", "define_niobe")
 
 define_pineapple()
 define_blair()
+define_niobe()
 define_sun()

+ 1 - 1
Kbuild

@@ -44,7 +44,7 @@ hdcp_qseecom_dlkm-objs := hdcp/hdcp_main.o hdcp/hdcp_smcinvoke.o hdcp/hdcp_qseec
 obj-$(CONFIG_HW_RANDOM_MSM_LEGACY) += qrng_dlkm.o
 qrng_dlkm-objs := qrng/msm_rng.o
 
-ifneq (, $(filter y, $(ARCH_QTI_VM) $(CONFIG_ARCH_PINEAPPLE)))
+ifneq (, $(filter y, $(ARCH_QTI_VM) $(CONFIG_ARCH_PINEAPPLE) $(CONFIG_ARCH_SUN)))
     include $(SSG_MODULE_ROOT)/config/sec-kernel_defconfig_smmu_proxy.conf
     LINUXINCLUDE += -include $(SSG_MODULE_ROOT)/config/sec-kernel_defconfig_smmu_proxy.h
 

+ 21 - 0
build/niobe.bzl

@@ -0,0 +1,21 @@
+load(":securemsm_kernel.bzl", "define_consolidate_gki_modules")
+
+def define_niobe():
+    define_consolidate_gki_modules(
+        target = "niobe",
+        modules = [
+            "smcinvoke_dlkm",
+            "tz_log_dlkm",
+            "hdcp_qseecom_dlkm",
+            "qce50_dlkm",
+            "qcedev-mod_dlkm",
+            "qrng_dlkm",
+            "qcrypto-msm_dlkm",
+            "smmu_proxy_dlkm",
+            "qseecom_dlkm"
+        ],
+        extra_options = [
+            "CONFIG_QCOM_SMCINVOKE",
+	    "CONFIG_QSEECOM_COMPAT",
+        ],
+    )

+ 7 - 1
build/sun.bzl

@@ -6,7 +6,13 @@ def define_sun():
         modules = [
             "smcinvoke_dlkm",
             "tz_log_dlkm",
-            "qseecom_dlkm"
+            "qseecom_dlkm",
+            "hdcp_qseecom_dlkm",
+            "qce50_dlkm",
+            "qcedev-mod_dlkm",
+            "qrng_dlkm",
+            "qcrypto-msm_dlkm",
+            "smmu_proxy_dlkm"
          ],
          extra_options = [
              "CONFIG_QCOM_SMCINVOKE",

+ 6 - 1
crypto-qti/ota_crypto.c

@@ -3,6 +3,7 @@
  * QTI Over the Air (OTA) Crypto driver
  *
  * Copyright (c) 2010-2014,2017-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <linux/types.h>
@@ -21,7 +22,7 @@
 #include <linux/uaccess.h>
 #include <linux/debugfs.h>
 #include <linux/cache.h>
-
+#include <linux/version.h>
 
 #include "linux/qcota.h"
 #include "qce.h"
@@ -673,7 +674,11 @@ static int qcota_probe(struct platform_device *pdev)
 		return rc;
 	}
 
+#if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE)
+	driver_class = class_create(QCOTA_DEV);
+#else
 	driver_class = class_create(THIS_MODULE, QCOTA_DEV);
+#endif
 	if (IS_ERR(driver_class)) {
 		rc = -ENOMEM;
 		pr_err("class_create failed %d\n", rc);

+ 9 - 3
crypto-qti/qce50.c

@@ -415,6 +415,7 @@ static int _probe_ce_engine(struct qce_device *pce_dev)
 {
 	unsigned int rev;
 	unsigned int maj_rev, min_rev, step_rev;
+	int i = 0;
 
 	rev = readl_relaxed(pce_dev->iobase + CRYPTO_VERSION_REG);
 	/*
@@ -461,12 +462,17 @@ static int _probe_ce_engine(struct qce_device *pce_dev)
 
 	pce_dev->ce_bam_info.ce_burst_size = MAX_CE_BAM_BURST_SIZE;
 
-	dev_dbg(pce_dev->pdev, "CE device = %#x IO base, CE = %pK Consumer (IN) PIPE %d,\nProducer (OUT) PIPE %d IO base BAM = %pK\nBAM IRQ %d Engines Availability = %#x\n",
+	dev_dbg(pce_dev->pdev, "CE device = %#x IO base, CE = %pK, IO base BAM = %pK\nBAM IRQ %d Engines Availability = %#x\n",
 			pce_dev->ce_bam_info.ce_device, pce_dev->iobase,
-			pce_dev->ce_bam_info.dest_pipe_index,
-			pce_dev->ce_bam_info.src_pipe_index,
 			pce_dev->ce_bam_info.bam_iobase,
 			pce_dev->ce_bam_info.bam_irq, pce_dev->engines_avail);
+
+	for (i = 0; i < QCE_OFFLOAD_OPER_LAST; i++) {
+		dev_dbg(pce_dev->pdev, "Consumer pipe IN [%d] = %d, Producer Pipe OUT [%d] = %d\n",
+				i, pce_dev->ce_bam_info.src_pipe_index[i],
+				i, pce_dev->ce_bam_info.dest_pipe_index[i]);
+	}
+
 	return 0;
 };
 

+ 5 - 0
crypto-qti/qcedev.c

@@ -26,6 +26,7 @@
 #include "linux/qcedev.h"
 #include <linux/interconnect.h>
 #include <linux/delay.h>
+#include <linux/version.h>
 
 #include <crypto/hash.h>
 #include "qcedevi.h"
@@ -2519,7 +2520,11 @@ static int qcedev_probe_device(struct platform_device *pdev)
 		return rc;
 	}
 
+#if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE)
+	driver_class = class_create(QCEDEV_DEV);
+#else
 	driver_class = class_create(THIS_MODULE, QCEDEV_DEV);
+#endif
 	if (IS_ERR(driver_class)) {
 		rc = -ENOMEM;
 		pr_err("class_create failed %d\n", rc);

+ 49 - 8
crypto-qti/qcrypto.c

@@ -28,6 +28,7 @@
 #include <linux/cache.h>
 #include <linux/interconnect.h>
 #include <linux/hardirq.h>
+#include <linux/version.h>
 #include "qcrypto.h"
 #include "qcom_crypto_device.h"
 
@@ -912,9 +913,12 @@ static void _qcrypto_ahash_cra_exit(struct crypto_tfm *tfm)
 	}
 }
 
-
+#if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE)
+static void _crypto_sha_hmac_ahash_req_complete(void *data, int err);
+#else
 static void _crypto_sha_hmac_ahash_req_complete(
-	struct crypto_async_request *req, int err);
+	    struct crypto_async_request *req, int err);
+#endif
 
 static int _qcrypto_ahash_hmac_cra_init(struct crypto_tfm *tfm)
 {
@@ -3134,14 +3138,22 @@ static void _qcrypto_aead_aes_192_fb_a_cb(struct qcrypto_cipher_req_ctx *rctx,
 	areq->complete(areq, res);
 }
 
+#if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE)
+static void _aead_aes_fb_stage2_ahash_complete(void *data, int err)
+#else
 static void _aead_aes_fb_stage2_ahash_complete(
-				struct crypto_async_request *base, int err)
+		struct crypto_async_request *base, int err)
+#endif
 {
 	struct qcrypto_cipher_req_ctx *rctx;
 	struct aead_request *req;
 	struct qcrypto_cipher_ctx *ctx;
 
+#if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE)
+	rctx = data;
+#else
 	rctx = base->data;
+#endif
 	req = rctx->aead_req;
 	ctx = crypto_tfm_ctx(req->base.tfm);
 	/* copy icv */
@@ -3153,7 +3165,6 @@ static void _aead_aes_fb_stage2_ahash_complete(
 	_qcrypto_aead_aes_192_fb_a_cb(rctx, err);
 }
 
-
 static int _start_aead_aes_fb_stage2_hmac(struct qcrypto_cipher_req_ctx *rctx)
 {
 	struct ahash_request *ahash_req;
@@ -3165,12 +3176,20 @@ static int _start_aead_aes_fb_stage2_hmac(struct qcrypto_cipher_req_ctx *rctx)
 	return crypto_ahash_digest(ahash_req);
 }
 
+#if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE)
+static void _aead_aes_fb_stage2_decrypt_complete(void *data, int err)
+#else
 static void _aead_aes_fb_stage2_decrypt_complete(
-			struct crypto_async_request *base, int err)
+		struct crypto_async_request *base, int err)
+#endif
 {
 	struct qcrypto_cipher_req_ctx *rctx;
 
+#if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE)
+	rctx = data;
+#else
 	rctx = base->data;
+#endif
 	_qcrypto_aead_aes_192_fb_a_cb(rctx, err);
 }
 
@@ -3185,14 +3204,22 @@ static int _start_aead_aes_fb_stage2_decrypt(
 	return crypto_skcipher_decrypt(aes_req);
 }
 
+#if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE)
+static void _aead_aes_fb_stage1_ahash_complete(void *data, int err)
+#else
 static void _aead_aes_fb_stage1_ahash_complete(
-				struct crypto_async_request *base, int err)
+		struct crypto_async_request *base, int err)
+#endif
 {
 	struct qcrypto_cipher_req_ctx *rctx;
 	struct aead_request *req;
 	struct qcrypto_cipher_ctx *ctx;
 
+#if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE)
+	rctx = data;
+#else
 	rctx = base->data;
+#endif
 	req = rctx->aead_req;
 	ctx = crypto_tfm_ctx(req->base.tfm);
 
@@ -3222,14 +3249,22 @@ ret:
 
 }
 
+#if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE)
+static void _aead_aes_fb_stage1_encrypt_complete(void *data, int err)
+#else
 static void _aead_aes_fb_stage1_encrypt_complete(
-				struct crypto_async_request *base, int err)
+		struct crypto_async_request *base, int err)
+#endif
 {
 	struct qcrypto_cipher_req_ctx *rctx;
 	struct aead_request *req;
 	struct qcrypto_cipher_ctx *ctx;
 
+#if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE)
+	rctx = data;
+#else
 	rctx = base->data;
+#endif
 	req = rctx->aead_req;
 	ctx = crypto_tfm_ctx(req->base.tfm);
 
@@ -3926,10 +3961,16 @@ static int _sha256_digest(struct ahash_request *req)
 	return _sha_digest(req);
 }
 
+#if (KERNEL_VERSION(6, 2, 0) <= LINUX_VERSION_CODE)
+static void _crypto_sha_hmac_ahash_req_complete(void *data, int err)
+{
+	struct completion *ahash_req_complete = data;
+#else
 static void _crypto_sha_hmac_ahash_req_complete(
-	struct crypto_async_request *req, int err)
+		struct crypto_async_request *req, int err)
 {
 	struct completion *ahash_req_complete = req->data;
+#endif
 
 	if (err == -EINPROGRESS)
 		return;

+ 0 - 1
hdcp/hdcp_main.h

@@ -14,7 +14,6 @@
 #include <linux/fs.h>
 #include <linux/hdcp_qseecom.h>
 #include <linux/io.h>
-#include <linux/ion.h>
 #include <linux/kernel.h>
 #include <linux/kthread.h>
 #include <linux/list.h>

+ 5 - 0
qrng/msm_rng.c

@@ -24,6 +24,7 @@
 #include <crypto/internal/rng.h>
 #include <linux/interconnect.h>
 #include <linux/sched/signal.h>
+#include <linux/version.h>
 
 #define DRIVER_NAME "msm_rng"
 
@@ -325,7 +326,11 @@ static int msm_rng_probe(struct platform_device *pdev)
 		goto err_reg_chrdev;
 	}
 
+#if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE)
+	msm_rng_class = class_create("msm-rng");
+#else
 	msm_rng_class = class_create(THIS_MODULE, "msm-rng");
+#endif
 	if (IS_ERR(msm_rng_class)) {
 		pr_err("class_create failed\n");
 		error = PTR_ERR(msm_rng_class);

+ 20 - 5
qseecom/qseecom.c

@@ -1268,12 +1268,11 @@ static int qseecom_dmabuf_cache_operations(struct dma_buf *dmabuf,
 
 	switch (cache_op) {
 	case QSEECOM_CACHE_CLEAN: /* Doing CLEAN and INVALIDATE */
-		dma_buf_begin_cpu_access(dmabuf, DMA_BIDIRECTIONAL);
 		dma_buf_end_cpu_access(dmabuf, DMA_BIDIRECTIONAL);
+		dma_buf_begin_cpu_access(dmabuf, DMA_BIDIRECTIONAL);
 		break;
 	case QSEECOM_CACHE_INVALIDATE:
-		dma_buf_begin_cpu_access(dmabuf, DMA_TO_DEVICE);
-		dma_buf_end_cpu_access(dmabuf, DMA_FROM_DEVICE);
+		dma_buf_begin_cpu_access(dmabuf, DMA_FROM_DEVICE);
 		break;
 	default:
 		pr_err("cache (%d) operation not supported\n",
@@ -1443,10 +1442,10 @@ static int qseecom_vaddr_map(int ion_fd,
 
 	*paddr = sg_dma_address(new_sgt->sgl);
 	*sb_length = new_sgt->sgl->length;
-
+	//Invalidate the Buffer
 	dma_buf_begin_cpu_access(new_dma_buf, DMA_BIDIRECTIONAL);
 	ret = dma_buf_vmap(new_dma_buf, &new_dma_buf_map);
-    new_va = ret ? NULL : new_dma_buf_map.vaddr;
+	new_va = ret ? NULL : new_dma_buf_map.vaddr;
 	if (!new_va) {
 		pr_err("dma_buf_vmap failed\n");
 		ret = -ENOMEM;
@@ -1459,7 +1458,9 @@ static int qseecom_vaddr_map(int ion_fd,
 	return ret;
 
 err_unmap:
+	//Flush the buffer (i.e. Clean and invalidate)
 	dma_buf_end_cpu_access(new_dma_buf, DMA_BIDIRECTIONAL);
+	dma_buf_begin_cpu_access(new_dma_buf, DMA_BIDIRECTIONAL);
 	qseecom_dmabuf_unmap(new_sgt, new_attach, new_dma_buf);
 	MAKE_NULL(*sgt, *attach, *dmabuf);
 err:
@@ -7639,6 +7640,16 @@ long qseecom_ioctl(struct file *file,
 	struct qseecom_dev_handle *data = file->private_data;
 	void __user *argp = (void __user *) arg;
 	bool perf_enabled = false;
+
+	if (atomic_read(&qseecom.qseecom_state) != QSEECOM_STATE_READY) {
+		pr_err("Not allowed to be called in %d state\n",
+				atomic_read(&qseecom.qseecom_state));
+		/* since the state is not ready returning device not configured yet
+		 * i.e operation can't be performed on device yet.
+		 */
+		return -ENXIO;
+	}
+
 	if (!data) {
 		pr_err("Invalid/uninitialized device handle\n");
 		return -EINVAL;
@@ -9336,7 +9347,11 @@ static int qseecom_init_dev(struct platform_device *pdev)
 		pr_err("alloc_chrdev_region failed %d\n", rc);
 		return rc;
 	}
+#if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE)
+	qseecom.driver_class = class_create(QSEECOM_DEV);
+#else
 	qseecom.driver_class = class_create(THIS_MODULE, QSEECOM_DEV);
+#endif
 	if (IS_ERR(qseecom.driver_class)) {
 		rc = PTR_ERR(qseecom.driver_class);
 		pr_err("class_create failed %x\n", rc);

+ 9 - 0
smcinvoke/smcinvoke.c

@@ -25,7 +25,12 @@
 #include <linux/mem-buf.h>
 #include <linux/of_platform.h>
 #include <linux/firmware.h>
+#include <linux/version.h>
+#if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE)
+#include <linux/firmware/qcom/qcom_scm.h>
+#else
 #include <linux/qcom_scm.h>
+#endif
 #include <linux/freezer.h>
 #include <linux/ratelimit.h>
 #include <asm/cacheflush.h>
@@ -3170,7 +3175,11 @@ static int smcinvoke_probe(struct platform_device *pdev)
 		pr_err("chrdev_region failed %d for %s\n", rc, SMCINVOKE_DEV);
 		goto exit_destroy_wkthread;
 	}
+#if  (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE)
+	driver_class = class_create(SMCINVOKE_DEV);
+#else
 	driver_class = class_create(THIS_MODULE, SMCINVOKE_DEV);
+#endif
 	if (IS_ERR(driver_class)) {
 		rc = -ENOMEM;
 		pr_err("class_create failed %d\n", rc);

+ 5 - 0
smmu-proxy/qti-smmu-proxy-common.c

@@ -4,6 +4,7 @@
  */
 
 #include <linux/cdev.h>
+#include <linux/version.h>
 #include "qti-smmu-proxy-common.h"
 #include "smcinvoke_object.h"
 #include "../include/linux/ITrustedCameraDriver.h"
@@ -75,7 +76,11 @@ int smmu_proxy_create_dev(const struct file_operations *fops)
 	if (ret < 0)
 		return ret;
 
+#if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE)
+	smmu_proxy_class = class_create("qti-smmu-proxy");
+#else
 	smmu_proxy_class = class_create(THIS_MODULE, "qti-smmu-proxy");
+#endif
 	if (IS_ERR(smmu_proxy_class)) {
 		ret = PTR_ERR(smmu_proxy_class);
 		goto err_class_create;

+ 1 - 1
smmu-proxy/qti-smmu-proxy-pvm.c

@@ -259,7 +259,7 @@ static int sender_probe_handler(struct platform_device *pdev)
 	msgq_hdl = gh_msgq_register(GH_MSGQ_LABEL_SMMU_PROXY);
 	if (IS_ERR(msgq_hdl)) {
 		ret = PTR_ERR(msgq_hdl);
-		pr_err("%s: Queue registration failed rc: %d!\n", __func__, PTR_ERR(msgq_hdl));
+		pr_err("%s: Queue registration failed rc: %ld!\n", __func__, PTR_ERR(msgq_hdl));
 		return ret;
 	}
 

+ 5 - 1
tz_log/tz_log.c

@@ -20,10 +20,14 @@
 #include <linux/uaccess.h>
 #include <linux/of.h>
 #include <linux/dma-buf.h>
+#include <linux/version.h>
+#if (KERNEL_VERSION(6, 3, 0) <= LINUX_VERSION_CODE)
+#include <linux/firmware/qcom/qcom_scm.h>
+#else
 #include <linux/qcom_scm.h>
+#endif
 #include <linux/qtee_shmbridge.h>
 #include <linux/proc_fs.h>
-#include <linux/version.h>
 #if IS_ENABLED(CONFIG_MSM_TMECOM_QMP)
 #include <linux/tmelog.h>
 #endif