From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752689AbeCPTcO (ORCPT ); Fri, 16 Mar 2018 15:32:14 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56280 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751748AbeCPTcI (ORCPT ); Fri, 16 Mar 2018 15:32:08 -0400 Date: Fri, 16 Mar 2018 12:31:52 -0700 From: Ram Pai 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 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: User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-GCONF: 00 x-cbid: 18031619-0040-0000-0000-0000044219FC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031619-0041-0000-0000-000020E52A11 Message-Id: <20180316193152.GG1060@ram.oc3035372033.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-16_12:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803160231 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@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