CrashReason: Add MTE tag check faults to the list of crash reasons.
authorPeter Collingbourne <peter@pcc.me.uk>
Thu, 17 Dec 2020 23:34:49 +0000 (15:34 -0800)
committerPeter Collingbourne <peter@pcc.me.uk>
Tue, 29 Dec 2020 22:36:50 +0000 (14:36 -0800)
As of Linux 5.10, the kernel may report either of the two following
crash reasons:
- SEGV_MTEAERR: async MTE tag check fault
- SEGV_MTESERR: sync MTE tag check fault

Teach LLDB about them.

Differential Revision: https://reviews.llvm.org/D93495

lldb/source/Plugins/Process/POSIX/CrashReason.cpp
lldb/source/Plugins/Process/POSIX/CrashReason.h

index 579077b..c6ede61 100644 (file)
@@ -58,6 +58,18 @@ CrashReason GetCrashReasonForSIGSEGV(const siginfo_t &info) {
 #endif
   case SEGV_BNDERR:
     return CrashReason::eBoundViolation;
+#ifdef __linux__
+#ifndef SEGV_MTEAERR
+#define SEGV_MTEAERR 8
+#endif
+  case SEGV_MTEAERR:
+    return CrashReason::eAsyncTagCheckFault;
+#ifndef SEGV_MTESERR
+#define SEGV_MTESERR 9
+#endif
+  case SEGV_MTESERR:
+    return CrashReason::eSyncTagCheckFault;
+#endif // __linux__
   }
 
   return CrashReason::eInvalidCrashReason;
@@ -166,6 +178,13 @@ std::string GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr) {
   case CrashReason::eBoundViolation:
     str = "signal SIGSEGV: bound violation";
     break;
+  case CrashReason::eAsyncTagCheckFault:
+    str = "signal SIGSEGV: async tag check fault";
+    break;
+  case CrashReason::eSyncTagCheckFault:
+    str = "signal SIGSEGV: sync tag check fault";
+    AppendFaultAddr(str, fault_addr);
+    break;
   case CrashReason::eIllegalOpcode:
     str = "signal SIGILL: illegal instruction";
     break;
@@ -246,6 +265,12 @@ const char *CrashReasonAsString(CrashReason reason) {
   case CrashReason::eBoundViolation:
     str = "eBoundViolation";
     break;
+  case CrashReason::eAsyncTagCheckFault:
+    str = "eAsyncTagCheckFault";
+    break;
+  case CrashReason::eSyncTagCheckFault:
+    str = "eSyncTagCheckFault";
+    break;
 
   // SIGILL crash reasons.
   case CrashReason::eIllegalOpcode:
index 9b4784a..f521389 100644 (file)
@@ -22,6 +22,8 @@ enum class CrashReason {
   eInvalidAddress,
   ePrivilegedAddress,
   eBoundViolation,
+  eAsyncTagCheckFault,
+  eSyncTagCheckFault,
 
   // SIGILL crash reasons.
   eIllegalOpcode,