Received: by 10.213.65.68 with SMTP id h4csp266654imn; Mon, 26 Mar 2018 21:17:03 -0700 (PDT) X-Google-Smtp-Source: AG47ELvn1jR/aAQvV9mPvOeEPto+6Nqj1chdnHsmokn+cKUHkucwrhDgtDntKxIOO5tmEJIY87Sk X-Received: by 10.99.114.77 with SMTP id c13mr30144515pgn.286.1522124223668; Mon, 26 Mar 2018 21:17:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522124223; cv=none; d=google.com; s=arc-20160816; b=cdx2VI0SC+u0Zk4t6Mp49auJClNJQ1FxyPfEhw+t9wy2Ush2O/9w6DrilpHZyQlOdF v5geTMBkvMOB5EQQUSPJf5ELzp41Lh0uNlgoDfPJOdFQ+rJ79p5tNWOGeR3/9JUWQN3+ kSrnxfKVUFvw2Bsj4NhQkZpDWorxxTLu+OvVGOEDbzEpSHibYSjtxX53Ewv23yOtmoI1 YG/6Z2gJ7WZFuyvo8sNacvEPy0kgjw7GzUON1/EMsOZLxo+uUBVbRIzWVVoSZax7Ctxg STjyAjM10ojCtkC+kHd+VO5c0NG1HXD2meJf0LKsdOy0XdFwbW5aD8CtZS6LEtyH9k46 0kkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=GdP97qeM+utoUiWSgMjU0XpaBbX409VKhSPJ1btULgw=; b=FkPY5/IU4KK8Jdu2bSTuQ4LNaEX12s1skB/32BZC4UcQVw17XayJb8PPzn99GzAJtG p+w2Jw58wpLhFYMnq7PfsJaUwjksys4B8YB/pSdchC3jcOHVaPS4Z3S/EhvvvrNGKN3c Zbf8HnD/u6ZjDKYHthZjDAG0a0CZO1jKTr4qxr2gUj4tyuNF117AMKLqitWMjnDDS8FT 2jaTyn49vblWMVkDNOADnYmUFOVskj/1CEuizueyr1vSEheb4fBqk+yqxtN42Fk8XaVf KjnkOHTgpkNafrFKoocCitVGdp+R1EgYybxmwMtc+YyZs8sONhvDW6VnRQEebxeFel60 TcMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MTV8YVdk; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x8-v6si342027plv.420.2018.03.26.21.16.48; Mon, 26 Mar 2018 21:17:03 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MTV8YVdk; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750993AbeC0EP5 (ORCPT + 99 others); Tue, 27 Mar 2018 00:15:57 -0400 Received: from mail-vk0-f65.google.com ([209.85.213.65]:41877 "EHLO mail-vk0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750800AbeC0EPz (ORCPT ); Tue, 27 Mar 2018 00:15:55 -0400 Received: by mail-vk0-f65.google.com with SMTP id l123so12459017vke.8; Mon, 26 Mar 2018 21:15:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=GdP97qeM+utoUiWSgMjU0XpaBbX409VKhSPJ1btULgw=; b=MTV8YVdkvUgdUBfw+5c+jOe7AKAhLOe2/cja2j7RbTl5KRH8HUVc88HghO8ZWQbBKj oP8WN+GYB5DO22AnYVYk1Ev4FtbeSMTTLdIm4Cx4Qu3/qo53i09DH20x1x7FccPWpaGQ qRUK7ttNo1A87jV32uIcdMnCyQJx1S1RRWHclrEqD3VIjLcRbst2y+c6xSH77J36QFh6 Z+u5z3KYoSghXOXrxFKCtSvPLiX3xBVXZ8cQJn0QXENV6inFBBf5wUJSgqdeHHwuIOTI fRG373HsoXue9ww7JR0cGfCKfeyJa/2nfi+1Y4qC8cLRrAXvFMJL6GBLwqJgXXSJGT4A 5CeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=GdP97qeM+utoUiWSgMjU0XpaBbX409VKhSPJ1btULgw=; b=LqloUHvVTPsy0BQ1CiviOgcCZ5qef6FJ4UvDnY1JsenbFu4BMwZMpN4zgERljAC21o OwZUfcHo1Q/mzZ4l4HITjq8cS/cqq/w5LwYvz9eDUI8QQ/KgzTHxI3eCkV3HeqRjjOvG AH4nD1OCe6HIBrD+Oq+rGC9G8JCBhaeAMWKImlbrkrPqPj0K6GqF/i4IK/obrnX2c04b APjgx1M7xhGp0+1DWE3zjlxUecT7/tImHufSf955p58mP/+pewAgcqAdalnOix8CUw+d ZTfRl2lM0LQmbAWUyG/iQt7za6YyC3hD1dyuSj96UGgshkvuqkSD8vJz/JiMXHkVs4NR 0wng== X-Gm-Message-State: AElRT7HqjJeUs35rPpysnh89Lne48RTNpvZArbBSOFmf4keHif5kMtw9 PM+4RImtfVJgkHOVP53e+26PvEZxxzaq8d+DaB0= X-Received: by 10.31.92.82 with SMTP id q79mr8165703vkb.159.1522124154548; Mon, 26 Mar 2018 21:15:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.97.133 with HTTP; Mon, 26 Mar 2018 21:15:53 -0700 (PDT) In-Reply-To: <87o9jaji0q.fsf@concordia.ellerman.id.au> References: <1521196416-18157-1-git-send-email-linuxram@us.ibm.com> <20180316193152.GG1060@ram.oc3035372033.ibm.com> <87o9jaji0q.fsf@concordia.ellerman.id.au> From: Balbir Singh Date: Tue, 27 Mar 2018 15:15:53 +1100 Message-ID: Subject: Re: [PATCH v4] mm, pkey: treat pkey-0 special To: Michael Ellerman Cc: Ram Pai , 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 27, 2018 at 2:48 PM, Michael Ellerman wrote: > 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. > I could not find counting from 0 anywhere, are we expected to look at the AMOR and figure out what we have access to? Why do we assume they'll be contiguous, it makes our life easy, but I really could not find any documentation on it > So for pkey 0 to be reserved there must be 0 keys available. > > End of story. > > cheers Cheers, Balbir Singh.