|
30 | 30 | /* Size of vardata block used for some of the cca requests/replies */ |
31 | 31 | #define VARDATASIZE 4096 |
32 | 32 |
|
33 | | -struct cca_info_list_entry { |
34 | | - struct list_head list; |
35 | | - u16 cardnr; |
36 | | - u16 domain; |
37 | | - struct cca_info info; |
38 | | -}; |
39 | | - |
40 | | -/* a list with cca_info_list_entry entries */ |
41 | | -static LIST_HEAD(cca_info_list); |
42 | | -static DEFINE_SPINLOCK(cca_info_list_lock); |
43 | | - |
44 | 33 | /* |
45 | 34 | * Cprb memory pool held for urgent cases where no memory |
46 | 35 | * can be allocated via kmalloc. This pool is only used |
@@ -1633,69 +1622,11 @@ int cca_query_crypto_facility(u16 cardnr, u16 domain, |
1633 | 1622 | } |
1634 | 1623 | EXPORT_SYMBOL(cca_query_crypto_facility); |
1635 | 1624 |
|
1636 | | -static int cca_info_cache_fetch(u16 cardnr, u16 domain, struct cca_info *ci) |
1637 | | -{ |
1638 | | - int rc = -ENOENT; |
1639 | | - struct cca_info_list_entry *ptr; |
1640 | | - |
1641 | | - spin_lock_bh(&cca_info_list_lock); |
1642 | | - list_for_each_entry(ptr, &cca_info_list, list) { |
1643 | | - if (ptr->cardnr == cardnr && ptr->domain == domain) { |
1644 | | - memcpy(ci, &ptr->info, sizeof(*ci)); |
1645 | | - rc = 0; |
1646 | | - break; |
1647 | | - } |
1648 | | - } |
1649 | | - spin_unlock_bh(&cca_info_list_lock); |
1650 | | - |
1651 | | - return rc; |
1652 | | -} |
1653 | | - |
1654 | | -static void cca_info_cache_update(u16 cardnr, u16 domain, |
1655 | | - const struct cca_info *ci) |
1656 | | -{ |
1657 | | - int found = 0; |
1658 | | - struct cca_info_list_entry *ptr; |
1659 | | - |
1660 | | - spin_lock_bh(&cca_info_list_lock); |
1661 | | - list_for_each_entry(ptr, &cca_info_list, list) { |
1662 | | - if (ptr->cardnr == cardnr && |
1663 | | - ptr->domain == domain) { |
1664 | | - memcpy(&ptr->info, ci, sizeof(*ci)); |
1665 | | - found = 1; |
1666 | | - break; |
1667 | | - } |
1668 | | - } |
1669 | | - if (!found) { |
1670 | | - ptr = kmalloc(sizeof(*ptr), GFP_ATOMIC); |
1671 | | - if (!ptr) { |
1672 | | - spin_unlock_bh(&cca_info_list_lock); |
1673 | | - return; |
1674 | | - } |
1675 | | - ptr->cardnr = cardnr; |
1676 | | - ptr->domain = domain; |
1677 | | - memcpy(&ptr->info, ci, sizeof(*ci)); |
1678 | | - list_add(&ptr->list, &cca_info_list); |
1679 | | - } |
1680 | | - spin_unlock_bh(&cca_info_list_lock); |
1681 | | -} |
1682 | | - |
1683 | | -static void __exit mkvp_cache_free(void) |
1684 | | -{ |
1685 | | - struct cca_info_list_entry *ptr, *pnext; |
1686 | | - |
1687 | | - spin_lock_bh(&cca_info_list_lock); |
1688 | | - list_for_each_entry_safe(ptr, pnext, &cca_info_list, list) { |
1689 | | - list_del(&ptr->list); |
1690 | | - kfree(ptr); |
1691 | | - } |
1692 | | - spin_unlock_bh(&cca_info_list_lock); |
1693 | | -} |
1694 | | - |
1695 | 1625 | /* |
1696 | | - * Fetch cca_info values via query_crypto_facility from adapter. |
| 1626 | + * Fetch cca_info values about a CCA queue via |
| 1627 | + * query_crypto_facility from adapter. |
1697 | 1628 | */ |
1698 | | -static int fetch_cca_info(u16 cardnr, u16 domain, struct cca_info *ci) |
| 1629 | +int cca_get_info(u16 cardnr, u16 domain, struct cca_info *ci) |
1699 | 1630 | { |
1700 | 1631 | int rc, found = 0; |
1701 | 1632 | size_t rlen, vlen; |
@@ -1765,28 +1696,10 @@ static int fetch_cca_info(u16 cardnr, u16 domain, struct cca_info *ci) |
1765 | 1696 | free_page((unsigned long)pg); |
1766 | 1697 | return found == 2 ? 0 : -ENOENT; |
1767 | 1698 | } |
1768 | | - |
1769 | | -/* |
1770 | | - * Fetch cca information about a CCA queue. |
1771 | | - */ |
1772 | | -int cca_get_info(u16 card, u16 dom, struct cca_info *ci, int verify) |
1773 | | -{ |
1774 | | - int rc; |
1775 | | - |
1776 | | - rc = cca_info_cache_fetch(card, dom, ci); |
1777 | | - if (rc || verify) { |
1778 | | - rc = fetch_cca_info(card, dom, ci); |
1779 | | - if (rc == 0) |
1780 | | - cca_info_cache_update(card, dom, ci); |
1781 | | - } |
1782 | | - |
1783 | | - return rc; |
1784 | | -} |
1785 | 1699 | EXPORT_SYMBOL(cca_get_info); |
1786 | 1700 |
|
1787 | 1701 | int cca_findcard2(u32 **apqns, u32 *nr_apqns, u16 cardnr, u16 domain, |
1788 | | - int minhwtype, int mktype, u64 cur_mkvp, u64 old_mkvp, |
1789 | | - int verify) |
| 1702 | + int minhwtype, int mktype, u64 cur_mkvp, u64 old_mkvp) |
1790 | 1703 | { |
1791 | 1704 | struct zcrypt_device_status_ext *device_status; |
1792 | 1705 | u32 *_apqns = NULL, _nr_apqns = 0; |
@@ -1827,7 +1740,7 @@ int cca_findcard2(u32 **apqns, u32 *nr_apqns, u16 cardnr, u16 domain, |
1827 | 1740 | if (domain != 0xFFFF && dom != domain) |
1828 | 1741 | continue; |
1829 | 1742 | /* get cca info on this apqn */ |
1830 | | - if (cca_get_info(card, dom, &ci, verify)) |
| 1743 | + if (cca_get_info(card, dom, &ci)) |
1831 | 1744 | continue; |
1832 | 1745 | /* current master key needs to be valid */ |
1833 | 1746 | if (mktype == AES_MK_SET && ci.cur_aes_mk_state != '2') |
@@ -1900,7 +1813,6 @@ int __init zcrypt_ccamisc_init(void) |
1900 | 1813 |
|
1901 | 1814 | void zcrypt_ccamisc_exit(void) |
1902 | 1815 | { |
1903 | | - mkvp_cache_free(); |
1904 | 1816 | mutex_lock(&dev_status_mem_mutex); |
1905 | 1817 | kvfree(dev_status_mem); |
1906 | 1818 | mutex_unlock(&dev_status_mem_mutex); |
|
0 commit comments