{"id":811888,"url":"http://patchwork.ozlabs.org/api/patches/811888/?format=json","web_url":"http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1504910713-7094-30-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-30-git-send-email-linuxram@us.ibm.com>","list_archive_url":"https://lore.kernel.org/linuxppc-dev/1504910713-7094-30-git-send-email-linuxram@us.ibm.com/","date":"2017-09-08T22:45:09","name":"[21/25] powerpc: introduce get_pte_pkey() helper","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"f5d8869d9c1b1c659509678a4f1d834b86d94d15","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-30-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/811888/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/811888/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 3xpv4k3jvTz9sRY\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat,  9 Sep 2017 09:42:30 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xpv4k2WG4zDqY8\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat,  9 Sep 2017 09:42:30 +1000 (AEST)","from mail-qt0-x243.google.com (mail-qt0-x243.google.com\n\t[IPv6:2607:f8b0:400d:c0d::243])\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 3xpss45JJdzDrcv\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tSat,  9 Sep 2017 08:47:20 +1000 (AEST)","by mail-qt0-x243.google.com with SMTP id h21so2358529qth.4\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tFri, 08 Sep 2017 15:47:20 -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.17\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 08 Sep 2017 15:47:18 -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=\"QUfx/di1\"; 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=\"QUfx/di1\"; dkim-atps=neutral","ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gmail.com\n\t(client-ip=2607:f8b0:400d:c0d::243; helo=mail-qt0-x243.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=\"QUfx/di1\"; 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=+VoIn631r1YpDumcGGVAhNUyQWA+zRFDgMxuui/WBo4=;\n\tb=QUfx/di17U7wEZ+R1ADZAlladcdjB+JWSd9cftVRzTBAmNpQxEzTDWc1lxN/EheWgg\n\tLFQYCpW6mJKvazQoJoKkB5B+Hol46vto8WlXOjQFF/4TVHT0c/xxzkP7pPzonXmFEcHG\n\tDbuLJPlp0yhMs4phvOjvcWGZbcfy8DRkkwM4PnSYLqzrGRHVHzd3PiucUfp3oBA+EYMV\n\tv0+BnK8CRohTk5MakkdI47elHnetjVwV1BU7UW4Xxhhv0+AixNVaOCJTSKEVUE5Q/rbu\n\tipeLPxFVaz7k9kR3WvPrGqt8Hv+oHoyL1sI/iE54eHhVt7w3PfkUWYu6dTLNSC+whxhi\n\tOFcQ==","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=+VoIn631r1YpDumcGGVAhNUyQWA+zRFDgMxuui/WBo4=;\n\tb=C062B70OXtJPKOUQbbjC8XML3Szfd35wJStEkCXC86Xou6PpJppl/AWZRJs5MHjQkc\n\t7UFnJhInFs6lPs7rwSAsV8dX1k/OaL9j5BjxKFsLrCo7J3T1Ut80FU/xnLFZOwM3h7c0\n\tQOCyoZNPfe1emx3EnGTuEJczO+cTbjvZO/IHBU7qh3N0Vv/t7Z/3JDfi6QAr3KNo9nlV\n\tV+53MmNNctdIrh5xTOf5gwqZDw66g2H9p/LIMoZkJ0urPiarS8u/f8Nu9GTQRfu0hVJb\n\tNDGr6q5sAQ7bsFau/cZD2nDbKZzwmu7nY3pqaP1rP0DBNsJoIXfs9Z5KunM/xJjGj0Qx\n\tcwYQ==","X-Gm-Message-State":"AHPjjUgKibiFZVnOjlbClQ9PsK1aHhwxPxngz7ITN+CJEfFF8QN1j1Wv\n\tvDkHBF+9ErYVFg5O","X-Google-Smtp-Source":"AOwi7QAgpJlMoWfht4pgl5uNL9Wkng5BcGnfZVSBdzcvvA/Y1/WBBpqsVNhrsNwU4zrZN4HvXL5lrQ==","X-Received":"by 10.200.38.71 with SMTP id v7mr6412553qtv.18.1504910838868;\n\tFri, 08 Sep 2017 15:47:18 -0700 (PDT)","From":"Ram Pai <linuxram@us.ibm.com>","To":"mpe@ellerman.id.au,\n\tlinuxppc-dev@lists.ozlabs.org","Subject":"[PATCH 21/25] powerpc: introduce get_pte_pkey() helper","Date":"Fri,  8 Sep 2017 15:45:09 -0700","Message-Id":"<1504910713-7094-30-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":"get_pte_pkey() helper returns the pkey associated with\na address corresponding to a given mm_struct.\n\nSigned-off-by: Ram Pai <linuxram@us.ibm.com>\n---\n arch/powerpc/include/asm/book3s/64/mmu-hash.h |    5 +++++\n arch/powerpc/mm/hash_utils_64.c               |   24 ++++++++++++++++++++++++\n 2 files changed, 29 insertions(+), 0 deletions(-)","diff":"diff --git a/arch/powerpc/include/asm/book3s/64/mmu-hash.h b/arch/powerpc/include/asm/book3s/64/mmu-hash.h\nindex 2e22357..8716031 100644\n--- a/arch/powerpc/include/asm/book3s/64/mmu-hash.h\n+++ b/arch/powerpc/include/asm/book3s/64/mmu-hash.h\n@@ -451,6 +451,11 @@ extern int hash_page(unsigned long ea, unsigned long access, unsigned long trap,\n int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid,\n \t\t     pte_t *ptep, unsigned long trap, unsigned long flags,\n \t\t     int ssize, unsigned int shift, unsigned int mmu_psize);\n+\n+#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS\n+u16 get_pte_pkey(struct mm_struct *mm, unsigned long address);\n+#endif /* CONFIG_PPC64_MEMORY_PROTECTION_KEYS */\n+\n #ifdef CONFIG_TRANSPARENT_HUGEPAGE\n extern int __hash_page_thp(unsigned long ea, unsigned long access,\n \t\t\t   unsigned long vsid, pmd_t *pmdp, unsigned long trap,\ndiff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c\nindex a739a2d..5917d45 100644\n--- a/arch/powerpc/mm/hash_utils_64.c\n+++ b/arch/powerpc/mm/hash_utils_64.c\n@@ -1572,6 +1572,30 @@ void hash_preload(struct mm_struct *mm, unsigned long ea,\n \tlocal_irq_restore(flags);\n }\n \n+#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS\n+/*\n+ * return the protection key associated with the given address\n+ * and the mm_struct.\n+ */\n+u16 get_pte_pkey(struct mm_struct *mm, unsigned long address)\n+{\n+\tpte_t *ptep;\n+\tu16 pkey = 0;\n+\tunsigned long flags;\n+\n+\tif (!mm || !mm->pgd)\n+\t\treturn 0;\n+\n+\tlocal_irq_save(flags);\n+\tptep = find_linux_pte(mm->pgd, address, NULL, NULL);\n+\tif (ptep)\n+\t\tpkey = pte_to_pkey_bits(pte_val(READ_ONCE(*ptep)));\n+\tlocal_irq_restore(flags);\n+\n+\treturn pkey;\n+}\n+#endif /* CONFIG_PPC64_MEMORY_PROTECTION_KEYS */\n+\n #ifdef CONFIG_PPC_TRANSACTIONAL_MEM\n static inline void tm_flush_hash_page(int local)\n {\n","prefixes":["21/25"]}