1

https://github.com/torvalds/linux/blob/bf272460d744112bacd4c4d562592decbf0edf64/arch/x86/kernel/cpu/mce/core.c#L1543

    if ((m.cs & 3) == 3) {
        /* If this triggers there is no way to recover. Die hard. */
        BUG_ON(!on_thread_stack() || !user_mode(regs));

as above, what is die hard? what is die soft?

Will the rest of the code continues running after BUG_ON() execution?

Kusalananda
  • 320,670
  • 36
  • 633
  • 936
Mark K
  • 779
  • 2
  • 13
  • 33
  • 1. https://kernelnewbies.org/FAQ/BUG. 2. no results when googling `"die soft" site:https://elixir.bootlin.com/linux/`. – don_aman Sep 01 '22 at 03:48
  • 1
    Bruce Willis did great work in the "Die Soft" movie series. – thrig Sep 01 '22 at 04:55
  • In the link, ". After that the current process will die." so the remaining code will not be executed after BUG_ON()? – Mark K Sep 01 '22 at 05:33
  • 1
    "Die hard" is probably meant to mean "die unceremoniously" or "die not so gracefully", i.e. without doing it in the normal way, because, as the comment suggest, there is no way to recover anyway. – Kusalananda Sep 01 '22 at 07:37

1 Answers1

2

The "die hard" means killing the thread. As opposed to letting it carry on running, possibly by returning a failure result, that calling code can then process to exit/continue gracefully. From the BUG FAQ that @don-aman referred to,

    BUG_ON( condition );

is the same as

   if ( condition )
        BUG();

So if the condition is false then the BUG_ON does not get tripped, and the code can continue - which is why you can see more code following in that if branch in core.c . Also, you can test BUG() yourself:

>>cat h.c
#include <stdio.h>

#define BUG() __asm__ __volatile__("ud2\n")

int main()
{
        printf ("hi\n");
        BUG();
        printf ("ho\n");
}
>>cc -o h h.c
>>./h
hi
Illegal instruction (core dumped)
>>
Andre Beaud
  • 406
  • 1
  • 6