Skip to content
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

core: arm: enable native interrupts before init calls #7262

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

etienne-lms
Copy link
Contributor

Enable native interrupts on Arm architecture before initcalls handlers are called. This change allows drivers to leverage interrupts during OP-TEE core initialization, as for example detecting a firewall access violation when it happens. Before this change, OP-TEE needed to complete its initialization and return the secure monitor for secure interrupts to be handled.

The feature is embedded upon config switch CFG_UNMASK_NATIVE_INTR_AT_BOOT and applies only when CFG_NS_VIRTUALIZATION is disabled. When CFG_NS_VIRTUALIZATION is enabled, early/service/driver initcalls already execute with native interrupts unmasked, from a standard call entry when the non-secure guest is registered.

@@ -1069,8 +1069,15 @@ void __weak boot_init_primary_late(unsigned long fdt __unused,

boot_primary_init_intc();
init_vfp_nsec();
if (!IS_ENABLED(CFG_NS_VIRTUALIZATION))
if (!IS_ENABLED(CFG_NS_VIRTUALIZATION)) {
if (IS_ENABLED(CFG_UNMASK_NATIVE_INTR_AT_BOOT)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not always enable this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair.

init_tee_runtime();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably disable the interrupts again since entry_a64.S doesn't expect interrupts to be enabled when boot_init_primary_late() returns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. Then i'll unmask them back in boot_init_primary_final() for call_driver_initcalls() and call_finalcalls() execution.

call_driver_initcalls();
}

call_finalcalls();
Copy link
Contributor

Choose a reason for hiding this comment

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

CFG_NS_VIRTUALIZATION may also benefit from unmasked native interrupts during finalcalls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I missed that. Thanks, i'll update.

Copy link
Contributor

@jenswi-linaro jenswi-linaro left a comment

Choose a reason for hiding this comment

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

Reviewed-by: Jens Wiklander <[email protected]>

Enable native interrupts on Arm architectures when executing
initcalls (early,service,driver,final). This change allows drivers
to leverage interrupts during OP-TEE core initialization, as for example
detecting a firewall access violation when it occurs. Before this change,
OP-TEE needed to complete its initialization and return the secure
monitor for secure interrupts to be handled.

Note that when CFG_NS_VIRTUALIZATION is enabled, initcalls called from
virt_on_stdcall() is not changed here since they are executing from a
standard call entry hence with native and foreign interrupts already
default unmasked.

Signed-off-by: Etienne Carriere <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
@etienne-lms
Copy link
Contributor Author

Fixup commits squashed and review tag applied.
Many thanks @jenswi-linaro for the feedback on this change.

@etienne-lms
Copy link
Contributor Author

I forgot to say that I've changed the commit message body. Please cross-check that it still matches change description expectations.

@jenswi-linaro
Copy link
Contributor

Looks good. :-)

@jforissier jforissier merged commit 259c34d into OP-TEE:master Feb 6, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants