From owner-freebsd-current@FreeBSD.ORG Fri Jun 11 16:21:20 2010 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 03B171065679 for ; Fri, 11 Jun 2010 16:21:20 +0000 (UTC) (envelope-from uqs@spoerlein.net) Received: from acme.spoerlein.net (acme.spoerlein.net [IPv6:2001:470:9a47::1]) by mx1.freebsd.org (Postfix) with ESMTP id 8D64E8FC17 for ; Fri, 11 Jun 2010 16:21:19 +0000 (UTC) Received: from acme.spoerlein.net (localhost.spoerlein.net [IPv6:::1]) by acme.spoerlein.net (8.14.4/8.14.4) with ESMTP id o5BGLIK7036669 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 11 Jun 2010 18:21:18 +0200 (CEST) (envelope-from uqs@spoerlein.net) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=spoerlein.net; s=dkim200908; t=1276273278; bh=w60hn2gFTZ91UNQ9TTJKQd6Hl021rLwAs/TJdU7EeZ4=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type; b=VghzMGdYayhz+SZsoyp3944rCN+kXW8Dfgd197bENCareiU4OvkdspQjvV4DPQfYw zzWpe1HwTbF1drgzLE/4TQ22B/BOSH32MWnbuVpxmGyja2PVRoo1S/Rg1VWj7DKpaH k4W8BeA1mPF8lAdeTDQS9EQOI9MtM8eL82Laluyo= Received: (from uqs@localhost) by acme.spoerlein.net (8.14.4/8.14.4/Submit) id o5BGLIbS036668 for current@freebsd.org; Fri, 11 Jun 2010 18:21:18 +0200 (CEST) (envelope-from uqs@spoerlein.net) Date: Fri, 11 Jun 2010 18:21:18 +0200 From: Ulrich =?utf-8?B?U3DDtnJsZWlu?= To: current@freebsd.org Message-ID: <20100611162118.GR39829@acme.spoerlein.net> Mail-Followup-To: current@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Cc: Subject: Cleanup for cryptographic algorithms vs. compiler optimizations X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Jun 2010 16:21:20 -0000 Hello, optimizing compilers have a tendency to remove assignments that have no side effects. The code in sys/crypto/sha2/sha2.c is doing a lot of zeroing variables, which is however optimized away. I haven't looked close enough to see if all these vars happen to fit into the registers, but a nice overview can be had here: https://www.spoerlein.net/scan-build/freebsd-head/sbin.gbde/2010-06-05-1/ Compiling the code with/without those assignment results in the same object code. Is there a canonical way to zero those variables and should we use them (memset perhaps? what are the performance implications?) Regards, Uli