Re: [PATCH v2 2/2] powerpc/vmx: avoid KASAN instrumentation in enter_vmx_ops() for kexec

Sourabh Jain
2026-04-04T03:22:12Z

On 04/04/26 06:31, Ritesh Harjani (IBM) wrote:
> Sourabh Jain <sourabhjain@linux.ibm.com> writes:
>
>> The kexec sequence invokes enter_vmx_ops() via copy_page() with the MMU
>> disabled. In this context, code must not rely on normal virtual address
>> translations or trigger page faults.
>>
>> With KASAN enabled, functions get instrumented and may access shadow
>> memory using regular address translation. When executed with the MMU
>> off, this can lead to page faults (bad_page_fault) from which the
>> kernel cannot recover in the kexec path, resulting in a hang.
>>
>> The kexec path sets preempt_count to HARDIRQ_OFFSET before entering
>> the MMU-off copy sequence.
>>
>> current_thread_info()->preempt_count = HARDIRQ_OFFSET
>> kexec_sequence(..., copy_with_mmu_off = 1)
>> -> kexec_copy_flush(image)
>> copy_segments()
>> -> copy_page(dest, addr)
>> bl enter_vmx_ops()
>> if (in_interrupt())
>> return 0
>> beq .Lnonvmx_copy
>>
>> Since kexec sets preempt_count to HARDIRQ_OFFSET, in_interrupt()
>> evaluates to true and enter_vmx_ops() returns early.
>>
>> As in_interrupt() (and preempt_count()) are always inlined, mark
>> enter_vmx_ops() with __no_sanitize_address to avoid KASAN
>> instrumentation and shadow memory access with MMU disabled, helping
>> kexec boot fine with KASAN enabled.
>>
> Nice! LGTM. Please feel free to add:
> Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>

Thanks, Ritesh!

Will add your Reviewed-by tag in the next version.

- Sourabh Jain