From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ram Pai Subject: Re: [PATCH v4] mm, pkey: treat pkey-0 special Date: Fri, 16 Mar 2018 12:31:52 -0700 Message-ID: <20180316193152.GG1060@ram.oc3035372033.ibm.com> References: <1521196416-18157-1-git-send-email-linuxram@us.ibm.com> Reply-To: Ram Pai Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Balbir Singh Cc: Michael Ellerman , Ingo Molnar , "akpm@linux-foundation.org" , "open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)" , linux-mm , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , linux-arch , "linux-kernel@vger.kernel.org" , Dave Hansen , Benjamin Herrenschmidt , Paul Mackerras , Anshuman Khandual , Aneesh Kumar KV , Haren Myneni/Beaverton/IBM , Michal Hocko , Thiago Jung Bauermann List-Id: linux-arch.vger.kernel.org On Fri, Mar 16, 2018 at 10:02:22PM +1100, Balbir Singh wrote: > On Fri, Mar 16, 2018 at 9:33 PM, Ram Pai wrote: > > Applications need the ability to associate an address-range with some > > key and latter revert to its initial default key. Pkey-0 comes close to > > providing this function but falls short, because the current > > implementation disallows applications to explicitly associate pkey-0 to > > the address range. > > > > Clarify the semantics of pkey-0 and provide the corresponding > > implementation. > > > > Pkey-0 is special with the following semantics. > > (a) it is implicitly allocated and can never be freed. It always exists. > > (b) it is the default key assigned to any address-range. > > (c) it can be explicitly associated with any address-range. > > > > Tested on powerpc only. Could not test on x86. > > > Ram, > > I was wondering if we should check the AMOR values on the ppc side to make sure > that pkey0 is indeed available for use as default. I am still of the > opinion that we AMOR cannot be read/written by the OS in priviledge-non-hypervisor-mode. We could try testing if key-0 is available to the OS by temproarily changing the bits key-0 bits of AMR or IAMR register. But will be dangeorous to do, for you might disable read,execute of all the pages, since all pages are asscoiated with key-0 bydefault. May be we can play with UAMOR register and check if its key-0 can be modified. That is a good indication that key-0 is available. If it is not available, disable the pkey-subsystem, and operate the legacy way; no pkeys. > should consider non-0 default pkey in the long run. I'm OK with the patches for > now, but really 0 is not special except for it being the default bit > values present > in the PTE. it will be a pain. Any new pte that gets instantiated will now have to explicitly initialize its key to this default-non-zero-key. I hope we or any architecture goes there ever. -- Ram Pai From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:33460 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751753AbeCPTcI (ORCPT ); Fri, 16 Mar 2018 15:32:08 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2GJW0gw102845 for ; Fri, 16 Mar 2018 15:32:08 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2grjdb3ybh-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Fri, 16 Mar 2018 15:32:08 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 16 Mar 2018 19:32:05 -0000 Date: Fri, 16 Mar 2018 12:31:52 -0700 From: Ram Pai Subject: Re: [PATCH v4] mm, pkey: treat pkey-0 special Reply-To: Ram Pai References: <1521196416-18157-1-git-send-email-linuxram@us.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Message-ID: <20180316193152.GG1060@ram.oc3035372033.ibm.com> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Balbir Singh Cc: Michael Ellerman , Ingo Molnar , "akpm@linux-foundation.org" , "open list:LINUX FOR POWERPC (32-BIT AND 64-BIT)" , linux-mm , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , linux-arch , "linux-kernel@vger.kernel.org" , Dave Hansen , Benjamin Herrenschmidt , Paul Mackerras , Anshuman Khandual , Aneesh Kumar KV , Haren Myneni/Beaverton/IBM , Michal Hocko , Thiago Jung Bauermann , "Eric W. Biederman" , Jonathan Corbet , Arnd Bergmann , fweimer@redhat.com, msuchanek@suse.com, Thomas Gleixner , Ulrich.Weigand@de.ibm.com, Ram Pai Message-ID: <20180316193152.mOsKNfbhDps5vmBtSUL8I4bpRGt0yD6jBq376IED6hc@z> On Fri, Mar 16, 2018 at 10:02:22PM +1100, Balbir Singh wrote: > On Fri, Mar 16, 2018 at 9:33 PM, Ram Pai wrote: > > Applications need the ability to associate an address-range with some > > key and latter revert to its initial default key. Pkey-0 comes close to > > providing this function but falls short, because the current > > implementation disallows applications to explicitly associate pkey-0 to > > the address range. > > > > Clarify the semantics of pkey-0 and provide the corresponding > > implementation. > > > > Pkey-0 is special with the following semantics. > > (a) it is implicitly allocated and can never be freed. It always exists. > > (b) it is the default key assigned to any address-range. > > (c) it can be explicitly associated with any address-range. > > > > Tested on powerpc only. Could not test on x86. > > > Ram, > > I was wondering if we should check the AMOR values on the ppc side to make sure > that pkey0 is indeed available for use as default. I am still of the > opinion that we AMOR cannot be read/written by the OS in priviledge-non-hypervisor-mode. We could try testing if key-0 is available to the OS by temproarily changing the bits key-0 bits of AMR or IAMR register. But will be dangeorous to do, for you might disable read,execute of all the pages, since all pages are asscoiated with key-0 bydefault. May be we can play with UAMOR register and check if its key-0 can be modified. That is a good indication that key-0 is available. If it is not available, disable the pkey-subsystem, and operate the legacy way; no pkeys. > should consider non-0 default pkey in the long run. I'm OK with the patches for > now, but really 0 is not special except for it being the default bit > values present > in the PTE. it will be a pain. Any new pte that gets instantiated will now have to explicitly initialize its key to this default-non-zero-key. I hope we or any architecture goes there ever. -- Ram Pai