[PATCH v3][Newlib] arm: Restrict processor mode change when in hypervisor mode.

Richard Earnshaw Richard.Earnshaw@foss.arm.com
Fri Mar 3 13:35:04 GMT 2023

Pushed (with tweaks to the commit message).


On 03/03/2023 13:12, Srinath Parvathaneni wrote:
> Hi All,
> In _stack_init function of crt0.S file, when the current mode is not 
> user mode,
> all the processor modes are parsed and the corresponding stack limit are 
> set for
> these modes for all A-profile and R-profile CPU's. But if a CPU 
> implements EL2
> as its highest exception level, then the core (or a model of it) will 
> start in that
> mode. For example, with Cortex-R52 the processor starts by default is 
> hypervisor
> mode (EL2), changing to any other mode using CPSR will result in an illegal
> instruction as per Arm-arm.
> This patch prevent the change of Hypervisor mode to any other EL1 modes in
> _stack_init function in crt0.S files and does not set the stack limit 
> for those
> EL1 modes.
> Regression tested on arm-none-eabi target for newlib and newlib-nano and 
> found
> no regressions.
> Ok for newlib master?
> Regards,
> Srinath.
> libgloss/ChangeLog:
> 2023-03-03  Srinath Parvathaneni<srinath.parvathaneni@arm.com>
>          * arm/crt0.S (_stack_init): Add check for hypervisor mode.
> newlib/ChangeLog:
> 2023-03-03  Srinath Parvathaneni<srinath.parvathaneni@arm.com>
>          * libc/sys/arm/crt0.S (_stack_init): Add check for hypervisor 
> mode.

More information about the Newlib mailing list