Skip to content

Conversation

@carlocaione
Copy link
Contributor

As explained in the commit message the {inc,dec}_nested_counter macros have several problems, mainly the macros can unexpectedly clobber several registers without any notice. It's just better to make the clobbered registers explicit again and avoid using a call to function to retrieve the current cpu pointer.

There are several issues with the current implemenation of the
{inc,dec}_nest_counter macros.

The first problem is that it's internally using a call to a misplaced
function called z_arm64_curr_cpu() (for some unknown reason hosted in
irq_manage.c) that could potentially clobber the caller-saved registers
without any notice to the user of the macro.

The second problem is that being a macro the clobbered registers should
be specified at the calling site, this is not possible given the current
implementation.

To fix these issues and make the call quicker, this patch rewrites the
code in assembly leveraging the availability of the _curr_cpu array. It
now clobbers only two registers passed from the calling site.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
z_arm64_* prefix should not be used for macros. Rename it.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
@github-actions github-actions bot added area: ARM ARM (32-bit) Architecture area: ARM_64 labels Mar 8, 2021
@carlocaione carlocaione requested a review from nashif March 8, 2021 15:15
@zephyrbot zephyrbot added the area: ARM64 ARM (64-bit) Architecture label Mar 9, 2021
@nashif nashif merged commit 8388794 into zephyrproject-rtos:master Mar 9, 2021
@carlocaione carlocaione deleted the fix_nest_counter branch March 9, 2021 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ARM ARM (32-bit) Architecture area: ARM64 ARM (64-bit) Architecture

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants