From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756861AbdJKD1W (ORCPT ); Tue, 10 Oct 2017 23:27:22 -0400 Received: from smtprelay0172.hostedemail.com ([216.40.44.172]:59809 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751952AbdJKD1U (ORCPT ); Tue, 10 Oct 2017 23:27:20 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2553:2559:2562:2692:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3871:3872:3874:4321:4605:5007:6119:6742:6743:7903:9040:10004:10400:10848:11232:11658:11914:12740:12760:12895:13069:13311:13357:13439:14096:14097:14181:14659:14721:21080:21451:21627:30012:30054:30060:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: dress32_3f86e095bd555 X-Filterd-Recvd-Size: 2727 Message-ID: <1507692434.3552.41.camel@perches.com> Subject: Re: [PATCH 0/3] add %pX specifier From: Joe Perches To: "Tobin C. Harding" , Linus Torvalds Cc: "kernel-hardening@lists.openwall.com" , KVM list , Linux Kernel Mailing List , Kees Cook , Paolo Bonzini , Tycho Andersen , "Roberts, William C" , Tejun Heo , Jordan Glover , Greg KH , Petr Mladek , Ian Campbell , Sergey Senozhatsky , Catalin Marinas , Will Deacon , Steven Rostedt , Chris Fries , Dave Weinstein , Daniel Micay , Djalal Harouni Date: Tue, 10 Oct 2017 20:27:14 -0700 In-Reply-To: <20171010233209.GB2049@eros> References: <1507676974-1298-1-git-send-email-me@tobin.cc> <20171010233209.GB2049@eros> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2017-10-11 at 10:32 +1100, Tobin C. Harding wrote: > On Tue, Oct 10, 2017 at 04:15:01PM -0700, Linus Torvalds wrote: > > On Tue, Oct 10, 2017 at 4:09 PM, Tobin C. Harding wrote: > > > > > > I did not understand the code (specifically why the right shift of 16 twice?) > > > > It's a traditional trick to get the upper 32 bits. > > > > So it basically splits the (possibly 64-bit) pointer into the lower 32 > > bits and the upper 32 bits for a hash such as "jhash()" that takes > > data that is "unsigned int". > > > > (NOTE! Using jhash here is not acceptable, since it's not > > cryptographically safe, but think of it as an example of a hash that > > takes 32-bit input). > > > > Doing ">> 32" is undefined on 32-bit architectures, and wouldn't work. > > > > But doing >> 16 >> 16 is a fine way to say "shift right by 32 on a > > 64-bit architecture" while also being well-defined on a 32-bit one. > > > > Linus > > Awesome, thanks. Another way is using the upper_32_bits() macro. It's perhaps a bit more readable.