On 13 March 2025 11:44:41 CET, Ingo Molnar <mi...@kernel.org> wrote:
>
>* David Woodhouse <dw...@infradead.org> wrote:
>
>> From: David Woodhouse <d...@amazon.co.uk>
>> 
>> Signed-off-by: David Woodhouse <d...@amazon.co.uk>
>> ---
>>  arch/x86/kernel/relocate_kernel_64.S | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/arch/x86/kernel/relocate_kernel_64.S 
>> b/arch/x86/kernel/relocate_kernel_64.S
>> index 17d41e6e1a4b..2b7fc59af373 100644
>> --- a/arch/x86/kernel/relocate_kernel_64.S
>> +++ b/arch/x86/kernel/relocate_kernel_64.S
>> @@ -158,7 +158,7 @@ SYM_CODE_START_LOCAL_NOALIGN(identity_mapped)
>>      lidt    (%rsp)
>>      addq    $10, %rsp
>>  
>> -    //int3
>> +    int3
>
>So this is all boot-serialized functionality with no SMP concerns 
>whatsoever, right?
>
>If yes then we could use something like this:
>
>       static int exception_selftest = 1;
>
>and add the INT3 point:
>
>       int3
>.globl after_int3
>after_int3:
>
>And do this in the early exception handler:
>
>       ...
>       
>       if (exception_selftest) {
>               exception_selftest = 0;
>
>               print_something_warm_and_fuzzy();
>
>               IRET-to-after_int3;
>       }
>
>       ...
>
>       ... regular exception path ...
>
>... but all in assembly or so ;-)
>
>This would make it reasonably certain that the most complex bits of 
>this new debuging code are in working order, all the time.
>
>Thanks,
>
>       Ingo

The exception handler already returns if the exception was int3, but not for 
anything else. Less so the "print something warm and fuzzy" part; it just does 
the same register dump. But we could change that.

I'm less keen on making it unconditional though. Kexec is a 
performance-critical path when every millisecond is perceived as guest steal 
time, and the serial output should only happen in production if something goes 
*wrong*.

And besides, most kexec users don't have early_printk enabled anyway so if we 
break them, this idea doesn't help.

Reply via email to