From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756673AbdJJXcO (ORCPT ); Tue, 10 Oct 2017 19:32:14 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:36887 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751858AbdJJXcN (ORCPT ); Tue, 10 Oct 2017 19:32:13 -0400 X-ME-Sender: X-Sasl-enc: aTqZ2nsJLaP9px2veykXmS4VuWSQ2sMIYUR3OVjlZeYY 1507678331 Date: Wed, 11 Oct 2017 10:32:09 +1100 From: "Tobin C. Harding" To: 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 , Joe Perches , Ian Campbell , Sergey Senozhatsky , Catalin Marinas , Will Deacon , Steven Rostedt , Chris Fries , Dave Weinstein , Daniel Micay , Djalal Harouni Subject: Re: [PATCH 0/3] add %pX specifier Message-ID: <20171010233209.GB2049@eros> References: <1507676974-1298-1-git-send-email-me@tobin.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailer: Mutt 1.5.24 (2015-08-30) User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Tobin.