{"id":811876,"url":"http://patchwork.ozlabs.org/api/patches/811876/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1504910713-7094-21-git-send-email-linuxram@us.ibm.com/","project":{"id":2,"url":"http://patchwork.ozlabs.org/api/projects/2/?format=json","name":"Linux PPC development","link_name":"linuxppc-dev","list_id":"linuxppc-dev.lists.ozlabs.org","list_email":"linuxppc-dev@lists.ozlabs.org","web_url":"https://github.com/linuxppc/wiki/wiki","scm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git","webscm_url":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/","list_archive_url":"https://lore.kernel.org/linuxppc-dev/","list_archive_url_format":"https://lore.kernel.org/linuxppc-dev/{}/","commit_url_format":"https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"},"msgid":"<1504910713-7094-21-git-send-email-linuxram@us.ibm.com>","list_archive_url":"https://lore.kernel.org/linuxppc-dev/1504910713-7094-21-git-send-email-linuxram@us.ibm.com/","date":"2017-09-08T22:45:00","name":"[12/25] powerpc: ability to associate pkey to a vma","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"2d032545347c46649fbee84a36869ec46d7d0c71","submitter":{"id":2667,"url":"http://patchwork.ozlabs.org/api/people/2667/?format=json","name":"Ram Pai","email":"linuxram@us.ibm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1504910713-7094-21-git-send-email-linuxram@us.ibm.com/mbox/","series":[{"id":2303,"url":"http://patchwork.ozlabs.org/api/series/2303/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=2303","date":"2017-09-08T22:44:40","name":"powerpc: Free up RPAGE_RSV bits","version":1,"mbox":"http://patchwork.ozlabs.org/series/2303/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/811876/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/811876/checks/","tags":{},"related":[],"headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xptjm6QThz9sBW\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat,  9 Sep 2017 09:26:04 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xptjm4sLGzDqYV\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat,  9 Sep 2017 09:26:04 +1000 (AEST)","from mail-qt0-x242.google.com (mail-qt0-x242.google.com\n\t[IPv6:2607:f8b0:400d:c0d::242])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xpsrm3QVJzDrdP\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tSat,  9 Sep 2017 08:47:04 +1000 (AEST)","by mail-qt0-x242.google.com with SMTP id k2so2348973qte.5\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tFri, 08 Sep 2017 15:47:04 -0700 (PDT)","from localhost.localdomain (50-39-103-96.bvtn.or.frontiernet.net.\n\t[50.39.103.96]) by smtp.gmail.com with ESMTPSA id\n\tx124sm2033726qka.85.2017.09.08.15.47.00\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 08 Sep 2017 15:47:02 -0700 (PDT)"],"Authentication-Results":["ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"slscx0dT\"; dkim-atps=neutral","lists.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"slscx0dT\"; dkim-atps=neutral","ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gmail.com\n\t(client-ip=2607:f8b0:400d:c0d::242; helo=mail-qt0-x242.google.com;\n\tenvelope-from=ram.n.pai@gmail.com; receiver=<UNKNOWN>)","lists.ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"slscx0dT\"; dkim-atps=neutral"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=sender:from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=bs5geoUAZTp+BNpFK0rKGWwwa0wPjee5S0xVP4aFROY=;\n\tb=slscx0dTt2AUeIE4exztJF2XGQh3RybC5WE2g+uHS22esu6780lmpZPgl4NUt28Gqc\n\t3TcZiF/nV6BYBy/AhwdxTR8h4gY75qscWdwPMPIdk3vN/+Ivcl1ByFvVW2zScXf+HX/6\n\tWwGGqT8tEZUtF8H9Z/okJ1DnNIRkpr33jB/HnvAAFYWxVuNPnfydZEl7DprGybw3HLpw\n\tqzlaLON00RV4ZSd8OrEkkHabA0uLTqoblh7Uyxs4ieNefETfP0oSHN+gH7gzJJGXPZ28\n\t2bswpCjc3AVq7Ceg2h6wY68QuN/1m9vPkRdKw70ac+viBHqHSwjqZ5DT/6VQSQAaDTN5\n\tsFgg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:sender:from:to:cc:subject:date:message-id\n\t:in-reply-to:references;\n\tbh=bs5geoUAZTp+BNpFK0rKGWwwa0wPjee5S0xVP4aFROY=;\n\tb=EcG9ahNGIosO3CnzQHwIuJOFKyZNETEKRHLBCXmYwgr8VBkev+blwipgDwWqazKyAq\n\tLXSao00CBeoj41E6EvIfLujqaHcsKKzPAxMVKR+VUest9JXyAI9SUlcU4+xmr+QGnLjo\n\t0533BYEgLfRRE5S21R5MsWttJgwwPzRpzCegltaGZalwkZnZD0C7ctX3wse5j2LOOrJr\n\tyZ6gBuY/yJYZMYQ5UQs7c1r4lrfwsv0z6I/GkxI0+1nnhVwxyhxiJq5H6uLGCPeMsi4M\n\tlAXm5rgevOntWtjq0gZhIsyk4hW5mB583DHxJ0F0sNHDqj0M2+4ucqWvslVRfbD4Zt4S\n\tcaPQ==","X-Gm-Message-State":"AHPjjUgcV1wpnniNdbUzne3gbOVWIobl2IEGPNDsTrbMV4VzTxh3mXB1\n\t3agekjvXnBLrew==","X-Google-Smtp-Source":"AOwi7QDcfMyZGB1cD5hpKAA/OQh38KSziXYIy6aEmspr1cP7W86+sFJhnvbUQYI0lFXX73qKIgOsUw==","X-Received":"by 10.200.15.132 with SMTP id b4mr6622574qtk.127.1504910822586; \n\tFri, 08 Sep 2017 15:47:02 -0700 (PDT)","From":"Ram Pai <linuxram@us.ibm.com>","To":"mpe@ellerman.id.au,\n\tlinuxppc-dev@lists.ozlabs.org","Subject":"[PATCH 12/25] powerpc: ability to associate pkey to a vma","Date":"Fri,  8 Sep 2017 15:45:00 -0700","Message-Id":"<1504910713-7094-21-git-send-email-linuxram@us.ibm.com>","X-Mailer":"git-send-email 1.7.1","In-Reply-To":"<1504910713-7094-1-git-send-email-linuxram@us.ibm.com>","References":"<1504910713-7094-1-git-send-email-linuxram@us.ibm.com>","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"ebiederm@xmission.com, linuxram@us.ibm.com, mhocko@kernel.org,\n\tpaulus@samba.org, aneesh.kumar@linux.vnet.ibm.com,\n\tbauerman@linux.vnet.ibm.com, khandual@linux.vnet.ibm.com","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"},"content":"arch-independent code expects the arch to  map\na  pkey  into the vma's protection bit setting.\nThe patch provides that ability.\n\nSigned-off-by: Ram Pai <linuxram@us.ibm.com>\n---\n arch/powerpc/include/asm/mman.h  |    8 +++++++-\n arch/powerpc/include/asm/pkeys.h |   18 ++++++++++++++++++\n 2 files changed, 25 insertions(+), 1 deletions(-)","diff":"diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h\nindex 30922f6..067eec2 100644\n--- a/arch/powerpc/include/asm/mman.h\n+++ b/arch/powerpc/include/asm/mman.h\n@@ -13,6 +13,7 @@\n \n #include <asm/cputable.h>\n #include <linux/mm.h>\n+#include <linux/pkeys.h>\n #include <asm/cpu_has_feature.h>\n \n /*\n@@ -22,7 +23,12 @@\n static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,\n \t\tunsigned long pkey)\n {\n-\treturn (prot & PROT_SAO) ? VM_SAO : 0;\n+#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS\n+\treturn (((prot & PROT_SAO) ? VM_SAO : 0) |\n+\t\t\tpkey_to_vmflag_bits(pkey));\n+#else\n+\treturn ((prot & PROT_SAO) ? VM_SAO : 0);\n+#endif\n }\n #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)\n \ndiff --git a/arch/powerpc/include/asm/pkeys.h b/arch/powerpc/include/asm/pkeys.h\nindex 0cf115f..f13e913 100644\n--- a/arch/powerpc/include/asm/pkeys.h\n+++ b/arch/powerpc/include/asm/pkeys.h\n@@ -23,6 +23,24 @@\n #define VM_PKEY_BIT4\tVM_HIGH_ARCH_4\n #endif\n \n+/* override any generic PKEY Permission defines */\n+#define PKEY_DISABLE_EXECUTE   0x4\n+#define PKEY_ACCESS_MASK       (PKEY_DISABLE_ACCESS |\\\n+\t\t\t\tPKEY_DISABLE_WRITE  |\\\n+\t\t\t\tPKEY_DISABLE_EXECUTE)\n+\n+static inline u64 pkey_to_vmflag_bits(u16 pkey)\n+{\n+\tif (!pkey_inited)\n+\t\treturn 0x0UL;\n+\n+\treturn (((pkey & 0x1UL) ? VM_PKEY_BIT0 : 0x0UL) |\n+\t\t((pkey & 0x2UL) ? VM_PKEY_BIT1 : 0x0UL) |\n+\t\t((pkey & 0x4UL) ? VM_PKEY_BIT2 : 0x0UL) |\n+\t\t((pkey & 0x8UL) ? VM_PKEY_BIT3 : 0x0UL) |\n+\t\t((pkey & 0x10UL) ? VM_PKEY_BIT4 : 0x0UL));\n+}\n+\n #define arch_max_pkey()  pkeys_total\n #define AMR_RD_BIT 0x1UL\n #define AMR_WR_BIT 0x2UL\n","prefixes":["12/25"]}