[PATCH v3 0/6] Hyper-V: Implement hypervisor core collection

Mukesh Rathor posted 6 patches 2 months, 1 week ago
arch/x86/hyperv/Makefile        |   6 +
arch/x86/hyperv/hv_crash.c      | 642 ++++++++++++++++++++++++++++++++
arch/x86/hyperv/hv_init.c       |   1 +
arch/x86/hyperv/hv_trampoline.S | 101 +++++
arch/x86/include/asm/mshyperv.h |  13 +
arch/x86/kernel/cpu/mshyperv.c  |   5 +-
include/hyperv/hvgdk_mini.h     |   2 +
include/hyperv/hvhdk_mini.h     |  55 +++
8 files changed, 823 insertions(+), 2 deletions(-)
create mode 100644 arch/x86/hyperv/hv_crash.c
create mode 100644 arch/x86/hyperv/hv_trampoline.S
[PATCH v3 0/6] Hyper-V: Implement hypervisor core collection
Posted by Mukesh Rathor 2 months, 1 week ago
This patch series implements hypervisor core collection when running
under Linux as root. By default initial hypervisor RAM is already mapped
into Linux as reserved. Further any RAM deposited comes from Linux memory
heap. The hypervisor locks all that RAM to protect it from root or any
other domains. At a high level, the methodology involes devirtualizing
the system on the fly upon either Linux crash or the hypervisor crash,
then collecting core as usual. This means hypervisor RAM is automatically
collected into the vmcore.  Devirtualization is the process of disabling
the hypervisor and taking control of the system.

Hypervisor pages are then accessible via crash command (using raw mem
dump) or windbg which has the ability to read hypervisor pdb symbol
file.

V3:
 o remove usage of the word "dom0" as asked by maintainer
 o change hyp to hv in comment and ipi to IPI
 o rebase to:  hyperv-next: commit b595edcb2472

V2:
 o change few comments and commit-messages
 o add support for panic_timeout for better support if kdump kernel
   is not loaded.
 o some other minor changes, like change devirt_cr3arg to devirt_arg,
   int to bool. 

V1:
 o Describe changes in imperative mood. Remove "This commit"
 o Remove pr_emerg: causing unnecessary review noise
 o Add missing kexec_crash_loaded()
 o Remove leftover unnecessary memcpy in hv_crash_setup_trampdata
 o Address objtool warnings via annotations

Mukesh Rathor (6):
  x86/hyperv: Rename guest crash shutdown function
  hyperv: Add two new hypercall numbers to guest ABI public header
  hyperv: Add definitions for hypervisor crash dump support
  x86/hyperv: Add trampoline asm code to transition from hypervisor
  x86/hyperv: Implement hypervisor RAM collection into vmcore
  x86/hyperv: Enable build of hypervisor crashdump collection files

 arch/x86/hyperv/Makefile        |   6 +
 arch/x86/hyperv/hv_crash.c      | 642 ++++++++++++++++++++++++++++++++
 arch/x86/hyperv/hv_init.c       |   1 +
 arch/x86/hyperv/hv_trampoline.S | 101 +++++
 arch/x86/include/asm/mshyperv.h |  13 +
 arch/x86/kernel/cpu/mshyperv.c  |   5 +-
 include/hyperv/hvgdk_mini.h     |   2 +
 include/hyperv/hvhdk_mini.h     |  55 +++
 8 files changed, 823 insertions(+), 2 deletions(-)
 create mode 100644 arch/x86/hyperv/hv_crash.c
 create mode 100644 arch/x86/hyperv/hv_trampoline.S

-- 
2.36.1.vfs.0.0
Re: [PATCH v3 0/6] Hyper-V: Implement hypervisor core collection
Posted by Wei Liu 1 month, 4 weeks ago
On Mon, Oct 06, 2025 at 03:42:02PM -0700, Mukesh Rathor wrote:
[...]
> Mukesh Rathor (6):
>   x86/hyperv: Rename guest crash shutdown function
>   hyperv: Add two new hypercall numbers to guest ABI public header
>   hyperv: Add definitions for hypervisor crash dump support
>   x86/hyperv: Add trampoline asm code to transition from hypervisor
>   x86/hyperv: Implement hypervisor RAM collection into vmcore
>   x86/hyperv: Enable build of hypervisor crashdump collection files
> 

Applied to hyperv-next. Thanks.

>  arch/x86/hyperv/Makefile        |   6 +
>  arch/x86/hyperv/hv_crash.c      | 642 ++++++++++++++++++++++++++++++++
>  arch/x86/hyperv/hv_init.c       |   1 +
>  arch/x86/hyperv/hv_trampoline.S | 101 +++++
>  arch/x86/include/asm/mshyperv.h |  13 +
>  arch/x86/kernel/cpu/mshyperv.c  |   5 +-
>  include/hyperv/hvgdk_mini.h     |   2 +
>  include/hyperv/hvhdk_mini.h     |  55 +++
>  8 files changed, 823 insertions(+), 2 deletions(-)
>  create mode 100644 arch/x86/hyperv/hv_crash.c
>  create mode 100644 arch/x86/hyperv/hv_trampoline.S
> 
> -- 
> 2.36.1.vfs.0.0
>
Re: [PATCH v3 0/6] Hyper-V: Implement hypervisor core collection
Posted by Wei Liu 1 month, 4 weeks ago
On Fri, Oct 17, 2025 at 10:33:00PM +0000, Wei Liu wrote:
> On Mon, Oct 06, 2025 at 03:42:02PM -0700, Mukesh Rathor wrote:
> [...]
> > Mukesh Rathor (6):
> >   x86/hyperv: Rename guest crash shutdown function
> >   hyperv: Add two new hypercall numbers to guest ABI public header
> >   hyperv: Add definitions for hypervisor crash dump support
> >   x86/hyperv: Add trampoline asm code to transition from hypervisor
> >   x86/hyperv: Implement hypervisor RAM collection into vmcore
> >   x86/hyperv: Enable build of hypervisor crashdump collection files
> > 
> 
> Applied to hyperv-next. Thanks.

This breaks i386 build.

/work/linux-on-hyperv/linux.git/arch/x86/hyperv/hv_init.c: In function ‘hyperv_init’:
/work/linux-on-hyperv/linux.git/arch/x86/hyperv/hv_init.c:557:17: error: implicit declaration of function ‘hv_root_crash_init’ [-Werror=implicit-function-declaration]
  557 |                 hv_root_crash_init();
      |                 ^~~~~~~~~~~~~~~~~~

That's because CONFIG_MSHV_ROOT is only available on x86_64. And the
crash feature is guarded by CONFIG_MSHV_ROOT.

Applying the following diff fixes the build.

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index e28737ec7054..c1300339d2eb 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -554,7 +554,9 @@ void __init hyperv_init(void)
                memunmap(src);

                hv_remap_tsc_clocksource();
+#ifdef CONFIG_X86_64
                hv_root_crash_init();
+#endif
        } else {
                hypercall_msr.guest_physical_address = vmalloc_to_pfn(hv_hypercall_pg);
                wrmsrq(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);

> 
> >  arch/x86/hyperv/Makefile        |   6 +
> >  arch/x86/hyperv/hv_crash.c      | 642 ++++++++++++++++++++++++++++++++
> >  arch/x86/hyperv/hv_init.c       |   1 +
> >  arch/x86/hyperv/hv_trampoline.S | 101 +++++
> >  arch/x86/include/asm/mshyperv.h |  13 +
> >  arch/x86/kernel/cpu/mshyperv.c  |   5 +-
> >  include/hyperv/hvgdk_mini.h     |   2 +
> >  include/hyperv/hvhdk_mini.h     |  55 +++
> >  8 files changed, 823 insertions(+), 2 deletions(-)
> >  create mode 100644 arch/x86/hyperv/hv_crash.c
> >  create mode 100644 arch/x86/hyperv/hv_trampoline.S
> > 
> > -- 
> > 2.36.1.vfs.0.0
> > 
Re: [PATCH v3 0/6] Hyper-V: Implement hypervisor core collection
Posted by Mukesh R 1 month, 4 weeks ago
On 10/17/25 15:57, Wei Liu wrote:
> On Fri, Oct 17, 2025 at 10:33:00PM +0000, Wei Liu wrote:
>> On Mon, Oct 06, 2025 at 03:42:02PM -0700, Mukesh Rathor wrote:
>> [...]
>>> Mukesh Rathor (6):
>>>   x86/hyperv: Rename guest crash shutdown function
>>>   hyperv: Add two new hypercall numbers to guest ABI public header
>>>   hyperv: Add definitions for hypervisor crash dump support
>>>   x86/hyperv: Add trampoline asm code to transition from hypervisor
>>>   x86/hyperv: Implement hypervisor RAM collection into vmcore
>>>   x86/hyperv: Enable build of hypervisor crashdump collection files
>>>
>>
>> Applied to hyperv-next. Thanks.
> 
> This breaks i386 build.
> 
> /work/linux-on-hyperv/linux.git/arch/x86/hyperv/hv_init.c: In function ?hyperv_init?:
> /work/linux-on-hyperv/linux.git/arch/x86/hyperv/hv_init.c:557:17: error: implicit declaration of function ?hv_root_crash_init? [-Werror=implicit-function-declaration]
>   557 |                 hv_root_crash_init();
>       |                 ^~~~~~~~~~~~~~~~~~
> 
> That's because CONFIG_MSHV_ROOT is only available on x86_64. And the
> crash feature is guarded by CONFIG_MSHV_ROOT.
> 
> Applying the following diff fixes the build.


Thanks. A bit surprising tho that CONFIG_MSHV_ROOT doesn't have 
hard dependency on x86_64. It should, no?

Thanks,
-Mukesh


> diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> index e28737ec7054..c1300339d2eb 100644
> --- a/arch/x86/hyperv/hv_init.c
> +++ b/arch/x86/hyperv/hv_init.c
> @@ -554,7 +554,9 @@ void __init hyperv_init(void)
>                 memunmap(src);
> 
>                 hv_remap_tsc_clocksource();
> +#ifdef CONFIG_X86_64
>                 hv_root_crash_init();
> +#endif
>         } else {
>                 hypercall_msr.guest_physical_address = vmalloc_to_pfn(hv_hypercall_pg);
>                 wrmsrq(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> 
>>
>>>  arch/x86/hyperv/Makefile        |   6 +
>>>  arch/x86/hyperv/hv_crash.c      | 642 ++++++++++++++++++++++++++++++++
>>>  arch/x86/hyperv/hv_init.c       |   1 +
>>>  arch/x86/hyperv/hv_trampoline.S | 101 +++++
>>>  arch/x86/include/asm/mshyperv.h |  13 +
>>>  arch/x86/kernel/cpu/mshyperv.c  |   5 +-
>>>  include/hyperv/hvgdk_mini.h     |   2 +
>>>  include/hyperv/hvhdk_mini.h     |  55 +++
>>>  8 files changed, 823 insertions(+), 2 deletions(-)
>>>  create mode 100644 arch/x86/hyperv/hv_crash.c
>>>  create mode 100644 arch/x86/hyperv/hv_trampoline.S
>>>
>>> -- 
>>> 2.36.1.vfs.0.0
>>>