From a14b43980097e9e555228b653825cec9591bdd48 Mon Sep 17 00:00:00 2001 From: Manish Bhardwaj Date: Fri, 17 Mar 2023 08:41:09 +0000 Subject: [PATCH] nvidia: fix ioctl call and tsec operation Using this patch we are fixing below 2 issues:- 1. Fixes below issue of invalid ioctl call. tnvvse_crypto_dev_ioctl(): invalid ioctl code(-1073440754[0xc004980e]) 2. Fixes below crash issue once we introduced [ 50.137568] Unable to handle kernel paging request at virtual address ffffffffffffff80 l c00498[ 50.172247] Mem abort info: [ 50.172248] printk: console [ttyS2]: printing thread stopped [ 50.172773] ESR = 0x96000004 [ 50.178757] swapper pgtable: 4k pages, 48-bit VAs, pgdp=0000000081c8f000 [ 50.202663] Hardware name: p3710-0010 (DT) [ 50.203353] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 50.204464] pc : tegra_ivc_notified+0x1c/0x160 [ 50.205194] lr : tegra_ivc_notified+0x1c/0x160 [ 50.205890] sp : ffff8000136733c0 [ 50.218023] Call trace: [ 50.218425] tegra_ivc_notified+0x1c/0x160 [ 50.219088] tegra_hv_ivc_channel_notified+0x24/0x1f0 [tegra_hv] [ 50.220077] tegra_hv_vse_get_db+0x1f80/0x6680 [tegra_hv_vse_safety] [ 50.221129] tegra_hv_vse_safety_tsec_get_keyload_status+0xf4/0x37c [tegra_hv_vse_safety] [ 50.222478] tnvvse_crypto_dev_ioctl+0x23bc/0x277c [tegra_nvvse_cryptodev] Bug 4030215 Bug 4031715 Change-Id: I25be3ab0708a5238daf342dcd20e8a948ee39508 Signed-off-by: Manish Bhardwaj Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2872785 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: Kasinadha Dendukuri Reviewed-by: Sandeep Trasi Reviewed-by: Ashutosh Patel Reviewed-by: Suresh Venkatachalam GVS: Gerrit_Virtual_Submit --- drivers/crypto/tegra-hv-vse-safety.c | 1 + include/uapi/misc/tegra-nvvse-cryptodev.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/tegra-hv-vse-safety.c b/drivers/crypto/tegra-hv-vse-safety.c index 5beca1a6..ef0fd472 100644 --- a/drivers/crypto/tegra-hv-vse-safety.c +++ b/drivers/crypto/tegra-hv-vse-safety.c @@ -2647,6 +2647,7 @@ int tegra_hv_vse_safety_tsec_get_keyload_status(uint32_t node_id, uint32_t *err_ return -ENODEV; se_dev = g_virtual_se_dev[g_crypto_to_ivc_map[node_id].se_engine]; + pivck = g_crypto_to_ivc_map[node_id].ivck; ivc_req_msg = devm_kzalloc(se_dev->dev, sizeof(*ivc_req_msg), GFP_KERNEL); diff --git a/include/uapi/misc/tegra-nvvse-cryptodev.h b/include/uapi/misc/tegra-nvvse-cryptodev.h index 672ca0e0..e015cfdb 100644 --- a/include/uapi/misc/tegra-nvvse-cryptodev.h +++ b/include/uapi/misc/tegra-nvvse-cryptodev.h @@ -372,7 +372,7 @@ struct tegra_nvvse_tsec_get_keyload_status { /* NVVSE Error code */ uint32_t err_code; }; -#define NVVSE_IOCTL_CMDID_TSEC_GET_KEYLOAD_STATUS _IOW(TEGRA_NVVSE_IOC_MAGIC, \ +#define NVVSE_IOCTL_CMDID_TSEC_GET_KEYLOAD_STATUS _IOWR(TEGRA_NVVSE_IOC_MAGIC, \ TEGRA_NVVSE_CMDID_TSEC_GET_KEYLOAD_STATUS, \ struct tegra_nvvse_tsec_get_keyload_status)