public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Earnshaw <rearnsha@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-8901] arm: testsuite: improve detection of CMSE hardware.
Date: Tue, 24 Aug 2021 13:33:02 +0000 (GMT)	[thread overview]
Message-ID: <20210824133302.E68C73858423@sourceware.org> (raw)

https://gcc.gnu.org/g:e5b56e805835b3052f67a03c0379db0adc1300a3

commit r11-8901-ge5b56e805835b3052f67a03c0379db0adc1300a3
Author: Richard Earnshaw <rearnsha@arm.com>
Date:   Fri Jun 18 17:13:04 2021 +0100

    arm: testsuite: improve detection of CMSE hardware.
    
    The test for CMSE support being available in hardware currently
    relies on the compiler not optimizing away a secure gateway operation.
    But even that is suspect, because the SG instruction is just a NOP
    on armv8-m implementations that do not support the security extension.
    
    Replace the existing test with a new one that reads and checks
    the appropriate hardware feature register (memory mapped).  This has
    to be run from secure mode, but that shouldn't matter, because if we
    can't do that we can't really test the CMSE extensions anyway.  We
    retain the SG instruction to ensure the test can't pass accidentally
    if run on pre-armv8-m devices.
    
    gcc/testsuite:
            * lib/target-supports.exp (check_effective_target_arm_cmse_hw):
            New function.
    
    (cherry picked from commit 79fb2700bdbab4212346d907be6063c5a32d3836)

Diff:
---
 gcc/testsuite/lib/target-supports.exp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 411e559f508..8aebd2e9a91 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -4861,6 +4861,23 @@ proc check_effective_target_arm_cmse_ok {} {
     } "-mcmse"];
 }
 
+# Return 1 if the target supports executing CMSE instructions, 0
+# otherwise.  Cache the result.
+
+proc check_effective_target_arm_cmse_hw { } {
+    return [check_runtime arm_cmse_hw_available {
+	int main (void)
+	{
+	    unsigned id_pfr1;
+	    asm ("ldr\t%0, =0xe000ed44\n" \
+		 "ldr\t%0, [%0]\n" \
+		 "sg" : "=l" (id_pfr1));
+	    /* Exit with code 0 iff security extension is available.  */
+	    return !(id_pfr1 & 0xf0);
+	}
+    } "-mcmse"]
+}
+
 # Return 1 if the target supports executing MVE instructions, 0
 # otherwise.


                 reply	other threads:[~2021-08-24 13:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210824133302.E68C73858423@sourceware.org \
    --to=rearnsha@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).