get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 807406,
    "url": "http://patchwork.ozlabs.org/api/patches/807406/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1504066360-30128-15-git-send-email-paulus@ozlabs.org/",
    "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": "<1504066360-30128-15-git-send-email-paulus@ozlabs.org>",
    "list_archive_url": "https://lore.kernel.org/linuxppc-dev/1504066360-30128-15-git-send-email-paulus@ozlabs.org/",
    "date": "2017-08-30T04:12:37",
    "name": "[v3,14/17] powerpc: Set regs->dar if memory access fails in emulate_step()",
    "commit_ref": "b9da9c8a48c56339c7c95d8ff0c9aff93727ac95",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "28b9c5d230614246b0e8c4ab8c6a366d83e7732e",
    "submitter": {
        "id": 67079,
        "url": "http://patchwork.ozlabs.org/api/people/67079/?format=api",
        "name": "Paul Mackerras",
        "email": "paulus@ozlabs.org"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1504066360-30128-15-git-send-email-paulus@ozlabs.org/mbox/",
    "series": [
        {
            "id": 522,
            "url": "http://patchwork.ozlabs.org/api/series/522/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=522",
            "date": "2017-08-30T04:12:25",
            "name": "powerpc: Do alignment fixups using analyse_instr etc.",
            "version": 3,
            "mbox": "http://patchwork.ozlabs.org/series/522/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/807406/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/807406/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",
            "linuxppc-dev@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 3xht9p2cBxz9sN7\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 30 Aug 2017 14:41:02 +1000 (AEST)",
            "from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xht9p1PdFzDqHj\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 30 Aug 2017 14:41:02 +1000 (AEST)",
            "from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xhsYK2by1zDqGG\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tWed, 30 Aug 2017 14:12:53 +1000 (AEST)",
            "by ozlabs.org (Postfix)\n\tid 3xhsYK0qxBz9sNc; Wed, 30 Aug 2017 14:12:53 +1000 (AEST)",
            "from authenticated.ozlabs.org (localhost [127.0.0.1])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPSA id 3xhsYJ5pkWz9sR9\n\tfor <linuxppc-dev@ozlabs.org>; Wed, 30 Aug 2017 14:12:52 +1000 (AEST)"
        ],
        "Authentication-Results": [
            "ozlabs.org; dkim=pass (2048-bit key;\n\tsecure) header.d=ozlabs.org header.i=@ozlabs.org header.b=\"miaS//0B\";\n\tdkim-atps=neutral",
            "lists.ozlabs.org; dkim=pass (2048-bit key;\n\tsecure) header.d=ozlabs.org header.i=@ozlabs.org header.b=\"miaS//0B\";\n\tdkim-atps=neutral",
            "lists.ozlabs.org; dkim=pass (2048-bit key;\n\tsecure) header.d=ozlabs.org header.i=@ozlabs.org header.b=\"miaS//0B\"; \n\tdkim-atps=neutral"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; \n\tt=1504066372; bh=oWpoVv9bomuw4k+liGy0Dn19sAg4attEwKYyOQKqILQ=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=miaS//0BZECk/JAto07SnU+yue5RKnTFOwNBrKRRz6HaetxLBTkDQyCzBxal/MfFR\n\t9OZ8Cpqs+a90KZfyCaPftzzZoymyjCUhnegdv+N1WX8EaLE8q5F2Cx5+D6Jcqugfwt\n\t6iZActl05yZvOrplOTFioQbRPwNg8sOSONVUgfLqU8gESpACoo6B5GcF4eNWOQEpwA\n\tEL3GO+cjGzJPMvUxcNFxCqM0iiF93/rJogyI9bqTAVslssfEtHXgrw0vtVKOw2Zi03\n\tubsn7pnTkHYF0fn9ntLiP44bYnuzrCUaUquDIDwtinr+wSI7fuvpXFvcI88U/XCOde\n\tJCbWvHiZTywFA==",
        "From": "Paul Mackerras <paulus@ozlabs.org>",
        "To": "linuxppc-dev@ozlabs.org",
        "Subject": "[PATCH v3 14/17] powerpc: Set regs->dar if memory access fails in\n\temulate_step()",
        "Date": "Wed, 30 Aug 2017 14:12:37 +1000",
        "Message-Id": "<1504066360-30128-15-git-send-email-paulus@ozlabs.org>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1504066360-30128-1-git-send-email-paulus@ozlabs.org>",
        "References": "<1504066360-30128-1-git-send-email-paulus@ozlabs.org>",
        "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>",
        "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": "This adds code to the instruction emulation code to set regs->dar\nto the address of any memory access that fails.  This address is\nnot necessarily the same as the effective address of the instruction,\nbecause if the memory access is unaligned, it might cross a page\nboundary and fault on the second page.\n\nSigned-off-by: Paul Mackerras <paulus@ozlabs.org>\n---\n arch/powerpc/lib/sstep.c | 74 ++++++++++++++++++++++++++++++++++--------------\n 1 file changed, 52 insertions(+), 22 deletions(-)",
    "diff": "diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c\nindex fa20f3a..5c0f50b 100644\n--- a/arch/powerpc/lib/sstep.c\n+++ b/arch/powerpc/lib/sstep.c\n@@ -103,11 +103,19 @@ static nokprobe_inline int branch_taken(unsigned int instr,\n \treturn 1;\n }\n \n-static nokprobe_inline long address_ok(struct pt_regs *regs, unsigned long ea, int nb)\n+static nokprobe_inline long address_ok(struct pt_regs *regs,\n+\t\t\t\t       unsigned long ea, int nb)\n {\n \tif (!user_mode(regs))\n \t\treturn 1;\n-\treturn __access_ok(ea, nb, USER_DS);\n+\tif (__access_ok(ea, nb, USER_DS))\n+\t\treturn 1;\n+\tif (__access_ok(ea, 1, USER_DS))\n+\t\t/* Access overlaps the end of the user region */\n+\t\tregs->dar = USER_DS.seg;\n+\telse\n+\t\tregs->dar = ea;\n+\treturn 0;\n }\n \n /*\n@@ -210,7 +218,8 @@ static nokprobe_inline unsigned long byterev_8(unsigned long x)\n #endif\n \n static nokprobe_inline int read_mem_aligned(unsigned long *dest,\n-\t\t\t\t\tunsigned long ea, int nb)\n+\t\t\t\t\t    unsigned long ea, int nb,\n+\t\t\t\t\t    struct pt_regs *regs)\n {\n \tint err = 0;\n \tunsigned long x = 0;\n@@ -233,6 +242,8 @@ static nokprobe_inline int read_mem_aligned(unsigned long *dest,\n \t}\n \tif (!err)\n \t\t*dest = x;\n+\telse\n+\t\tregs->dar = ea;\n \treturn err;\n }\n \n@@ -240,7 +251,8 @@ static nokprobe_inline int read_mem_aligned(unsigned long *dest,\n  * Copy from userspace to a buffer, using the largest possible\n  * aligned accesses, up to sizeof(long).\n  */\n-static int nokprobe_inline copy_mem_in(u8 *dest, unsigned long ea, int nb)\n+static int nokprobe_inline copy_mem_in(u8 *dest, unsigned long ea, int nb,\n+\t\t\t\t       struct pt_regs *regs)\n {\n \tint err = 0;\n \tint c;\n@@ -268,8 +280,10 @@ static int nokprobe_inline copy_mem_in(u8 *dest, unsigned long ea, int nb)\n \t\t\tbreak;\n #endif\n \t\t}\n-\t\tif (err)\n+\t\tif (err) {\n+\t\t\tregs->dar = ea;\n \t\t\treturn err;\n+\t\t}\n \t\tdest += c;\n \t\tea += c;\n \t}\n@@ -289,7 +303,7 @@ static nokprobe_inline int read_mem_unaligned(unsigned long *dest,\n \n \tu.ul = 0;\n \ti = IS_BE ? sizeof(unsigned long) - nb : 0;\n-\terr = copy_mem_in(&u.b[i], ea, nb);\n+\terr = copy_mem_in(&u.b[i], ea, nb, regs);\n \tif (!err)\n \t\t*dest = u.ul;\n \treturn err;\n@@ -306,13 +320,14 @@ static int read_mem(unsigned long *dest, unsigned long ea, int nb,\n \tif (!address_ok(regs, ea, nb))\n \t\treturn -EFAULT;\n \tif ((ea & (nb - 1)) == 0)\n-\t\treturn read_mem_aligned(dest, ea, nb);\n+\t\treturn read_mem_aligned(dest, ea, nb, regs);\n \treturn read_mem_unaligned(dest, ea, nb, regs);\n }\n NOKPROBE_SYMBOL(read_mem);\n \n static nokprobe_inline int write_mem_aligned(unsigned long val,\n-\t\t\t\t\tunsigned long ea, int nb)\n+\t\t\t\t\t     unsigned long ea, int nb,\n+\t\t\t\t\t     struct pt_regs *regs)\n {\n \tint err = 0;\n \n@@ -332,6 +347,8 @@ static nokprobe_inline int write_mem_aligned(unsigned long val,\n \t\tbreak;\n #endif\n \t}\n+\tif (err)\n+\t\tregs->dar = ea;\n \treturn err;\n }\n \n@@ -339,7 +356,8 @@ static nokprobe_inline int write_mem_aligned(unsigned long val,\n  * Copy from a buffer to userspace, using the largest possible\n  * aligned accesses, up to sizeof(long).\n  */\n-static int nokprobe_inline copy_mem_out(u8 *dest, unsigned long ea, int nb)\n+static int nokprobe_inline copy_mem_out(u8 *dest, unsigned long ea, int nb,\n+\t\t\t\t\tstruct pt_regs *regs)\n {\n \tint err = 0;\n \tint c;\n@@ -367,8 +385,10 @@ static int nokprobe_inline copy_mem_out(u8 *dest, unsigned long ea, int nb)\n \t\t\tbreak;\n #endif\n \t\t}\n-\t\tif (err)\n+\t\tif (err) {\n+\t\t\tregs->dar = ea;\n \t\t\treturn err;\n+\t\t}\n \t\tdest += c;\n \t\tea += c;\n \t}\n@@ -387,7 +407,7 @@ static nokprobe_inline int write_mem_unaligned(unsigned long val,\n \n \tu.ul = val;\n \ti = IS_BE ? sizeof(unsigned long) - nb : 0;\n-\treturn copy_mem_out(&u.b[i], ea, nb);\n+\treturn copy_mem_out(&u.b[i], ea, nb, regs);\n }\n \n /*\n@@ -400,7 +420,7 @@ static int write_mem(unsigned long val, unsigned long ea, int nb,\n \tif (!address_ok(regs, ea, nb))\n \t\treturn -EFAULT;\n \tif ((ea & (nb - 1)) == 0)\n-\t\treturn write_mem_aligned(val, ea, nb);\n+\t\treturn write_mem_aligned(val, ea, nb, regs);\n \treturn write_mem_unaligned(val, ea, nb, regs);\n }\n NOKPROBE_SYMBOL(write_mem);\n@@ -422,7 +442,7 @@ static int do_fp_load(int rn, unsigned long ea, int nb, struct pt_regs *regs)\n \n \tif (!address_ok(regs, ea, nb))\n \t\treturn -EFAULT;\n-\terr = copy_mem_in(u.b, ea, nb);\n+\terr = copy_mem_in(u.b, ea, nb, regs);\n \tif (err)\n \t\treturn err;\n \tpreempt_disable();\n@@ -471,7 +491,7 @@ static int do_fp_store(int rn, unsigned long ea, int nb, struct pt_regs *regs)\n \t\t\tu.l[1] = current->thread.TS_FPR(rn);\n \t}\n \tpreempt_enable();\n-\treturn copy_mem_out(u.b, ea, nb);\n+\treturn copy_mem_out(u.b, ea, nb, regs);\n }\n NOKPROBE_SYMBOL(do_fp_store);\n #endif\n@@ -491,7 +511,7 @@ static nokprobe_inline int do_vec_load(int rn, unsigned long ea,\n \t\treturn -EFAULT;\n \t/* align to multiple of size */\n \tea &= ~(size - 1);\n-\terr = copy_mem_in(&u.b[ea & 0xf], ea, size);\n+\terr = copy_mem_in(&u.b[ea & 0xf], ea, size, regs);\n \tif (err)\n \t\treturn err;\n \n@@ -523,7 +543,7 @@ static nokprobe_inline int do_vec_store(int rn, unsigned long ea,\n \telse\n \t\tu.v = current->thread.vr_state.vr[rn];\n \tpreempt_enable();\n-\treturn copy_mem_out(&u.b[ea & 0xf], ea, size);\n+\treturn copy_mem_out(&u.b[ea & 0xf], ea, size, regs);\n }\n #endif /* CONFIG_ALTIVEC */\n \n@@ -725,7 +745,7 @@ static nokprobe_inline int do_vsx_load(struct instruction_op *op,\n \tunion vsx_reg buf;\n \tint size = GETSIZE(op->type);\n \n-\tif (!address_ok(regs, ea, size) || copy_mem_in(mem, ea, size))\n+\tif (!address_ok(regs, ea, size) || copy_mem_in(mem, ea, size, regs))\n \t\treturn -EFAULT;\n \n \temulate_vsx_load(op, &buf, mem);\n@@ -776,7 +796,7 @@ static nokprobe_inline int do_vsx_store(struct instruction_op *op,\n \t}\n \tpreempt_enable();\n \temulate_vsx_store(op, &buf, mem);\n-\treturn  copy_mem_out(mem, ea, size);\n+\treturn  copy_mem_out(mem, ea, size, regs);\n }\n #endif /* CONFIG_VSX */\n \n@@ -797,8 +817,10 @@ int emulate_dcbz(unsigned long ea, struct pt_regs *regs)\n \t\treturn -EFAULT;\n \tfor (i = 0; i < size; i += sizeof(long)) {\n \t\terr = __put_user(0, (unsigned long __user *) (ea + i));\n-\t\tif (err)\n+\t\tif (err) {\n+\t\t\tregs->dar = ea;\n \t\t\treturn err;\n+\t\t}\n \t}\n \treturn 0;\n }\n@@ -2640,8 +2662,10 @@ int emulate_step(struct pt_regs *regs, unsigned int instr)\n \t\t\terr = emulate_dcbz(ea, regs);\n \t\t\tbreak;\n \t\t}\n-\t\tif (err)\n+\t\tif (err) {\n+\t\t\tregs->dar = ea;\n \t\t\treturn 0;\n+\t\t}\n \t\tgoto instr_done;\n \n \tcase LARX:\n@@ -2668,12 +2692,16 @@ int emulate_step(struct pt_regs *regs, unsigned int instr)\n \t\t\tbreak;\n \t\tcase 16:\n \t\t\terr = do_lqarx(ea, &regs->gpr[op.reg]);\n-\t\t\tgoto ldst_done;\n+\t\t\tbreak;\n #endif\n \t\tdefault:\n \t\t\treturn 0;\n \t\t}\n-\t\tif (!err)\n+\t\tif (err) {\n+\t\t\tregs->dar = ea;\n+\t\t\treturn 0;\n+\t\t}\n+\t\tif (size < 16)\n \t\t\tregs->gpr[op.reg] = val;\n \t\tgoto ldst_done;\n \n@@ -2711,6 +2739,8 @@ int emulate_step(struct pt_regs *regs, unsigned int instr)\n \t\t\tregs->ccr = (regs->ccr & 0x0fffffff) |\n \t\t\t\t(cr & 0xe0000000) |\n \t\t\t\t((regs->xer >> 3) & 0x10000000);\n+\t\telse\n+\t\t\tregs->dar = ea;\n \t\tgoto ldst_done;\n \n \tcase LOAD:\n",
    "prefixes": [
        "v3",
        "14/17"
    ]
}