From patchwork Tue Sep 23 04:42:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Behan Webster X-Patchwork-Id: 37719 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 423B1202A1 for ; Tue, 23 Sep 2014 04:46:06 +0000 (UTC) Received: by mail-wg0-f70.google.com with SMTP id a1sf2126538wgh.9 for ; Mon, 22 Sep 2014 21:46:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type :content-transfer-encoding; bh=ZIsPTXQX38ZyLvg9+1hgEJ/KxE/BVp0nQBH6WGtXjbY=; b=ci8vKrheTCjh7MnGJqQh0FrMspXrQmcARdKdDOQyp0tJIy4bE6WDOoSzLCDQMyaRf1 CqZr4z2gSrQWZm651hCQQZiW5V7Hpc6xa9jx0wVlYlweg6mOTTREoukbpstWt+KY0PFC Q80Bjf0kWxJOzYRCOGNib85lHZhHbITraqdWyLUx1txc9GbmriAUO2r0qW8SCdC6K7i+ 4SX1JXLBaZONZKgmme53+CoQF4BCBsuRM6QmODWs4u8ErlfYyHg5s5luegFFShgreBJJ 6L9nIcfmsdya6TzSwwx0CYrjq6NIFhBd8QwMLcFXn7C0gCDSkkyG6Gy+FAOdOnuq9PI+ sSuA== X-Gm-Message-State: ALoCoQn/6or2D/nJUqxzLmPnaUgYCsBcI82TCFvfNVTuEeUowz/Qh5MU+/PCd5PsXPWECQP2gGFJ X-Received: by 10.180.88.8 with SMTP id bc8mr62255wib.0.1411447565488; Mon, 22 Sep 2014 21:46:05 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.18.133 with SMTP id w5ls4722lad.24.gmail; Mon, 22 Sep 2014 21:46:05 -0700 (PDT) X-Received: by 10.112.150.194 with SMTP id uk2mr648264lbb.97.1411447565001; Mon, 22 Sep 2014 21:46:05 -0700 (PDT) Received: from mail-lb0-x22f.google.com (mail-lb0-x22f.google.com [2a00:1450:4010:c04::22f]) by mx.google.com with ESMTPS id am7si16921041lac.74.2014.09.22.21.46.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Sep 2014 21:46:04 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22f as permitted sender) client-ip=2a00:1450:4010:c04::22f; Received: by mail-lb0-f175.google.com with SMTP id w7so2304983lbi.6 for ; Mon, 22 Sep 2014 21:46:04 -0700 (PDT) X-Received: by 10.112.62.200 with SMTP id a8mr28048668lbs.34.1411447564768; Mon, 22 Sep 2014 21:46:04 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp352286lbb; Mon, 22 Sep 2014 21:46:03 -0700 (PDT) X-Received: by 10.70.94.3 with SMTP id cy3mr36624759pdb.114.1411447562477; Mon, 22 Sep 2014 21:46:02 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id id5si18517222pbc.71.2014.09.22.21.46.01 for ; Mon, 22 Sep 2014 21:46:02 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753786AbaIWEnK (ORCPT + 27 others); Tue, 23 Sep 2014 00:43:10 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:58547 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753080AbaIWEmr (ORCPT ); Tue, 23 Sep 2014 00:42:47 -0400 Received: by mail-pa0-f50.google.com with SMTP id rd3so4676631pab.9 for ; Mon, 22 Sep 2014 21:42:46 -0700 (PDT) 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-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Original-Sender: behanw@converseincode.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::22f as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=neutral (body hash did not verify) header.i=@ Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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,