Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965776AbdLRW21 (ORCPT ); Mon, 18 Dec 2017 17:28:27 -0500 Received: from mga03.intel.com ([134.134.136.65]:34122 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938304AbdLRW2V (ORCPT ); Mon, 18 Dec 2017 17:28:21 -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="159899448" Subject: Re: [PATCH v9 29/51] mm/mprotect, powerpc/mm/pkeys, x86/mm/pkeys: Add sysfs interface To: Ram Pai References: <1509958663-18737-1-git-send-email-linuxram@us.ibm.com> <1509958663-18737-30-git-send-email-linuxram@us.ibm.com> <20171218221850.GD5461@ram.oc3035372033.ibm.com> Cc: mpe@ellerman.id.au, mingo@redhat.com, akpm@linux-foundation.org, corbet@lwn.net, arnd@arndb.de, 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 14:28:14 -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: <20171218221850.GD5461@ram.oc3035372033.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: 1734 Lines: 40 On 12/18/2017 02:18 PM, Ram Pai wrote: > b) minimum number of keys available to the application. > if libraries consumes a few, they could provide a library > interface to the application informing the number available to > the application. The library interface can leverage (b) to > provide the information. OK, let's see a real user of this including a few libraries. Then we'll put it in the kernel. > c) types of disable-rights supported by keys. > Helps the application to determine the types of disable-features > available. This is helpful, otherwise the app has to > make pkey_alloc() call with the corresponding parameter set > and see if it suceeds or fails. Painful from an application > point of view, in my opinion. Again, let's see a real-world use of this. How does it look? How does an app "fall back" if it can't set a restriction the way it wants to? Are we *sure* that such an interface makes sense? For instance, will it be possible for some keys to be execute-disable while other are only write-disable? > I think on x86 you look for some hardware registers to determine which > hardware features are enabled by the kernel. No, we use CPUID. It's a part of the ISA that's designed for enumerating CPU and (sometimes) OS support for CPU features. > We do not have generic support for something like that on ppc. > The kernel looks at the device tree to determine what hardware features > are available. But does not have mechanism to tell the hardware to track > which of its features are currently enabled/used by the kernel; atleast > not for the memory-key feature. Bummer. You're missing out. But, you could still do this with a syscall. "Hey, kernel, do you support this feature?"