atrosinenko created this revision.
atrosinenko added reviewers: ab, kristof.beyls, apazos, pcc, psmith, 
t.p.northover.
Herald added a subscriber: hiraditya.
Herald added a project: All.
atrosinenko requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.
In some situations, such as re-signing pointers or performing tail
calls, the code generator has to authenticate a signed pointer that will
not be dereferenced immediately. In such cases it may be necessary to
emit extra code to make sure that the authentication succeeded to prevent
introducing authentication/signing oracles.

If the target CPU is known to support FEAT_FPAC, this extra code can be
skipped as AUT* instructions are known to fault on invalid PAC by
themselves.

Note that unlike many other features, FEAT_FPAC does not add any new
supported instructions, but changes the semantics of several existing
ones. Thus, care should be taken to not enable FPAC when not actually
supported as it does not make code fail explicitly under normal
operation, but makes it less secure on unsupported CPUs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156784

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  llvm/lib/Target/AArch64/AArch64.td


Index: llvm/lib/Target/AArch64/AArch64.td
===================================================================
--- llvm/lib/Target/AArch64/AArch64.td
+++ llvm/lib/Target/AArch64/AArch64.td
@@ -316,6 +316,10 @@
     "pauth", "HasPAuth", "true",
     "Enable v8.3-A Pointer Authentication extension (FEAT_PAuth)">;
 
+def FeatureFPAC : SubtargetFeature<
+    "fpac", "HasFPAC", "true",
+    "Assume AUT* instructions generate fault on invalid PAC (FEAT_FPAC)">;
+
 def FeatureJS : SubtargetFeature<
     "jsconv", "HasJS", "true",
     "Enable v8.3-A JavaScript FP conversion instructions (FEAT_JSCVT)",
Index: clang/lib/Basic/Targets/AArch64.h
===================================================================
--- clang/lib/Basic/Targets/AArch64.h
+++ clang/lib/Basic/Targets/AArch64.h
@@ -45,6 +45,7 @@
   bool HasMTE = false;
   bool HasTME = false;
   bool HasPAuth = false;
+  bool HasFPAC = false;
   bool HasLS64 = false;
   bool HasRandGen = false;
   bool HasMatMul = false;
Index: clang/lib/Basic/Targets/AArch64.cpp
===================================================================
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -909,6 +909,8 @@
       HasTME = true;
     if (Feature == "+pauth")
       HasPAuth = true;
+    if (Feature == "+fpac")
+      HasFPAC = true;
     if (Feature == "+i8mm")
       HasMatMul = true;
     if (Feature == "+bf16")


Index: llvm/lib/Target/AArch64/AArch64.td
===================================================================
--- llvm/lib/Target/AArch64/AArch64.td
+++ llvm/lib/Target/AArch64/AArch64.td
@@ -316,6 +316,10 @@
     "pauth", "HasPAuth", "true",
     "Enable v8.3-A Pointer Authentication extension (FEAT_PAuth)">;
 
+def FeatureFPAC : SubtargetFeature<
+    "fpac", "HasFPAC", "true",
+    "Assume AUT* instructions generate fault on invalid PAC (FEAT_FPAC)">;
+
 def FeatureJS : SubtargetFeature<
     "jsconv", "HasJS", "true",
     "Enable v8.3-A JavaScript FP conversion instructions (FEAT_JSCVT)",
Index: clang/lib/Basic/Targets/AArch64.h
===================================================================
--- clang/lib/Basic/Targets/AArch64.h
+++ clang/lib/Basic/Targets/AArch64.h
@@ -45,6 +45,7 @@
   bool HasMTE = false;
   bool HasTME = false;
   bool HasPAuth = false;
+  bool HasFPAC = false;
   bool HasLS64 = false;
   bool HasRandGen = false;
   bool HasMatMul = false;
Index: clang/lib/Basic/Targets/AArch64.cpp
===================================================================
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -909,6 +909,8 @@
       HasTME = true;
     if (Feature == "+pauth")
       HasPAuth = true;
+    if (Feature == "+fpac")
+      HasFPAC = true;
     if (Feature == "+i8mm")
       HasMatMul = true;
     if (Feature == "+bf16")
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D156784: [AArch... Anatoly Trosinenko via Phabricator via cfe-commits

Reply via email to