Re: [PATCH 2/3] rust: hrtimer: declare cfi_encoding for hrtimer_restart

From: FUJITA Tomonori

Date: Tue Oct 20 2026 - 08:51:37 EST


On Mon, 19 Oct 2026 23:34:38 +0000
Sami Tolvanen <samitolvanen@xxxxxxxxxx> wrote:

> The hrtimer callbacks return bindings::hrtimer_restart, which bindgen
> generates as c_uint. C calls them through hrtimer->function, which
> returns enum hrtimer_restart. kCFI encodes enum types by name even with
> integer normalization, so the type ids never match and every call fails
> the CFI check.
>
> Generate hrtimer_restart as a newtype with a cfi_encoding, as is done
> for lru_status, and adapt HrTimerRestart to the newtype.
>
> Fixes: 8a8afe9349fb ("rust: hrtimer: introduce hrtimer support")
> Signed-off-by: Sami Tolvanen <samitolvanen@xxxxxxxxxx>
> ---
> rust/bindgen_parameters | 2 ++
> rust/kernel/time/hrtimer.rs | 6 +++---
> 2 files changed, 5 insertions(+), 3 deletions(-)

Tested the hrtimer doctests on x86_64 QEMU with CONFIG_CFI=y. Without
this patch they hit a CFI failure in __hrtimer_run_queues, and with it
they pass.

Reviewed-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxx>
Tested-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxx>