From: Khalid Aziz <khalid.aziz@oracle.com> To: davem@davemloft.net, dave.hansen@linux.intel.com Cc: Khalid Aziz <khalid.aziz@oracle.com>, dan.carpenter@oracle.com, Liam.Howlett@oracle.com, mingo@kernel.org, paul.gortmaker@windriver.com, vegard.nossum@oracle.com, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, Khalid Aziz <khalid@gonehiking.org> Subject: [PATCH v7 5/9] sparc64: Add handler for "Memory Corruption Detected" trap Date: Wed, 9 Aug 2017 15:25:58 -0600 [thread overview] Message-ID: <21d8ea1868877ba9b50b2b26a660aa5c9d0916b5.1502219353.git.khalid.aziz@oracle.com> (raw) In-Reply-To: <cover.1502219353.git.khalid.aziz@oracle.com> In-Reply-To: <cover.1502219353.git.khalid.aziz@oracle.com> M7 and newer processors add a "Memory corruption Detected" trap with the addition of ADI feature. This trap is vectored into kernel by HV through resumable error trap with error attribute for the resumable error set to 0x00000800. Signed-off-by: Khalid Aziz <khalid.aziz@oracle.com> Cc: Khalid Aziz <khalid@gonehiking.org> --- v7: - new patch split off from patch 4/4 in v6 arch/sparc/kernel/traps_64.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c index 88c96d349f2f..c14fa0a634b1 100644 --- a/arch/sparc/kernel/traps_64.c +++ b/arch/sparc/kernel/traps_64.c @@ -1825,6 +1825,7 @@ struct sun4v_error_entry { #define SUN4V_ERR_ATTRS_ASI 0x00000080 #define SUN4V_ERR_ATTRS_PRIV_REG 0x00000100 #define SUN4V_ERR_ATTRS_SPSTATE_MSK 0x00000600 +#define SUN4V_ERR_ATTRS_MCD 0x00000800 #define SUN4V_ERR_ATTRS_SPSTATE_SHFT 9 #define SUN4V_ERR_ATTRS_MODE_MSK 0x03000000 #define SUN4V_ERR_ATTRS_MODE_SHFT 24 @@ -2022,6 +2023,56 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent, } } +/* Handle memory corruption detected error which is vectored in + * through resumable error trap. + */ +void do_mcd_err(struct pt_regs *regs, struct sun4v_error_entry ent) +{ + siginfo_t info; + + if (notify_die(DIE_TRAP, "MCD error", regs, 0, 0x34, + SIGSEGV) == NOTIFY_STOP) + return; + + if (regs->tstate & TSTATE_PRIV) { + /* MCD exception could happen because the task was + * running a system call with MCD enabled and passed a + * non-versioned pointer or pointer with bad version + * tag to the system call. In such cases, hypervisor + * places the address of offending instruction in the + * resumable error report. This is a deferred error, + * so the read/write that caused the trap was potentially + * retired long time back and we may have no choice + * but to send SIGSEGV to the process. + */ + const struct exception_table_entry *entry; + + entry = search_exception_tables(regs->tpc); + if (entry) { + /* Looks like a bad syscall parameter */ +#ifdef DEBUG_EXCEPTIONS + pr_emerg("Exception: PC<%016lx> faddr<UNKNOWN>\n", + regs->tpc); + pr_emerg("EX_TABLE: insn<%016lx> fixup<%016lx>\n", + ent.err_raddr, entry->fixup); +#endif + regs->tpc = entry->fixup; + regs->tnpc = regs->tpc + 4; + return; + } + } + + /* Send SIGSEGV to the userspace process with the right signal + * code + */ + info.si_signo = SIGSEGV; + info.si_errno = 0; + info.si_code = SEGV_ADIDERR; + info.si_addr = (void __user *)ent.err_raddr; + info.si_trapno = 0; + force_sig_info(SIGSEGV, &info, current); +} + /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate. * Log the event and clear the first word of the entry. */ @@ -2059,6 +2110,14 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset) goto out; } + /* If this is a memory corruption detected error vectored in + * by HV through resumable error trap, call the handler + */ + if (local_copy.err_attrs & SUN4V_ERR_ATTRS_MCD) { + do_mcd_err(regs, local_copy); + return; + } + sun4v_log_error(regs, &local_copy, cpu, KERN_ERR "RESUMABLE ERROR", &sun4v_resum_oflow_cnt); -- 2.11.0
WARNING: multiple messages have this Message-ID (diff)
From: Khalid Aziz <khalid.aziz@oracle.com> To: davem@davemloft.net, dave.hansen@linux.intel.com Cc: Khalid Aziz <khalid.aziz@oracle.com>, dan.carpenter@oracle.com, Liam.Howlett@oracle.com, mingo@kernel.org, paul.gortmaker@windriver.com, vegard.nossum@oracle.com, sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, Khalid Aziz <khalid@gonehiking.org> Subject: [PATCH v7 5/9] sparc64: Add handler for "Memory Corruption Detected" trap Date: Wed, 09 Aug 2017 21:25:58 +0000 [thread overview] Message-ID: <21d8ea1868877ba9b50b2b26a660aa5c9d0916b5.1502219353.git.khalid.aziz@oracle.com> (raw) In-Reply-To: <cover.1502219353.git.khalid.aziz@oracle.com> M7 and newer processors add a "Memory corruption Detected" trap with the addition of ADI feature. This trap is vectored into kernel by HV through resumable error trap with error attribute for the resumable error set to 0x00000800. Signed-off-by: Khalid Aziz <khalid.aziz@oracle.com> Cc: Khalid Aziz <khalid@gonehiking.org> --- v7: - new patch split off from patch 4/4 in v6 arch/sparc/kernel/traps_64.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c index 88c96d349f2f..c14fa0a634b1 100644 --- a/arch/sparc/kernel/traps_64.c +++ b/arch/sparc/kernel/traps_64.c @@ -1825,6 +1825,7 @@ struct sun4v_error_entry { #define SUN4V_ERR_ATTRS_ASI 0x00000080 #define SUN4V_ERR_ATTRS_PRIV_REG 0x00000100 #define SUN4V_ERR_ATTRS_SPSTATE_MSK 0x00000600 +#define SUN4V_ERR_ATTRS_MCD 0x00000800 #define SUN4V_ERR_ATTRS_SPSTATE_SHFT 9 #define SUN4V_ERR_ATTRS_MODE_MSK 0x03000000 #define SUN4V_ERR_ATTRS_MODE_SHFT 24 @@ -2022,6 +2023,56 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent, } } +/* Handle memory corruption detected error which is vectored in + * through resumable error trap. + */ +void do_mcd_err(struct pt_regs *regs, struct sun4v_error_entry ent) +{ + siginfo_t info; + + if (notify_die(DIE_TRAP, "MCD error", regs, 0, 0x34, + SIGSEGV) = NOTIFY_STOP) + return; + + if (regs->tstate & TSTATE_PRIV) { + /* MCD exception could happen because the task was + * running a system call with MCD enabled and passed a + * non-versioned pointer or pointer with bad version + * tag to the system call. In such cases, hypervisor + * places the address of offending instruction in the + * resumable error report. This is a deferred error, + * so the read/write that caused the trap was potentially + * retired long time back and we may have no choice + * but to send SIGSEGV to the process. + */ + const struct exception_table_entry *entry; + + entry = search_exception_tables(regs->tpc); + if (entry) { + /* Looks like a bad syscall parameter */ +#ifdef DEBUG_EXCEPTIONS + pr_emerg("Exception: PC<%016lx> faddr<UNKNOWN>\n", + regs->tpc); + pr_emerg("EX_TABLE: insn<%016lx> fixup<%016lx>\n", + ent.err_raddr, entry->fixup); +#endif + regs->tpc = entry->fixup; + regs->tnpc = regs->tpc + 4; + return; + } + } + + /* Send SIGSEGV to the userspace process with the right signal + * code + */ + info.si_signo = SIGSEGV; + info.si_errno = 0; + info.si_code = SEGV_ADIDERR; + info.si_addr = (void __user *)ent.err_raddr; + info.si_trapno = 0; + force_sig_info(SIGSEGV, &info, current); +} + /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate. * Log the event and clear the first word of the entry. */ @@ -2059,6 +2110,14 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset) goto out; } + /* If this is a memory corruption detected error vectored in + * by HV through resumable error trap, call the handler + */ + if (local_copy.err_attrs & SUN4V_ERR_ATTRS_MCD) { + do_mcd_err(regs, local_copy); + return; + } + sun4v_log_error(regs, &local_copy, cpu, KERN_ERR "RESUMABLE ERROR", &sun4v_resum_oflow_cnt); -- 2.11.0
next prev parent reply other threads:[~2017-08-09 21:27 UTC|newest] Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-08-09 21:25 [PATCH v7 0/9] Application Data Integrity feature introduced by SPARC M7 Khalid Aziz 2017-08-09 21:25 ` Khalid Aziz 2017-08-09 21:25 ` Khalid Aziz 2017-08-09 21:25 ` Khalid Aziz 2017-08-09 21:25 ` [PATCH v7 1/9] signals, sparc: Add signal codes for ADI violations Khalid Aziz 2017-08-09 21:25 ` Khalid Aziz 2017-08-09 21:25 ` [PATCH v7 2/9] mm, swap: Add infrastructure for saving page metadata on swap Khalid Aziz 2017-08-09 21:25 ` Khalid Aziz 2017-08-09 21:25 ` Khalid Aziz 2017-08-16 4:53 ` David Miller 2017-08-16 4:53 ` David Miller 2017-08-16 4:53 ` David Miller 2017-08-16 14:34 ` Khalid Aziz 2017-08-16 14:34 ` Khalid Aziz 2017-08-16 14:34 ` Khalid Aziz 2017-08-09 21:25 ` [PATCH v7 3/9] sparc64: Add support for ADI register fields, ASIs and traps Khalid Aziz 2017-08-09 21:25 ` Khalid Aziz 2017-08-09 21:25 ` [PATCH v7 4/9] sparc64: Add HV fault type handlers for ADI related faults Khalid Aziz 2017-08-09 21:25 ` Khalid Aziz 2017-08-09 21:25 ` Khalid Aziz [this message] 2017-08-09 21:25 ` [PATCH v7 5/9] sparc64: Add handler for "Memory Corruption Detected" trap Khalid Aziz 2017-08-09 21:25 ` [PATCH v7 6/9] sparc64: Add auxiliary vectors to report platform ADI properties Khalid Aziz 2017-08-09 21:25 ` Khalid Aziz 2017-08-09 21:26 ` [PATCH v7 7/9] mm: Add address parameter to arch_validate_prot() Khalid Aziz 2017-08-09 21:26 ` Khalid Aziz 2017-08-09 21:26 ` Khalid Aziz 2017-08-10 13:20 ` Michael Ellerman 2017-08-10 13:20 ` Michael Ellerman 2017-08-10 13:20 ` Michael Ellerman 2017-08-10 14:41 ` Khalid Aziz 2017-08-10 14:41 ` Khalid Aziz 2017-08-10 14:41 ` Khalid Aziz 2017-08-15 5:02 ` Michael Ellerman 2017-08-15 5:02 ` Michael Ellerman 2017-08-15 5:02 ` Michael Ellerman 2017-08-15 5:02 ` Michael Ellerman 2017-08-15 14:32 ` Khalid Aziz 2017-08-15 14:32 ` Khalid Aziz 2017-08-15 14:32 ` Khalid Aziz 2017-08-09 21:26 ` [PATCH v7 8/9] mm: Clear arch specific VM flags on protection change Khalid Aziz 2017-08-09 21:26 ` Khalid Aziz 2017-08-09 21:26 ` Khalid Aziz 2017-08-09 21:26 ` [PATCH v7 9/9] sparc64: Add support for ADI (Application Data Integrity) Khalid Aziz 2017-08-09 21:26 ` Khalid Aziz 2017-08-09 21:26 ` Khalid Aziz 2017-08-16 4:58 ` David Miller 2017-08-16 4:58 ` David Miller 2017-08-16 4:58 ` David Miller 2017-08-16 14:44 ` Khalid Aziz 2017-08-16 14:44 ` Khalid Aziz 2017-08-16 14:44 ` Khalid Aziz 2017-08-25 22:31 ` Anthony Yznaga 2017-08-25 22:31 ` Anthony Yznaga 2017-08-25 22:31 ` Anthony Yznaga 2017-08-30 22:27 ` Khalid Aziz 2017-08-30 22:27 ` Khalid Aziz 2017-08-30 22:27 ` Khalid Aziz 2017-08-30 22:38 ` David Miller 2017-08-30 22:38 ` David Miller 2017-08-30 22:38 ` David Miller 2017-08-30 23:23 ` Khalid Aziz 2017-08-30 23:23 ` Khalid Aziz 2017-08-30 23:23 ` Khalid Aziz 2017-08-31 0:09 ` David Miller 2017-08-31 0:09 ` David Miller 2017-08-31 0:09 ` David Miller 2017-08-31 16:38 ` Khalid Aziz 2017-08-31 16:38 ` Khalid Aziz 2017-08-31 16:38 ` Khalid Aziz 2017-09-01 5:38 ` Anthony Yznaga 2017-09-01 5:38 ` Anthony Yznaga 2017-09-01 5:38 ` Anthony Yznaga 2017-09-04 16:25 ` Pavel Machek 2017-09-04 16:25 ` Pavel Machek 2017-09-04 16:25 ` Pavel Machek 2017-09-05 21:44 ` David Miller 2017-09-05 21:44 ` David Miller 2017-09-05 21:44 ` David Miller 2017-09-06 22:32 ` Pavel Machek 2017-09-06 22:32 ` Pavel Machek 2017-09-08 12:18 ` Steven Sistare 2017-09-08 12:18 ` Steven Sistare 2017-09-08 12:18 ` Steven Sistare 2017-09-06 14:10 ` Khalid Aziz 2017-09-06 14:10 ` Khalid Aziz 2017-09-06 14:10 ` Khalid Aziz
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=21d8ea1868877ba9b50b2b26a660aa5c9d0916b5.1502219353.git.khalid.aziz@oracle.com \ --to=khalid.aziz@oracle.com \ --cc=Liam.Howlett@oracle.com \ --cc=dan.carpenter@oracle.com \ --cc=dave.hansen@linux.intel.com \ --cc=davem@davemloft.net \ --cc=khalid@gonehiking.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mingo@kernel.org \ --cc=paul.gortmaker@windriver.com \ --cc=sparclinux@vger.kernel.org \ --cc=vegard.nossum@oracle.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.