From patchwork Tue Sep 23 04:42:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 4952931 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3FC62BEEA5 for ; Tue, 23 Sep 2014 04:43:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 583DD201FA for ; Tue, 23 Sep 2014 04:43:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 17138201C0 for ; Tue, 23 Sep 2014 04:43:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753520AbaIWEnE (ORCPT ); Tue, 23 Sep 2014 00:43:04 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:58002 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753005AbaIWEmr (ORCPT ); Tue, 23 Sep 2014 00:42:47 -0400 Received: by mail-pd0-f176.google.com with SMTP id z10so4391402pdj.35 for ; Mon, 22 Sep 2014 21:42:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=converseincode.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=2W5SndzWr9ldVdQ/ryqTvROZnm3T4X4vr5vOGs39qAY=; b=H0IajpdktMUdxA/PnB/8JyM5qt75Jtk7kEwIO7nODUGxhZ0lr3VG3Sk6saUnG1SM3U Cjk9apfPvTqogbQETmKG6txQA+tCpFeiBiVkhU6pQtiPauDYk4EgF6DMXY3wxsfuJKq4 vUmKKIFjeDdyQQC+c/+QrJVEkAwUfX+HQYxtI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=2W5SndzWr9ldVdQ/ryqTvROZnm3T4X4vr5vOGs39qAY=; b=LA1GJz6L5PLFjYrL0OxlybSMjAvuYA7Vj4TjsdmveCr+wTAWRb1YTfS88pCU5SQa/V 0dxoSbbGklfbLCEa8Nqu8Jnw75vFcNKYxRYuehKvFCDnCF0bI9v2DJ4i0qCbC6OT6r2q WIiHi6RFT13tPoBlpmWCZM+bm0ovq2iICk5fnRJDuug6YNx5QqD1vyHqfjEmxBEUoM7c s5NNVu0pA9JKNG6u+YVQYd1/xc/GMa8J0WB68ztnKSulARFPmeySBlOx4by+gtdHGtGj TQXOwIIPR4Pqs1tNUQFe4wt2FBL5rrXFKN5qYzMXYHZRmkiYwifNEbTJ7618aned0v3B pZiw== X-Gm-Message-State: ALoCoQmoLfAhawzrzSxdAZGhB4TkEbfJ7aSLFbVFB/Ep5/Q1jqiiudzxyxohX2219Q8USXHZwpWA X-Received: by 10.70.130.228 with SMTP id oh4mr21178816pdb.54.1411447366280; Mon, 22 Sep 2014 21:42:46 -0700 (PDT) Received: from galdor.websterwood.com (S0106dc9fdb80cffd.gv.shawcable.net. [96.50.97.138]) by mx.google.com with ESMTPSA id j13sm10774808pbq.42.2014.09.22.21.42.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 22 Sep 2014 21:42:45 -0700 (PDT) From: behanw@converseincode.com To: agk@redhat.com, clm@fb.com, davem@davemloft.net, dm-devel@redhat.com, fabf@skynet.be, herbert@gondor.apana.org.au, jbacik@fb.com, snitzer@redhat.com, tadeusz.struk@intel.com Cc: akpm@linux-foundation.org, bruce.w.allan@intel.com, d.kasatkin@samsung.com, james.l.morris@oracle.com, john.griffin@intel.com, linux-btrfs@vger.kernel.org, linux-crypto@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, linux-ima-user@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, linux-security-module@vger.kernel.org, neilb@suse.de, qat-linux@intel.com, serge@hallyn.com, thomas.lendacky@amd.com, zohar@linux.vnet.ibm.com, torvalds@linux-foundation.org, Behan Webster , =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH v4 01/12] crypto: LLVMLinux: Add macro to remove use of VLAIS in crypto code Date: Mon, 22 Sep 2014 21:42:06 -0700 Message-Id: <1411447337-22362-2-git-send-email-behanw@converseincode.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411447337-22362-1-git-send-email-behanw@converseincode.com> References: <1411447337-22362-1-git-send-email-behanw@converseincode.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Behan Webster Add a macro which replaces the use of a Variable Length Array In Struct (VLAIS) with a C99 compliant equivalent. This macro instead allocates the appropriate amount of memory using an char array. The new code can be compiled with both gcc and clang. struct shash_desc contains a flexible array member member ctx declared with CRYPTO_MINALIGN_ATTR, so sizeof(struct shash_desc) aligns the beginning of the array declared after struct shash_desc with long long. No trailing padding is required because it is not a struct type that can be used in an array. The CRYPTO_MINALIGN_ATTR is required so that desc is aligned with long long as would be the case for a struct containing a member with CRYPTO_MINALIGN_ATTR. If you want to get to the ctx at the end of the shash_desc as before you can do so using shash_desc_ctx(shash) Signed-off-by: Behan Webster Reviewed-by: Mark Charlebois Acked-by: Herbert Xu Cc: Micha? Miros?aw --- include/crypto/hash.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/crypto/hash.h b/include/crypto/hash.h index a391955..74b13ec 100644 --- a/include/crypto/hash.h +++ b/include/crypto/hash.h @@ -58,6 +58,11 @@ struct shash_desc { void *__ctx[] CRYPTO_MINALIGN_ATTR; }; +#define SHASH_DESC_ON_STACK(shash, ctx) \ + char __##shash##_desc[sizeof(struct shash_desc) + \ + crypto_shash_descsize(ctx)] CRYPTO_MINALIGN_ATTR; \ + struct shash_desc *shash = (struct shash_desc *)__##shash##_desc + struct shash_alg { int (*init)(struct shash_desc *desc); int (*update)(struct shash_desc *desc, const u8 *data,