Skip to content

Commit 02383ef

Browse files
hfreudehcahca
authored andcommitted
s390/zcrypt: Remove unused functions from cca misc
The static function findcard() and the zcrypt cca_findcard() function are both not used any more. Remove this outdated code and an internal function only called by these. Signed-off-by: Harald Freudenberger <freude@linux.ibm.com> Reviewed-by: Holger Dengler <dengler@linux.ibm.com> Link: https://lore.kernel.org/r/20250424133619.16495-12-freude@linux.ibm.com Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent d2fd25b commit 02383ef

2 files changed

Lines changed: 0 additions & 151 deletions

File tree

drivers/s390/crypto/zcrypt_ccamisc.c

Lines changed: 0 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,22 +1680,6 @@ static void cca_info_cache_update(u16 cardnr, u16 domain,
16801680
spin_unlock_bh(&cca_info_list_lock);
16811681
}
16821682

1683-
static void cca_info_cache_scrub(u16 cardnr, u16 domain)
1684-
{
1685-
struct cca_info_list_entry *ptr;
1686-
1687-
spin_lock_bh(&cca_info_list_lock);
1688-
list_for_each_entry(ptr, &cca_info_list, list) {
1689-
if (ptr->cardnr == cardnr &&
1690-
ptr->domain == domain) {
1691-
list_del(&ptr->list);
1692-
kfree(ptr);
1693-
break;
1694-
}
1695-
}
1696-
spin_unlock_bh(&cca_info_list_lock);
1697-
}
1698-
16991683
static void __exit mkvp_cache_free(void)
17001684
{
17011685
struct cca_info_list_entry *ptr, *pnext;
@@ -1800,132 +1784,6 @@ int cca_get_info(u16 card, u16 dom, struct cca_info *ci, int verify)
18001784
}
18011785
EXPORT_SYMBOL(cca_get_info);
18021786

1803-
/*
1804-
* Search for a matching crypto card based on the
1805-
* Master Key Verification Pattern given.
1806-
*/
1807-
static int findcard(u64 mkvp, u16 *pcardnr, u16 *pdomain,
1808-
int verify, int minhwtype)
1809-
{
1810-
struct zcrypt_device_status_ext *device_status;
1811-
u16 card, dom;
1812-
struct cca_info ci;
1813-
int i, rc, oi = -1;
1814-
1815-
/* mkvp must not be zero, minhwtype needs to be >= 0 */
1816-
if (mkvp == 0 || minhwtype < 0)
1817-
return -EINVAL;
1818-
1819-
/* fetch status of all crypto cards */
1820-
device_status = kvcalloc(MAX_ZDEV_ENTRIES_EXT,
1821-
sizeof(struct zcrypt_device_status_ext),
1822-
GFP_KERNEL);
1823-
if (!device_status)
1824-
return -ENOMEM;
1825-
1826-
zcrypt_device_status_mask_ext(device_status,
1827-
MAX_ZDEV_CARDIDS_EXT,
1828-
MAX_ZDEV_DOMAINS_EXT);
1829-
1830-
/* walk through all crypto cards */
1831-
for (i = 0; i < MAX_ZDEV_ENTRIES_EXT; i++) {
1832-
card = AP_QID_CARD(device_status[i].qid);
1833-
dom = AP_QID_QUEUE(device_status[i].qid);
1834-
if (device_status[i].online &&
1835-
device_status[i].functions & 0x04) {
1836-
/* enabled CCA card, check current mkvp from cache */
1837-
if (cca_info_cache_fetch(card, dom, &ci) == 0 &&
1838-
ci.hwtype >= minhwtype &&
1839-
ci.cur_aes_mk_state == '2' &&
1840-
ci.cur_aes_mkvp == mkvp) {
1841-
if (!verify)
1842-
break;
1843-
/* verify: refresh card info */
1844-
if (fetch_cca_info(card, dom, &ci) == 0) {
1845-
cca_info_cache_update(card, dom, &ci);
1846-
if (ci.hwtype >= minhwtype &&
1847-
ci.cur_aes_mk_state == '2' &&
1848-
ci.cur_aes_mkvp == mkvp)
1849-
break;
1850-
}
1851-
}
1852-
} else {
1853-
/* Card is offline and/or not a CCA card. */
1854-
/* del mkvp entry from cache if it exists */
1855-
cca_info_cache_scrub(card, dom);
1856-
}
1857-
}
1858-
if (i >= MAX_ZDEV_ENTRIES_EXT) {
1859-
/* nothing found, so this time without cache */
1860-
for (i = 0; i < MAX_ZDEV_ENTRIES_EXT; i++) {
1861-
if (!(device_status[i].online &&
1862-
device_status[i].functions & 0x04))
1863-
continue;
1864-
card = AP_QID_CARD(device_status[i].qid);
1865-
dom = AP_QID_QUEUE(device_status[i].qid);
1866-
/* fresh fetch mkvp from adapter */
1867-
if (fetch_cca_info(card, dom, &ci) == 0) {
1868-
cca_info_cache_update(card, dom, &ci);
1869-
if (ci.hwtype >= minhwtype &&
1870-
ci.cur_aes_mk_state == '2' &&
1871-
ci.cur_aes_mkvp == mkvp)
1872-
break;
1873-
if (ci.hwtype >= minhwtype &&
1874-
ci.old_aes_mk_state == '2' &&
1875-
ci.old_aes_mkvp == mkvp &&
1876-
oi < 0)
1877-
oi = i;
1878-
}
1879-
}
1880-
if (i >= MAX_ZDEV_ENTRIES_EXT && oi >= 0) {
1881-
/* old mkvp matched, use this card then */
1882-
card = AP_QID_CARD(device_status[oi].qid);
1883-
dom = AP_QID_QUEUE(device_status[oi].qid);
1884-
}
1885-
}
1886-
if (i < MAX_ZDEV_ENTRIES_EXT || oi >= 0) {
1887-
if (pcardnr)
1888-
*pcardnr = card;
1889-
if (pdomain)
1890-
*pdomain = dom;
1891-
rc = (i < MAX_ZDEV_ENTRIES_EXT ? 0 : 1);
1892-
} else {
1893-
rc = -ENODEV;
1894-
}
1895-
1896-
kvfree(device_status);
1897-
return rc;
1898-
}
1899-
1900-
/*
1901-
* Search for a matching crypto card based on the Master Key
1902-
* Verification Pattern provided inside a secure key token.
1903-
*/
1904-
int cca_findcard(const u8 *key, u16 *pcardnr, u16 *pdomain, int verify)
1905-
{
1906-
u64 mkvp;
1907-
int minhwtype = 0;
1908-
const struct keytoken_header *hdr = (struct keytoken_header *)key;
1909-
1910-
if (hdr->type != TOKTYPE_CCA_INTERNAL)
1911-
return -EINVAL;
1912-
1913-
switch (hdr->version) {
1914-
case TOKVER_CCA_AES:
1915-
mkvp = ((struct secaeskeytoken *)key)->mkvp;
1916-
break;
1917-
case TOKVER_CCA_VLSC:
1918-
mkvp = ((struct cipherkeytoken *)key)->mkvp0;
1919-
minhwtype = AP_DEVICE_TYPE_CEX6;
1920-
break;
1921-
default:
1922-
return -EINVAL;
1923-
}
1924-
1925-
return findcard(mkvp, pcardnr, pdomain, verify, minhwtype);
1926-
}
1927-
EXPORT_SYMBOL(cca_findcard);
1928-
19291787
int cca_findcard2(u32 **apqns, u32 *nr_apqns, u16 cardnr, u16 domain,
19301788
int minhwtype, int mktype, u64 cur_mkvp, u64 old_mkvp,
19311789
int verify)

drivers/s390/crypto/zcrypt_ccamisc.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,6 @@ int cca_query_crypto_facility(u16 cardnr, u16 domain,
207207
u8 *rarray, size_t *rarraylen,
208208
u8 *varray, size_t *varraylen);
209209

210-
/*
211-
* Search for a matching crypto card based on the Master Key
212-
* Verification Pattern provided inside a secure key.
213-
* Works with CCA AES data and cipher keys.
214-
* Returns < 0 on failure, 0 if CURRENT MKVP matches and
215-
* 1 if OLD MKVP matches.
216-
*/
217-
int cca_findcard(const u8 *key, u16 *pcardnr, u16 *pdomain, int verify);
218-
219210
/*
220211
* Build a list of cca apqns meeting the following constrains:
221212
* - apqn is online and is in fact a CCA apqn

0 commit comments

Comments
 (0)