get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 790841,
    "url": "http://patchwork.ozlabs.org/api/1.2/patches/790841/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20170719065912.19183-3-npiggin@gmail.com/",
    "project": {
        "id": 2,
        "url": "http://patchwork.ozlabs.org/api/1.2/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": "<20170719065912.19183-3-npiggin@gmail.com>",
    "list_archive_url": "https://lore.kernel.org/linuxppc-dev/20170719065912.19183-3-npiggin@gmail.com/",
    "date": "2017-07-19T06:59:11",
    "name": "[v2,2/3] powerpc/powernv: machine check use kernel crash path",
    "commit_ref": "6fcd6baa90aeec9dcbe30786e15c125bf50503b2",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "a23cb088df4e5d12189ace4449a9104dffcf605e",
    "submitter": {
        "id": 69518,
        "url": "http://patchwork.ozlabs.org/api/1.2/people/69518/?format=api",
        "name": "Nicholas Piggin",
        "email": "npiggin@gmail.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20170719065912.19183-3-npiggin@gmail.com/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/790841/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/790841/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 3xC7MN2CYrz9s8P\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 19 Jul 2017 17:05:04 +1000 (AEST)",
            "from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xC7MN0wtCzDrVq\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 19 Jul 2017 17:05:04 +1000 (AEST)",
            "from mail-pf0-x241.google.com (mail-pf0-x241.google.com\n\t[IPv6:2607:f8b0:400e:c00::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 3xC7F30KFczDrVJ\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tWed, 19 Jul 2017 16:59:35 +1000 (AEST)",
            "by mail-pf0-x241.google.com with SMTP id e199so5442142pfh.0\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tTue, 18 Jul 2017 23:59:34 -0700 (PDT)",
            "from roar.ozlabs.ibm.com. ([122.99.82.10])\n\tby smtp.gmail.com with ESMTPSA id\n\th90sm11326422pfh.133.2017.07.18.23.59.29\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tTue, 18 Jul 2017 23:59:31 -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=\"EzmKdsYp\"; 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=\"EzmKdsYp\"; dkim-atps=neutral",
            "lists.ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"EzmKdsYp\"; 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=iHJ96ZIad47u0Yer8XUKoJY/URzMdfJTbpr9FnTm7RM=;\n\tb=EzmKdsYpZqej3NyvDRkXgPOmEJJrO9E4eJY8tVKka/Ac7K/TPHERRZ1CZC7nHIPT+U\n\teHn1EEhFhj40GZAPQFilD63seFTkR5/F9c1EdouiLpwPF2RGImuYfUYASQTuuvJsF+fS\n\t5PvUPlEcD703nd71qRu3SeI27YpxUDH0O6YUwnNykwoqSq6UrTCo/k9XToD5dcmkL9wd\n\tPZbN4JHcvHt4g5gq1Aa8FvhT5dasVs//00zsYwXUZLUdI0Wa9msHnIalTCGp075Ko+vz\n\tvs8mKe4GfSJ3dmB5R8fwQKS2iGt2pCwkgu7tsBdEdpU9vSKHs1v6QWP+wxmsjDf0weZZ\n\tOUOg==",
        "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=iHJ96ZIad47u0Yer8XUKoJY/URzMdfJTbpr9FnTm7RM=;\n\tb=UrF2plBs72r8i5qHA9/KKVnNhnkt3h9AsyQ3eKMb/lclJTGqXz0Qz3n/ILLO0AJvxN\n\tyRkiuKVBLD87Kj8381dzCqIESVxXa2ko4g6I1T25lPZeaSjdtDOoF7wx5664Z0wCQfRX\n\twdzrYvvqlndAbq67/wfPf7dWO2GALZfhqDO+0L3zNyVDICOYvqhTBZeMFMOvp2FBFthn\n\t296/I4b7HdmhGCchCWj4c/X1Po8BWNR/w84LUVbMrtkiBRGKYO3vi4nOU6hnHHNw/IwG\n\t1cdu98hFjepcfBJGar98c6+HsGn7PHJYaEOYxHii5Z9PIFFd+TdUMX4Oqdya+Ndxw9Tn\n\t+G2g==",
        "X-Gm-Message-State": "AIVw1106n7slSWjcx1hVs92VkG2exDSfnzAmSJtooz+c+AOghQYuyayW\n\tkkAd5gh9R0LX+Q4T",
        "X-Received": "by 10.84.140.107 with SMTP id 98mr1634726pls.97.1500447572767;\n\tTue, 18 Jul 2017 23:59:32 -0700 (PDT)",
        "From": "Nicholas Piggin <npiggin@gmail.com>",
        "To": "linuxppc-dev@lists.ozlabs.org",
        "Subject": "[PATCH v2 2/3] powerpc/powernv: machine check use kernel crash path",
        "Date": "Wed, 19 Jul 2017 16:59:11 +1000",
        "Message-Id": "<20170719065912.19183-3-npiggin@gmail.com>",
        "X-Mailer": "git-send-email 2.11.0",
        "In-Reply-To": "<20170719065912.19183-1-npiggin@gmail.com>",
        "References": "<20170719065912.19183-1-npiggin@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": "Nicholas Piggin <npiggin@gmail.com>,\n\tMahesh Jagannath Salgaonkar <mahesh@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": "There are quite a few machine check exceptions that can be caused by\nkernel bugs. To make debugging easier, use the kernel crash path in\ncases of synchronous machine checks that occur in kernel mode, if that\nwould not result in the machine going straight to panic or crash dump.\n\nThere is a downside here that die()ing the process in kernel mode can\nstill leave the system unstable. panic_on_oops will always force the\nsystem to fail-stop, so systems where that behaviour is important will\nstill do the right thing.\n\nAs a test, when triggering an i-side 0111b error (ifetch from foreign\naddress) in kernel mode process context on POWER9, the kernel currently\ndies quickly like this:\n\nSevere Machine check interrupt [Not recovered]\n  NIP [ffff000000000000]: 0xffff000000000000\n  Initiator: CPU\n  Error type: Real address [Instruction fetch (foreign)]\n[  127.426651616,0] OPAL: Reboot requested due to Platform error.\n    Effective[  127.426693712,3] OPAL: Reboot requested due to Platform error. address: ffff000000000000\nopal: Reboot type 1 not supported\nKernel panic - not syncing: PowerNV Unrecovered Machine Check\nCPU: 56 PID: 4425 Comm: syscall Tainted: G   M            4.12.0-rc1-13857-ga4700a261072-dirty #35\nCall Trace:\n[  128.017988928,4] IPMI: BUG: Dropping ESEL on the floor due to buggy/mising code in OPAL for this BMCRebooting in 10 seconds..\nTrying to free IRQ 496 from IRQ context!\n\n\nAfter this patch, the process is killed and the kernel continues with\nthis message, which gives enough information to identify the offending\nbranch (i.e., with CFAR):\n\nSevere Machine check interrupt [Not recovered]\n  NIP [ffff000000000000]: 0xffff000000000000\n  Initiator: CPU\n  Error type: Real address [Instruction fetch (foreign)]\n    Effective address: ffff000000000000\nOops: Machine check, sig: 7 [#1]\nSMP NR_CPUS=2048\nNUMA\nPowerNV\nModules linked in: iptable_mangle ipt_MASQUERADE nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack ipt_REJECT nf_reject_ipv4 xt_tcpudp tun bridge stp llc kvm_hv kvm iptable_filter binfmt_misc vmx_crypto ip_tables x_tables autofs4 crc32c_vpmsum\nCPU: 22 PID: 4436 Comm: syscall Tainted: G   M            4.12.0-rc1-13857-ga4700a261072-dirty #36\ntask: c000000932300000 task.stack: c000000932380000\nNIP: ffff000000000000 LR: 00000000217706a4 CTR: ffff000000000000\nREGS: c00000000fc8fd80 TRAP: 0200   Tainted: G   M             (4.12.0-rc1-13857-ga4700a261072-dirty)\nMSR: 90000000001c1003 <SF,HV,ME,RI,LE>\n  CR: 24000484  XER: 20000000\nCFAR: c000000000004c80 DAR: 0000000021770a90 DSISR: 0a000000 SOFTE: 1\nGPR00: 0000000000001ebe 00007fffce4818b0 0000000021797f00 0000000000000000\nGPR04: 00007fff8007ac24 0000000044000484 0000000000004000 00007fff801405e8\nGPR08: 900000000280f033 0000000024000484 0000000000000000 0000000000000030\nGPR12: 9000000000001003 00007fff801bc370 0000000000000000 0000000000000000\nGPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000\nGPR20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000\nGPR24: 0000000000000000 0000000000000000 0000000000000000 0000000000000000\nGPR28: 00007fff801b0000 0000000000000000 00000000217707a0 00007fffce481918\nNIP [ffff000000000000] 0xffff000000000000\nLR [00000000217706a4] 0x217706a4\nCall Trace:\nInstruction dump:\nXXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX\nXXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX\n---[ end trace 32ae1dabb4f8dae6 ]---\n\nSigned-off-by: Nicholas Piggin <npiggin@gmail.com>\n---\n arch/powerpc/include/asm/bug.h        |  1 +\n arch/powerpc/include/asm/fadump.h     |  2 ++\n arch/powerpc/kernel/fadump.c          |  9 ++++++++-\n arch/powerpc/kernel/traps.c           | 22 ++++++++++++++++++++++\n arch/powerpc/platforms/powernv/opal.c | 32 ++++++++++++++++++++++++++------\n 5 files changed, 59 insertions(+), 7 deletions(-)",
    "diff": "diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h\nindex 0151af6c2a50..9a918b3ca5ee 100644\n--- a/arch/powerpc/include/asm/bug.h\n+++ b/arch/powerpc/include/asm/bug.h\n@@ -133,6 +133,7 @@ extern int do_page_fault(struct pt_regs *, unsigned long, unsigned long);\n extern void bad_page_fault(struct pt_regs *, unsigned long, int);\n extern void _exception(int, struct pt_regs *, int, unsigned long);\n extern void die(const char *, struct pt_regs *, long);\n+extern bool die_will_crash(void);\n \n #endif /* !__ASSEMBLY__ */\n \ndiff --git a/arch/powerpc/include/asm/fadump.h b/arch/powerpc/include/asm/fadump.h\nindex ce88bbe1d809..5a23010af600 100644\n--- a/arch/powerpc/include/asm/fadump.h\n+++ b/arch/powerpc/include/asm/fadump.h\n@@ -209,11 +209,13 @@ extern int early_init_dt_scan_fw_dump(unsigned long node,\n extern int fadump_reserve_mem(void);\n extern int setup_fadump(void);\n extern int is_fadump_active(void);\n+extern int should_fadump_crash(void);\n extern void crash_fadump(struct pt_regs *, const char *);\n extern void fadump_cleanup(void);\n \n #else\t/* CONFIG_FA_DUMP */\n static inline int is_fadump_active(void) { return 0; }\n+static inline int should_fadump_crash(void) { return 0; }\n static inline void crash_fadump(struct pt_regs *regs, const char *str) { }\n #endif\n #endif\ndiff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c\nindex da8830e49696..8a3058f5943b 100644\n--- a/arch/powerpc/kernel/fadump.c\n+++ b/arch/powerpc/kernel/fadump.c\n@@ -125,6 +125,13 @@ int is_fadump_boot_memory_area(u64 addr, ulong size)\n \treturn (addr + size) > RMA_START && addr <= fw_dump.boot_memory_size;\n }\n \n+int should_fadump_crash(void)\n+{\n+\tif (!fw_dump.dump_registered || !fw_dump.fadumphdr_addr)\n+\t\treturn 0;\n+\treturn 1;\n+}\n+\n int is_fadump_active(void)\n {\n \treturn fw_dump.dump_active;\n@@ -518,7 +525,7 @@ void crash_fadump(struct pt_regs *regs, const char *str)\n \tstruct fadump_crash_info_header *fdh = NULL;\n \tint old_cpu, this_cpu;\n \n-\tif (!fw_dump.dump_registered || !fw_dump.fadumphdr_addr)\n+\tif (!should_fadump_crash())\n \t\treturn;\n \n \t/*\ndiff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c\nindex 574e949f8db9..2849c4f50324 100644\n--- a/arch/powerpc/kernel/traps.c\n+++ b/arch/powerpc/kernel/traps.c\n@@ -114,6 +114,28 @@ static void pmac_backlight_unblank(void)\n static inline void pmac_backlight_unblank(void) { }\n #endif\n \n+/*\n+ * If oops/die is expected to crash the machine, return true here.\n+ *\n+ * This should not be expected to be 100% accurate, there may be\n+ * notifiers registered or other unexpected conditions that may bring\n+ * down the kernel. Or if the current process in the kernel is holding\n+ * locks or has other critical state, the kernel may become effectively\n+ * unusable anyway.\n+ */\n+bool die_will_crash(void)\n+{\n+\tif (should_fadump_crash())\n+\t\treturn true;\n+\tif (kexec_should_crash(current))\n+\t\treturn true;\n+\tif (in_interrupt() || panic_on_oops ||\n+\t\t\t!current->pid || is_global_init(current))\n+\t\treturn true;\n+\n+\treturn false;\n+}\n+\n static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;\n static int die_owner = -1;\n static unsigned int die_nest_count;\ndiff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c\nindex 96436d129684..140350aacca5 100644\n--- a/arch/powerpc/platforms/powernv/opal.c\n+++ b/arch/powerpc/platforms/powernv/opal.c\n@@ -34,6 +34,7 @@\n #include <asm/opal.h>\n #include <asm/firmware.h>\n #include <asm/mce.h>\n+#include <asm/bug.h>\n \n #include \"powernv.h\"\n \n@@ -426,17 +427,36 @@ static int opal_recover_mce(struct pt_regs *regs,\n \t\t/* Fatal machine check */\n \t\tpr_err(\"Machine check interrupt is fatal\\n\");\n \t\trecovered = 0;\n-\t} else if ((evt->severity == MCE_SEV_ERROR_SYNC) &&\n-\t\t\t(user_mode(regs) && !is_global_init(current))) {\n+\t}\n+\n+\tif (!recovered && evt->severity == MCE_SEV_ERROR_SYNC) {\n \t\t/*\n-\t\t * For now, kill the task if we have received exception when\n-\t\t * in userspace.\n+\t\t * Try to kill processes if we get a synchronous machine check\n+\t\t * (e.g., one caused by execution of this instruction). This\n+\t\t * will devolve into a panic if we try to kill init or are in\n+\t\t * an interrupt etc.\n \t\t *\n \t\t * TODO: Queue up this address for hwpoisioning later.\n+\t\t * TODO: This is not quite right for d-side machine\n+\t\t *       checks ->nip is not necessarily the important\n+\t\t *       address.\n \t\t */\n-\t\t_exception(SIGBUS, regs, BUS_MCEERR_AR, regs->nip);\n-\t\trecovered = 1;\n+\t\tif ((user_mode(regs))) {\n+\t\t\t_exception(SIGBUS, regs, BUS_MCEERR_AR, regs->nip);\n+\t\t\trecovered = 1;\n+\t\t} else if (die_will_crash()) {\n+\t\t\t/*\n+\t\t\t * die() would kill the kernel, so better to go via\n+\t\t\t * the platform reboot code that will log the\n+\t\t\t * machine check.\n+\t\t\t */\n+\t\t\trecovered = 0;\n+\t\t} else {\n+\t\t\tdie(\"Machine check\", regs, SIGBUS);\n+\t\t\trecovered = 1;\n+\t\t}\n \t}\n+\n \treturn recovered;\n }\n \n",
    "prefixes": [
        "v2",
        "2/3"
    ]
}