Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/811874/?format=api
{ "id": 811874, "url": "http://patchwork.ozlabs.org/api/patches/811874/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1504910713-7094-19-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-19-git-send-email-linuxram@us.ibm.com>", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/1504910713-7094-19-git-send-email-linuxram@us.ibm.com/", "date": "2017-09-08T22:44:58", "name": "[10/25] powerpc: store and restore the pkey state across context switches", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": false, "hash": "641ded01803a590f8d659d4dba6427ff2d409837", "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-19-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/811874/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/811874/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 [IPv6:2401:3900:2:1::3])\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 3xptdN4Tslz9s7h\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 9 Sep 2017 09:22:16 +1000 (AEST)", "from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xptdN2vdVzDqYR\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 9 Sep 2017 09:22:16 +1000 (AEST)", "from mail-qt0-x241.google.com (mail-qt0-x241.google.com\n\t[IPv6:2607:f8b0:400d:c0d::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 3xpsrh56MRzDrcq\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tSat, 9 Sep 2017 08:47:00 +1000 (AEST)", "by mail-qt0-x241.google.com with SMTP id p55so2360678qtc.2\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tFri, 08 Sep 2017 15:47:00 -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.46.56\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 08 Sep 2017 15:46:58 -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=\"ke6z+Por\"; 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=\"ke6z+Por\"; dkim-atps=neutral", "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gmail.com\n\t(client-ip=2607:f8b0:400d:c0d::241; helo=mail-qt0-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=\"ke6z+Por\"; 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=by3Lkv+RvC1EkqOnppltXOyYzMj646uxEcKCYxO2ecU=;\n\tb=ke6z+PorYkNIX4S5T1L8ivwxdWZc5YMMwh+2cqrvZxdiR515YCDAoaMaNusUm3ZaG1\n\tdBkahYpfskLnBv4frpxK+DHu/wh+NJ5uwkyRG5QykxhUy5JGKe/YguVY+CTK1IQ9PnIx\n\t78mxbHG8WzxYvGXZrFFVlyfVuuP+BjGZQcxMACPktt9DmHwGd5NwzjUO4dnNVhYJq/iS\n\ty/HLPhiKO9d92lE6SYJCgBwgVq/T+dli6BR6DtdzBTGdzeI01ACnhZvw3JBXTL1SbQDs\n\tMgZtf9iAh71a5+MXHb/O6SYUdjKRg32ELo0d0wuTT01Jo4+eXjul3qmWIDJ576UveHDf\n\t9JWg==", "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=by3Lkv+RvC1EkqOnppltXOyYzMj646uxEcKCYxO2ecU=;\n\tb=nIuvZDYI38xFjegeJs/OJgmTbh0pclREXf5+OjTKvslVHUHWpfuPiM31JwaE3C2wAV\n\tqXxCRoaIEnFN/7LgzhzgWBKg6Fke1F4hH2Jf7jXLsPLZa5wCksJP5gT67wKiUCVSIvNG\n\thvHmlO/CnonUCBLocqOubWQxEyGikElxCS1GCfX7FyUSkm79QoeDhbgWpoyC7oYLf30l\n\taMdzCshFvnngMJJx6xLOHhDsUR/SkqQfKmhjVKSC+y4p9n8T07NXDS8ljVU+Vrj/wyjv\n\tqbWjwVLxFCrbDnlVe0OYtodRQD5/qzioJaxT7zz3I33AdlIAD9kuzuY4Ol+7PFPfUXU2\n\tXAng==", "X-Gm-Message-State": "AHPjjUhPI1G39VU/wHQnm0jtqufsCZvkcIEab9cBLth143akw4pPvxZO\n\t/egykFESGqiiZg==", "X-Google-Smtp-Source": "AOwi7QAdyt+uzZhcjLhCVSSCwJjl2LOW2ftJs8Lx6R980h5HaH8xDQcUosotkYg+orolElgUOv1hlQ==", "X-Received": "by 10.200.39.70 with SMTP id h6mr5990188qth.227.1504910818828;\n\tFri, 08 Sep 2017 15:46:58 -0700 (PDT)", "From": "Ram Pai <linuxram@us.ibm.com>", "To": "mpe@ellerman.id.au,\n\tlinuxppc-dev@lists.ozlabs.org", "Subject": "[PATCH 10/25] powerpc: store and restore the pkey state across\n\tcontext switches", "Date": "Fri, 8 Sep 2017 15:44:58 -0700", "Message-Id": "<1504910713-7094-19-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": "Store and restore the AMR, IAMR and UAMOR register state of the task\nbefore scheduling out and after scheduling in, respectively.\n\nSigned-off-by: Ram Pai <linuxram@us.ibm.com>\n---\n arch/powerpc/include/asm/pkeys.h | 4 +++\n arch/powerpc/include/asm/processor.h | 5 ++++\n arch/powerpc/kernel/process.c | 10 ++++++++\n arch/powerpc/mm/pkeys.c | 39 ++++++++++++++++++++++++++++++++++\n 4 files changed, 58 insertions(+), 0 deletions(-)", "diff": "diff --git a/arch/powerpc/include/asm/pkeys.h b/arch/powerpc/include/asm/pkeys.h\nindex 7fd48a4..78c5362 100644\n--- a/arch/powerpc/include/asm/pkeys.h\n+++ b/arch/powerpc/include/asm/pkeys.h\n@@ -143,5 +143,9 @@ static inline void pkey_mm_init(struct mm_struct *mm)\n \tmm_pkey_allocation_map(mm) = initial_allocation_mask;\n }\n \n+extern void thread_pkey_regs_save(struct thread_struct *thread);\n+extern void thread_pkey_regs_restore(struct thread_struct *new_thread,\n+\t\t\tstruct thread_struct *old_thread);\n+extern void thread_pkey_regs_init(struct thread_struct *thread);\n extern void pkey_initialize(void);\n #endif /*_ASM_PPC64_PKEYS_H */\ndiff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h\nindex fab7ff8..de9d9ba 100644\n--- a/arch/powerpc/include/asm/processor.h\n+++ b/arch/powerpc/include/asm/processor.h\n@@ -309,6 +309,11 @@ struct thread_struct {\n \tstruct thread_vr_state ckvr_state; /* Checkpointed VR state */\n \tunsigned long\tckvrsave; /* Checkpointed VRSAVE */\n #endif /* CONFIG_PPC_TRANSACTIONAL_MEM */\n+#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS\n+\tunsigned long\tamr;\n+\tunsigned long\tiamr;\n+\tunsigned long\tuamor;\n+#endif\n #ifdef CONFIG_KVM_BOOK3S_32_HANDLER\n \tvoid*\t\tkvm_shadow_vcpu; /* KVM internal data */\n #endif /* CONFIG_KVM_BOOK3S_32_HANDLER */\ndiff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c\nindex a0c74bb..ba80002 100644\n--- a/arch/powerpc/kernel/process.c\n+++ b/arch/powerpc/kernel/process.c\n@@ -42,6 +42,7 @@\n #include <linux/hw_breakpoint.h>\n #include <linux/uaccess.h>\n #include <linux/elf-randomize.h>\n+#include <linux/pkeys.h>\n \n #include <asm/pgtable.h>\n #include <asm/io.h>\n@@ -1085,6 +1086,9 @@ static inline void save_sprs(struct thread_struct *t)\n \t\tt->tar = mfspr(SPRN_TAR);\n \t}\n #endif\n+#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS\n+\tthread_pkey_regs_save(t);\n+#endif\n }\n \n static inline void restore_sprs(struct thread_struct *old_thread,\n@@ -1120,6 +1124,9 @@ static inline void restore_sprs(struct thread_struct *old_thread,\n \t\t\tmtspr(SPRN_TAR, new_thread->tar);\n \t}\n #endif\n+#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS\n+\tthread_pkey_regs_restore(new_thread, old_thread);\n+#endif\n }\n \n #ifdef CONFIG_PPC_BOOK3S_64\n@@ -1705,6 +1712,9 @@ void start_thread(struct pt_regs *regs, unsigned long start, unsigned long sp)\n \tcurrent->thread.tm_tfiar = 0;\n \tcurrent->thread.load_tm = 0;\n #endif /* CONFIG_PPC_TRANSACTIONAL_MEM */\n+#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS\n+\tthread_pkey_regs_init(¤t->thread);\n+#endif /* CONFIG_PPC64_MEMORY_PROTECTION_KEYS */\n }\n EXPORT_SYMBOL(start_thread);\n \ndiff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c\nindex 2282864..7cd1be4 100644\n--- a/arch/powerpc/mm/pkeys.c\n+++ b/arch/powerpc/mm/pkeys.c\n@@ -149,3 +149,42 @@ int __arch_set_user_pkey_access(struct task_struct *tsk, int pkey,\n \tinit_amr(pkey, new_amr_bits);\n \treturn 0;\n }\n+\n+void thread_pkey_regs_save(struct thread_struct *thread)\n+{\n+\tif (!pkey_inited)\n+\t\treturn;\n+\n+\t/* @TODO skip saving any registers if the thread\n+\t * has not used any keys yet.\n+\t */\n+\n+\tthread->amr = read_amr();\n+\tthread->iamr = read_iamr();\n+\tthread->uamor = read_uamor();\n+}\n+\n+void thread_pkey_regs_restore(struct thread_struct *new_thread,\n+\t\t\tstruct thread_struct *old_thread)\n+{\n+\tif (!pkey_inited)\n+\t\treturn;\n+\n+\t/* @TODO just reset uamor to zero if the new_thread\n+\t * has not used any keys yet.\n+\t */\n+\n+\tif (old_thread->amr != new_thread->amr)\n+\t\twrite_amr(new_thread->amr);\n+\tif (old_thread->iamr != new_thread->iamr)\n+\t\twrite_iamr(new_thread->iamr);\n+\tif (old_thread->uamor != new_thread->uamor)\n+\t\twrite_uamor(new_thread->uamor);\n+}\n+\n+void thread_pkey_regs_init(struct thread_struct *thread)\n+{\n+\twrite_amr(0x0ul);\n+\twrite_iamr(0x0ul);\n+\twrite_uamor(0x0ul);\n+}\n", "prefixes": [ "10/25" ] }