From: Wei Liu <wei.liu@kernel.org>
To: Mukesh Rathor <mrathor@linux.microsoft.com>
Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arch@vger.kernel.org, kys@microsoft.com,
haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com,
tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
arnd@arndb.de
Subject: Re: [PATCH v2 5/6] x86/hyperv: Implement hypervisor RAM collection into vmcore
Date: Thu, 2 Oct 2025 21:42:36 +0000 [thread overview]
Message-ID: <20251002214236.GC925245@liuwe-devbox-debian-v2.local> (raw)
In-Reply-To: <20250923214609.4101554-6-mrathor@linux.microsoft.com>
On Tue, Sep 23, 2025 at 02:46:08PM -0700, Mukesh Rathor wrote:
[...]
> +
> +/*
> + * This is the C entry point from the asm glue code after the devirt hypercall.
devirt -> devirtualization
> + * We enter here in IA32-e long mode, ie, full 64bit mode running on kernel
> + * page tables with our below 4G page identity mapped, but using a temporary
> + * GDT. ds/fs/gs/es are null. ss is not usable. bp is null. stack is not
> + * available. We restore kernel GDT, and rest of the context, and continue
> + * to kexec.
> + */
[...]
> +
> +static noinline __noclone void crash_nmi_callback(struct pt_regs *regs)
> +{
> + struct hv_input_disable_hyp_ex *input;
> + u64 status;
> + int msecs = 1000, ccpu = smp_processor_id();
> +
> + if (ccpu == 0) {
> + /* crash_save_cpu() will be done in the kexec path */
> + cpu_emergency_stop_pt(); /* disable performance trace */
> + atomic_inc(&crash_cpus_wait);
> + } else {
> + crash_save_cpu(regs, ccpu);
> + cpu_emergency_stop_pt(); /* disable performance trace */
> + atomic_inc(&crash_cpus_wait);
> + for (;;)
> + cpu_relax();
> + }
> +
> + while (atomic_read(&crash_cpus_wait) < num_online_cpus() && msecs--)
> + mdelay(1);
> +
> + stop_nmi();
> + if (!hv_has_crashed)
> + hv_notify_prepare_hyp();
> +
> + if (crashing_cpu == -1)
> + crashing_cpu = ccpu; /* crash cmd uses this */
> +
> + hv_hvcrash_ctxt_save();
> + hv_mark_tss_not_busy();
> + hv_crash_fixup_kernpt();
> +
> + input = *this_cpu_ptr(hyperv_pcpu_input_arg);
> + memset(input, 0, sizeof(*input));
> + input->rip = trampoline_pa;
> + input->arg = devirt_arg;
> +
> + status = hv_do_hypercall(HVCALL_DISABLE_HYP_EX, input, NULL);
> +
If I understand this correctly, after this call, upon return from the
hypervisor, Linux will start executing the trampoline code.
> + hv_panic_timeout_reboot();
Why is this needed? Is it to catch the case when the hypercall fails?
[...]
> +static void __noclone hv_crash_stop_other_cpus(void)
> +{
> + static bool crash_stop_done;
> + struct pt_regs lregs;
> + int ccpu = smp_processor_id();
> +
> + if (hv_has_crashed)
> + return; /* all cpus already in NMI handler path */
> +
> + if (!kexec_crash_loaded()) {
> + hv_notify_prepare_hyp();
> + hv_panic_timeout_reboot(); /* no return */
> + }
> +
> + /* If hyp crashes also, we could come here again before cpus_stopped is
hypervisor or hv (given the same term is used in the function)
> + * set in crash_smp_send_stop(). So use our own check.
> + */
> + if (crash_stop_done)
> + return;
> + crash_stop_done = true;
> +
> + /* Linux has crashed: hv is healthy, we can ipi safely */
IPI.
> +
> +err_out:
> + unregister_nmi_handler(NMI_LOCAL, "hv_crash_nmi");
> + pr_err("Hyper-V: only linux (but not hyp) kdump support enabled\n");
hypervisor not hyp. This is a message for the user so we should be as
clear as possible.
Wei
> +}
> --
> 2.36.1.vfs.0.0
>
next prev parent reply other threads:[~2025-10-02 21:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 21:46 [PATCH v2 0/6] Hyper-V: Implement hypervisor core collection Mukesh Rathor
2025-09-23 21:46 ` [PATCH v2 1/6] x86/hyperv: Rename guest crash shutdown function Mukesh Rathor
2025-09-23 21:46 ` [PATCH v2 2/6] hyperv: Add two new hypercall numbers to guest ABI public header Mukesh Rathor
2025-09-23 21:46 ` [PATCH v2 3/6] hyperv: Add definitions for hypervisor crash dump support Mukesh Rathor
2025-09-23 21:46 ` [PATCH v2 4/6] x86/hyperv: Add trampoline asm code to transition from hypervisor Mukesh Rathor
2025-10-01 6:00 ` Wei Liu
2025-10-01 21:07 ` Mukesh R
2025-09-23 21:46 ` [PATCH v2 5/6] x86/hyperv: Implement hypervisor RAM collection into vmcore Mukesh Rathor
2025-10-02 21:42 ` Wei Liu [this message]
2025-10-02 22:07 ` Mukesh R
2025-09-23 21:46 ` [PATCH v2 6/6] x86/hyperv: Enable build of hypervisor crashdump collection files Mukesh Rathor
2025-09-24 17:07 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251002214236.GC925245@liuwe-devbox-debian-v2.local \
--to=wei.liu@kernel.org \
--cc=arnd@arndb.de \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=kys@microsoft.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mrathor@linux.microsoft.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).