get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/811881/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 811881,
    "url": "http://patchwork.ozlabs.org/api/patches/811881/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1504910713-7094-26-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-26-git-send-email-linuxram@us.ibm.com>",
    "list_archive_url": "https://lore.kernel.org/linuxppc-dev/1504910713-7094-26-git-send-email-linuxram@us.ibm.com/",
    "date": "2017-09-08T22:45:05",
    "name": "[17/25] powerpc: helper to validate key-access permissions of a pte",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "714d8fac20e05dce454146910546184994d367a6",
    "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-26-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/811881/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/811881/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 3xptwC5h1mz9sBW\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat,  9 Sep 2017 09:35:07 +1000 (AEST)",
            "from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xptwC4QyZzDrJZ\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat,  9 Sep 2017 09:35:07 +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 3xpsrx3hkhzDrcv\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tSat,  9 Sep 2017 08:47:13 +1000 (AEST)",
            "by mail-qt0-x242.google.com with SMTP id h21so2358358qth.4\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tFri, 08 Sep 2017 15:47:13 -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.09\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 08 Sep 2017 15:47:11 -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=\"I72h9PCF\"; 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=\"I72h9PCF\"; 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=\"I72h9PCF\"; 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=8KmrqFg30K76tisB9MMiRJR0yuUD3GwQGcFlEsL6uLk=;\n\tb=I72h9PCFdClqGRt3m59OTmX2nev4hmOTUksWfRykuN8/p5CU4SoDZDRBCEawfij253\n\txME27HGt/T70kXGKaAr5421Uac77+pULtfKPInKihwTTOtVpYCoalhXmiKOKG4dx/7j+\n\tebv549x8xP/kANZbyyecwWl6v2QgcYYK8ClI6Hs1o1tY123OjfoGZVyh/pWIxwslIo4F\n\tu8uGL6RTcaGRNmRxkwEVbAZokHFPUB4utyqJFiUOWqhEP4mWxwm2759bQfrdr+ffhcYb\n\tcHuxGBZpvTGnUVGpHYyTW4DLcx7bDMjv4Of3RW/oEHjPPsSDGYQgkXmLNefquV8r3b2x\n\treqw==",
        "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=8KmrqFg30K76tisB9MMiRJR0yuUD3GwQGcFlEsL6uLk=;\n\tb=QTk9CfZlyN1yXNd3im29ZwqgrWyuOVOnsyGCiujFnRHQoUV4lRa59hu10+dD1dXuCL\n\tPH581gtOPXFlNKvzfyWl7SabuFmHbE3oQ+JIhNNHts4V4gx0Y2MXzRE7gXnjNEzXlbhB\n\t+Ubxi2Ohn1PaU7KaOblabS22W4KNlVInzxCpoA5Ebc9fjkNVfZ+Cf0KwATyBbK1d2Lq8\n\tVdZjPOIWEkqfX9+0Dtg8+rcW+744u8n5vS43lXsUZUc9FDZca/2XgE5Ua/ztRMeQ0+ok\n\tKYDVFRWIpOqlpDRsGTp5w9+Iqd63yQIWk/k3iDInrj7aulgkleDER/oh0DTDsEiqAza7\n\tQkMg==",
        "X-Gm-Message-State": "AHPjjUi4gApWEiQgdAgzctGK9yx6PjGVC2qCbdI23u/pwe4/euU0mPJw\n\tIdYQMjsX/bk1/g==",
        "X-Google-Smtp-Source": "AOwi7QC5ChtbGgYYP8nepDZWTt05j1i2L0GeqxBbh/SzBLo8emLLn+svwNnfyrcw9tuiw2UynyeVow==",
        "X-Received": "by 10.200.56.57 with SMTP id q54mr3088848qtb.310.1504910831624; \n\tFri, 08 Sep 2017 15:47:11 -0700 (PDT)",
        "From": "Ram Pai <linuxram@us.ibm.com>",
        "To": "mpe@ellerman.id.au,\n\tlinuxppc-dev@lists.ozlabs.org",
        "Subject": "[PATCH 17/25] powerpc: helper to validate key-access permissions of\n\ta pte",
        "Date": "Fri,  8 Sep 2017 15:45:05 -0700",
        "Message-Id": "<1504910713-7094-26-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": "helper function that checks if the read/write/execute is allowed\non the pte.\n\nSigned-off-by: Ram Pai <linuxram@us.ibm.com>\n---\n arch/powerpc/include/asm/book3s/64/pgtable.h |    4 +++\n arch/powerpc/include/asm/pkeys.h             |   12 +++++++++++\n arch/powerpc/mm/pkeys.c                      |   28 ++++++++++++++++++++++++++\n 3 files changed, 44 insertions(+), 0 deletions(-)",
    "diff": "diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h\nindex 5935d4e..bd244b3 100644\n--- a/arch/powerpc/include/asm/book3s/64/pgtable.h\n+++ b/arch/powerpc/include/asm/book3s/64/pgtable.h\n@@ -492,6 +492,10 @@ static inline void write_uamor(u64 value)\n \tmtspr(SPRN_UAMOR, value);\n }\n \n+#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS\n+extern bool arch_pte_access_permitted(u64 pte, bool write, bool execute);\n+#endif /* CONFIG_PPC64_MEMORY_PROTECTION_KEYS */\n+\n #define __HAVE_ARCH_PTEP_GET_AND_CLEAR\n static inline pte_t ptep_get_and_clear(struct mm_struct *mm,\n \t\t\t\t       unsigned long addr, pte_t *ptep)\ndiff --git a/arch/powerpc/include/asm/pkeys.h b/arch/powerpc/include/asm/pkeys.h\nindex cd3924c..50522a0 100644\n--- a/arch/powerpc/include/asm/pkeys.h\n+++ b/arch/powerpc/include/asm/pkeys.h\n@@ -80,6 +80,18 @@ static inline u64 pte_to_hpte_pkey_bits(u64 pteflags)\n \t\t((pteflags & H_PAGE_PKEY_BIT4) ? HPTE_R_KEY_BIT4 : 0x0UL));\n }\n \n+static inline u16 pte_to_pkey_bits(u64 pteflags)\n+{\n+\tif (!pkey_inited)\n+\t\treturn 0x0UL;\n+\n+\treturn (((pteflags & H_PAGE_PKEY_BIT0) ? 0x10 : 0x0UL) |\n+\t\t((pteflags & H_PAGE_PKEY_BIT1) ? 0x8 : 0x0UL) |\n+\t\t((pteflags & H_PAGE_PKEY_BIT2) ? 0x4 : 0x0UL) |\n+\t\t((pteflags & H_PAGE_PKEY_BIT3) ? 0x2 : 0x0UL) |\n+\t\t((pteflags & H_PAGE_PKEY_BIT4) ? 0x1 : 0x0UL));\n+}\n+\n #define ARCH_VM_PKEY_FLAGS (VM_PKEY_BIT0 | VM_PKEY_BIT1 | VM_PKEY_BIT2 | \\\n \t\t\t\tVM_PKEY_BIT3 | VM_PKEY_BIT4)\n #define AMR_BITS_PER_PKEY 2\ndiff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c\nindex fb1a76a..24589d9 100644\n--- a/arch/powerpc/mm/pkeys.c\n+++ b/arch/powerpc/mm/pkeys.c\n@@ -292,3 +292,31 @@ int __arch_override_mprotect_pkey(struct vm_area_struct *vma, int prot,\n \t */\n \treturn vma_pkey(vma);\n }\n+\n+static bool pkey_access_permitted(int pkey, bool write, bool execute)\n+{\n+\tint pkey_shift;\n+\tu64 amr;\n+\n+\tif (!pkey)\n+\t\treturn true;\n+\n+\tpkey_shift = pkeyshift(pkey);\n+\tif (!(read_uamor() & (0x3UL << pkey_shift)))\n+\t\treturn true;\n+\n+\tif (execute && !(read_iamr() & (IAMR_EX_BIT << pkey_shift)))\n+\t\treturn true;\n+\n+\tamr = read_amr(); /* delay reading amr uptil absolutely needed*/\n+\treturn ((!write && !(amr & (AMR_RD_BIT << pkey_shift))) ||\n+\t\t(write &&  !(amr & (AMR_WR_BIT << pkey_shift))));\n+}\n+\n+bool arch_pte_access_permitted(u64 pte, bool write, bool execute)\n+{\n+\tif (!pkey_inited)\n+\t\treturn true;\n+\treturn pkey_access_permitted(pte_to_pkey_bits(pte),\n+\t\t\twrite, execute);\n+}\n",
    "prefixes": [
        "17/25"
    ]
}