Skip to content

Conversation

@andylinpersonal
Copy link

@andylinpersonal andylinpersonal commented Dec 15, 2025

When the divmod_s32s32_unsafe and divmod_u32u32_unsafe
is called without enabled PICO_DIVIDER_DISABLE_INTERRUPTS,
ldr r2, =SIO_BASE will be bypassed. Later access to SIO_DIV
will crash.

Fixes #2773

@andylinpersonal andylinpersonal changed the title Uninitialized r2 in divmod_u32u32_unsafe and divmod_s32s32_unsafe Dec 16, 2025
  When the ``divmod_s32s32_unsafe`` and ``divmod_u32u32_unsafe``
is called without enabled ``PICO_DIVIDER_DISABLE_INTERRUPTS``,
``ldr r2, =SIO_BASE`` will be bypassed. Later access to ``SIO_DIV``
will crash.

Fixes raspberrypi#2773

Signed-off-by: Andy Lin <andylinpersonal@gmail.com>
@kilograham
Copy link
Contributor

good spot; i think i'd probably want to extract the unsafe variants into their own code/section (I doubt they are that ocmmonly used) to avoid the extra 2 cycles in the common divide code path

@andylinpersonal
Copy link
Author

andylinpersonal commented Jan 12, 2026

Maybe it's useful when used inside RTOS. In those case we can delegate the saving stuff to context-switch code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants