From 2c9a94941408fa8f2740b384ac9e2f9c319918ec Mon Sep 17 00:00:00 2001 From: Xiangyu Xu Date: Sat, 7 Dec 2024 22:56:38 +0800 Subject: [PATCH 1/8] anolis: crypto: ccp: optimize the performance of CCP SM4 multiprocessing. ANBZ: #6244 add independent req queues for each ccp Signed-off-by: Xiangyu Xu Signed-off-by: yangdepei --- drivers/crypto/ccp/ccp-crypto-main.c | 67 +++++++++++++++++----------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/drivers/crypto/ccp/ccp-crypto-main.c b/drivers/crypto/ccp/ccp-crypto-main.c index c664950cea52..128e8526a001 100644 --- a/drivers/crypto/ccp/ccp-crypto-main.c +++ b/drivers/crypto/ccp/ccp-crypto-main.c @@ -62,8 +62,13 @@ struct ccp_crypto_queue { #define CCP_CRYPTO_MAX_QLEN 100 -static struct ccp_crypto_queue req_queue; -static spinlock_t req_queue_lock; +#define MAX_REQ_QUEUE_NUM 64 +struct ccp_req_queue { + struct ccp_crypto_queue req_queue; + spinlock_t req_queue_lock; +}; + +static struct ccp_req_queue req_queue_arr[MAX_REQ_QUEUE_NUM] = {0}; struct ccp_crypto_cmd { struct list_head entry; @@ -80,6 +85,7 @@ struct ccp_crypto_cmd { /* Used for held command processing to determine state */ int ret; + int req_queue_idx; }; struct ccp_crypto_cpu { @@ -102,16 +108,17 @@ static struct ccp_crypto_cmd *ccp_crypto_cmd_complete( { struct ccp_crypto_cmd *held = NULL, *tmp; unsigned long flags; + struct ccp_req_queue *req_queue_data = &req_queue_arr[crypto_cmd->req_queue_idx]; *backlog = NULL; - spin_lock_irqsave(&req_queue_lock, flags); + spin_lock_irqsave(&req_queue_data->req_queue_lock, flags); /* Held cmds will be after the current cmd in the queue so start * searching for a cmd with a matching tfm for submission. */ tmp = crypto_cmd; - list_for_each_entry_continue(tmp, &req_queue.cmds, entry) { + list_for_each_entry_continue(tmp, &req_queue_data->req_queue.cmds, entry) { if (crypto_cmd->tfm != tmp->tfm) continue; held = tmp; @@ -122,25 +129,25 @@ static struct ccp_crypto_cmd *ccp_crypto_cmd_complete( * Because cmds can be executed from any point in the cmd list * special precautions have to be taken when handling the backlog. */ - if (req_queue.backlog != &req_queue.cmds) { + if (req_queue_data->req_queue.backlog != &req_queue_data->req_queue.cmds) { /* Skip over this cmd if it is the next backlog cmd */ - if (req_queue.backlog == &crypto_cmd->entry) - req_queue.backlog = crypto_cmd->entry.next; + if (req_queue_data->req_queue.backlog == &crypto_cmd->entry) + req_queue_data->req_queue.backlog = crypto_cmd->entry.next; - *backlog = container_of(req_queue.backlog, + *backlog = container_of(req_queue_data->req_queue.backlog, struct ccp_crypto_cmd, entry); - req_queue.backlog = req_queue.backlog->next; + req_queue_data->req_queue.backlog = req_queue_data->req_queue.backlog->next; /* Skip over this cmd if it is now the next backlog cmd */ - if (req_queue.backlog == &crypto_cmd->entry) - req_queue.backlog = crypto_cmd->entry.next; + if (req_queue_data->req_queue.backlog == &crypto_cmd->entry) + req_queue_data->req_queue.backlog = crypto_cmd->entry.next; } /* Remove the cmd entry from the list of cmds */ - req_queue.cmd_count--; + req_queue_data->req_queue.cmd_count--; list_del(&crypto_cmd->entry); - spin_unlock_irqrestore(&req_queue_lock, flags); + spin_unlock_irqrestore(&req_queue_data->req_queue_lock, flags); return held; } @@ -217,12 +224,15 @@ static int ccp_crypto_enqueue_cmd(struct ccp_crypto_cmd *crypto_cmd) struct ccp_crypto_cmd *active = NULL, *tmp; unsigned long flags; bool free_cmd = true; + int req_queue_idx = current->pid % MAX_REQ_QUEUE_NUM; + struct ccp_req_queue *req_queue_data = &req_queue_arr[req_queue_idx]; int ret; - spin_lock_irqsave(&req_queue_lock, flags); + crypto_cmd->req_queue_idx = req_queue_idx; + spin_lock_irqsave(&req_queue_data->req_queue_lock, flags); /* Check if the cmd can/should be queued */ - if (req_queue.cmd_count >= CCP_CRYPTO_MAX_QLEN) { + if (req_queue_data->req_queue.cmd_count >= CCP_CRYPTO_MAX_QLEN) { if (!(crypto_cmd->cmd->flags & CCP_CMD_MAY_BACKLOG)) { ret = -ENOSPC; goto e_lock; @@ -233,7 +243,7 @@ static int ccp_crypto_enqueue_cmd(struct ccp_crypto_cmd *crypto_cmd) * with the same tfm in the list then the current cmd cannot * be submitted to the CCP yet. */ - list_for_each_entry(tmp, &req_queue.cmds, entry) { + list_for_each_entry(tmp, &req_queue_data->req_queue.cmds, entry) { if (crypto_cmd->tfm != tmp->tfm) continue; active = tmp; @@ -247,20 +257,20 @@ static int ccp_crypto_enqueue_cmd(struct ccp_crypto_cmd *crypto_cmd) goto e_lock; /* Error, don't queue it */ } - if (req_queue.cmd_count >= CCP_CRYPTO_MAX_QLEN) { + if (req_queue_data->req_queue.cmd_count >= CCP_CRYPTO_MAX_QLEN) { ret = -EBUSY; - if (req_queue.backlog == &req_queue.cmds) - req_queue.backlog = &crypto_cmd->entry; + if (req_queue_data->req_queue.backlog == &req_queue_data->req_queue.cmds) + req_queue_data->req_queue.backlog = &crypto_cmd->entry; } crypto_cmd->ret = ret; - req_queue.cmd_count++; - list_add_tail(&crypto_cmd->entry, &req_queue.cmds); + req_queue_data->req_queue.cmd_count++; + list_add_tail(&crypto_cmd->entry, &req_queue_data->req_queue.cmds); free_cmd = false; e_lock: - spin_unlock_irqrestore(&req_queue_lock, flags); + spin_unlock_irqrestore(&req_queue_data->req_queue_lock, flags); if (free_cmd) kfree(crypto_cmd); @@ -425,6 +435,8 @@ static void ccp_unregister_algs(void) static int ccp_crypto_init(void) { int ret; + int i; + struct ccp_req_queue *req_queue_data = NULL; ret = ccp_present(); if (ret) { @@ -432,10 +444,13 @@ static int ccp_crypto_init(void) return ret; } - spin_lock_init(&req_queue_lock); - INIT_LIST_HEAD(&req_queue.cmds); - req_queue.backlog = &req_queue.cmds; - req_queue.cmd_count = 0; + for (i = 0; i < MAX_REQ_QUEUE_NUM; i++) { + req_queue_data = &req_queue_arr[i]; + spin_lock_init(&req_queue_data->req_queue_lock); + INIT_LIST_HEAD(&req_queue_data->req_queue.cmds); + req_queue_data->req_queue.backlog = &req_queue_data->req_queue.cmds; + req_queue_data->req_queue.cmd_count = 0; + } ret = ccp_register_algs(); if (ret) -- Gitee From 6f81ba2eec1737295a21386be830cd06884e60c2 Mon Sep 17 00:00:00 2001 From: Yabin Li Date: Fri, 21 Jun 2024 10:52:09 +0800 Subject: [PATCH 2/8] anolis: hct: adding a file node to mark used MDEV device ANBZ: #6244 mark hct-mdev device usage status Signed-off-by: Yabin Li Signed-off-by: yangdepei --- drivers/crypto/ccp/hct.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/crypto/ccp/hct.c b/drivers/crypto/ccp/hct.c index 4f5c7d73da48..2b59c2d059cc 100644 --- a/drivers/crypto/ccp/hct.c +++ b/drivers/crypto/ccp/hct.c @@ -239,6 +239,7 @@ struct mdev_state { struct list_head next; struct vfio_device_info dev_info; unsigned long ref; + unsigned long used; struct eventfd_ctx *trigger[MCCP_DEV_QUEUE_MAX]; u8 efd_start; u8 efd_count; @@ -991,6 +992,7 @@ static int hct_open_device(struct mdev_device *mdev) hct_data.mdev_ref++; mutex_unlock(&hct_data.lock); + mdev_state->used = 1; return 0; } @@ -1005,6 +1007,7 @@ static void hct_close_device(struct mdev_device *mdev) for (i = 0; i < mdev_state->efd_count; i++) eventfd_ctx_put(mdev_state->trigger[i]); mdev_state->efd_count = 0; + mdev_state->used = 0; mutex_lock(&hct_data.lock); hct_data.mdev_ref--; @@ -1120,14 +1123,35 @@ static ssize_t idx_show(struct device *dev, struct device_attribute *attr, return sprintf(buf, "\n"); } +static ssize_t use_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct mdev_state *mdev_state; + ssize_t size; + + if (mdev_from_dev(dev)) { + mdev_state = mdev_get_drvdata(mdev_from_dev(dev)); + if (!mdev_state) + goto exit; + + size = sprintf(buf, "%lu", mdev_state->used); + return size; + } + +exit: + return sprintf(buf, "\n"); +} + static DEVICE_ATTR_RO(address); static DEVICE_ATTR_RO(id); static DEVICE_ATTR_RO(idx); +static DEVICE_ATTR_RO(use); static struct attribute *mdev_dev_attrs[] = { &dev_attr_address.attr, &dev_attr_id.attr, &dev_attr_idx.attr, + &dev_attr_use.attr, NULL, }; -- Gitee From 7f616d1f2d3d1bf91d9054fc23e115f68471c00e Mon Sep 17 00:00:00 2001 From: Yabin Li Date: Fri, 21 Jun 2024 11:00:27 +0800 Subject: [PATCH 3/8] anolis: hct: sharing CCP resources between host and virtual machines. ANBZ: #6244 support host and guest use CCP at same time Signed-off-by: Yabin Li Signed-off-by: yangdepei --- drivers/crypto/ccp/hct.c | 91 ++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 36 deletions(-) diff --git a/drivers/crypto/ccp/hct.c b/drivers/crypto/ccp/hct.c index 2b59c2d059cc..dec7229c2558 100644 --- a/drivers/crypto/ccp/hct.c +++ b/drivers/crypto/ccp/hct.c @@ -40,12 +40,13 @@ * and performance optimization in virtual machines (enable caching). * 0.4 -- support compiling hct.ko when mdev module is disabled. * 0.5 -- change the maximum number of supported ccps from 16 to 48. + * 0.6 -- sharing CCP resources between host and virtual machines. */ #undef pr_fmt #define pr_fmt(fmt) "hct: " fmt -#define VERSION_STRING "0.5" +#define VERSION_STRING "0.6" #define DRIVER_AUTHOR "HYGON Corporation" #define VERSION_SIZE 16 @@ -90,6 +91,7 @@ #define MCCP_INSTANCE_OFFSET 8 #define MCCP_INSTANCE_MASK (~((1u << MCCP_INSTANCE_OFFSET) - 1)) #define MCCP_PASID_SIZE (1 << 8) +#define MCCP_PASID_MASK_BIT 0x03 #define MCCP_IOVA_MAX_SLOT 1024 #define MCCP_DEV_MAX 48 #define MCCP_DEV_QUEUE_MAX 8 @@ -134,13 +136,26 @@ struct hct_shared_cfg { unsigned int ccp_state[MCCP_DEV_MAX]; } __aligned(PAGE_SIZE); +struct hct_shr_pg_cfg { + unsigned long mdev_bitmap[BITS_TO_LONGS(MCCP_INSTANCE_MAX)]; + unsigned int ccp_queue_state[MCCP_DEV_QUEUE]; + unsigned int userid[MCCP_DEV_QUEUE]; + unsigned int vq_work_mode[MCCP_DEV_QUEUE]; + unsigned int dev_lock_state; + unsigned int dev_init_state; + unsigned int vq_sync_count; + unsigned int vq_async_count; + unsigned int numa_node; +} ____cacheline_aligned; + struct hct_dev_ctrl { unsigned char op; unsigned char rsvd[3]; union { unsigned char version[VERSION_SIZE]; - unsigned int id; unsigned long sme_mask; + unsigned int id; + unsigned int pasid; struct { unsigned long vaddr; unsigned long iova; @@ -206,6 +221,7 @@ static struct hct_data { unsigned long dma_share_ref; unsigned long mdev_ref; unsigned long ids[BITS_TO_LONGS(MCCP_INSTANCE_MAX)]; + unsigned long pasids[BITS_TO_LONGS(MCCP_PASID_SIZE)]; } hct_data; static struct hct_share_cfg { @@ -1249,6 +1265,7 @@ struct hct_private { struct list_head head; struct mutex lock; unsigned int id; + unsigned int pasid; }; static int hct_share_open(struct inode *inode, struct file *file) @@ -1746,7 +1763,8 @@ static void hct_iommu_unmap_all(struct hct_private *private) static struct page *hct_get_page(pgoff_t page_idx) { - u64 *node; + struct hct_shr_pg_cfg *shr_cfg = NULL; + int numa_node; mutex_lock(&hct_share.lock); if (!hct_share.pages[page_idx]) { @@ -1759,8 +1777,12 @@ static struct page *hct_get_page(pgoff_t page_idx) } get_page(hct_share.pages[page_idx]); - node = page_to_virt(hct_share.pages[page_idx]) + PAGE_SIZE - 8; - *node = hct_data.iommu[page_idx].pdev->dev.numa_node; + numa_node = hct_data.iommu[page_idx].pdev->dev.numa_node; + if (numa_node < 0) + numa_node = 0; + + shr_cfg = (void *)page_to_virt(hct_share.pages[page_idx]); + shr_cfg->numa_node = numa_node; mutex_unlock(&hct_share.lock); return hct_share.pages[page_idx]; @@ -1779,22 +1801,24 @@ static void hct_put_pages(void) } } -/* Clear status information when exiting abnormally. */ -static void hct_clear_shared_lock_memory(unsigned int gid) +static void hct_shared_page_memory_clear(unsigned int gid) { - int *base; - int *queue_lck; - int dev_idx; - int queue_idx; + struct hct_shr_pg_cfg *shr_cfg = NULL; + int i, q; - for (dev_idx = 0; dev_idx < MCCP_DEV_MAX && - hct_share.pages[dev_idx]; dev_idx++) { - base = (int *)page_to_virt(hct_share.pages[dev_idx]); - for (queue_idx = 0; queue_idx < MCCP_DEV_QUEUE; queue_idx++) { - queue_lck = base + queue_idx; - if (*queue_lck == gid) - *queue_lck = 0; /* vq userid will be changed. */ - } + for (i = 0; i < MCCP_DEV_MAX; i++) { + if (!hct_share.pages[i]) + continue; + + shr_cfg = (void *)page_to_virt(hct_share.pages[i]); + if ((shr_cfg->dev_init_state & MCCP_INSTANCE_MASK) == gid) + shr_cfg->dev_init_state = 0; + if (shr_cfg->dev_lock_state == gid) + shr_cfg->dev_lock_state = 0; + + for (q = 0; q < MCCP_DEV_QUEUE; q++) + if (shr_cfg->ccp_queue_state[q] == gid) + shr_cfg->ccp_queue_state[q] = MCCP_QUEUE_NEED_INIT; } } @@ -1843,14 +1867,14 @@ static long hct_share_ioctl(struct file *file, unsigned int ioctl, unsigned long ret = 0; break; case MCCP_SHARE_OP_GET_PASID: - /* The different virtual machines is distinguished through pasid. */ - pasid = private->id >> MCCP_INSTANCE_OFFSET; + pasid = find_first_zero_bit(hct_data.pasids, MCCP_PASID_SIZE); if (pasid >= MCCP_PASID_SIZE) { ret = -EINVAL; break; } - - dev_ctrl.id = pasid; + private->pasid = pasid; + dev_ctrl.pasid = pasid; + bitmap_set(hct_data.pasids, pasid, 1); if (copy_to_user((void __user *)arg, &dev_ctrl, sizeof(dev_ctrl))) ret = -EINVAL; break; @@ -1882,32 +1906,23 @@ static int hct_share_close(struct inode *inode, struct file *file) if (private->id == cfg->ccps_ref_lock) cfg->ccps_ref_lock = 0; - for (i = 0; i < MCCP_DEV_MAX; i++) - if (private->id == (MCCP_INSTANCE_MASK & cfg->ccp_state[i])) - cfg->ccp_state[i] = 0; - - for (i = 0; i < MCCP_QUEUES_MAX; i++) - if (private->id == cfg->ccp_queue_state[i]) - cfg->ccp_queue_state[i] = MCCP_QUEUE_NEED_INIT; - for (i = 0; i < MCCP_IOVA_MAX_SLOT; i++) if (private->id == cfg->iova_slot[i]) cfg->iova_slot[i] = 0; } - hct_clear_shared_lock_memory(private->id); + hct_shared_page_memory_clear(private->id); hct_share.ref--; - if (!hct_share.ref) { + if (!hct_share.ref) hct_put_pages(); - if (hct_share.vaddr) - memset(hct_share.vaddr, 0x00, hct_share.size); - } mutex_unlock(&hct_share.lock); mutex_lock(&hct_data.lock); if (--id < MCCP_INSTANCE_MAX) bitmap_clear(hct_data.ids, id, 1); + if (private->pasid) + bitmap_clear(hct_data.pasids, private->pasid, 1); mutex_unlock(&hct_data.lock); mutex_lock(&private->lock); @@ -2018,6 +2033,10 @@ static int hct_share_init(void) hct_data.prot = IOMMU_READ | IOMMU_WRITE; } + /* When the pasid value is 0 or 1, the address space overlaps with the host, + * so the pasid needs to start from 2. + */ + hct_data.pasids[0] |= MCCP_PASID_MASK_BIT; return ret; } -- Gitee From 7586e89139f42426dfac344ee627f082b8c0388f Mon Sep 17 00:00:00 2001 From: Yabin Li Date: Sat, 13 Jul 2024 16:35:01 +0800 Subject: [PATCH 4/8] anolis: hct: update hct_shr_pg_cfg sync with SDK ANBZ: #6244 1. replacing random values with a combination of pasid and time values as the userid of VQ. 2. SDK compatible with hct.ko modules in versions 0.5 Signed-off-by: Yabin Li Signed-off-by: yangdepei --- drivers/crypto/ccp/hct.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/ccp/hct.c b/drivers/crypto/ccp/hct.c index dec7229c2558..ab4aac5ca5a5 100644 --- a/drivers/crypto/ccp/hct.c +++ b/drivers/crypto/ccp/hct.c @@ -137,9 +137,9 @@ struct hct_shared_cfg { } __aligned(PAGE_SIZE); struct hct_shr_pg_cfg { - unsigned long mdev_bitmap[BITS_TO_LONGS(MCCP_INSTANCE_MAX)]; unsigned int ccp_queue_state[MCCP_DEV_QUEUE]; - unsigned int userid[MCCP_DEV_QUEUE]; + unsigned long mdev_bitmap[BITS_TO_LONGS(MCCP_INSTANCE_MAX)]; + unsigned long userid[MCCP_DEV_QUEUE]; unsigned int vq_work_mode[MCCP_DEV_QUEUE]; unsigned int dev_lock_state; unsigned int dev_init_state; -- Gitee From db40ce1d5013d94994d40a6870b4f687d71a5773 Mon Sep 17 00:00:00 2001 From: Yabin Li Date: Mon, 12 Aug 2024 14:46:21 +0800 Subject: [PATCH 5/8] anolis: hct: fix wrong page map in hct_cdev_vma_fault ANBZ: #6244 when executing the madvise function, the starting address vm_start of the pre allocated vma changes. it will cause hct_share node to obtain wrong pages. Signed-off-by: Yabin Li Signed-off-by: yangdepei --- drivers/crypto/ccp/hct.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/ccp/hct.c b/drivers/crypto/ccp/hct.c index ab4aac5ca5a5..8b2884c1c07b 100644 --- a/drivers/crypto/ccp/hct.c +++ b/drivers/crypto/ccp/hct.c @@ -1264,6 +1264,7 @@ static const struct mdev_parent_ops hct_mdev_fops = { struct hct_private { struct list_head head; struct mutex lock; + unsigned long vm_start; unsigned int id; unsigned int pasid; }; @@ -1935,8 +1936,9 @@ static int hct_share_close(struct inode *inode, struct file *file) static vm_fault_t hct_cdev_vma_fault(struct vm_fault *vmf) { - struct vm_area_struct *vma = vmf->vma; - pgoff_t page_idx = (vmf->address - vma->vm_start) >> PAGE_SHIFT; + struct file *file = vmf->vma->vm_file; + struct hct_private *private = file->private_data; + pgoff_t page_idx = (vmf->address - private->vm_start) >> PAGE_SHIFT; if (page_idx >= hct_share.pagecount) return VM_FAULT_SIGBUS; @@ -1954,6 +1956,7 @@ static const struct vm_operations_struct hct_cdev_vm_ops = { static int hct_share_mmap(struct file *file, struct vm_area_struct *vma) { + struct hct_private *private = file->private_data; unsigned long len; int ret = 0; @@ -1965,6 +1968,7 @@ static int hct_share_mmap(struct file *file, struct vm_area_struct *vma) * and will follow the pagefault process. */ vma->vm_ops = &hct_cdev_vm_ops; + private->vm_start = vma->vm_start; goto exit; } -- Gitee From 5b30c0b6e71142f49f510d8c3c0d1c9d7ec4a9db Mon Sep 17 00:00:00 2001 From: Yabin Li Date: Fri, 13 Sep 2024 14:22:10 +0800 Subject: [PATCH 6/8] anolis: hct: add write operation support to the node file use of MDEV devices. ANBZ: #6244 support write status for mdev deivces Signed-off-by: Yabin Li Signed-off-by: yangdepei --- drivers/crypto/ccp/hct.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/ccp/hct.c b/drivers/crypto/ccp/hct.c index 8b2884c1c07b..9aaefedfc548 100644 --- a/drivers/crypto/ccp/hct.c +++ b/drivers/crypto/ccp/hct.c @@ -1008,7 +1008,6 @@ static int hct_open_device(struct mdev_device *mdev) hct_data.mdev_ref++; mutex_unlock(&hct_data.lock); - mdev_state->used = 1; return 0; } @@ -1023,7 +1022,6 @@ static void hct_close_device(struct mdev_device *mdev) for (i = 0; i < mdev_state->efd_count; i++) eventfd_ctx_put(mdev_state->trigger[i]); mdev_state->efd_count = 0; - mdev_state->used = 0; mutex_lock(&hct_data.lock); hct_data.mdev_ref--; @@ -1147,8 +1145,10 @@ static ssize_t use_show(struct device *dev, struct device_attribute *attr, if (mdev_from_dev(dev)) { mdev_state = mdev_get_drvdata(mdev_from_dev(dev)); - if (!mdev_state) + if (!mdev_state) { + pr_err("mdev_state is NULL"); goto exit; + } size = sprintf(buf, "%lu", mdev_state->used); return size; @@ -1158,10 +1158,41 @@ static ssize_t use_show(struct device *dev, struct device_attribute *attr, return sprintf(buf, "\n"); } +static ssize_t use_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct mdev_state *mdev_state; + + if (mdev_from_dev(dev)) { + mdev_state = mdev_get_drvdata(mdev_from_dev(dev)); + if (!mdev_state) { + pr_err("mdev_state is NULL"); + goto exit; + } + + if (count > 2 || buf[0] == '\0' || buf[0] == '\n') { + pr_err("count:%ld buf[0]:0x%x, invalid.\n", count, buf[0]); + goto exit; + } + + if (buf[0] == '0') + mdev_state->used = 0; + else if (buf[0] == '1') + mdev_state->used = 1; + else + goto exit; + + return count; + } + +exit: + return -1; +} + static DEVICE_ATTR_RO(address); static DEVICE_ATTR_RO(id); static DEVICE_ATTR_RO(idx); -static DEVICE_ATTR_RO(use); +static DEVICE_ATTR_RW(use); static struct attribute *mdev_dev_attrs[] = { &dev_attr_address.attr, -- Gitee From a9b76929d0e0a0cc95e3c34011fd50c72dabc02d Mon Sep 17 00:00:00 2001 From: Xiangyu Xu Date: Wed, 6 Nov 2024 14:54:30 +0800 Subject: [PATCH 7/8] anolis: hct: remove the unused variables from hct shared structure. ANBZ: #6244 Signed-off-by: Xiangyu Xu Signed-off-by: yangdepei --- drivers/crypto/ccp/hct.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/crypto/ccp/hct.c b/drivers/crypto/ccp/hct.c index 9aaefedfc548..569847900c00 100644 --- a/drivers/crypto/ccp/hct.c +++ b/drivers/crypto/ccp/hct.c @@ -143,8 +143,6 @@ struct hct_shr_pg_cfg { unsigned int vq_work_mode[MCCP_DEV_QUEUE]; unsigned int dev_lock_state; unsigned int dev_init_state; - unsigned int vq_sync_count; - unsigned int vq_async_count; unsigned int numa_node; } ____cacheline_aligned; -- Gitee From b561b69d4c2bc68b85ece4f1b8f28c93d7d103d7 Mon Sep 17 00:00:00 2001 From: yangdepei Date: Thu, 9 Jan 2025 20:50:49 +0800 Subject: [PATCH 8/8] anolis: bugfix: crypto: ccp: remove repeated sm4-hs mode ANBZ: #6244 remove the repeated sm4-hs mode definition, otherwise, it will caused ccp-crypto module load err in the following Signed-off-by: yangdepei --- drivers/crypto/ccp/ccp-crypto-sm4-hygon.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/crypto/ccp/ccp-crypto-sm4-hygon.c b/drivers/crypto/ccp/ccp-crypto-sm4-hygon.c index 0d1c750ff118..2328a9f87218 100644 --- a/drivers/crypto/ccp/ccp-crypto-sm4-hygon.c +++ b/drivers/crypto/ccp/ccp-crypto-sm4-hygon.c @@ -205,15 +205,6 @@ static struct ccp_sm4_def sm4_algs[] = { .ivsize = 0, .alg_defaults = &ccp_sm4_defaults, }, - { - .mode = CCP_SM4_ALG_MODE_ECB_HS, - .version = CCP_VERSION(5, 0), - .name = "ecb(sm4)", - .driver_name = "ecb-sm4-hs-ccp", - .blocksize = SM4_BLOCK_SIZE, - .ivsize = 0, - .alg_defaults = &ccp_sm4_defaults, - }, { .mode = CCP_SM4_ALG_MODE_CBC, .version = CCP_VERSION(5, 0), @@ -232,15 +223,6 @@ static struct ccp_sm4_def sm4_algs[] = { .ivsize = SM4_BLOCK_SIZE, .alg_defaults = &ccp_sm4_defaults, }, - { - .mode = CCP_SM4_ALG_MODE_CBC_HS, - .version = CCP_VERSION(5, 0), - .name = "cbc(sm4)", - .driver_name = "cbc-sm4-hs-ccp", - .blocksize = SM4_BLOCK_SIZE, - .ivsize = SM4_BLOCK_SIZE, - .alg_defaults = &ccp_sm4_defaults, - }, { .mode = CCP_SM4_ALG_MODE_OFB, .version = CCP_VERSION(5, 0), -- Gitee