From nobody Sun Feb 8 04:13:26 2026 Received: from mx4.wp.pl (mx4.wp.pl [212.77.101.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C36021257E for ; Tue, 30 Dec 2025 23:52:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.77.101.11 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767138751; cv=none; b=LV4NqR4FzBd7i0YF/I8F3P9CUA/YYB/dZ4p1goB5E/AxIoJ46MSn+pihrqDapHfPFXuTl6RBIkyftYSFaLCQs745+AnsKJdpmvcLSd+g46AAOQPvmadHhOq+rm/X3xYl/YgVOF6Bs0D6wI85mWRrtOA3HymqO18woTXSPSfawsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767138751; c=relaxed/simple; bh=Yj+1kBT/xzBsmsLD/iNchYPF23fp+YZZBWM7ypXQ6Hg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ZxMTEsURiA//rxrPYyvZBIxcUuERqVyqHw3iGKInWJ28/15HomFPVy1a2q6DxSEwBKISytLZNhAuYhG2XBhgx1Qzn+U9j6e024TSvgIs4RANxK8/KiZjK6t50xjq2inCqSfXJ2KRBL38GcOEdspRHClzilm8vizChpJ2+KSGX5o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wp.pl; spf=pass smtp.mailfrom=wp.pl; dkim=pass (2048-bit key) header.d=wp.pl header.i=@wp.pl header.b=STtIoNEE; arc=none smtp.client-ip=212.77.101.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wp.pl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wp.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wp.pl header.i=@wp.pl header.b="STtIoNEE" Received: (wp-smtpd smtp.wp.pl 10168 invoked from network); 31 Dec 2025 00:52:25 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=20241105; t=1767138745; bh=2V/j4nTU5LxxzBYu2oXs3k3yGpEUDph8mKEMwSjdXfI=; h=From:To:Cc:Subject; b=STtIoNEEIJyHhD9sAE6oKpK0pJRyZER+ZFQdfX9fuYnz4wOtJfxmPJee5vuElr2Bd Zjj3cWJgnbinTCeKIuNMiDiIFfRzZODu5Ph5Q3cYGzRubGODiJSnD9TZTbpv1KgSZl zWkdnMgC/M6l5/dhtN6W4WnMQEUYiPGVYeMgE0HfpzZq/5FqKiAVZFBS6gfkKctj/G KhFki+LlBIy65wuS/slfUHbAf3e9m1HgZ1qgailwqlzU94MUR/uk5cT74aFmk8EmSR h6dmFrwLB5A+PDfsJoWjWsdCfWQOa2YaGoBnKJoKux82A/D2kCQb4tqT7wS2xs94u/ +YvE7FxSRaTGg== Received: from 83.5.157.18.ipv4.supernova.orange.pl (HELO laptop-olek.lan) (olek2@wp.pl@[83.5.157.18]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP for ; 31 Dec 2025 00:52:25 +0100 From: Aleksander Jan Bajkowski To: ansuelsmth@gmail.com, atenart@kernel.org, herbert@gondor.apana.org.au, davem@davemloft.net, vschagen@icloud.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Aleksander Jan Bajkowski Subject: [PATCH] crypto: inside-secure/eip93 - unregister only available algorithm Date: Wed, 31 Dec 2025 00:51:57 +0100 Message-ID: <20251230235222.2113987-1-olek2@wp.pl> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-WP-DKIM-Status: good (id: wp.pl) X-WP-MailID: 40b4068a9f09c1d9b430ab71df20e0df X-WP-AV: skaner antywirusowy Poczty Wirtualnej Polski X-WP-SPAM: NO 0000007 [cfRB] Content-Type: text/plain; charset="utf-8" EIP93 has an options register. This register indicates which crypto algorithms are implemented in silicon. Supported algorithms are registered on this basis. Unregister algorithms on the same basis. Currently, all algorithms are unregistered, even those not supported by HW. This results in panic on platforms that don't have all options implemented in silicon. Fixes: 9739f5f93b78 ("crypto: eip93 - Add Inside Secure SafeXcel EIP-93 cry= pto engine support") Signed-off-by: Aleksander Jan Bajkowski --- .../crypto/inside-secure/eip93/eip93-main.c | 107 ++++++++++-------- 1 file changed, 61 insertions(+), 46 deletions(-) diff --git a/drivers/crypto/inside-secure/eip93/eip93-main.c b/drivers/cryp= to/inside-secure/eip93/eip93-main.c index 3cdc3308dcac..dfac2b23e2d9 100644 --- a/drivers/crypto/inside-secure/eip93/eip93-main.c +++ b/drivers/crypto/inside-secure/eip93/eip93-main.c @@ -77,11 +77,65 @@ inline void eip93_irq_clear(struct eip93_device *eip93,= u32 mask) __raw_writel(mask, eip93->base + EIP93_REG_INT_CLR); } =20 -static void eip93_unregister_algs(unsigned int i) +static int eip93_algo_is_supported(struct eip93_alg_template *eip93_algo, + u32 supported_algo_flags) +{ + u32 alg_flags =3D eip93_algo->flags; + + if ((IS_DES(alg_flags) || IS_3DES(alg_flags)) && + !(supported_algo_flags & EIP93_PE_OPTION_TDES)) + return 0; + + if (IS_AES(alg_flags)) { + if (!(supported_algo_flags & EIP93_PE_OPTION_AES)) + return 0; + + if (!IS_HMAC(alg_flags)) { + if (supported_algo_flags & EIP93_PE_OPTION_AES_KEY128) + eip93_algo->alg.skcipher.max_keysize =3D + AES_KEYSIZE_128; + + if (supported_algo_flags & EIP93_PE_OPTION_AES_KEY192) + eip93_algo->alg.skcipher.max_keysize =3D + AES_KEYSIZE_192; + + if (supported_algo_flags & EIP93_PE_OPTION_AES_KEY256) + eip93_algo->alg.skcipher.max_keysize =3D + AES_KEYSIZE_256; + + if (IS_RFC3686(alg_flags)) + eip93_algo->alg.skcipher.max_keysize +=3D + CTR_RFC3686_NONCE_SIZE; + } + } + + if (IS_HASH_MD5(alg_flags) && + !(supported_algo_flags & EIP93_PE_OPTION_MD5)) + return 0; + + if (IS_HASH_SHA1(alg_flags) && + !(supported_algo_flags & EIP93_PE_OPTION_SHA_1)) + return 0; + + if (IS_HASH_SHA224(alg_flags) && + !(supported_algo_flags & EIP93_PE_OPTION_SHA_224)) + return 0; + + if (IS_HASH_SHA256(alg_flags) && + !(supported_algo_flags & EIP93_PE_OPTION_SHA_256)) + return 0; + + return 1; +} + +static void eip93_unregister_algs(u32 supported_algo_flags, unsigned int i) { unsigned int j; =20 for (j =3D 0; j < i; j++) { + if (!eip93_algo_is_supported(eip93_algs[j], supported_algo_flags)) + continue; + switch (eip93_algs[j]->type) { case EIP93_ALG_TYPE_SKCIPHER: crypto_unregister_skcipher(&eip93_algs[j]->alg.skcipher); @@ -102,51 +156,9 @@ static int eip93_register_algs(struct eip93_device *ei= p93, u32 supported_algo_fl int ret =3D 0; =20 for (i =3D 0; i < ARRAY_SIZE(eip93_algs); i++) { - u32 alg_flags =3D eip93_algs[i]->flags; - eip93_algs[i]->eip93 =3D eip93; =20 - if ((IS_DES(alg_flags) || IS_3DES(alg_flags)) && - !(supported_algo_flags & EIP93_PE_OPTION_TDES)) - continue; - - if (IS_AES(alg_flags)) { - if (!(supported_algo_flags & EIP93_PE_OPTION_AES)) - continue; - - if (!IS_HMAC(alg_flags)) { - if (supported_algo_flags & EIP93_PE_OPTION_AES_KEY128) - eip93_algs[i]->alg.skcipher.max_keysize =3D - AES_KEYSIZE_128; - - if (supported_algo_flags & EIP93_PE_OPTION_AES_KEY192) - eip93_algs[i]->alg.skcipher.max_keysize =3D - AES_KEYSIZE_192; - - if (supported_algo_flags & EIP93_PE_OPTION_AES_KEY256) - eip93_algs[i]->alg.skcipher.max_keysize =3D - AES_KEYSIZE_256; - - if (IS_RFC3686(alg_flags)) - eip93_algs[i]->alg.skcipher.max_keysize +=3D - CTR_RFC3686_NONCE_SIZE; - } - } - - if (IS_HASH_MD5(alg_flags) && - !(supported_algo_flags & EIP93_PE_OPTION_MD5)) - continue; - - if (IS_HASH_SHA1(alg_flags) && - !(supported_algo_flags & EIP93_PE_OPTION_SHA_1)) - continue; - - if (IS_HASH_SHA224(alg_flags) && - !(supported_algo_flags & EIP93_PE_OPTION_SHA_224)) - continue; - - if (IS_HASH_SHA256(alg_flags) && - !(supported_algo_flags & EIP93_PE_OPTION_SHA_256)) + if (!eip93_algo_is_supported(eip93_algs[i], supported_algo_flags)) continue; =20 switch (eip93_algs[i]->type) { @@ -167,7 +179,7 @@ static int eip93_register_algs(struct eip93_device *eip= 93, u32 supported_algo_fl return 0; =20 fail: - eip93_unregister_algs(i); + eip93_unregister_algs(supported_algo_flags, i); =20 return ret; } @@ -469,8 +481,11 @@ static int eip93_crypto_probe(struct platform_device *= pdev) static void eip93_crypto_remove(struct platform_device *pdev) { struct eip93_device *eip93 =3D platform_get_drvdata(pdev); + u32 algo_flags; + + algo_flags =3D readl(eip93->base + EIP93_REG_PE_OPTION_1); =20 - eip93_unregister_algs(ARRAY_SIZE(eip93_algs)); + eip93_unregister_algs(algo_flags, ARRAY_SIZE(eip93_algs)); eip93_cleanup(eip93); } =20 --=20 2.47.3