Received: by 10.213.65.68 with SMTP id h4csp251857imn; Mon, 26 Mar 2018 20:49:58 -0700 (PDT) X-Google-Smtp-Source: AG47ELuUQPZcnM+JAhslBxIUYNN3oYjI85L3DsveXcH/FKZeFEOjvH2eCm1I7raElsARLezTB8Ms X-Received: by 10.101.89.74 with SMTP id g10mr30174032pgu.415.1522122598217; Mon, 26 Mar 2018 20:49:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522122598; cv=none; d=google.com; s=arc-20160816; b=uLkhjEBj12u0NWCEsMF+EupcZ3trwrsmkSZj2qSo5kRkgYXFnyER6lU3KLnKMMNNky EKrnRaDkJettbEj27CRaMIYtkR7T8a6rSuZNIgmLNtUL5iOIL4O+nezGTsZpHz4qJqWY HcI/dJhvX7VnqG43NTnDGRZ4vV8E2+GhE+LBe0F50j7MwFekkiA+npAXoI3dbImWUoeq 64F2Aeo5RwNzMm4yWI1qnnBPVNghzfEAJY3O79ChAJFACw8UYs633Ot9vxVHdy1RdsdX cOtSDlYSa6ipG21aPPstQMjI5lXCqh8uuT/RYZckLaT0h/QEzk17U6PQf7G+OaxcF3Ag 6yvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:arc-authentication-results; bh=mxXLd2mnaMYl2pWbzRtvbQMhHHoZ3RcK5lUPsltn9EA=; b=Ch6OQ29yfcfb3e6c/gDUBwxDF1ksUFkvuX0F+dGnQpOQ6jRvJwWz/egOUk24JnmZn9 HTZrADhMaZaIkXB7lmX7SQ2gq/IQubbi1SWL5CuNrWo89//RRgACE5oQgAcnzU6CHAg1 hU4jQu/Q/oj2wWB0/oKEpRyfiv2TDWdx/NPm6uGJA13IBIqPH4wXS5+ZnKkGDf1+WIrV 06g9jzCfBciBjH58Kk+1VVMo2oZUMUU3lVvYI2ixVp0dBAMCgM0A1/9/n8XMsPOwBrhz pv3B+n4Zlj7oqktYhVNqtNYFBF4Hp4157jszUq35L3pDzfVExOZ4LdIFbgthNG2zAr0v +pwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k3si256151pff.82.2018.03.26.20.49.43; Mon, 26 Mar 2018 20:49:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752130AbeC0Ds2 (ORCPT + 99 others); Mon, 26 Mar 2018 23:48:28 -0400 Received: from ozlabs.org ([103.22.144.67]:33499 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751765AbeC0Ds1 (ORCPT ); Mon, 26 Mar 2018 23:48:27 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 409H6c2z4Dz9s0m; Tue, 27 Mar 2018 14:48:24 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au From: Michael Ellerman To: Ram Pai , Balbir Singh Cc: 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 In-Reply-To: <20180316193152.GG1060@ram.oc3035372033.ibm.com> References: <1521196416-18157-1-git-send-email-linuxram@us.ibm.com> <20180316193152.GG1060@ram.oc3035372033.ibm.com> Date: Tue, 27 Mar 2018 14:48:21 +1100 Message-ID: <87o9jaji0q.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ram Pai writes: > 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. No we should do what firmware tells us. If it says key 0 is available we use it, otherwise we don't. Now if you notice the way the firmware API (device tree property) is defined, it tells us how many keys are available, counting from 0. So for pkey 0 to be reserved there must be 0 keys available. End of story. cheers