Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Nov 2022 21:48:06 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: b0da3d887c4b - stable/13 - Clang: Add Diags for targets pre to i686 for -fcf-protection
Message-ID:  <202211102148.2AALm6pP014047@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=b0da3d887c4b3e9e1b35f4c0e9696fa6d339e82f

commit b0da3d887c4b3e9e1b35f4c0e9696fa6d339e82f
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-11-04 15:59:49 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-11-10 21:47:48 +0000

    Clang: Add Diags for targets pre to i686 for -fcf-protection
    
    Intel Control-flow Enforcement Technology (CET) provides new
    instructions `endbr32/64` for the indirect branch control.
    They are NOPs on i686 and new targets.  We need to check for that
    in case it crashes on older targets.
    
    PR:             264497, 267401
    Reviewed by:    dim
    MFC after:      1 week
    Obtained from:  LLVM commit 52516782972730ff065a34123a9d8876da08c254
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D37268
    
    (cherry picked from commit 9c231325e77b1989c006daf083a3e9bd143c3d07)
---
 contrib/llvm-project/clang/lib/Basic/Targets/X86.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/X86.h b/contrib/llvm-project/clang/lib/Basic/Targets/X86.h
index d1b66432e38b..b34a16bb5f5b 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/X86.h
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/X86.h
@@ -223,12 +223,16 @@ public:
 
   virtual bool
   checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const override {
-    return true;
+    if (CPU == llvm::X86::CK_None || CPU >= llvm::X86::CK_PentiumPro)
+      return true;
+    return TargetInfo::checkCFProtectionReturnSupported(Diags);
   };
 
   virtual bool
   checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const override {
-    return true;
+    if (CPU == llvm::X86::CK_None || CPU >= llvm::X86::CK_PentiumPro)
+      return true;
+    return TargetInfo::checkCFProtectionBranchSupported(Diags);
   };
 
   virtual bool validateOperandSize(const llvm::StringMap<bool> &FeatureMap,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202211102148.2AALm6pP014047>