From patchwork Mon Oct 8 21:15:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 148444 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp4125240lji; Mon, 8 Oct 2018 14:16:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV61mYLj8vh933IiXlzG1XFpATy6I7QnnY8Mi8y30zAnOe+LoVI03kWc5Uyp82/7+h9kyVTa2 X-Received: by 2002:a63:df06:: with SMTP id u6-v6mr22717572pgg.202.1539033368727; Mon, 08 Oct 2018 14:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539033368; cv=none; d=google.com; s=arc-20160816; b=NwNz7Lo6ybNj0m9Qni8a2sl4UcGlxGIC2Yb9L+opocAkoXBcVFSgXelY8rZSmpLaXn STi9CSjISlEKqT5XCL5Q1HoW7TckC97LB+MDRB7jjoJ/jYLmmGzOL+bXBRDPGheYnGMQ zTzTNJBHrQmeNmiBPxBjg75/C+EuLDrwGRDVfXHJp2VY4qBQtmXF64PLE57bvFrGEdnH FzaBVUaS0wDjYyroPMCmV1QI4M+3zksqVgY2YN3oSdTPp3dLeQOYBCBQe5bfdJg30bpK UJCov2X0QD3xGIO2zpKwvWteeCYfVxzwFwLyQR+EnqthEMTEmkqgXiOqsN1fuNsRHHcQ 0MOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=6AEmz2gjqxTLKt66e1B0JcsyXdkYIAAMgpbrOLsF0V4=; b=Gzc/8DwSjBPaQImG5lEFCK7h8lvl82aaUaw6Ptwq2rMtDbXzXUkqf/kyWAP4ymn5/O yVrW2bNht5rdKihLk+tBJjKNtye1uFHJc5oogw1aIED3VcGEeMiwTt8H+5L4M2MC/LKc hLlhXrNeZit7yj1Rgf+YyzWG8AkKM5xR4eEEfshJqTJQQi30H6HXMkElrpds9HOQ49U5 Vk4gYGtGBfS/c2NUrQLcCmuJlinB+21speia3R9lG3Fw0bCThCrcMhOn48Ucs1D0FtMq FY/iPNXuu6UQGZFZ5QDEjbXFdWpqfoodlSJnHij98NQee8P5COMY3HQioNxK8OErC0ZQ 19dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WMhxLxyC; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w4-v6si18552811pll.214.2018.10.08.14.16.08; Mon, 08 Oct 2018 14:16:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WMhxLxyC; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726522AbeJIE3s (ORCPT + 2 others); Tue, 9 Oct 2018 00:29:48 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:38043 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725828AbeJIE3s (ORCPT ); Tue, 9 Oct 2018 00:29:48 -0400 Received: by mail-wm1-f67.google.com with SMTP id 193-v6so9571796wme.3 for ; Mon, 08 Oct 2018 14:16:06 -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; bh=6AEmz2gjqxTLKt66e1B0JcsyXdkYIAAMgpbrOLsF0V4=; b=WMhxLxyCTjF1aA8e7XRJgqBeB8j/lc+lVBFA59fYDlLzica8KxSkdJL+1nNx3z+4O+ pYjvaQ/dzenOGrBZLJ6uej2lAtIelviwbHfK1fd+HtE1mbJLaYG6U48MQmLPZK+Jl2zg 2mC5FP8qeMjcBcn+u2HD1hDJyOgbiPu8TQZbI= 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; bh=6AEmz2gjqxTLKt66e1B0JcsyXdkYIAAMgpbrOLsF0V4=; b=NamnDSkwX9NIwDgswrHZofmMWvr6S91quYHy+RE5nYi6X9XOhDpEMJPHyy5g74OhtG 1yjQHLbA4MVbpw2BA8xQMXrXbb8wghSgjuQKXADcNlQ0DQqf1VSZWBaGFNEfPl6c8GS/ /ZjDkXcLd/CwF7YeWPyXesCK8m1zqqegpCcJrM4qrneYZ5QKAPYgdCQBoQnoRSL1zKLJ 1kqo2cGXYdtQYWVRAaIBMrjJ+LqyKwnuw9ENxQwZJHwlIO9iOxFKM5neMvgc9CxbJ4hC WcpFlzu6Tp3SZNcmuyUFMW3z0e0J0obA3pmmrIgxH+qvi83eHJVGsSnkIK8jj/bm+2qj Bbhg== X-Gm-Message-State: ABuFfogNL8aaLyOCs2h28dCkFXyyekncYzvDN/iIgI83h0AywSVDfgNj jfv5U2sMKW3PrP3j31rdQn3YL2g1x1A= X-Received: by 2002:a1c:6504:: with SMTP id z4-v6mr15660124wmb.130.1539033365141; Mon, 08 Oct 2018 14:16:05 -0700 (PDT) Received: from localhost.localdomain ([2a01:cb1d:112:6f00:8084:9715:d038:c67d]) by smtp.gmail.com with ESMTPSA id s24-v6sm7563308wmc.7.2018.10.08.14.16.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 14:16:03 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, arnd@arndb.de, jason@zx2c4.com, ebiggers@google.com, linux-arm-kernel@lists.infradead.org, Ard Biesheuvel Subject: [PATCH 0/3] crypto: use unaligned accessors in aligned fast paths Date: Mon, 8 Oct 2018 23:15:51 +0200 Message-Id: <20181008211554.5355-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS behaves a bit counterintuitively on ARM: we set it for architecture revisions v6 and up, which support any alignment for load/store instructions that operate on bytes, half words or words. However, load/store double word and load store multiple instructions still require 32-bit alignment, and using them on unaligned quantities results in costly alignment traps that have to be fixed up by the kernel's fixup code. Fortunately, the unaligned accessors do the right thing here: on architectures that really tolerate any misalignment, they simply resolve to the aligned accessors, while on ARMv6+ (which uses the packed struct wrappers for unaligned accesses), they result in load/store sequences that avoid the instructions that require 32-bit alignment. Since there is not really a downside to using the unaligned accessors on aligned paths for architectures other than ARM that define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS, let's switch to them in a couple of places in the crypto code. Note that all patches are against code that has been observed to be emitted with ldm or ldrd instructions when building ARM's multi_v7_defconfig. Ard Biesheuvel (3): crypto: memneq - use unaligned accessors for aligned fast path crypto: crypto_xor - use unaligned accessors for aligned fast path crypto: siphash - drop _aligned variants crypto/algapi.c | 7 +- crypto/memneq.c | 24 +++-- include/crypto/algapi.h | 11 +- include/linux/siphash.h | 106 +++++++++----------- lib/siphash.c | 103 ++----------------- 5 files changed, 83 insertions(+), 168 deletions(-) -- 2.11.0