From patchwork Thu Aug 13 03:25:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 247648 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp924743ilo; Wed, 12 Aug 2020 20:25:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQ4GFcfUzrGhc3V9lXcHCwd32uSlrEILDLsfUYakSBzD2KQPtcMn42Pm6/pxEUGefz1YHo X-Received: by 2002:a25:d7d8:: with SMTP id o207mr3674708ybg.409.1597289157041; Wed, 12 Aug 2020 20:25:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597289157; cv=none; d=google.com; s=arc-20160816; b=paVbZ4xT9lJ2P2dENpJ8g/Jeudje+gQiqHkBdS3cN2eNTdWEno63V283suOLMzA8Kq xKFjvJzMqD4ZW38EcEaKFb19Rhcmj1y8lHBmUqD6EuauZQhy6H+9DLry7M4zvPE558Pm jKuqsnsGsuLDzQRIlIs0LOB8rNYetqWQ5HgT+cPxrN06lNhXFGG9avxG28G847Y9qkAz Thma8BXEqaXSwwHbK33NsDBKcJOvEB19i2ePcA9ezc1f3O8XWSWSMRjjqHcnaRKglLHp FBqGQlFQAUBM9dT3E/eLHFlc0kAwpIzhsAzn/PaUw8R4Dk3PunSPaeBY+vJX0RebOZzS tZvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature; bh=yxz0Qaq8AtWOwY+U8QGeL50oM68x15zE4/mb/u2JmxM=; b=DNpmWZBmxBIDBr+1FddRB+yHZB5N4sMmakg2ZA91EuE+TYXpHASs33ZQZ83B40Yj10 doT4LzfjgXmXUg5fsaXCO9WRhmSfBVIjcKjh47gOrv5KnCBR2XqJFaYIJBs8t9JYAvSd Be200+KuJ3EWJZHKfKO2UK/K1JTkuynARfXd7bS2Vca/ibM7C7aBjQ9HwqygLtCzlU1Q Qiru4gyf+h+f2LGIYAT0hp1aqt+IifcLAgEo3bouH9BHAzj0vK8N/ADe56OrfxaftZXc iloDTaR3m/AJCfwOihmoyNT1AOsmkGbuMCY+nm+Fcf1wIpgP/r0YbDa1Gex7/fi9kO5e SJBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nSUl9UQ6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a16si4547225ybp.422.2020.08.12.20.25.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Aug 2020 20:25:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nSUl9UQ6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k63sK-0004jU-Di for patch@linaro.org; Wed, 12 Aug 2020 23:25:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k63s8-0004jD-7K for qemu-devel@nongnu.org; Wed, 12 Aug 2020 23:25:44 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:45954) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k63s6-0008U5-DE for qemu-devel@nongnu.org; Wed, 12 Aug 2020 23:25:43 -0400 Received: by mail-pg1-x52a.google.com with SMTP id x6so2105180pgx.12 for ; Wed, 12 Aug 2020 20:25:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yxz0Qaq8AtWOwY+U8QGeL50oM68x15zE4/mb/u2JmxM=; b=nSUl9UQ6D2fBmAgkjE41IS+JnJB31/alks/tKSd4wU2aeKaO/faqT9UIcI5JN4Qvyi /3y47bGOfD3AGWeWuCvgUAyEcneJ1gAvqed4TLRWvyKBJX6Z2oUvKcssotUc9kZAunSf 0mqptATD6bGlSmL/U207WSIOKMypoHlOkqGo3SMWwmjbGZKVhNVnRHgcS61OUcv/JYbw IJAL8oySIE1pORETuVbjnSoI6jTAitQ1LiyOr6n1uNpBEkdIUVDabE/wU9W4UroEUUgM 6TyXGV3860MNnxBnx2PDS/iEtkPVVvXmRaDQT+Yof9l0ejfFMXJrmMQGfvk5MUuuqcbr vkyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yxz0Qaq8AtWOwY+U8QGeL50oM68x15zE4/mb/u2JmxM=; b=C2Jj2IeTUBq1m3OKXdiGHN/a0igIU/WYFYtrO/6b3UFDTd7AKbvMW/K3dso1pDg0Gk JtW8uxayVeU7RrPYaop1moPPl1a4YtMdJginIzXXNJ/ri+ZCFz/GHJ0kx1NkSDtT3VJo A7gQkVvE56SLCscdY4WJLTeqUeAeYz72npSEqI8Ksu6xwogxT21CREwlm0r96IUPpS9M Nj75Ha7B2cccvIoy+Y/OqNj4xWtNk9A6sO0AbXzFQ+9+9uk+m86lXwLmsejYCOEMRhSz gI9p4qx4eqae3keJ8toXt6O6lEHjfOgHzhPYVvF7XY7btlRrDGbjxgEOMzS8cvxdaLL+ p43A== X-Gm-Message-State: AOAM531WjDCtQAk0E+gOjd9+e0+pZSJxtHsUM9e1NtkSYft8ZJNOiWKB XhO18Ryfws0qJcNVtXs5rbOLqHnOHCc= X-Received: by 2002:a62:d10a:: with SMTP id z10mr2562130pfg.7.1597289140335; Wed, 12 Aug 2020 20:25:40 -0700 (PDT) Received: from localhost.localdomain ([71.212.141.89]) by smtp.gmail.com with ESMTPSA id m19sm3633164pgd.21.2020.08.12.20.25.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2020 20:25:39 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 00/17] crypto/cipher: Class hierarchy cleanups Date: Wed, 12 Aug 2020 20:25:20 -0700 Message-Id: <20200813032537.2888593-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: berrange@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Mostly this is intended to cleanup the class hierarchy used for the ciphers. We currently have multiple levels of dispatch, and multiple separate allocations. The final patches rearrange this to one level of indirect call, and all memory allocated contiguously. But on the way there are a number of other misc cleanups. I know those final patches are somewhat big, but I don't immediately see how to split them apart. I noticed this while profiling patches to make ARM PAUTH use the crypto subsystem. The qcrypto_cipher_* dispatch routines were consuming a noticeable portion of the runtime, and with these changes they were down below 1% where they ought to be. While I did not continue with PAUTH using AES, I still think these are good cleanups. r~ Richard Henderson (17): crypto: Move QCryptoCipher typedef to qemu/typedefs.h crypto: Move QCryptoCipherDriver typedef to qemu/typedefs.h crypto: Assume blocksize is a power of 2 crypto: Rename cipher include files to .inc.c crypto: Remove redundant includes crypto/nettle: Fix xts_encrypt arguments crypto: Use the correct const type for driver crypto: Allocate QCryptoCipher with the subclass crypto: Move cipher->driver init to qcrypto_*_cipher_ctx_new crypto: Constify cipher data tables crypto/builtin: Remove odd-sized AES block handling crypto/builtin: Merge qcrypto_cipher_aes_{ecb,xts}_{en,de}crypt crypto/builtin: Move AES_cbc_encrypt into cipher-builtin.inc.c crypto/builtin: Split and simplify AES_encrypt_cbc crypto/builtin: Split QCryptoCipherBuiltin into subclasses crypto/nettle: Split QCryptoCipherNettle into subclasses crypto/gcrypt: Split QCryptoCipherGcrypt into subclasses crypto/afalgpriv.h | 3 + crypto/cipherpriv.h | 6 +- include/crypto/aes.h | 4 - include/crypto/cipher.h | 5 +- include/qemu/typedefs.h | 2 + crypto/aes.c | 51 -- crypto/cipher-afalg.c | 25 +- crypto/cipher-builtin.c | 532 ------------ crypto/cipher-builtin.inc.c | 425 ++++++++++ .../{cipher-gcrypt.c => cipher-gcrypt.inc.c} | 522 ++++++------ crypto/cipher-nettle.c | 733 ----------------- crypto/cipher-nettle.inc.c | 756 ++++++++++++++++++ crypto/cipher.c | 44 +- 13 files changed, 1477 insertions(+), 1631 deletions(-) delete mode 100644 crypto/cipher-builtin.c create mode 100644 crypto/cipher-builtin.inc.c rename crypto/{cipher-gcrypt.c => cipher-gcrypt.inc.c} (51%) delete mode 100644 crypto/cipher-nettle.c create mode 100644 crypto/cipher-nettle.inc.c -- 2.25.1 Tested-by: Philippe Mathieu-Daudé