* RE: [PATCH v8 1/6] arm64: hyperv: Add Hyper-V hypercall and register access utilities
[not found] ` <1614649360-5087-2-git-send-email-mikelley@microsoft.com>
@ 2021-03-03 0:34 ` Sunil Muthuswamy
2021-03-03 18:28 ` Sunil Muthuswamy
2021-03-05 20:56 ` Michael Kelley
0 siblings, 2 replies; 10+ messages in thread
From: Sunil Muthuswamy @ 2021-03-03 0:34 UTC (permalink / raw)
To: Michael Kelley
Cc: will, catalin.marinas, Mark Rutland, linux-arm-kernel,
linux-kernel, linux-hyperv, linux-efi, arnd, wei.liu, ardb,
daniel.lezcano, KY Srinivasan
> +}
> +EXPORT_SYMBOL_GPL(hv_do_fast_hypercall8);
> +
> +
nit: Extra line, here and few other places
> +u64 hv_get_vpreg(u32 msr)
> +{
> + struct hv_get_vp_registers_input *input;
> + struct hv_get_vp_registers_output *output;
> + u64 result;
It seems like the code is using both spaces and tabs to align variable names. Can
we stick to one or the other, preferably spaces.
> +
> + /*
> + * Allocate a power of 2 size so alignment to that size is
> + * guaranteed, since the hypercall input and output areas
> + * must not cross a page boundary.
> + */
> + input = kzalloc(roundup_pow_of_two(sizeof(input->header) +
> + sizeof(input->element[0])), GFP_ATOMIC);
> + output = kmalloc(roundup_pow_of_two(sizeof(*output)), GFP_ATOMIC);
> +
Check for null from these malloc routines? Here and in other places.
> + __hv_get_vpreg_128(msr, input, output);
+ * Linux-specific definitions for managing interactions with Microsoft's
+ * Hyper-V hypervisor. The definitions in this file are specific to
+ * the ARM64 architecture. See include/asm-generic/mshyperv.h for
nit: Two space before 'See'. Here and in couple of other places.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH v8 1/6] arm64: hyperv: Add Hyper-V hypercall and register access utilities
2021-03-03 0:34 ` [PATCH v8 1/6] arm64: hyperv: Add Hyper-V hypercall and register access utilities Sunil Muthuswamy
@ 2021-03-03 18:28 ` Sunil Muthuswamy
2021-03-05 20:58 ` Michael Kelley
2021-03-05 20:56 ` Michael Kelley
1 sibling, 1 reply; 10+ messages in thread
From: Sunil Muthuswamy @ 2021-03-03 18:28 UTC (permalink / raw)
To: Sunil Muthuswamy, Michael Kelley
Cc: will, catalin.marinas, Mark Rutland, linux-arm-kernel,
linux-kernel, linux-hyperv, linux-efi, arnd, wei.liu, ardb,
daniel.lezcano, KY Srinivasan
> > +
> > + /*
> > + * Allocate a power of 2 size so alignment to that size is
> > + * guaranteed, since the hypercall input and output areas
> > + * must not cross a page boundary.
> > + */
> > + input = kzalloc(roundup_pow_of_two(sizeof(input->header) +
> > + sizeof(input->element[0])), GFP_ATOMIC);
> > + output = kmalloc(roundup_pow_of_two(sizeof(*output)), GFP_ATOMIC);
> > +
> Check for null from these malloc routines? Here and in other places.
Between, is there a plan to setup a percpu input/output page for hypercall
input/output on ARM (like we do for x64)? I didn't check the specific size requirement
for this particular call, but, that generally will remove the need for these
allocations.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH v8 1/6] arm64: hyperv: Add Hyper-V hypercall and register access utilities
2021-03-03 18:28 ` Sunil Muthuswamy
@ 2021-03-05 20:58 ` Michael Kelley
0 siblings, 0 replies; 10+ messages in thread
From: Michael Kelley @ 2021-03-05 20:58 UTC (permalink / raw)
To: Sunil Muthuswamy
Cc: will, catalin.marinas, Mark Rutland, linux-arm-kernel,
linux-kernel, linux-hyperv, linux-efi, arnd, wei.liu, ardb,
daniel.lezcano, KY Srinivasan
From: Sunil Muthuswamy <sunilmut@microsoft.com> Sent: Wednesday, March 3, 2021 10:28 AM
>
> > > +
> > > + /*
> > > + * Allocate a power of 2 size so alignment to that size is
> > > + * guaranteed, since the hypercall input and output areas
> > > + * must not cross a page boundary.
> > > + */
> > > + input = kzalloc(roundup_pow_of_two(sizeof(input->header) +
> > > + sizeof(input->element[0])), GFP_ATOMIC);
> > > + output = kmalloc(roundup_pow_of_two(sizeof(*output)), GFP_ATOMIC);
> > > +
> > Check for null from these malloc routines? Here and in other places.
>
> Between, is there a plan to setup a percpu input/output page for hypercall
> input/output on ARM (like we do for x64)? I didn't check the specific size requirement
> for this particular call, but, that generally will remove the need for these
> allocations.
I'm not planning to add percpu input/output pages in this patch set. As noted
in another reply, we can eliminate these memory allocations entirely by using
"fast" hypercalls. At that point, there would be no usage of percpu input/output
pages in this patch set. If the need arises in the context of future work, we can
add them at that time.
Michael
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH v8 1/6] arm64: hyperv: Add Hyper-V hypercall and register access utilities
2021-03-03 0:34 ` [PATCH v8 1/6] arm64: hyperv: Add Hyper-V hypercall and register access utilities Sunil Muthuswamy
2021-03-03 18:28 ` Sunil Muthuswamy
@ 2021-03-05 20:56 ` Michael Kelley
1 sibling, 0 replies; 10+ messages in thread
From: Michael Kelley @ 2021-03-05 20:56 UTC (permalink / raw)
To: Sunil Muthuswamy
Cc: will, catalin.marinas, Mark Rutland, linux-arm-kernel,
linux-kernel, linux-hyperv, linux-efi, arnd, wei.liu, ardb,
daniel.lezcano, KY Srinivasan
From: Sunil Muthuswamy <sunilmut@microsoft.com> Sent: Tuesday, March 2, 2021 4:35 PM
>
> > +}
> > +EXPORT_SYMBOL_GPL(hv_do_fast_hypercall8);
> > +
> > +
> nit: Extra line, here and few other places
I'll try to clean these up.
>
> > +u64 hv_get_vpreg(u32 msr)
> > +{
> > + struct hv_get_vp_registers_input *input;
> > + struct hv_get_vp_registers_output *output;
> > + u64 result;
> It seems like the code is using both spaces and tabs to align variable names. Can
> we stick to one or the other, preferably spaces.
I think the general preference is to use tabs for alignment, not
spaces, so I'll try to clean these up in the next version.
>
> > +
> > + /*
> > + * Allocate a power of 2 size so alignment to that size is
> > + * guaranteed, since the hypercall input and output areas
> > + * must not cross a page boundary.
> > + */
> > + input = kzalloc(roundup_pow_of_two(sizeof(input->header) +
> > + sizeof(input->element[0])), GFP_ATOMIC);
> > + output = kmalloc(roundup_pow_of_two(sizeof(*output)), GFP_ATOMIC);
> > +
> Check for null from these malloc routines? Here and in other places.
See my comment back to Boqun Feng on the same point.
>
> > + __hv_get_vpreg_128(msr, input, output);
>
> + * Linux-specific definitions for managing interactions with Microsoft's
> + * Hyper-V hypervisor. The definitions in this file are specific to
> + * the ARM64 architecture. See include/asm-generic/mshyperv.h for
> nit: Two space before 'See'. Here and in couple of other places.
The debate rages in the broader world of writing about using one
space vs. two spaces. :-) I'm still old school on this point, and use two
spaces out of decades of habit, particularly with monospaced fonts,
though I'm probably not 100% consistent.
Michael
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <1614649360-5087-7-git-send-email-mikelley@microsoft.com>]
* RE: [PATCH v8 6/6] Drivers: hv: Enable Hyper-V code to be built on ARM64
[not found] ` <1614649360-5087-7-git-send-email-mikelley@microsoft.com>
@ 2021-03-03 19:22 ` Sunil Muthuswamy
0 siblings, 0 replies; 10+ messages in thread
From: Sunil Muthuswamy @ 2021-03-03 19:22 UTC (permalink / raw)
To: Michael Kelley
Cc: will, catalin.marinas, Mark Rutland, linux-arm-kernel,
linux-kernel, linux-hyperv, linux-efi, arnd, wei.liu, ardb,
daniel.lezcano, KY Srinivasan
> Update drivers/hv/Kconfig so CONFIG_HYPERV can be selected on
> ARM64, causing the Hyper-V specific code to be built.
>
> Signed-off-by: Michael Kelley <mikelley@microsoft.com>
> ---
> drivers/hv/Kconfig | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig
> index 79e5356..d492682 100644
> --- a/drivers/hv/Kconfig
> +++ b/drivers/hv/Kconfig
> @@ -4,7 +4,8 @@ menu "Microsoft Hyper-V guest support"
>
> config HYPERV
> tristate "Microsoft Hyper-V client drivers"
> - depends on X86 && ACPI && X86_LOCAL_APIC && HYPERVISOR_GUEST
> + depends on ACPI && ((X86 && X86_LOCAL_APIC && HYPERVISOR_GUEST) \
> + || (ARM64 && !CPU_BIG_ENDIAN))
> select PARAVIRT
> select X86_HV_CALLBACK_VECTOR
> help
> --
> 1.8.3.1
Reviewed-by: Sunil Muthuswamy <sunilmut@microsoft.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <1614649360-5087-3-git-send-email-mikelley@microsoft.com>]
* RE: [PATCH v8 2/6] arm64: hyperv: Add Hyper-V clocksource/clockevent support
[not found] ` <1614649360-5087-3-git-send-email-mikelley@microsoft.com>
@ 2021-03-03 19:29 ` Sunil Muthuswamy
0 siblings, 0 replies; 10+ messages in thread
From: Sunil Muthuswamy @ 2021-03-03 19:29 UTC (permalink / raw)
To: Michael Kelley
Cc: will, catalin.marinas, Mark Rutland, linux-arm-kernel,
linux-kernel, linux-hyperv, linux-efi, arnd, wei.liu, ardb,
daniel.lezcano, KY Srinivasan
> +/* Define the interrupt ID used by STIMER0 Direct Mode interrupts. This
> + * value can't come from ACPI tables because it is needed before the
> + * Linux ACPI subsystem is initialized.
> + */
> +#define HYPERV_STIMER0_VECTOR 31
nit: On x64, this is defined in HEX
> +
> + return 0;
> +}
> +TIMER_ACPI_DECLARE(hyperv, ACPI_SIG_GTDT, hyperv_timer_init);
> --
> 1.8.3.1
Reviewed-by: Sunil Muthuswamy <sunilmut@microsoft.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <1614649360-5087-5-git-send-email-mikelley@microsoft.com>]
* RE: [PATCH v8 4/6] arm64: hyperv: Initialize hypervisor on boot
[not found] ` <1614649360-5087-5-git-send-email-mikelley@microsoft.com>
@ 2021-03-03 20:21 ` Sunil Muthuswamy
2021-03-05 21:03 ` Michael Kelley
0 siblings, 1 reply; 10+ messages in thread
From: Sunil Muthuswamy @ 2021-03-03 20:21 UTC (permalink / raw)
To: Michael Kelley
Cc: will, catalin.marinas, Mark Rutland, linux-arm-kernel,
linux-kernel, linux-hyperv, linux-efi, arnd, wei.liu, ardb,
daniel.lezcano, KY Srinivasan
> +static u64 hypercall_output __initdata;
> +
> +static int __init hyperv_init(void)
> +{
> + struct hv_get_vpindex_from_apicid_input *input;
> + u64 status;
> + int i;
nit: both, tabs & spaces are being used to indent variable names. Can we stick
to one?
> +
> + /*
> + * Hypercall inputs must not cross a page boundary, so allocate
> + * power of 2 size, which will be aligned to that size.
> + */
> + input = kzalloc(roundup_pow_of_two(sizeof(input->header) +
> + sizeof(input->element[0])), GFP_KERNEL);
> + if (!input)
> + return -ENOMEM;
Similar to the comment on the other patch, can this be done through a
per-cpu hypercall input page?
> + if ((status & HV_HYPERCALL_RESULT_MASK) == HV_STATUS_SUCCESS)
> + hv_vp_index[i] = hypercall_output;
> + else {
CNF suggests using braces even for single line 'if' statements if the 'else' is a multi-line
statement
> + pr_warn("Hyper-V: No VP index for CPU %d MPIDR %llx status %llx\n",
> + i, cpu_logical_map(i), status);
> + hv_vp_index[i] = VP_INVAL;
> + }
> +bool hv_is_hyperv_initialized(void)
> +{
> + return hyperv_initialized;
> +}
> +EXPORT_SYMBOL_GPL(hv_is_hyperv_initialized);
This to me seems like more of an indication that whether the hypervisor is Hyper-V or
something else, rather than if necessary Hyper-V pieces have been initialized. If that is
the case, suggest renaming. Maybe just call it 'hv_is_hyperv'?
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH v8 4/6] arm64: hyperv: Initialize hypervisor on boot
2021-03-03 20:21 ` [PATCH v8 4/6] arm64: hyperv: Initialize hypervisor on boot Sunil Muthuswamy
@ 2021-03-05 21:03 ` Michael Kelley
0 siblings, 0 replies; 10+ messages in thread
From: Michael Kelley @ 2021-03-05 21:03 UTC (permalink / raw)
To: Sunil Muthuswamy
Cc: will, catalin.marinas, Mark Rutland, linux-arm-kernel,
linux-kernel, linux-hyperv, linux-efi, arnd, wei.liu, ardb,
daniel.lezcano, KY Srinivasan
From: Sunil Muthuswamy <sunilmut@microsoft.com> Sent: Wednesday, March 3, 2021 12:21 PM
>
> > +static u64 hypercall_output __initdata;
> > +
> > +static int __init hyperv_init(void)
> > +{
> > + struct hv_get_vpindex_from_apicid_input *input;
> > + u64 status;
> > + int i;
> nit: both, tabs & spaces are being used to indent variable names. Can we stick
> to one?
>
Agreed. Will make this consistent in the next version.
> > +
> > + /*
> > + * Hypercall inputs must not cross a page boundary, so allocate
> > + * power of 2 size, which will be aligned to that size.
> > + */
> > + input = kzalloc(roundup_pow_of_two(sizeof(input->header) +
> > + sizeof(input->element[0])), GFP_KERNEL);
> > + if (!input)
> > + return -ENOMEM;
> Similar to the comment on the other patch, can this be done through a
> per-cpu hypercall input page?
Per comments on other previous patch, these allocations can be eliminated
and the problem avoided entirely.
>
> > + if ((status & HV_HYPERCALL_RESULT_MASK) == HV_STATUS_SUCCESS)
> > + hv_vp_index[i] = hypercall_output;
> > + else {
> CNF suggests using braces even for single line 'if' statements if the 'else' is a multi-line
> statement
Will do.
>
> > + pr_warn("Hyper-V: No VP index for CPU %d MPIDR %llx status
> %llx\n",
> > + i, cpu_logical_map(i), status);
> > + hv_vp_index[i] = VP_INVAL;
> > + }
>
> > +bool hv_is_hyperv_initialized(void)
> > +{
> > + return hyperv_initialized;
> > +}
> > +EXPORT_SYMBOL_GPL(hv_is_hyperv_initialized);
>
> This to me seems like more of an indication that whether the hypervisor is Hyper-V or
> something else, rather than if necessary Hyper-V pieces have been initialized. If that is
> the case, suggest renaming. Maybe just call it 'hv_is_hyperv'?
This function also exists on the x86/x64 side and is used in architecture independent
code. It's meaning is somewhere between "is Hyper-V" and "is Hyper-V initialized".
I'm not sure there's much value in changing the name everywhere.
Michael
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <1614649360-5087-4-git-send-email-mikelley@microsoft.com>]
* RE: [PATCH v8 3/6] arm64: hyperv: Add kexec and panic handlers
[not found] ` <1614649360-5087-4-git-send-email-mikelley@microsoft.com>
@ 2021-03-03 21:29 ` Sunil Muthuswamy
0 siblings, 0 replies; 10+ messages in thread
From: Sunil Muthuswamy @ 2021-03-03 21:29 UTC (permalink / raw)
To: Michael Kelley
Cc: will, catalin.marinas, Mark Rutland, linux-arm-kernel,
linux-kernel, linux-hyperv, linux-efi, arnd, wei.liu, ardb,
daniel.lezcano, KY Srinivasan
> +EXPORT_SYMBOL_GPL(hv_setup_crash_handler);
> +
> +void hv_remove_crash_handler(void)
> +{
> +}
> +EXPORT_SYMBOL_GPL(hv_remove_crash_handler);
> --
> 1.8.3.1
Reviewed-by: Sunil Muthuswamy <sunilmut@microsoft.com>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v8 0/6] Enable Linux guests on Hyper-V on ARM64
@ 2021-02-18 23:16 Michael Kelley
2021-02-18 23:16 ` [PATCH v8 3/6] arm64: hyperv: Add kexec and panic handlers Michael Kelley
0 siblings, 1 reply; 10+ messages in thread
From: Michael Kelley @ 2021-02-18 23:16 UTC (permalink / raw)
To: will, catalin.marinas, mark.rutland, linux-arm-kernel,
linux-kernel, linux-hyperv, linux-efi, arnd, wei.liu, ardb,
daniel.lezcano, kys
Cc: mikelley
This series enables Linux guests running on Hyper-V on ARM64
hardware. New ARM64-specific code in arch/arm64/hyperv initializes
Hyper-V, including its interrupts and hypercall mechanism.
Existing architecture independent drivers for Hyper-V's VMbus and
synthetic devices just work when built for ARM64. Hyper-V code is
built and included in the image and modules only if CONFIG_HYPERV
is enabled.
The six patches are organized as follows:
1) Add definitions and functions for making Hyper-V hypercalls
and getting/setting virtual processor registers provided by
Hyper-V
2) Add architecture specific definitions needed by the
architecture independent Hyper-V clocksource driver in
drivers/clocksource/hyperv_timer.c. Update the clocksource
driver to be initialized on ARM64.
3) Add functions needed by the arch independent VMbus driver
for reporting a panic to Hyper-V and as stubs for the kexec
and crash handlers.
4) Add Hyper-V initialization code and utility functions that
report Hyper-v status.
5) Export screen_info so it may be used by the Hyper-V frame buffer
driver built as a module. It is already exported for x86,
powerpc, and alpha architectures.
6) Make CONFIG_HYPERV selectable on ARM64 in addition to x86/x64.
Hyper-V on ARM64 runs with a 4 Kbyte page size, but allows guests
with 4K/16K/64K page size. Linux guests with this ARM64 enablement
code work with all three supported ARM64 page sizes.
The Hyper-V vPCI driver at drivers/pci/host/pci-hyperv.c has
x86/x64-specific code and is not being built for ARM64. Fixing
this driver to enable vPCI devices on ARM64 will be done later.
In a few cases, terminology from the x86/x64 world has been carried
over into the ARM64 code ("MSR", "TSC"). Hyper-V still uses the
x86/x64 terminology and has not replaced it with something more
generic, so the code uses the Hyper-V terminology. This will be
fixed when Hyper-V updates the usage in the TLFS.
This patch set is based on the 5.11.0 code tree, plus this patch series
https://lore.kernel.org/lkml/1611779025-21503-1-git-send-email-mikelley@microsoft.com/
that refactors the boundary between arch independent and arch
dependent code for Hyper-V.
Changes in v8:
* Removed a fair amount of code based on refactoring the boundary between
arch independent and arch dependent code for Hyper-V, per comments
from Arnd Bergmann. The removed code was either duplicated on
the x86 side, or has been folded into architecture independent
code as not really being architecture dependent.
* Added config dependency on !CONFIG_CPU_BIG_ENDIAN [Arnd Bergmann]
* Reworked the approach to Hyper-V initialization. The functionality
is the same, but is now structured like the Xen code with an early
init function called in setup_arch() and an early initcall to
finish the initialization. [Arnd Bergmann]
Changes in v7:
* Separately upstreamed split of hyperv-tlfs.h into arch dependent
and independent versions. In this patch set, update the ARM64
hyperv-tlfs.h to include architecture independent definitions.
This approach eliminates a lot of lines of otherwise duplicated
code on the ARM64 side.
* Break ARM64 mshyperv.h into smaller pieces. Have an initial
baseline, and add code along with patches for a particular
functional area. [Marc Zyngier]
* In mshyperv.h, use static inline functions instead of #defines
where possible. [Arnd Bergmann]
* Use VMbus INTID obtained from ACPI DSDT instead of hardcoding.
The STIMER INTID is still hardcoded because it is needed
before Linux has initialized the ACPI subsystem, so it can't
be obtained from the DSDT. Wedging it into the GTDT seems
dubious, so was not done. [Marc Zyngier]
* Update Hyper-V page size allocation functions to use
alloc_page() if PAGE_SIZE == HV_HYP_PAGE_SIZE [Arnd
Bergmann]
* Various other minor changes based on feedback and to rebase
to latest linux-next [Marc Zyngier and Arnd Bergmann]
Changes in v6:
* Use SMCCC hypercall interface instead of direct invocation
of HVC instruction and the Hyper-V hypercall interface
[Marc Zyngier]
* Reimplemented functions to alloc/free Hyper-V size pages
using kmalloc/kfree since kmalloc now guarantees alignment of
power of 2 size allocations [Marc Zyngier]
* Export screen_info in arm64 architecture so it can be used
by the Hyper-V buffer driver built as a module
* Renamed source file arch/arm64/hyperv/hv_init.c to hv_core.c
to better reflect its content
* Fixed the bit position of certain feature flags presented by
Hyper-V to the guest. The bit positions on ARM64 don't match
the position on x86 like originally thought.
* Minor fixups to rebase to 5.6-rc5 linux-next
Changes in v5:
* Minor fixups to rebase to 5.4-rc1 linux-next
Changes in v4:
* Moved clock-related code into an architecture independent
Hyper-V clocksource driver that is already upstream. Clock
related code is removed from this patch set except for the
ARM64 specific interrupt handler. [Marc Zyngier]
* Separately upstreamed the split of mshyperv.h into arch independent
and arch dependent portions. The arch independent portion has been
removed from this patch set.
* Divided patch #2 of the series into multiple smaller patches
[Marc Zyngier]
* Changed a dozen or so smaller things based on feedback
[Marc Zyngier, Will Deacon]
* Added functions to alloc/free Hyper-V size pages for use by
drivers for Hyper-V synthetic devices when updated to not assume
guest page size and Hyper-v page size are the same
Changes in v3:
* Added initialization of hv_vp_index array like was recently
added on x86 branch [KY Srinivasan]
* Changed Hyper-V ARM64 register symbols to be all uppercase
instead of mixed case [KY Srinivasan]
* Separated mshyperv.h into two files, one architecture
independent and one architecture dependent. After this code
is upstream, will make changes to the x86 code to use the
architecture independent file and remove duplication. And
once we have a multi-architecture Hyper-V TLFS, will do a
separate patch to split hyperv-tlfs.h in the same way.
[KY Srinivasan]
* Minor tweaks to rebase to latest linux-next code
Changes in v2:
* Removed patch to implement slow_virt_to_phys() on ARM64.
Use of slow_virt_to_phys() in arch independent Hyper-V
drivers has been eliminated by commit 6ba34171bcbd
("Drivers: hv: vmbus: Remove use of slow_virt_to_phys()")
* Minor tweaks to rebase to latest linux-next code
Michael Kelley (6):
arm64: hyperv: Add Hyper-V hypercall and register access utilities
arm64: hyperv: Add Hyper-V clocksource/clockevent support
arm64: hyperv: Add kexec and panic handlers
arm64: hyperv: Initialize hypervisor on boot
arm64: efi: Export screen_info
Drivers: hv: Enable Hyper-V code to be built on ARM64
MAINTAINERS | 3 +
arch/arm64/Kbuild | 1 +
arch/arm64/hyperv/Makefile | 2 +
arch/arm64/hyperv/hv_core.c | 220 +++++++++++++++++++++++++++++++++++
arch/arm64/hyperv/mshyperv.c | 194 ++++++++++++++++++++++++++++++
arch/arm64/include/asm/hyperv-tlfs.h | 69 +++++++++++
arch/arm64/include/asm/mshyperv.h | 73 ++++++++++++
arch/arm64/kernel/efi.c | 1 +
arch/arm64/kernel/setup.c | 4 +
drivers/clocksource/hyperv_timer.c | 14 +++
drivers/hv/Kconfig | 3 +-
11 files changed, 583 insertions(+), 1 deletion(-)
create mode 100644 arch/arm64/hyperv/Makefile
create mode 100644 arch/arm64/hyperv/hv_core.c
create mode 100644 arch/arm64/hyperv/mshyperv.c
create mode 100644 arch/arm64/include/asm/hyperv-tlfs.h
create mode 100644 arch/arm64/include/asm/mshyperv.h
--
1.8.3.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v8 3/6] arm64: hyperv: Add kexec and panic handlers
2021-02-18 23:16 [PATCH v8 0/6] Enable Linux guests on Hyper-V on ARM64 Michael Kelley
@ 2021-02-18 23:16 ` Michael Kelley
0 siblings, 0 replies; 10+ messages in thread
From: Michael Kelley @ 2021-02-18 23:16 UTC (permalink / raw)
To: will, catalin.marinas, mark.rutland, linux-arm-kernel,
linux-kernel, linux-hyperv, linux-efi, arnd, wei.liu, ardb,
daniel.lezcano, kys
Cc: mikelley
Add function to inform Hyper-V about a guest panic.
Also add functions to set up and remove kexec and panic
handlers, which are currently unused on ARM64 but are
called from architecture independent code in the VMbus
driver.
This code is built only when CONFIG_HYPERV is enabled.
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
---
arch/arm64/hyperv/Makefile | 2 +-
arch/arm64/hyperv/hv_core.c | 53 +++++++++++++++++++++++++++++++++++++++++++
arch/arm64/hyperv/mshyperv.c | 54 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 108 insertions(+), 1 deletion(-)
create mode 100644 arch/arm64/hyperv/mshyperv.c
diff --git a/arch/arm64/hyperv/Makefile b/arch/arm64/hyperv/Makefile
index 1697d30..87c31c0 100644
--- a/arch/arm64/hyperv/Makefile
+++ b/arch/arm64/hyperv/Makefile
@@ -1,2 +1,2 @@
# SPDX-License-Identifier: GPL-2.0
-obj-y := hv_core.o
+obj-y := hv_core.o mshyperv.o
diff --git a/arch/arm64/hyperv/hv_core.c b/arch/arm64/hyperv/hv_core.c
index 9a37124..d4e3808 100644
--- a/arch/arm64/hyperv/hv_core.c
+++ b/arch/arm64/hyperv/hv_core.c
@@ -165,3 +165,56 @@ void hv_get_vpreg_128(u32 msr, struct hv_get_vp_registers_output *res)
kfree(output);
}
EXPORT_SYMBOL_GPL(hv_get_vpreg_128);
+
+/*
+ * hyperv_report_panic - report a panic to Hyper-V. This function uses
+ * the older version of the Hyper-V interface that admittedly doesn't
+ * pass enough information to be useful beyond just recording the
+ * occurrence of a panic. The parallel hv_kmsg_dump() uses the
+ * new interface that allows reporting 4 Kbytes of data, which is much
+ * more useful. Hyper-V on ARM64 always supports the newer interface, but
+ * we retain support for the older version because the sysadmin is allowed
+ * to disable the newer version via sysctl in case of information security
+ * concerns about the more verbose version.
+ */
+void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die)
+{
+ static bool panic_reported;
+ u64 guest_id;
+
+ /* Don't report a panic to Hyper-V if we're not going to panic */
+ if (in_die && !panic_on_oops)
+ return;
+
+ /*
+ * We prefer to report panic on 'die' chain as we have proper
+ * registers to report, but if we miss it (e.g. on BUG()) we need
+ * to report it on 'panic'.
+ *
+ * Calling code in the 'die' and 'panic' paths ensures that only
+ * one CPU is running this code, so no atomicity is needed.
+ */
+ if (panic_reported)
+ return;
+ panic_reported = true;
+
+ guest_id = hv_get_vpreg(HV_REGISTER_GUEST_OSID);
+
+ /*
+ * Hyper-V provides the ability to store only 5 values.
+ * Pick the passed in error value, the guest_id, and the PC.
+ * The first two general registers are added arbitrarily.
+ */
+ hv_set_vpreg(HV_REGISTER_CRASH_P0, err);
+ hv_set_vpreg(HV_REGISTER_CRASH_P1, guest_id);
+ hv_set_vpreg(HV_REGISTER_CRASH_P2, regs->pc);
+ hv_set_vpreg(HV_REGISTER_CRASH_P3, regs->regs[0]);
+ hv_set_vpreg(HV_REGISTER_CRASH_P4, regs->regs[1]);
+
+ /*
+ * Let Hyper-V know there is crash data available
+ */
+ hv_set_vpreg(HV_REGISTER_CRASH_CTL, HV_CRASH_CTL_CRASH_NOTIFY);
+}
+EXPORT_SYMBOL_GPL(hyperv_report_panic);
+
diff --git a/arch/arm64/hyperv/mshyperv.c b/arch/arm64/hyperv/mshyperv.c
new file mode 100644
index 0000000..d202b4c
--- /dev/null
+++ b/arch/arm64/hyperv/mshyperv.c
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * Core routines for interacting with Microsoft's Hyper-V hypervisor.
+ * Includes hypervisor initialization, and handling of crashes and
+ * kexecs through a set of static "handler" variables set by the
+ * architecture independent VMbus driver.
+ *
+ * Copyright (C) 2021, Microsoft, Inc.
+ *
+ * Author : Michael Kelley <mikelley@microsoft.com>
+ */
+
+#include <linux/types.h>
+#include <linux/export.h>
+#include <linux/ptrace.h>
+
+/*
+ * The VMbus handler functions are no-ops on ARM64 because
+ * VMbus interrupts are handled as percpu IRQs.
+ */
+void hv_setup_vmbus_handler(void (*handler)(void))
+{
+}
+EXPORT_SYMBOL_GPL(hv_setup_vmbus_handler);
+
+void hv_remove_vmbus_handler(void)
+{
+}
+EXPORT_SYMBOL_GPL(hv_remove_vmbus_handler);
+
+/*
+ * The kexec and crash handler functions are
+ * currently no-ops on ARM64.
+ */
+void hv_setup_kexec_handler(void (*handler)(void))
+{
+}
+EXPORT_SYMBOL_GPL(hv_setup_kexec_handler);
+
+void hv_remove_kexec_handler(void)
+{
+}
+EXPORT_SYMBOL_GPL(hv_remove_kexec_handler);
+
+void hv_setup_crash_handler(void (*handler)(struct pt_regs *regs))
+{
+}
+EXPORT_SYMBOL_GPL(hv_setup_crash_handler);
+
+void hv_remove_crash_handler(void)
+{
+}
+EXPORT_SYMBOL_GPL(hv_remove_crash_handler);
--
1.8.3.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-03-05 21:05 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1614649360-5087-1-git-send-email-mikelley@microsoft.com>
[not found] ` <1614649360-5087-2-git-send-email-mikelley@microsoft.com>
2021-03-03 0:34 ` [PATCH v8 1/6] arm64: hyperv: Add Hyper-V hypercall and register access utilities Sunil Muthuswamy
2021-03-03 18:28 ` Sunil Muthuswamy
2021-03-05 20:58 ` Michael Kelley
2021-03-05 20:56 ` Michael Kelley
[not found] ` <1614649360-5087-7-git-send-email-mikelley@microsoft.com>
2021-03-03 19:22 ` [PATCH v8 6/6] Drivers: hv: Enable Hyper-V code to be built on ARM64 Sunil Muthuswamy
[not found] ` <1614649360-5087-3-git-send-email-mikelley@microsoft.com>
2021-03-03 19:29 ` [PATCH v8 2/6] arm64: hyperv: Add Hyper-V clocksource/clockevent support Sunil Muthuswamy
[not found] ` <1614649360-5087-5-git-send-email-mikelley@microsoft.com>
2021-03-03 20:21 ` [PATCH v8 4/6] arm64: hyperv: Initialize hypervisor on boot Sunil Muthuswamy
2021-03-05 21:03 ` Michael Kelley
[not found] ` <1614649360-5087-4-git-send-email-mikelley@microsoft.com>
2021-03-03 21:29 ` [PATCH v8 3/6] arm64: hyperv: Add kexec and panic handlers Sunil Muthuswamy
2021-02-18 23:16 [PATCH v8 0/6] Enable Linux guests on Hyper-V on ARM64 Michael Kelley
2021-02-18 23:16 ` [PATCH v8 3/6] arm64: hyperv: Add kexec and panic handlers Michael Kelley
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).