Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760189AbdLRSyk (ORCPT ); Mon, 18 Dec 2017 13:54:40 -0500 Received: from mga01.intel.com ([192.55.52.88]:31295 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758525AbdLRSyc (ORCPT ); Mon, 18 Dec 2017 13:54:32 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,423,1508828400"; d="scan'208";a="159847321" Subject: Re: [PATCH v9 29/51] mm/mprotect, powerpc/mm/pkeys, x86/mm/pkeys: Add sysfs interface To: Ram Pai , mpe@ellerman.id.au, mingo@redhat.com, akpm@linux-foundation.org, corbet@lwn.net, arnd@arndb.de References: <1509958663-18737-1-git-send-email-linuxram@us.ibm.com> <1509958663-18737-30-git-send-email-linuxram@us.ibm.com> Cc: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, benh@kernel.crashing.org, paulus@samba.org, khandual@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com, bsingharora@gmail.com, hbabu@us.ibm.com, mhocko@kernel.org, bauerman@linux.vnet.ibm.com, ebiederm@xmission.com From: Dave Hansen Message-ID: Date: Mon, 18 Dec 2017 10:54:26 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <1509958663-18737-30-git-send-email-linuxram@us.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1467 Lines: 30 On 11/06/2017 12:57 AM, Ram Pai wrote: > Expose useful information for programs using memory protection keys. > Provide implementation for powerpc and x86. > > On a powerpc system with pkeys support, here is what is shown: > > $ head /sys/kernel/mm/protection_keys/* > ==> /sys/kernel/mm/protection_keys/disable_access_supported <== > true This is cute, but I don't think it should be part of the ABI. Put it in debugfs if you want it for cute tests. The stuff that this tells you can and should come from pkey_alloc() for the ABI. http://man7.org/linux/man-pages/man7/pkeys.7.html > Any application wanting to use protection keys needs to be able to > function without them. They might be unavailable because the > hardware that the application runs on does not support them, the > kernel code does not contain support, the kernel support has been > disabled, or because the keys have all been allocated, perhaps by a > library the application is using. It is recommended that > applications wanting to use protection keys should simply call > pkey_alloc(2) and test whether the call succeeds, instead of > attempting to detect support for the feature in any other way. Do you really not have standard way on ppc to say whether hardware features are supported by the kernel? For instance, how do you know if a given set of registers are known to and are being context-switched by the kernel?