Skip to content

Fix SPM HAL test #9128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 2, 2019
Merged

Fix SPM HAL test #9128

merged 3 commits into from
Jan 2, 2019

Conversation

orenc17
Copy link
Contributor

@orenc17 orenc17 commented Dec 17, 2018

Description

When accessing non-secure ram and flash r1 was actually used by the calling function.
Change to a callee saved register.

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[X] Test update
[ ] Breaking change

@alzix @mikisch81 please review

Oren Cohen added 2 commits December 17, 2018 16:38
When accessing non-secure ram and flash r1 was actually used by the calling function.
Change to a callee saved register.
@cmonr
Copy link
Contributor

cmonr commented Dec 17, 2018

Waiting on #9131 for a fix to Travis CI.

@cmonr cmonr requested a review from a team December 17, 2018 16:54
@alzix
Copy link
Contributor

alzix commented Dec 17, 2018

@orenc17 please elaborate on the change.
What is the problem you experience with using r1 register?
You cannot use r4. The reason it is called calleesave is that the callee must restore it's value upon returning from the function. While caller save registers are backed up by the caller itself, so callee may use them as scratch registers.
Since call_mem is a naked function no epilogue is generated by the compiler, so no one will cleanup r4 register you are trying to use.

@orenc17
Copy link
Contributor Author

orenc17 commented Dec 18, 2018

@alzix call_mem() is being called by test_memory() which receives 2 arguments.
that means that r0 and r1 are being used.
so when call_mem(), which is a naked function as you said, is being called on the non-secure cases it will over-write the r1 register which holds the 2nd paramenter of test_memory() and that's what this PR is fixing

and anyway test_memory() takes care of saving r4 and restoring it

Copy link
Contributor

@alzix alzix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to AAPCS:

A subroutine must preserve the contents of the registers r4-r8, r10, r11 and SP (and r9 in PCS variants that designate r9 as v6).

Use r3 instead of r4

Co-Authored-By: orenc17 <[email protected]>
Copy link
Contributor

@alzix alzix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alzix
Copy link
Contributor

alzix commented Dec 23, 2018

created a ticket for GCC_ARM https://bugs.launchpad.net/gcc-arm-embedded/+bug/1809607

@cmonr
Copy link
Contributor

cmonr commented Dec 28, 2018

CI started

@mbed-ci
Copy link

mbed-ci commented Dec 28, 2018

Test run: SUCCESS

Summary: 9 of 9 test jobs passed
Build number : 1
Build artifacts

@0xc0170 0xc0170 merged commit d7497a8 into ARMmbed:master Jan 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants