linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Khalid Aziz <khalid.aziz@oracle.com>
To: davem@davemloft.net, dave.hansen@linux.intel.com
Cc: Khalid Aziz <khalid.aziz@oracle.com>,
	akpm@linux-foundation.org, vegard.nossum@oracle.com,
	mingo@kernel.org, peterz@infradead.org, dan.carpenter@oracle.com,
	Liam.Howlett@oracle.com, paul.gortmaker@windriver.com,
	sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org,
	Khalid Aziz <khalid@gonehiking.org>
Subject: [PATCH v7 4/9] sparc64: Add HV fault type handlers for ADI related faults
Date: Wed,  9 Aug 2017 15:25:57 -0600	[thread overview]
Message-ID: <870629f367fbd5d487a54b3796f66348218b5d7d.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>

ADI (Application Data Integrity) feature on M7 and newer processors
adds new fault types for hypervisor - Invalid ASI and MCD disabled.
This patch expands data access exception handler to handle these
faults.

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 | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
index 88eed0dc3faf..88c96d349f2f 100644
--- a/arch/sparc/kernel/traps_64.c
+++ b/arch/sparc/kernel/traps_64.c
@@ -352,12 +352,35 @@ void sun4v_data_access_exception(struct pt_regs *regs, unsigned long addr, unsig
 		regs->tpc &= 0xffffffff;
 		regs->tnpc &= 0xffffffff;
 	}
-	info.si_signo = SIGSEGV;
+	/* MCD (Memory Corruption Detection) disabled trap (TT=0x19) in HV
+	 * is vectored thorugh data access exception trap with fault type
+	 * set to HV_FAULT_TYPE_MCD_DIS. Check for MCD disabled trap.
+	 * Accessing an address with invalid ASI for the address, for
+	 * example setting an ADI tag on an address with ASI_MCD_PRIMARY
+	 * when TTE.mcd is not set for the VA, is also vectored into
+	 * kerbel by HV as data access exception with fault type set to
+	 * HV_FAULT_TYPE_INV_ASI.
+	 */
 	info.si_errno = 0;
-	info.si_code = SEGV_MAPERR;
 	info.si_addr = (void __user *) addr;
 	info.si_trapno = 0;
-	force_sig_info(SIGSEGV, &info, current);
+	switch (type) {
+	case HV_FAULT_TYPE_INV_ASI:
+		info.si_signo = SIGILL;
+		info.si_code = ILL_ILLADR;
+		force_sig_info(SIGILL, &info, current);
+		break;
+	case HV_FAULT_TYPE_MCD_DIS:
+		info.si_signo = SIGSEGV;
+		info.si_code = SEGV_ACCADI;
+		force_sig_info(SIGSEGV, &info, current);
+		break;
+	default:
+		info.si_signo = SIGSEGV;
+		info.si_code = SEGV_MAPERR;
+		force_sig_info(SIGSEGV, &info, current);
+		break;
+	}
 }
 
 void sun4v_data_access_exception_tl1(struct pt_regs *regs, unsigned long addr, unsigned long type_ctx)
-- 
2.11.0

  parent reply	other threads:[~2017-08-09 21:28 UTC|newest]

Thread overview: 30+ 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 ` [PATCH v7 1/9] signals, sparc: Add signal codes for ADI violations 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-16  4:53   ` David Miller
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 [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:26 ` [PATCH v7 7/9] mm: Add address parameter to arch_validate_prot() Khalid Aziz
2017-08-10 13:20   ` Michael Ellerman
2017-08-10 14:41     ` Khalid Aziz
2017-08-15  5:02       ` Michael Ellerman
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 ` [PATCH v7 9/9] sparc64: Add support for ADI (Application Data Integrity) Khalid Aziz
2017-08-16  4:58   ` David Miller
2017-08-16 14:44     ` Khalid Aziz
2017-08-25 22:31   ` Anthony Yznaga
2017-08-30 22:27     ` Khalid Aziz
2017-08-30 22:38       ` David Miller
2017-08-30 23:23         ` Khalid Aziz
2017-08-31  0:09           ` David Miller
2017-08-31 16:38             ` Khalid Aziz
2017-09-01  5:38       ` Anthony Yznaga
2017-09-04 16:25   ` Pavel Machek
2017-09-05 21:44     ` David Miller
2017-09-06 22:32       ` Pavel Machek
2017-09-08 12:18         ` Steven Sistare
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=870629f367fbd5d487a54b3796f66348218b5d7d.1502219353.git.khalid.aziz@oracle.com \
    --to=khalid.aziz@oracle.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --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=peterz@infradead.org \
    --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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).