On 9/8/25 09:21, Stanislav Kinsburskii wrote:
> On Wed, Sep 03, 2025 at 07:10:16PM -0700, Mukesh Rathor wrote:
>> This commit introduces a new file to enable collection of hypervisor ram
>> into the vmcore collected by linux. By default, the hypervisor ram is locked,
>> ie, protected via hw page table. Hyper-V implements a disable hypercall which
>> essentially devirtualizes the system on the fly. This mechanism makes the
>> hypervisor ram accessible to linux without any extra work because it is
>> already mapped into linux address space. Details of the implementation
>> are available in the file prologue.
>>
>> Signed-off-by: Mukesh Rathor <[email protected]>
>> ---
>>  arch/x86/hyperv/hv_crash.c | 618 +++++++++++++++++++++++++++++++++++++
>>  1 file changed, 618 insertions(+)
>>  create mode 100644 arch/x86/hyperv/hv_crash.c
>>
>> diff --git a/arch/x86/hyperv/hv_crash.c b/arch/x86/hyperv/hv_crash.c
>> new file mode 100644
>> index 000000000000..50c54d39f0e2
>> --- /dev/null
>> +++ b/arch/x86/hyperv/hv_crash.c
>> +
> 
> <snip>
> 
>> +/*
>> + * generic nmi callback handler: could be called without any crash also.
>> + *  hv crash: hypervisor injects nmi's into all cpus
>> + *  lx crash: panicing cpu sends nmi to all but self via 
>> crash_stop_other_cpus
>> + */
>> +static int hv_crash_nmi_local(unsigned int cmd, struct pt_regs *regs)
>> +{
>> +    int ccpu = smp_processor_id();
>> +
>> +    if (!hv_has_crashed && hv_cda && hv_cda->cda_valid)
>> +            hv_has_crashed = 1;
>> +
>> +    if (!hv_has_crashed && !lx_has_crashed)
>> +            return NMI_DONE;        /* ignore the nmi */
>> +
>> +    if (hv_has_crashed && !hv_crash_enabled) {
>> +            if (ccpu == 0) {
>> +                    pr_emerg("Hyper-V: core collect not setup. Reboot\n");
>> +                    native_wrmsrq(HV_X64_MSR_RESET, 1);     /* reboot */
>> +            } else
>> +                    for (;;)
>> +                            cpu_relax();
>> +    }
>> +
>> +    crash_nmi_callback(regs);
>> +    return NMI_DONE;
>> +}
> 
> One more thing.
> It looks like the function above goes through the new logic even when
> hypervisor is intact and there is no crash kernel loaded.
> This is redundant and it should rather return back to the existent
> generic kernel panic logic.

Yeah, that is already addressed in V1 coming up.


Reply via email to