Incorrect epilogue code in __attribute__((cmse_nonsecure_entry)) function

Bug #1903018 reported by CCLi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
New
Undecided
Unassigned

Bug Description

Pertinent bug report info:

- GCC version: 9-2020-q2
- CPU: Arm Cortex-M23
- Optimization level: Os

---------

Checking the following non-secure callable (NSC) function with Os,

```C
int __attribute__((cmse_nonsecure_entry))
foo(int a)
{
    return a + 1;
}
```

Compiled assembly code:

```ASM
                  foo:
0x000004E8 3001 ADDS r0,#1
0x000004EA 0001 MOVS r1,r0
0x000004EC 0002 MOVS r2,r0
0x000004EE 0003 MOVS r3,r0
0x000004F0 4680 MOV r8,r0
0x000004F2 4681 MOV r9,r0
0x000004F4 4682 MOV r10,r0
0x000004F6 4683 MOV r11,r0
0x000004F8 4684 MOV r12,r0
0x000004FA F38E8800 MSR APSR_nzcvq,lr ; formerly CPSR_f
0x000004FE 4774 BXNS lr
```

According to Arm's "ARMv8-M Security Extensions: Requirements on Development Tools", on return from an entry function, restore all callee-saved registers (here r8~r12) as mandated by [AAPCS], rather than clear them.

Revision history for this message
stewo (wolfer-y) wrote : [Autoreply] [Bug 1903018] [NEW] Incorrect epilogue code in __attribute__((cmse_nonsecure_entry)) function
Download full text (3.4 KiB)

Ich bin bis 09.11. nicht im Haus und kann Ihre Nachricht daher leider nicht bearbeiten. In dringenden Fällen wenden Sie sich bitte an <email address hidden> bzw. für technische Fragen an <email address hidden>.

I am out of office until November 9th and won't be able to read your message. In urgent cases, please refer to <email address hidden> or for technical questions to <email address hidden>.

Mit freundlichen Grüßen / Best regards

Steffen Wolfer

--
Dipl.-Inform. Steffen Wolfer
Software Engineer Embedded Systems

WEISS ROBOTICS GmbH & Co. KG
Karl-Heinrich-Käferle-Str. 8
D-71640 Ludwigsburg, Germany

Phone: +49 7141 94702-22
Fax: +49 7141 94702-99
http://www.weiss-robotics.com

Sitz der Gesellschaft: Ludwigsburg
Registergericht Stuttgart, HRA725006

Pers. haftende Gesellschafterin:
Weiss Robotics Verwaltungs-GmbH, Sitz Ludwigsburg
Registergericht Stuttgart, HRB73310
Geschäftsführer: Dr. Karsten Weiß

Public bug reported:

Pertinent bug report info:

- GCC version: 9-2020-q2
- CPU: Arm Cortex-M23
- Optimization level: Os

---------

Checking the following non-secure callable (NSC) function with Os,

```C
int __attribute__((cmse_nonsecure_entry))
foo(int a)
{
    return a + 1;
}
```

Compiled assembly code:

```ASM
                  foo:
0x000004E8 3001 ADDS r0,#1
0x000004EA 0001 MOVS r1,r0
0x000004EC 0002 MOVS r2,r0
0x000004EE 0003 MOVS r3,r0
0x000004F0 4680 MOV r8,r0
0x000004F2 4681 MOV r9,r0
0x000004F4 4682 MOV r10,r0
0x000004F6 4683 MOV r11,r0
0x000004F8 4684 MOV r12,r0
0x000004FA F38E8800 MSR APSR_nzcvq,lr ; formerly CPSR_f
0x000004FE 4774 BXNS lr
```

According to Arm's "ARMv8-M Security Extensions: Requirements on
Development Tools", on return from an entry function, restore all
callee-saved registers (here r8~r12) as mandated by [AAPCS], rather than
clear them.

** Affects: gcc-arm-embedded
     Importance: Undecided
         Status: New

--
You received this bug notification because you are subscribed to GNU Arm
Embedded Toolchain.
Matching subscriptions: Älles
https://bugs.launchpad.net/bugs/1903018

Title:
  Incorrect epilogue code in __attribute__((cmse_nonsecure_entry))
  function

Status in GNU Arm Embedded Toolchain:
  New

Bug description:
  Pertinent bug report info:

  - GCC version: 9-2020-q2
  - CPU: Arm Cortex-M23
  - Optimization level: Os

  ---------

  Checking the following non-secure callable (NSC) function with Os,

  ```C
  int __attribute__((cmse_nonsecure_entry))
  foo(int a)
  {
      return a + 1;
  }
  ```

  Compiled assembly code:

  ```ASM
                    foo:
  0x000004E8 3001 ADDS r0,#1
  0x000004EA 0001 MOVS r1,r0
  0x000004EC 0002 MOVS r2,r0
  0x000004EE 0003 MOVS r3,r0
  0x000004F0 4680 MOV r8,r0
  0x000004F2 4681 MOV r9,r0
  0x000004F4 4682 MOV r10,r0
  0x000004F6 4683 MOV r11,r0
  0x000004F8 4684 MOV r12,r0
  0x000004FA F38E8800 MSR APSR_nzcvq,lr ; formerly CPSR_f
  0x000004FE 4774 BXNS lr
  ```

  According to Arm's "ARMv8-M Security Extensions: Requirements on
  Develop...

Read more...

Revision history for this message
Ken Liu (kenliu007) wrote :

Hi,

I believe this is the one addressing the reported bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95646

/K

Revision history for this message
CCLi (ccli8) wrote :

Thanks. Yes, 95646 is addressing it.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.