Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/811891/?format=api
{ "id": 811891, "url": "http://patchwork.ozlabs.org/api/patches/811891/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1504910713-7094-33-git-send-email-linuxram@us.ibm.com/", "project": { "id": 2, "url": "http://patchwork.ozlabs.org/api/projects/2/?format=api", "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-33-git-send-email-linuxram@us.ibm.com>", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/1504910713-7094-33-git-send-email-linuxram@us.ibm.com/", "date": "2017-09-08T22:45:12", "name": "[24/25] powerpc/ptrace: Add memory protection key regset", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": false, "hash": "142fa9fbe16c230e85a053715f0c922d8facc8b2", "submitter": { "id": 2667, "url": "http://patchwork.ozlabs.org/api/people/2667/?format=api", "name": "Ram Pai", "email": "linuxram@us.ibm.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1504910713-7094-33-git-send-email-linuxram@us.ibm.com/mbox/", "series": [ { "id": 2303, "url": "http://patchwork.ozlabs.org/api/series/2303/?format=api", "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/811891/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/811891/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 3xpvBr4SGJz9sBZ\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 9 Sep 2017 09:47:48 +1000 (AEST)", "from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xpvBr3FhpzDrbM\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 9 Sep 2017 09:47:48 +1000 (AEST)", "from mail-qk0-x241.google.com (mail-qk0-x241.google.com\n\t[IPv6:2607:f8b0:400d:c09::241])\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 3xpssB0LYtzDrcq\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tSat, 9 Sep 2017 08:47:26 +1000 (AEST)", "by mail-qk0-x241.google.com with SMTP id r66so2160388qke.4\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tFri, 08 Sep 2017 15:47:25 -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.22\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 08 Sep 2017 15:47:23 -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=\"kly31o2X\"; 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=\"kly31o2X\"; dkim-atps=neutral", "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gmail.com\n\t(client-ip=2607:f8b0:400d:c09::241; helo=mail-qk0-x241.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=\"kly31o2X\"; 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=o/sHVEw425RTKuTGgT2eaPAU4jM72PMOybAWHgtJPxk=;\n\tb=kly31o2XMjkgyqQDeEPMR5B2xk//chwVkcPbU2ifJ31EKbtY74WlW9HAlgfZ+PkmeF\n\tJ3QmM+LEBjQ/urLZOwVvIqf1n4BbsvhZVnNrM+C2S6WanXau+ACKSMm1o04r+Up5Wl5p\n\tYmYLgnHPWY/C+IerBmD/GTF7w4noqia0yTXC14uaclhbLviLlIfwq5/R4ozzbU+caP0z\n\tXIjewruxjm3SIAVSlEGGfDwI59SOOSzH53k2DXecJXjMLRGpKIlPjg6k9UE/Zxzy/WBH\n\tmp6gj8O+qtjKv11gCzjHrJlHYDoqc76+3R0dJw3BGbwnUyoKIakUU0VZWQ8Oe9Y61AuF\n\tBb6g==", "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=o/sHVEw425RTKuTGgT2eaPAU4jM72PMOybAWHgtJPxk=;\n\tb=UQ3kC5ABZUFazCBGBuO/6WLXJp1RRpe3xPg7nfKBZLbeKtKGd0D4mNKSnZ5gLzpqNz\n\tFbPEX0bF0TBQfl79nOfq854eboXlCwyqqDhnJJMLp+T73j0zkkWFkBPHbh8/zrtcMuRa\n\tGVrGHv6fjM9PzKTsgqtOmI875BKDYkRm2S/AEmpgH9CDAhO4dhsG7cYxBEXiKJi4ZykJ\n\t046K7wx5ijfwkibCABzI4ADaxpUY35BYfbaTLVIe3mas+7JuWExP7K6YAQmu6ply0ZhJ\n\tECS5ingPBLj2cE3JKeTJC/olebLJLvn7fZaQparXAnZEpq31mPeqhLUjNaLyIu0U191c\n\t//pQ==", "X-Gm-Message-State": "AHPjjUhEHwDBZJ9sMB/hVDL+vTYpR1gYgFd8zQSMTPwxBvSmG5IbLnmr\n\tc145qBxWGvYXNA==", "X-Google-Smtp-Source": "AOwi7QCGPyqSrIycaqJ1/HQP/PvBKQttzSI74Ox3Mi26noYfVDQwF3E5mXwlBewTX0HZWoxvEOg6HA==", "X-Received": "by 10.55.221.217 with SMTP id u86mr6282241qku.64.1504910844106; \n\tFri, 08 Sep 2017 15:47:24 -0700 (PDT)", "From": "Ram Pai <linuxram@us.ibm.com>", "To": "mpe@ellerman.id.au,\n\tlinuxppc-dev@lists.ozlabs.org", "Subject": "[PATCH 24/25] powerpc/ptrace: Add memory protection key regset", "Date": "Fri, 8 Sep 2017 15:45:12 -0700", "Message-Id": "<1504910713-7094-33-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": "From: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>\n\nThe AMR/IAMR/UAMOR are part of the program context.\nAllow it to be accessed via ptrace and through core files.\n\nSigned-off-by: Ram Pai <linuxram@us.ibm.com>\nSigned-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>\n---\n arch/powerpc/include/asm/pkeys.h | 5 +++\n arch/powerpc/include/uapi/asm/elf.h | 1 +\n arch/powerpc/kernel/ptrace.c | 66 +++++++++++++++++++++++++++++++++++\n include/uapi/linux/elf.h | 1 +\n 4 files changed, 73 insertions(+), 0 deletions(-)", "diff": "diff --git a/arch/powerpc/include/asm/pkeys.h b/arch/powerpc/include/asm/pkeys.h\nindex 50522a0..a0111de 100644\n--- a/arch/powerpc/include/asm/pkeys.h\n+++ b/arch/powerpc/include/asm/pkeys.h\n@@ -209,6 +209,11 @@ static inline int arch_set_user_pkey_access(struct task_struct *tsk, int pkey,\n \treturn __arch_set_user_pkey_access(tsk, pkey, init_val);\n }\n \n+static inline bool arch_pkeys_enabled(void)\n+{\n+\treturn pkey_inited;\n+}\n+\n static inline void pkey_mm_init(struct mm_struct *mm)\n {\n \tif (!pkey_inited)\ndiff --git a/arch/powerpc/include/uapi/asm/elf.h b/arch/powerpc/include/uapi/asm/elf.h\nindex b2c6fdd..923e6d5 100644\n--- a/arch/powerpc/include/uapi/asm/elf.h\n+++ b/arch/powerpc/include/uapi/asm/elf.h\n@@ -96,6 +96,7 @@\n #define ELF_NTMSPRREG\t3\t/* include tfhar, tfiar, texasr */\n #define ELF_NEBB\t3\t/* includes ebbrr, ebbhr, bescr */\n #define ELF_NPMU\t5\t/* includes siar, sdar, sier, mmcr2, mmcr0 */\n+#define ELF_NPKEY\t3\t/* includes amr, iamr, uamor */\n \n typedef unsigned long elf_greg_t64;\n typedef elf_greg_t64 elf_gregset_t64[ELF_NGREG];\ndiff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c\nindex 07cd22e..6a9d3ec 100644\n--- a/arch/powerpc/kernel/ptrace.c\n+++ b/arch/powerpc/kernel/ptrace.c\n@@ -39,6 +39,7 @@\n #include <asm/pgtable.h>\n #include <asm/switch_to.h>\n #include <asm/tm.h>\n+#include <asm/pkeys.h>\n #include <asm/asm-prototypes.h>\n \n #define CREATE_TRACE_POINTS\n@@ -1775,6 +1776,61 @@ static int pmu_set(struct task_struct *target,\n \treturn ret;\n }\n #endif\n+\n+#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS\n+static int pkey_active(struct task_struct *target,\n+\t\t const struct user_regset *regset)\n+{\n+\tif (!arch_pkeys_enabled())\n+\t\treturn -ENODEV;\n+\n+\treturn regset->n;\n+}\n+\n+static int pkey_get(struct task_struct *target,\n+\t\t const struct user_regset *regset,\n+\t\t unsigned int pos, unsigned int count,\n+\t\t void *kbuf, void __user *ubuf)\n+{\n+\tBUILD_BUG_ON(TSO(amr) + sizeof(unsigned long) != TSO(iamr));\n+\tBUILD_BUG_ON(TSO(iamr) + sizeof(unsigned long) != TSO(uamor));\n+\n+\tif (!arch_pkeys_enabled())\n+\t\treturn -ENODEV;\n+\n+\treturn user_regset_copyout(&pos, &count, &kbuf, &ubuf,\n+\t\t\t\t &target->thread.amr, 0,\n+\t\t\t\t ELF_NPKEY * sizeof(unsigned long));\n+}\n+\n+static int pkey_set(struct task_struct *target,\n+\t\t const struct user_regset *regset,\n+\t\t unsigned int pos, unsigned int count,\n+\t\t const void *kbuf, const void __user *ubuf)\n+{\n+\tu64 new_amr;\n+\tint ret;\n+\n+\tif (!arch_pkeys_enabled())\n+\t\treturn -ENODEV;\n+\n+\t/* Only the AMR can be set from userspace */\n+\tif (pos != 0 || count != sizeof(new_amr))\n+\t\treturn -EINVAL;\n+\n+\tret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,\n+\t\t\t\t &new_amr, 0, sizeof(new_amr));\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/* UAMOR determines which bits of the AMR can be set from userspace. */\n+\ttarget->thread.amr = (new_amr & target->thread.uamor) |\n+\t\t(target->thread.amr & ~target->thread.uamor);\n+\n+\treturn 0;\n+}\n+#endif /* CONFIG_PPC64_MEMORY_PROTECTION_KEYS */\n+\n /*\n * These are our native regset flavors.\n */\n@@ -1809,6 +1865,9 @@ enum powerpc_regset {\n \tREGSET_EBB,\t\t/* EBB registers */\n \tREGSET_PMR,\t\t/* Performance Monitor Registers */\n #endif\n+#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS\n+\tREGSET_PKEY,\t\t/* AMR register */\n+#endif\n };\n \n static const struct user_regset native_regsets[] = {\n@@ -1914,6 +1973,13 @@ enum powerpc_regset {\n \t\t.active = pmu_active, .get = pmu_get, .set = pmu_set\n \t},\n #endif\n+#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS\n+\t[REGSET_PKEY] = {\n+\t\t.core_note_type = NT_PPC_PKEY, .n = ELF_NPKEY,\n+\t\t.size = sizeof(u64), .align = sizeof(u64),\n+\t\t.active = pkey_active, .get = pkey_get, .set = pkey_set\n+\t},\n+#endif\n };\n \n static const struct user_regset_view user_ppc_native_view = {\ndiff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h\nindex b5280db..0708516 100644\n--- a/include/uapi/linux/elf.h\n+++ b/include/uapi/linux/elf.h\n@@ -395,6 +395,7 @@\n #define NT_PPC_TM_CTAR\t0x10d\t\t/* TM checkpointed Target Address Register */\n #define NT_PPC_TM_CPPR\t0x10e\t\t/* TM checkpointed Program Priority Register */\n #define NT_PPC_TM_CDSCR\t0x10f\t\t/* TM checkpointed Data Stream Control Register */\n+#define NT_PPC_PKEY\t0x110\t\t/* Memory Protection Keys registers */\n #define NT_386_TLS\t0x200\t\t/* i386 TLS slots (struct user_desc) */\n #define NT_386_IOPERM\t0x201\t\t/* x86 io permission bitmap (1=deny) */\n #define NT_X86_XSTATE\t0x202\t\t/* x86 extended state using xsave */\n", "prefixes": [ "24/25" ] }