From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753804AbbK3Pvw (ORCPT ); Mon, 30 Nov 2015 10:51:52 -0500 Received: from www.sr71.net ([198.145.64.142]:55487 "EHLO blackbird.sr71.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752297AbbK3Pvu (ORCPT ); Mon, 30 Nov 2015 10:51:50 -0500 Subject: Re: [PATCH 17/37] x86, pkeys: add functions to fetch PKRU To: Thomas Gleixner References: <20151117033511.BFFA1440@viggo.jf.intel.com> <20151117033534.75F03664@viggo.jf.intel.com> Cc: linux-kernel@vger.kernel.org, x86@kernel.org, dave.hansen@linux.intel.com From: Dave Hansen Message-ID: <565C7094.8070706@sr71.net> Date: Mon, 30 Nov 2015 07:51:48 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/27/2015 01:51 AM, Thomas Gleixner wrote: > On Mon, 16 Nov 2015, Dave Hansen wrote: >> +#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS >> +static inline u32 __read_pkru(void) >> +{ >> + unsigned int eax, edx; >> + unsigned int ecx = 0; >> + unsigned int pkru; >> + >> + asm volatile(".byte 0x0f,0x01,0xee\n\t" >> + : "=a" (eax), "=d" (edx) >> + : "c" (ecx)); >> + pkru = eax; >> + return pkru; > > Wouldn't a simple 'return eax;' be sufficient? Yes. I wanted to make it clear that EAX specifically was where the data we want was ending up. But, I guess the "=a" does that equally well. I'll fix it up. Also, looking at this, it also deserves a mention that this is the "rdpkru" instruction. Otherwise, it's hard to figure out what instruction this is.