get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 809918,
    "url": "http://patchwork.ozlabs.org/api/patches/809918/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20170905041555.27696-3-bsingharora@gmail.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": "<20170905041555.27696-3-bsingharora@gmail.com>",
    "list_archive_url": "https://lore.kernel.org/linuxppc-dev/20170905041555.27696-3-bsingharora@gmail.com/",
    "date": "2017-09-05T04:15:54",
    "name": "[rfc,2/3] powerpc/mce: Extract physical_address for UE errors",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "a65e242402ea1f3a9456ca4767f8b699d8026af0",
    "submitter": {
        "id": 9347,
        "url": "http://patchwork.ozlabs.org/api/people/9347/?format=api",
        "name": "Balbir Singh",
        "email": "bsingharora@gmail.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20170905041555.27696-3-bsingharora@gmail.com/mbox/",
    "series": [
        {
            "id": 1484,
            "url": "http://patchwork.ozlabs.org/api/series/1484/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=1484",
            "date": "2017-09-05T04:15:52",
            "name": "Revisit MCE handling for UE errors",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/1484/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/809918/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/809918/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 [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 3xmYSf6kbDz9s9Y\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue,  5 Sep 2017 14:21:38 +1000 (AEST)",
            "from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xmYSf5YjWzDrFT\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue,  5 Sep 2017 14:21:38 +1000 (AEST)",
            "from ozlabs.org (bilbo.ozlabs.org [103.22.144.67])\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 3xmYLR3hzQzDrCc\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tTue,  5 Sep 2017 14:16:15 +1000 (AEST)",
            "from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2])\n\tby bilbo.ozlabs.org (Postfix) with ESMTP id 3xmYLR1N8Sz8t2N\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tTue,  5 Sep 2017 14:16:15 +1000 (AEST)",
            "by ozlabs.org (Postfix)\n\tid 3xmYLR0bYZz9sPk; Tue,  5 Sep 2017 14:16:15 +1000 (AEST)",
            "from mail-pf0-x243.google.com (mail-pf0-x243.google.com\n\t[IPv6:2607:f8b0:400e:c00::243])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xmYLQ3PyCz9s9Y\n\tfor <linuxppc-dev@ozlabs.org>; Tue,  5 Sep 2017 14:16:14 +1000 (AEST)",
            "by mail-pf0-x243.google.com with SMTP id m1so1109705pfk.0\n\tfor <linuxppc-dev@ozlabs.org>; Mon, 04 Sep 2017 21:16:14 -0700 (PDT)",
            "from firefly.ozlabs.ibm.com.ozlabs.ibm.com ([122.99.82.10])\n\tby smtp.gmail.com with ESMTPSA id\n\tw6sm11634415pfb.13.2017.09.04.21.16.10\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tMon, 04 Sep 2017 21:16:12 -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=\"EjbxFSus\"; 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=\"EjbxFSus\"; dkim-atps=neutral",
            "lists.ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"EjbxFSus\"; dkim-atps=neutral",
            "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gmail.com\n\t(client-ip=2607:f8b0:400e:c00::243; helo=mail-pf0-x243.google.com;\n\tenvelope-from=bsingharora@gmail.com; receiver=<UNKNOWN>)",
            "ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"EjbxFSus\"; dkim-atps=neutral"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=6Zzi3FRt8O6xlo0nG3EeB1F0CVOl/l21wu4UyktiPu0=;\n\tb=EjbxFSussgv3ubuJHRaS1MGNtfFylrRQu7tYwT6WdK8B/hNIIsL0AdxTyxtehxJD35\n\tr3TfL8l1oV8+9nBBfhmByBGXpW7lmADctjfo1S3AGd6yX9JYuoq7+OGxnOAHNbC5tH/8\n\t4+8kIEc7utd9YcaFp6gMr92jAwhX7yD3+CEOdec+V1LCo3LKTYM9srKveAMpMo0o7f/1\n\tvOBHe/I8qxlTK4kbMTYHh1adLXONYucQ8TF4dx2SeqII9bTaXmLlm/uQYm742su4omtZ\n\tgcYJS3SlMryFXbaM0s7ocZprcm0CT4+Y+FAWjsNAKv12Q4orh4WHErxu/bTH5920fI+d\n\tDQTw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=6Zzi3FRt8O6xlo0nG3EeB1F0CVOl/l21wu4UyktiPu0=;\n\tb=mz73ug4IJrPTc8YrLFhGenQJ8AuuqbalgToW4ot2GE7kGvVfyG41hyceHuCRvPtfhh\n\tPyRLdPypi8kYAF0GyJ6CAygMRrcXCzMozCxu4KOsW3TfmXHnAFY1E3Tiey5uSQI+x9a1\n\t8Bca16sle4IaNiAIE2WMBcCxjtSsg4vdAdb6W8/tb6wHv1jrcLNeMwaDQgB76H4ZVxor\n\t8B7CISvGvis9+JvMoNv222YIod9qBF6dpNtu8pN194qbB3KGLLigL5OAPjYGe8R1zDi6\n\t8xJDPbc893DtclMd433AJ106KDCE6IoNaRjMivgTRS9b8tcLHp62QzBs3BP5bXI1fK1h\n\twdlg==",
        "X-Gm-Message-State": "AHPjjUiDWgjTiSdr/wipi96gzrsCLmLwnIUTfm/XWL5vdtyn5mixjl+0\n\tW0A6sSNyv6PMSA==",
        "X-Google-Smtp-Source": "ADKCNb4iuoPUjXRjd9MJEPHdfXij2WSb4xDGufLMO8EHWOWYqnsmM3H87PbmllwREqtvOWRu4ZnWZg==",
        "X-Received": "by 10.84.129.72 with SMTP id 66mr2886674plb.102.1504584972917;\n\tMon, 04 Sep 2017 21:16:12 -0700 (PDT)",
        "From": "Balbir Singh <bsingharora@gmail.com>",
        "To": "npiggin@gmail.com,\n\tmahesh@linux.vnet.ibm.com,\n\talistair@popple.id.au",
        "Subject": "[rfc 2/3] powerpc/mce: Extract physical_address for UE errors",
        "Date": "Tue,  5 Sep 2017 14:15:54 +1000",
        "Message-Id": "<20170905041555.27696-3-bsingharora@gmail.com>",
        "X-Mailer": "git-send-email 2.9.5",
        "In-Reply-To": "<20170905041555.27696-1-bsingharora@gmail.com>",
        "References": "<20170905041555.27696-1-bsingharora@gmail.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": "linuxppc-dev@ozlabs.org",
        "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": "Walk the page table for NIP and extract the instruction. Then\nuse the instruction to find the effective address via analyse_instr().\n\nWe might have page table walking races, but we expect them to\nbe rare, the physical address extraction is best effort. The idea\nis to then hook up this infrastructure to memory failure eventually.\n\nSigned-off-by: Balbir Singh <bsingharora@gmail.com>\n---\n arch/powerpc/include/asm/mce.h  |  2 +-\n arch/powerpc/kernel/mce.c       |  6 ++++-\n arch/powerpc/kernel/mce_power.c | 60 +++++++++++++++++++++++++++++++++++++----\n 3 files changed, 61 insertions(+), 7 deletions(-)",
    "diff": "diff --git a/arch/powerpc/include/asm/mce.h b/arch/powerpc/include/asm/mce.h\nindex 75292c7..3a1226e 100644\n--- a/arch/powerpc/include/asm/mce.h\n+++ b/arch/powerpc/include/asm/mce.h\n@@ -204,7 +204,7 @@ struct mce_error_info {\n \n extern void save_mce_event(struct pt_regs *regs, long handled,\n \t\t\t   struct mce_error_info *mce_err, uint64_t nip,\n-\t\t\t   uint64_t addr);\n+\t\t\t   uint64_t addr, uint64_t phys_addr);\n extern int get_mce_event(struct machine_check_event *mce, bool release);\n extern void release_mce_event(void);\n extern void machine_check_queue_event(void);\ndiff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c\nindex e254399..f41a75d 100644\n--- a/arch/powerpc/kernel/mce.c\n+++ b/arch/powerpc/kernel/mce.c\n@@ -82,7 +82,7 @@ static void mce_set_error_info(struct machine_check_event *mce,\n  */\n void save_mce_event(struct pt_regs *regs, long handled,\n \t\t    struct mce_error_info *mce_err,\n-\t\t    uint64_t nip, uint64_t addr)\n+\t\t    uint64_t nip, uint64_t addr, uint64_t phys_addr)\n {\n \tint index = __this_cpu_inc_return(mce_nest_count) - 1;\n \tstruct machine_check_event *mce = this_cpu_ptr(&mce_event[index]);\n@@ -140,6 +140,10 @@ void save_mce_event(struct pt_regs *regs, long handled,\n \t} else if (mce->error_type == MCE_ERROR_TYPE_UE) {\n \t\tmce->u.ue_error.effective_address_provided = true;\n \t\tmce->u.ue_error.effective_address = addr;\n+\t\tif (phys_addr != ULONG_MAX) {\n+\t\t\tmce->u.ue_error.physical_address_provided = true;\n+\t\t\tmce->u.ue_error.physical_address = phys_addr;\n+\t\t}\n \t}\n \treturn;\n }\ndiff --git a/arch/powerpc/kernel/mce_power.c b/arch/powerpc/kernel/mce_power.c\nindex b76ca19..b77a698 100644\n--- a/arch/powerpc/kernel/mce_power.c\n+++ b/arch/powerpc/kernel/mce_power.c\n@@ -27,6 +27,25 @@\n #include <asm/mmu.h>\n #include <asm/mce.h>\n #include <asm/machdep.h>\n+#include <asm/pgtable.h>\n+#include <asm/pte-walk.h>\n+#include <asm/sstep.h>\n+\n+static unsigned long addr_to_pfn(struct mm_struct *mm, unsigned long addr)\n+{\n+\tpte_t *ptep;\n+\tunsigned long flags;\n+\n+\tlocal_irq_save(flags);\n+\tif (mm == current->mm)\n+\t\tptep = find_current_mm_pte(mm->pgd, addr, NULL, NULL);\n+\telse\n+\t\tptep = find_init_mm_pte(addr, NULL);\n+\tlocal_irq_restore(flags);\n+\tif (!ptep)\n+\t\treturn ULONG_MAX;\n+\treturn pte_pfn(*ptep);\n+}\n \n static void flush_tlb_206(unsigned int num_sets, unsigned int action)\n {\n@@ -489,7 +508,8 @@ static int mce_handle_ierror(struct pt_regs *regs,\n \n static int mce_handle_derror(struct pt_regs *regs,\n \t\tconst struct mce_derror_table table[],\n-\t\tstruct mce_error_info *mce_err, uint64_t *addr)\n+\t\tstruct mce_error_info *mce_err, uint64_t *addr,\n+\t\tuint64_t *phys_addr)\n {\n \tuint64_t dsisr = regs->dsisr;\n \tint handled = 0;\n@@ -555,7 +575,37 @@ static int mce_handle_derror(struct pt_regs *regs,\n \t\tmce_err->initiator = table[i].initiator;\n \t\tif (table[i].dar_valid)\n \t\t\t*addr = regs->dar;\n-\n+\t\telse if (mce_err->severity == MCE_SEV_ERROR_SYNC &&\n+\t\t\t\ttable[i].error_type == MCE_ERROR_TYPE_UE) {\n+\t\t\t/*\n+\t\t\t * Carefully look at the NIP to determine\n+\t\t\t * the instruction to analyse. Reading the NIP\n+\t\t\t * in real-mode is tricky and can lead to recursive\n+\t\t\t * faults\n+\t\t\t */\n+\t\t\tint instr;\n+\t\t\tstruct mm_struct *mm;\n+\t\t\tunsigned long nip = regs->nip;\n+\t\t\tunsigned long pfn = 0, instr_addr;\n+\t\t\tstruct instruction_op op;\n+\t\t\tstruct pt_regs tmp = *regs;\n+\n+\t\t\tif (user_mode(regs))\n+\t\t\t\tmm = current->mm;\n+\t\t\telse\n+\t\t\t\tmm = &init_mm;\n+\n+\t\t\tpfn = addr_to_pfn(mm, nip);\n+\t\t\tif (pfn != ULONG_MAX) {\n+\t\t\t\tinstr_addr = (pfn << PAGE_SHIFT) + (nip & ~PAGE_MASK);\n+\t\t\t\tinstr = *(unsigned int *)(instr_addr);\n+\t\t\t\tif (!analyse_instr(&op, &tmp, instr)) {\n+\t\t\t\t\tpfn = addr_to_pfn(mm, op.ea);\n+\t\t\t\t\t*addr = op.ea;\n+\t\t\t\t\t*phys_addr = pfn;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n \t\tfound = 1;\n \t}\n \n@@ -592,19 +642,19 @@ static long mce_handle_error(struct pt_regs *regs,\n \t\tconst struct mce_ierror_table itable[])\n {\n \tstruct mce_error_info mce_err = { 0 };\n-\tuint64_t addr;\n+\tuint64_t addr, phys_addr;\n \tuint64_t srr1 = regs->msr;\n \tlong handled;\n \n \tif (SRR1_MC_LOADSTORE(srr1))\n-\t\thandled = mce_handle_derror(regs, dtable, &mce_err, &addr);\n+\t\thandled = mce_handle_derror(regs, dtable, &mce_err, &addr, &phys_addr);\n \telse\n \t\thandled = mce_handle_ierror(regs, itable, &mce_err, &addr);\n \n \tif (!handled && mce_err.error_type == MCE_ERROR_TYPE_UE)\n \t\thandled = mce_handle_ue_error(regs);\n \n-\tsave_mce_event(regs, handled, &mce_err, regs->nip, addr);\n+\tsave_mce_event(regs, handled, &mce_err, regs->nip, addr, phys_addr);\n \n \treturn handled;\n }\n",
    "prefixes": [
        "rfc",
        "2/3"
    ]
}