Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 10 Oct 2017 16:15:01 -0700
From: Linus Torvalds <>
To: "Tobin C. Harding" <>
Cc: "" <>, 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

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.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.