get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2183228/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2183228,
    "url": "http://patchwork.ozlabs.org/api/patches/2183228/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260112192035.10427-17-ebiggers@kernel.org/",
    "project": {
        "id": 2,
        "url": "http://patchwork.ozlabs.org/api/projects/2/?format=api",
        "name": "Linux PPC development",
        "link_name": "linuxppc-dev",
        "list_id": "linuxppc-dev.lists.ozlabs.org",
        "list_email": "linuxppc-dev@lists.ozlabs.org",
        "web_url": "https://github.com/linuxppc/wiki/wiki",
        "scm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git",
        "webscm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/",
        "list_archive_url": "https://lore.kernel.org/linuxppc-dev/",
        "list_archive_url_format": "https://lore.kernel.org/linuxppc-dev/{}/",
        "commit_url_format": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"
    },
    "msgid": "<20260112192035.10427-17-ebiggers@kernel.org>",
    "list_archive_url": "https://lore.kernel.org/linuxppc-dev/20260112192035.10427-17-ebiggers@kernel.org/",
    "date": "2026-01-12T19:20:14",
    "name": "[v2,16/35] lib/crypto: sparc/aes: Migrate optimized code into library",
    "commit_ref": null,
    "pull_url": null,
    "state": "handled-elsewhere",
    "archived": false,
    "hash": "db7bcede9e3114e4766cb271572f1e65958d28d8",
    "submitter": {
        "id": 74690,
        "url": "http://patchwork.ozlabs.org/api/people/74690/?format=api",
        "name": "Eric Biggers",
        "email": "ebiggers@kernel.org"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20260112192035.10427-17-ebiggers@kernel.org/mbox/",
    "series": [
        {
            "id": 488089,
            "url": "http://patchwork.ozlabs.org/api/series/488089/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=488089",
            "date": "2026-01-12T19:19:58",
            "name": "AES library improvements",
            "version": 2,
            "mbox": "http://patchwork.ozlabs.org/series/488089/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2183228/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2183228/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "\n <linuxppc-dev+bounces-15584-incoming=patchwork.ozlabs.org@lists.ozlabs.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "linuxppc-dev@lists.ozlabs.org"
        ],
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=JCiiPnjj;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org\n (client-ip=2404:9400:21b9:f100::1; helo=lists.ozlabs.org;\n envelope-from=linuxppc-dev+bounces-15584-incoming=patchwork.ozlabs.org@lists.ozlabs.org;\n receiver=patchwork.ozlabs.org)",
            "lists.ozlabs.org;\n arc=none smtp.remote-ip=172.105.4.254",
            "lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org",
            "lists.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=JCiiPnjj;\n\tdkim-atps=neutral",
            "lists.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org\n (client-ip=172.105.4.254; helo=tor.source.kernel.org;\n envelope-from=ebiggers@kernel.org; receiver=lists.ozlabs.org)"
        ],
        "Received": [
            "from lists.ozlabs.org (lists.ozlabs.org\n [IPv6:2404:9400:21b9:f100::1])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4dqj7j5Fvrz1xpY\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 13 Jan 2026 06:27:29 +1100 (AEDT)",
            "from boromir.ozlabs.org (localhost [127.0.0.1])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 4dqj3h2Phmz3cR2;\n\tTue, 13 Jan 2026 06:24:00 +1100 (AEDT)",
            "from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 4dqj3g1YD4z3c4r\n\tfor <linuxppc-dev@lists.ozlabs.org>; Tue, 13 Jan 2026 06:23:59 +1100 (AEDT)",
            "from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n\tby tor.source.kernel.org (Postfix) with ESMTP id 1455E600B0;\n\tMon, 12 Jan 2026 19:23:27 +0000 (UTC)",
            "by smtp.kernel.org (Postfix) with ESMTPSA id 5CBEEC19422;\n\tMon, 12 Jan 2026 19:23:26 +0000 (UTC)"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1768245840;\n\tcv=none;\n b=iJFPk4uITENLxA9X93M8DUuMuCki8bT05Z3RmpuNmx5JXbRy9+jIeRH/+p72kUYaAOInu2fw6BEVf+nSUuSieknMx8cajP3fe9YGj8jPpFXS2gWhFQcZ0hPotWO5HSoTwsI7dj6ELHs9q2X0iZCHlSNAVcEBB+ntB+OCKCUuoFfxoKZYNLe97POt2LcX0sh00bh2pStBr/K47KchuIdPQCy4fQnK9ALW/LgICxfhX4c2oSi325lkRGZUa8y5zmfHoKLVyYeVbHvnx9+S3+aSE5bnlal+nD/tASdiM+NOiB/UeMlHKK59wqCRiiNIOXjAh6k/o2QJ+ib/WjGytjHwxw==",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707;\n\tt=1768245840; c=relaxed/relaxed;\n\tbh=EorFE+xpV+RBa9joeaHj/cD2ImfvzWYT1Y7O0LNfVUM=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=fOlGEynzmM7+CwZvGHxKdbR4mNR4zVrattlqaQFtuHS4rthKqgMzjdI6hh4tE+MEwHRkGljjTOWRql+vIkDemCor2OxzKODaV6EM5GFAbdLEqempsuwwVWN2cJfdjJ6wPGE10MzXaa7sMSvkJWEy4vvULBE5JiLtVsAUhhAppcDjK/CblZzgQE26+9L+ErS9j0y1fhnUiFY8bIBXWvjTm0l1+lME84GPjAIprO9nPiJ1UsrPIrfOwBeKIPPCbG7Xtq+UnHgZlcudksZ7Has3Mb7XXOvF/LFsfZm0L7micbMhxV4Y1QL1yQXaVWW/CEGrkegSiBSrXZHzjevjdR8Z2Q==",
        "ARC-Authentication-Results": "i=1; lists.ozlabs.org;\n dmarc=pass (p=quarantine dis=none) header.from=kernel.org;\n dkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=JCiiPnjj; dkim-atps=neutral;\n spf=pass (client-ip=172.105.4.254; helo=tor.source.kernel.org;\n envelope-from=ebiggers@kernel.org;\n receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1768245806;\n\tbh=7nOYA53rVKMBmiYRkvB3gnI+C0K7bNCp4etYWtVMyvo=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=JCiiPnjjYlBeQyBWozdPIX+saMsvrJDEwgu7dCuRuMYKMU5NfFnoTo81iuxS6B0qC\n\t 4q4ZiTRDFFYuB+fTDc8vQ7hWs774CWcR8W3dbXQ8aytn4kABvXAzr8WlQXM4JoYxlU\n\t XNWFOfSbTaoplp9MJxqnTJGs+xT2bWZCP9kWRafQsQl1E2RSxblIZMnCwsKzl52LYC\n\t JxfRuNsSuxOrWYKzYs3O/uIlMM3oEPMZlVtbIXEYyqCiHgdAWTrPudPemkJlwjJo0f\n\t dGgAtB1bvdlOrNaCQhrul5JBAgrJ0v5lL8EcwReKQSR6ArkoPVrPXmgyttqLkev26g\n\t vZN91kqQejenw==",
        "From": "Eric Biggers <ebiggers@kernel.org>",
        "To": "linux-crypto@vger.kernel.org",
        "Cc": "linux-kernel@vger.kernel.org,\n\tArd Biesheuvel <ardb@kernel.org>,\n\t\"Jason A . Donenfeld\" <Jason@zx2c4.com>,\n\tHerbert Xu <herbert@gondor.apana.org.au>,\n\tlinux-arm-kernel@lists.infradead.org,\n\tlinuxppc-dev@lists.ozlabs.org,\n\tlinux-riscv@lists.infradead.org,\n\tlinux-s390@vger.kernel.org,\n\tsparclinux@vger.kernel.org,\n\tx86@kernel.org,\n\tHolger Dengler <dengler@linux.ibm.com>,\n\tHarald Freudenberger <freude@linux.ibm.com>,\n\tEric Biggers <ebiggers@kernel.org>",
        "Subject": "[PATCH v2 16/35] lib/crypto: sparc/aes: Migrate optimized code into\n library",
        "Date": "Mon, 12 Jan 2026 11:20:14 -0800",
        "Message-ID": "<20260112192035.10427-17-ebiggers@kernel.org>",
        "X-Mailer": "git-send-email 2.52.0",
        "In-Reply-To": "<20260112192035.10427-1-ebiggers@kernel.org>",
        "References": "<20260112192035.10427-1-ebiggers@kernel.org>",
        "X-Mailing-List": "linuxppc-dev@lists.ozlabs.org",
        "List-Id": "<linuxppc-dev.lists.ozlabs.org>",
        "List-Help": "<mailto:linuxppc-dev+help@lists.ozlabs.org>",
        "List-Owner": "<mailto:linuxppc-dev+owner@lists.ozlabs.org>",
        "List-Post": "<mailto:linuxppc-dev@lists.ozlabs.org>",
        "List-Archive": "<https://lore.kernel.org/linuxppc-dev/>,\n  <https://lists.ozlabs.org/pipermail/linuxppc-dev/>",
        "List-Subscribe": "<mailto:linuxppc-dev+subscribe@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-digest@lists.ozlabs.org>,\n  <mailto:linuxppc-dev+subscribe-nomail@lists.ozlabs.org>",
        "List-Unsubscribe": "<mailto:linuxppc-dev+unsubscribe@lists.ozlabs.org>",
        "Precedence": "list",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-Spam-Status": "No, score=-0.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED,\n\tDKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS\n\tautolearn=disabled version=4.0.1 OzLabs 8",
        "X-Spam-Checker-Version": "SpamAssassin 4.0.1 (2024-03-25) on lists.ozlabs.org"
    },
    "content": "Move the SPARC64 AES assembly code into lib/crypto/, wire the key\nexpansion and single-block en/decryption functions up to the AES library\nAPI, and remove the \"aes-sparc64\" crypto_cipher algorithm.\n\nThe result is that both the AES library and crypto_cipher APIs use the\nSPARC64 AES opcodes, whereas previously only crypto_cipher did (and it\nwasn't enabled by default, which this commit fixes as well).\n\nNote that some of the functions in the SPARC64 AES assembly code are\nstill used by the AES mode implementations in\narch/sparc/crypto/aes_glue.c.  For now, just export these functions.\nThese exports will go away once the AES mode implementations are\nmigrated to the library as well.  (Trying to split up the assembly file\nseemed like much more trouble than it would be worth.)\n\nAcked-by: Ard Biesheuvel <ardb@kernel.org>\nSigned-off-by: Eric Biggers <ebiggers@kernel.org>\n---\n arch/sparc/crypto/Kconfig                     |   2 +-\n arch/sparc/crypto/Makefile                    |   2 +-\n arch/sparc/crypto/aes_glue.c                  | 140 +---------------\n include/crypto/aes.h                          |  42 +++++\n lib/crypto/Kconfig                            |   1 +\n lib/crypto/Makefile                           |   1 +\n lib/crypto/sparc/aes.h                        | 149 ++++++++++++++++++\n .../crypto => lib/crypto/sparc}/aes_asm.S     |   0\n 8 files changed, 200 insertions(+), 137 deletions(-)\n create mode 100644 lib/crypto/sparc/aes.h\n rename {arch/sparc/crypto => lib/crypto/sparc}/aes_asm.S (100%)",
    "diff": "diff --git a/arch/sparc/crypto/Kconfig b/arch/sparc/crypto/Kconfig\nindex f755da979534..c1932ce46c7f 100644\n--- a/arch/sparc/crypto/Kconfig\n+++ b/arch/sparc/crypto/Kconfig\n@@ -17,13 +17,13 @@ config CRYPTO_DES_SPARC64\n \t  Architecture: sparc64\n \n config CRYPTO_AES_SPARC64\n \ttristate \"Ciphers: AES, modes: ECB, CBC, CTR\"\n \tdepends on SPARC64\n+\tselect CRYPTO_LIB_AES\n \tselect CRYPTO_SKCIPHER\n \thelp\n-\t  Block ciphers: AES cipher algorithms (FIPS-197)\n \t  Length-preseving ciphers: AES with ECB, CBC, and CTR modes\n \n \t  Architecture: sparc64 using crypto instructions\n \n config CRYPTO_CAMELLIA_SPARC64\ndiff --git a/arch/sparc/crypto/Makefile b/arch/sparc/crypto/Makefile\nindex 7b4796842ddd..cdf9f4b3efbb 100644\n--- a/arch/sparc/crypto/Makefile\n+++ b/arch/sparc/crypto/Makefile\n@@ -5,8 +5,8 @@\n \n obj-$(CONFIG_CRYPTO_AES_SPARC64) += aes-sparc64.o\n obj-$(CONFIG_CRYPTO_DES_SPARC64) += des-sparc64.o\n obj-$(CONFIG_CRYPTO_CAMELLIA_SPARC64) += camellia-sparc64.o\n \n-aes-sparc64-y := aes_asm.o aes_glue.o\n+aes-sparc64-y := aes_glue.o\n des-sparc64-y := des_asm.o des_glue.o\n camellia-sparc64-y := camellia_asm.o camellia_glue.o\ndiff --git a/arch/sparc/crypto/aes_glue.c b/arch/sparc/crypto/aes_glue.c\nindex 359f22643b05..661561837415 100644\n--- a/arch/sparc/crypto/aes_glue.c\n+++ b/arch/sparc/crypto/aes_glue.c\n@@ -30,12 +30,10 @@\n #include <asm/opcodes.h>\n #include <asm/pstate.h>\n #include <asm/elf.h>\n \n struct aes_ops {\n-\tvoid (*encrypt)(const u64 *key, const u32 *input, u32 *output);\n-\tvoid (*decrypt)(const u64 *key, const u32 *input, u32 *output);\n \tvoid (*load_encrypt_keys)(const u64 *key);\n \tvoid (*load_decrypt_keys)(const u64 *key);\n \tvoid (*ecb_encrypt)(const u64 *key, const u64 *input, u64 *output,\n \t\t\t    unsigned int len);\n \tvoid (*ecb_decrypt)(const u64 *key, const u64 *input, u64 *output,\n@@ -53,123 +51,44 @@ struct crypto_sparc64_aes_ctx {\n \tu64 key[AES_MAX_KEYLENGTH / sizeof(u64)];\n \tu32 key_length;\n \tu32 expanded_key_length;\n };\n \n-extern void aes_sparc64_encrypt_128(const u64 *key, const u32 *input,\n-\t\t\t\t    u32 *output);\n-extern void aes_sparc64_encrypt_192(const u64 *key, const u32 *input,\n-\t\t\t\t    u32 *output);\n-extern void aes_sparc64_encrypt_256(const u64 *key, const u32 *input,\n-\t\t\t\t    u32 *output);\n-\n-extern void aes_sparc64_decrypt_128(const u64 *key, const u32 *input,\n-\t\t\t\t    u32 *output);\n-extern void aes_sparc64_decrypt_192(const u64 *key, const u32 *input,\n-\t\t\t\t    u32 *output);\n-extern void aes_sparc64_decrypt_256(const u64 *key, const u32 *input,\n-\t\t\t\t    u32 *output);\n-\n-extern void aes_sparc64_load_encrypt_keys_128(const u64 *key);\n-extern void aes_sparc64_load_encrypt_keys_192(const u64 *key);\n-extern void aes_sparc64_load_encrypt_keys_256(const u64 *key);\n-\n-extern void aes_sparc64_load_decrypt_keys_128(const u64 *key);\n-extern void aes_sparc64_load_decrypt_keys_192(const u64 *key);\n-extern void aes_sparc64_load_decrypt_keys_256(const u64 *key);\n-\n-extern void aes_sparc64_ecb_encrypt_128(const u64 *key, const u64 *input,\n-\t\t\t\t\tu64 *output, unsigned int len);\n-extern void aes_sparc64_ecb_encrypt_192(const u64 *key, const u64 *input,\n-\t\t\t\t\tu64 *output, unsigned int len);\n-extern void aes_sparc64_ecb_encrypt_256(const u64 *key, const u64 *input,\n-\t\t\t\t\tu64 *output, unsigned int len);\n-\n-extern void aes_sparc64_ecb_decrypt_128(const u64 *key, const u64 *input,\n-\t\t\t\t\tu64 *output, unsigned int len);\n-extern void aes_sparc64_ecb_decrypt_192(const u64 *key, const u64 *input,\n-\t\t\t\t\tu64 *output, unsigned int len);\n-extern void aes_sparc64_ecb_decrypt_256(const u64 *key, const u64 *input,\n-\t\t\t\t\tu64 *output, unsigned int len);\n-\n-extern void aes_sparc64_cbc_encrypt_128(const u64 *key, const u64 *input,\n-\t\t\t\t\tu64 *output, unsigned int len,\n-\t\t\t\t\tu64 *iv);\n-\n-extern void aes_sparc64_cbc_encrypt_192(const u64 *key, const u64 *input,\n-\t\t\t\t\tu64 *output, unsigned int len,\n-\t\t\t\t\tu64 *iv);\n-\n-extern void aes_sparc64_cbc_encrypt_256(const u64 *key, const u64 *input,\n-\t\t\t\t\tu64 *output, unsigned int len,\n-\t\t\t\t\tu64 *iv);\n-\n-extern void aes_sparc64_cbc_decrypt_128(const u64 *key, const u64 *input,\n-\t\t\t\t\tu64 *output, unsigned int len,\n-\t\t\t\t\tu64 *iv);\n-\n-extern void aes_sparc64_cbc_decrypt_192(const u64 *key, const u64 *input,\n-\t\t\t\t\tu64 *output, unsigned int len,\n-\t\t\t\t\tu64 *iv);\n-\n-extern void aes_sparc64_cbc_decrypt_256(const u64 *key, const u64 *input,\n-\t\t\t\t\tu64 *output, unsigned int len,\n-\t\t\t\t\tu64 *iv);\n-\n-extern void aes_sparc64_ctr_crypt_128(const u64 *key, const u64 *input,\n-\t\t\t\t      u64 *output, unsigned int len,\n-\t\t\t\t      u64 *iv);\n-extern void aes_sparc64_ctr_crypt_192(const u64 *key, const u64 *input,\n-\t\t\t\t      u64 *output, unsigned int len,\n-\t\t\t\t      u64 *iv);\n-extern void aes_sparc64_ctr_crypt_256(const u64 *key, const u64 *input,\n-\t\t\t\t      u64 *output, unsigned int len,\n-\t\t\t\t      u64 *iv);\n-\n static struct aes_ops aes128_ops = {\n-\t.encrypt\t\t= aes_sparc64_encrypt_128,\n-\t.decrypt\t\t= aes_sparc64_decrypt_128,\n \t.load_encrypt_keys\t= aes_sparc64_load_encrypt_keys_128,\n \t.load_decrypt_keys\t= aes_sparc64_load_decrypt_keys_128,\n \t.ecb_encrypt\t\t= aes_sparc64_ecb_encrypt_128,\n \t.ecb_decrypt\t\t= aes_sparc64_ecb_decrypt_128,\n \t.cbc_encrypt\t\t= aes_sparc64_cbc_encrypt_128,\n \t.cbc_decrypt\t\t= aes_sparc64_cbc_decrypt_128,\n \t.ctr_crypt\t\t= aes_sparc64_ctr_crypt_128,\n };\n \n static struct aes_ops aes192_ops = {\n-\t.encrypt\t\t= aes_sparc64_encrypt_192,\n-\t.decrypt\t\t= aes_sparc64_decrypt_192,\n \t.load_encrypt_keys\t= aes_sparc64_load_encrypt_keys_192,\n \t.load_decrypt_keys\t= aes_sparc64_load_decrypt_keys_192,\n \t.ecb_encrypt\t\t= aes_sparc64_ecb_encrypt_192,\n \t.ecb_decrypt\t\t= aes_sparc64_ecb_decrypt_192,\n \t.cbc_encrypt\t\t= aes_sparc64_cbc_encrypt_192,\n \t.cbc_decrypt\t\t= aes_sparc64_cbc_decrypt_192,\n \t.ctr_crypt\t\t= aes_sparc64_ctr_crypt_192,\n };\n \n static struct aes_ops aes256_ops = {\n-\t.encrypt\t\t= aes_sparc64_encrypt_256,\n-\t.decrypt\t\t= aes_sparc64_decrypt_256,\n \t.load_encrypt_keys\t= aes_sparc64_load_encrypt_keys_256,\n \t.load_decrypt_keys\t= aes_sparc64_load_decrypt_keys_256,\n \t.ecb_encrypt\t\t= aes_sparc64_ecb_encrypt_256,\n \t.ecb_decrypt\t\t= aes_sparc64_ecb_decrypt_256,\n \t.cbc_encrypt\t\t= aes_sparc64_cbc_encrypt_256,\n \t.cbc_decrypt\t\t= aes_sparc64_cbc_decrypt_256,\n \t.ctr_crypt\t\t= aes_sparc64_ctr_crypt_256,\n };\n \n-extern void aes_sparc64_key_expand(const u32 *in_key, u64 *output_key,\n-\t\t\t\t   unsigned int key_len);\n-\n-static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,\n-\t\t       unsigned int key_len)\n+static int aes_set_key_skcipher(struct crypto_skcipher *tfm, const u8 *in_key,\n+\t\t\t\tunsigned int key_len)\n {\n-\tstruct crypto_sparc64_aes_ctx *ctx = crypto_tfm_ctx(tfm);\n+\tstruct crypto_sparc64_aes_ctx *ctx = crypto_skcipher_ctx(tfm);\n \n \tswitch (key_len) {\n \tcase AES_KEYSIZE_128:\n \t\tctx->expanded_key_length = 0xb0;\n \t\tctx->ops = &aes128_ops;\n@@ -193,30 +112,10 @@ static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,\n \tctx->key_length = key_len;\n \n \treturn 0;\n }\n \n-static int aes_set_key_skcipher(struct crypto_skcipher *tfm, const u8 *in_key,\n-\t\t\t\tunsigned int key_len)\n-{\n-\treturn aes_set_key(crypto_skcipher_tfm(tfm), in_key, key_len);\n-}\n-\n-static void crypto_aes_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)\n-{\n-\tstruct crypto_sparc64_aes_ctx *ctx = crypto_tfm_ctx(tfm);\n-\n-\tctx->ops->encrypt(&ctx->key[0], (const u32 *) src, (u32 *) dst);\n-}\n-\n-static void crypto_aes_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)\n-{\n-\tstruct crypto_sparc64_aes_ctx *ctx = crypto_tfm_ctx(tfm);\n-\n-\tctx->ops->decrypt(&ctx->key[0], (const u32 *) src, (u32 *) dst);\n-}\n-\n static int ecb_encrypt(struct skcipher_request *req)\n {\n \tstruct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);\n \tconst struct crypto_sparc64_aes_ctx *ctx = crypto_skcipher_ctx(tfm);\n \tstruct skcipher_walk walk;\n@@ -356,30 +255,10 @@ static int ctr_crypt(struct skcipher_request *req)\n \t}\n \tfprs_write(0);\n \treturn err;\n }\n \n-static struct crypto_alg cipher_alg = {\n-\t.cra_name\t\t= \"aes\",\n-\t.cra_driver_name\t= \"aes-sparc64\",\n-\t.cra_priority\t\t= SPARC_CR_OPCODE_PRIORITY,\n-\t.cra_flags\t\t= CRYPTO_ALG_TYPE_CIPHER,\n-\t.cra_blocksize\t\t= AES_BLOCK_SIZE,\n-\t.cra_ctxsize\t\t= sizeof(struct crypto_sparc64_aes_ctx),\n-\t.cra_alignmask\t\t= 3,\n-\t.cra_module\t\t= THIS_MODULE,\n-\t.cra_u\t= {\n-\t\t.cipher\t= {\n-\t\t\t.cia_min_keysize\t= AES_MIN_KEY_SIZE,\n-\t\t\t.cia_max_keysize\t= AES_MAX_KEY_SIZE,\n-\t\t\t.cia_setkey\t\t= aes_set_key,\n-\t\t\t.cia_encrypt\t\t= crypto_aes_encrypt,\n-\t\t\t.cia_decrypt\t\t= crypto_aes_decrypt\n-\t\t}\n-\t}\n-};\n-\n static struct skcipher_alg skcipher_algs[] = {\n \t{\n \t\t.base.cra_name\t\t= \"ecb(aes)\",\n \t\t.base.cra_driver_name\t= \"ecb-aes-sparc64\",\n \t\t.base.cra_priority\t= SPARC_CR_OPCODE_PRIORITY,\n@@ -438,30 +317,21 @@ static bool __init sparc64_has_aes_opcode(void)\n \treturn true;\n }\n \n static int __init aes_sparc64_mod_init(void)\n {\n-\tint err;\n-\n \tif (!sparc64_has_aes_opcode()) {\n \t\tpr_info(\"sparc64 aes opcodes not available.\\n\");\n \t\treturn -ENODEV;\n \t}\n \tpr_info(\"Using sparc64 aes opcodes optimized AES implementation\\n\");\n-\terr = crypto_register_alg(&cipher_alg);\n-\tif (err)\n-\t\treturn err;\n-\terr = crypto_register_skciphers(skcipher_algs,\n-\t\t\t\t\tARRAY_SIZE(skcipher_algs));\n-\tif (err)\n-\t\tcrypto_unregister_alg(&cipher_alg);\n-\treturn err;\n+\treturn crypto_register_skciphers(skcipher_algs,\n+\t\t\t\t\t ARRAY_SIZE(skcipher_algs));\n }\n \n static void __exit aes_sparc64_mod_fini(void)\n {\n-\tcrypto_unregister_alg(&cipher_alg);\n \tcrypto_unregister_skciphers(skcipher_algs, ARRAY_SIZE(skcipher_algs));\n }\n \n module_init(aes_sparc64_mod_init);\n module_exit(aes_sparc64_mod_fini);\ndiff --git a/include/crypto/aes.h b/include/crypto/aes.h\nindex 19fd99f383fb..4a56aed59973 100644\n--- a/include/crypto/aes.h\n+++ b/include/crypto/aes.h\n@@ -47,10 +47,13 @@ union aes_enckey_arch {\n \t */\n \tstruct p8_aes_key p8;\n #elif defined(CONFIG_S390)\n \t/* Used when the CPU supports CPACF AES for this key's length */\n \tu8 raw_key[AES_MAX_KEY_SIZE];\n+#elif defined(CONFIG_SPARC64)\n+\t/* Used when the CPU supports the SPARC64 AES opcodes */\n+\tu64 sparc_rndkeys[AES_MAX_KEYLENGTH / sizeof(u64)];\n #endif\n #endif /* CONFIG_CRYPTO_LIB_AES_ARCH */\n };\n \n union aes_invkey_arch {\n@@ -197,10 +200,49 @@ void aes_p8_xts_encrypt(const u8 *in, u8 *out, size_t len,\n \t\t\tconst struct p8_aes_key *key1,\n \t\t\tconst struct p8_aes_key *key2, u8 *iv);\n void aes_p8_xts_decrypt(const u8 *in, u8 *out, size_t len,\n \t\t\tconst struct p8_aes_key *key1,\n \t\t\tconst struct p8_aes_key *key2, u8 *iv);\n+#elif defined(CONFIG_SPARC64)\n+void aes_sparc64_key_expand(const u32 *in_key, u64 *output_key,\n+\t\t\t    unsigned int key_len);\n+void aes_sparc64_load_encrypt_keys_128(const u64 *key);\n+void aes_sparc64_load_encrypt_keys_192(const u64 *key);\n+void aes_sparc64_load_encrypt_keys_256(const u64 *key);\n+void aes_sparc64_load_decrypt_keys_128(const u64 *key);\n+void aes_sparc64_load_decrypt_keys_192(const u64 *key);\n+void aes_sparc64_load_decrypt_keys_256(const u64 *key);\n+void aes_sparc64_ecb_encrypt_128(const u64 *key, const u64 *input, u64 *output,\n+\t\t\t\t unsigned int len);\n+void aes_sparc64_ecb_encrypt_192(const u64 *key, const u64 *input, u64 *output,\n+\t\t\t\t unsigned int len);\n+void aes_sparc64_ecb_encrypt_256(const u64 *key, const u64 *input, u64 *output,\n+\t\t\t\t unsigned int len);\n+void aes_sparc64_ecb_decrypt_128(const u64 *key, const u64 *input, u64 *output,\n+\t\t\t\t unsigned int len);\n+void aes_sparc64_ecb_decrypt_192(const u64 *key, const u64 *input, u64 *output,\n+\t\t\t\t unsigned int len);\n+void aes_sparc64_ecb_decrypt_256(const u64 *key, const u64 *input, u64 *output,\n+\t\t\t\t unsigned int len);\n+void aes_sparc64_cbc_encrypt_128(const u64 *key, const u64 *input, u64 *output,\n+\t\t\t\t unsigned int len, u64 *iv);\n+void aes_sparc64_cbc_encrypt_192(const u64 *key, const u64 *input, u64 *output,\n+\t\t\t\t unsigned int len, u64 *iv);\n+void aes_sparc64_cbc_encrypt_256(const u64 *key, const u64 *input, u64 *output,\n+\t\t\t\t unsigned int len, u64 *iv);\n+void aes_sparc64_cbc_decrypt_128(const u64 *key, const u64 *input, u64 *output,\n+\t\t\t\t unsigned int len, u64 *iv);\n+void aes_sparc64_cbc_decrypt_192(const u64 *key, const u64 *input, u64 *output,\n+\t\t\t\t unsigned int len, u64 *iv);\n+void aes_sparc64_cbc_decrypt_256(const u64 *key, const u64 *input, u64 *output,\n+\t\t\t\t unsigned int len, u64 *iv);\n+void aes_sparc64_ctr_crypt_128(const u64 *key, const u64 *input, u64 *output,\n+\t\t\t       unsigned int len, u64 *iv);\n+void aes_sparc64_ctr_crypt_192(const u64 *key, const u64 *input, u64 *output,\n+\t\t\t       unsigned int len, u64 *iv);\n+void aes_sparc64_ctr_crypt_256(const u64 *key, const u64 *input, u64 *output,\n+\t\t\t       unsigned int len, u64 *iv);\n #endif\n \n /**\n  * aes_preparekey() - Prepare an AES key for encryption and decryption\n  * @key: (output) The key structure to initialize\ndiff --git a/lib/crypto/Kconfig b/lib/crypto/Kconfig\nindex 56a9b4f53b0e..920d96e6b498 100644\n--- a/lib/crypto/Kconfig\n+++ b/lib/crypto/Kconfig\n@@ -18,10 +18,11 @@ config CRYPTO_LIB_AES_ARCH\n \tdefault y if ARM64\n \tdefault y if PPC && (SPE || (PPC64 && VSX))\n \tdefault y if RISCV && 64BIT && TOOLCHAIN_HAS_VECTOR_CRYPTO && \\\n \t\t     RISCV_EFFICIENT_VECTOR_UNALIGNED_ACCESS\n \tdefault y if S390\n+\tdefault y if SPARC64\n \n config CRYPTO_LIB_AESCFB\n \ttristate\n \tselect CRYPTO_LIB_AES\n \tselect CRYPTO_LIB_UTILS\ndiff --git a/lib/crypto/Makefile b/lib/crypto/Makefile\nindex 811b60787dd5..761d52d91f92 100644\n--- a/lib/crypto/Makefile\n+++ b/lib/crypto/Makefile\n@@ -49,10 +49,11 @@ targets += powerpc/aesp8-ppc.S\n OBJECT_FILES_NON_STANDARD_powerpc/aesp8-ppc.o := y\n endif # !CONFIG_SPE\n endif # CONFIG_PPC\n \n libaes-$(CONFIG_RISCV) += riscv/aes-riscv64-zvkned.o\n+libaes-$(CONFIG_SPARC) += sparc/aes_asm.o\n endif # CONFIG_CRYPTO_LIB_AES_ARCH\n \n ################################################################################\n \n obj-$(CONFIG_CRYPTO_LIB_AESCFB)\t\t\t+= libaescfb.o\ndiff --git a/lib/crypto/sparc/aes.h b/lib/crypto/sparc/aes.h\nnew file mode 100644\nindex 000000000000..e354aa507ee0\n--- /dev/null\n+++ b/lib/crypto/sparc/aes.h\n@@ -0,0 +1,149 @@\n+/* SPDX-License-Identifier: GPL-2.0-only */\n+/*\n+ * AES accelerated using the sparc64 aes opcodes\n+ *\n+ * Copyright (C) 2008, Intel Corp.\n+ * Copyright (c) 2010, Intel Corporation.\n+ * Copyright 2026 Google LLC\n+ */\n+\n+#include <asm/fpumacro.h>\n+#include <asm/opcodes.h>\n+#include <asm/pstate.h>\n+#include <asm/elf.h>\n+\n+static __ro_after_init DEFINE_STATIC_KEY_FALSE(have_aes_opcodes);\n+\n+EXPORT_SYMBOL_GPL(aes_sparc64_key_expand);\n+EXPORT_SYMBOL_GPL(aes_sparc64_load_encrypt_keys_128);\n+EXPORT_SYMBOL_GPL(aes_sparc64_load_encrypt_keys_192);\n+EXPORT_SYMBOL_GPL(aes_sparc64_load_encrypt_keys_256);\n+EXPORT_SYMBOL_GPL(aes_sparc64_load_decrypt_keys_128);\n+EXPORT_SYMBOL_GPL(aes_sparc64_load_decrypt_keys_192);\n+EXPORT_SYMBOL_GPL(aes_sparc64_load_decrypt_keys_256);\n+EXPORT_SYMBOL_GPL(aes_sparc64_ecb_encrypt_128);\n+EXPORT_SYMBOL_GPL(aes_sparc64_ecb_encrypt_192);\n+EXPORT_SYMBOL_GPL(aes_sparc64_ecb_encrypt_256);\n+EXPORT_SYMBOL_GPL(aes_sparc64_ecb_decrypt_128);\n+EXPORT_SYMBOL_GPL(aes_sparc64_ecb_decrypt_192);\n+EXPORT_SYMBOL_GPL(aes_sparc64_ecb_decrypt_256);\n+EXPORT_SYMBOL_GPL(aes_sparc64_cbc_encrypt_128);\n+EXPORT_SYMBOL_GPL(aes_sparc64_cbc_encrypt_192);\n+EXPORT_SYMBOL_GPL(aes_sparc64_cbc_encrypt_256);\n+EXPORT_SYMBOL_GPL(aes_sparc64_cbc_decrypt_128);\n+EXPORT_SYMBOL_GPL(aes_sparc64_cbc_decrypt_192);\n+EXPORT_SYMBOL_GPL(aes_sparc64_cbc_decrypt_256);\n+EXPORT_SYMBOL_GPL(aes_sparc64_ctr_crypt_128);\n+EXPORT_SYMBOL_GPL(aes_sparc64_ctr_crypt_192);\n+EXPORT_SYMBOL_GPL(aes_sparc64_ctr_crypt_256);\n+\n+void aes_sparc64_encrypt_128(const u64 *key, const u32 *input, u32 *output);\n+void aes_sparc64_encrypt_192(const u64 *key, const u32 *input, u32 *output);\n+void aes_sparc64_encrypt_256(const u64 *key, const u32 *input, u32 *output);\n+void aes_sparc64_decrypt_128(const u64 *key, const u32 *input, u32 *output);\n+void aes_sparc64_decrypt_192(const u64 *key, const u32 *input, u32 *output);\n+void aes_sparc64_decrypt_256(const u64 *key, const u32 *input, u32 *output);\n+\n+static void aes_preparekey_arch(union aes_enckey_arch *k,\n+\t\t\t\tunion aes_invkey_arch *inv_k,\n+\t\t\t\tconst u8 *in_key, int key_len, int nrounds)\n+{\n+\tif (static_branch_likely(&have_aes_opcodes)) {\n+\t\tu32 aligned_key[AES_MAX_KEY_SIZE / 4];\n+\n+\t\tif (IS_ALIGNED((uintptr_t)in_key, 4)) {\n+\t\t\taes_sparc64_key_expand((const u32 *)in_key,\n+\t\t\t\t\t       k->sparc_rndkeys, key_len);\n+\t\t} else {\n+\t\t\tmemcpy(aligned_key, in_key, key_len);\n+\t\t\taes_sparc64_key_expand(aligned_key,\n+\t\t\t\t\t       k->sparc_rndkeys, key_len);\n+\t\t\tmemzero_explicit(aligned_key, key_len);\n+\t\t}\n+\t\t/*\n+\t\t * Note that nothing needs to be written to inv_k (if it's\n+\t\t * non-NULL) here, since the SPARC64 assembly code uses\n+\t\t * k->sparc_rndkeys for both encryption and decryption.\n+\t\t */\n+\t} else {\n+\t\taes_expandkey_generic(k->rndkeys,\n+\t\t\t\t      inv_k ? inv_k->inv_rndkeys : NULL,\n+\t\t\t\t      in_key, key_len);\n+\t}\n+}\n+\n+static void aes_sparc64_encrypt(const struct aes_enckey *key,\n+\t\t\t\tconst u32 *input, u32 *output)\n+{\n+\tif (key->len == AES_KEYSIZE_128)\n+\t\taes_sparc64_encrypt_128(key->k.sparc_rndkeys, input, output);\n+\telse if (key->len == AES_KEYSIZE_192)\n+\t\taes_sparc64_encrypt_192(key->k.sparc_rndkeys, input, output);\n+\telse\n+\t\taes_sparc64_encrypt_256(key->k.sparc_rndkeys, input, output);\n+}\n+\n+static void aes_encrypt_arch(const struct aes_enckey *key,\n+\t\t\t     u8 out[AES_BLOCK_SIZE],\n+\t\t\t     const u8 in[AES_BLOCK_SIZE])\n+{\n+\tu32 bounce_buf[AES_BLOCK_SIZE / 4];\n+\n+\tif (static_branch_likely(&have_aes_opcodes)) {\n+\t\tif (IS_ALIGNED((uintptr_t)in | (uintptr_t)out, 4)) {\n+\t\t\taes_sparc64_encrypt(key, (const u32 *)in, (u32 *)out);\n+\t\t} else {\n+\t\t\tmemcpy(bounce_buf, in, AES_BLOCK_SIZE);\n+\t\t\taes_sparc64_encrypt(key, bounce_buf, bounce_buf);\n+\t\t\tmemcpy(out, bounce_buf, AES_BLOCK_SIZE);\n+\t\t}\n+\t} else {\n+\t\taes_encrypt_generic(key->k.rndkeys, key->nrounds, out, in);\n+\t}\n+}\n+\n+static void aes_sparc64_decrypt(const struct aes_key *key,\n+\t\t\t\tconst u32 *input, u32 *output)\n+{\n+\tif (key->len == AES_KEYSIZE_128)\n+\t\taes_sparc64_decrypt_128(key->k.sparc_rndkeys, input, output);\n+\telse if (key->len == AES_KEYSIZE_192)\n+\t\taes_sparc64_decrypt_192(key->k.sparc_rndkeys, input, output);\n+\telse\n+\t\taes_sparc64_decrypt_256(key->k.sparc_rndkeys, input, output);\n+}\n+\n+static void aes_decrypt_arch(const struct aes_key *key,\n+\t\t\t     u8 out[AES_BLOCK_SIZE],\n+\t\t\t     const u8 in[AES_BLOCK_SIZE])\n+{\n+\tu32 bounce_buf[AES_BLOCK_SIZE / 4];\n+\n+\tif (static_branch_likely(&have_aes_opcodes)) {\n+\t\tif (IS_ALIGNED((uintptr_t)in | (uintptr_t)out, 4)) {\n+\t\t\taes_sparc64_decrypt(key, (const u32 *)in, (u32 *)out);\n+\t\t} else {\n+\t\t\tmemcpy(bounce_buf, in, AES_BLOCK_SIZE);\n+\t\t\taes_sparc64_decrypt(key, bounce_buf, bounce_buf);\n+\t\t\tmemcpy(out, bounce_buf, AES_BLOCK_SIZE);\n+\t\t}\n+\t} else {\n+\t\taes_decrypt_generic(key->inv_k.inv_rndkeys, key->nrounds,\n+\t\t\t\t    out, in);\n+\t}\n+}\n+\n+#define aes_mod_init_arch aes_mod_init_arch\n+static void aes_mod_init_arch(void)\n+{\n+\tunsigned long cfr;\n+\n+\tif (!(sparc64_elf_hwcap & HWCAP_SPARC_CRYPTO))\n+\t\treturn;\n+\n+\t__asm__ __volatile__(\"rd %%asr26, %0\" : \"=r\" (cfr));\n+\tif (!(cfr & CFR_AES))\n+\t\treturn;\n+\n+\tstatic_branch_enable(&have_aes_opcodes);\n+}\ndiff --git a/arch/sparc/crypto/aes_asm.S b/lib/crypto/sparc/aes_asm.S\nsimilarity index 100%\nrename from arch/sparc/crypto/aes_asm.S\nrename to lib/crypto/sparc/aes_asm.S\n",
    "prefixes": [
        "v2",
        "16/35"
    ]
}