arm64: hyperv: Add Hyper-V hypercall and register access utilities
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Review
Quoted 4 lines
(quoted diff) +4
-0+} +EXPORT_SYMBOL_GPL(hv_do_fast_hypercall8); + +
nit: Extra line, here and few other places
Review
Quoted 5 lines
(quoted diff) +5
-0+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.
Review
Quoted 10 lines
(quoted diff) +10
-0+ + /* + * 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.
Review
Quoted 1 line
(quoted diff) +1
-0+ __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.
Quoted 11 lines
Review
Quoted 10 lines
(quoted diff) +10
-0+ + /* + * 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.
From: Sunil Muthuswamy <[email protected]> Sent: Wednesday, March 3, 2021 10:28 AM
Quoted 13 lines
Quoted 12 lines
Review
Quoted 11 lines
(quoted diff) +10
-0+ + /* + * 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.
Quoted 4 lines
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
From: Sunil Muthuswamy <[email protected]> Sent: Tuesday, March 2, 2021 4:35 PM
Quoted 6 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+} +EXPORT_SYMBOL_GPL(hv_do_fast_hypercall8); + +nit: Extra line, here and few other places
I'll try to clean these up.
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +5
-0+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.
Quoted 12 lines
Review
Quoted 11 lines
(quoted diff) +10
-0+ + /* + * 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.
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +1
-0+ __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. Seeinclude/asm-generic/mshyperv.hfor
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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Sunil Muthuswamy
Reviewed-byRE: [PATCH v8 6/6] Drivers: hv: Enable Hyper-V code to be built on ARM64
Quoted 23 lines
Update
drivers/hv/KconfigsoCONFIG_HYPERVcan be selected on ARM64, causing the Hyper-V specific code to be built.Signed-off-by Michael Kelley <[email protected]>--- drivers/hv/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/hv/Kconfig +2
-2@@ -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 --
Quoted 1 line
1.8.3.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
RE: [PATCH v8 4/6] arm64: hyperv: Initialize hypervisor on boot
Review
Quoted 7 lines
(quoted diff) +7
-0+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?
Review
Quoted 9 lines
(quoted diff) +9
-0+ + /* + * 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?
Review
Quoted 3 lines
(quoted diff) +3
-0+ 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
Review
Quoted 10 lines
(quoted diff) +9
-0+ 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'?
RE: [PATCH v8 4/6] arm64: hyperv: Initialize hypervisor on boot
From: Sunil Muthuswamy <[email protected]> Sent: Wednesday, March 3, 2021 12:21 PM
Quoted 11 lines
Review
Quoted 8 lines
(quoted diff) +7
-0+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.
Quoted 11 lines
Review
Quoted 9 lines
(quoted diff) +9
-0+ + /* + * 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.
Quoted 6 lines
Review
Quoted 4 lines
(quoted diff) +3
-0+ 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.
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +1
-0+ pr_warn("Hyper-V: No VP index for CPU %d MPIDR %llx status%llx\n",
Quoted 3 lines
(quoted diff) +3
-0+ i, cpu_logical_map(i), status); + hv_vp_index[i] = VP_INVAL; + }
Quoted 9 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+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
A message that is not in the archive (sent off-list or not yet received): [email protected]
Sunil Muthuswamy
Reviewed-byRE: [PATCH v8 2/6] arm64: hyperv: Add Hyper-V clocksource/clockevent support
Review
Quoted 5 lines
(quoted diff) +5
-0+/* 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
Quoted 6 lines
(quoted diff) +4
-1+ + return 0; +} +TIMER_ACPI_DECLARE(hyperv, ACPI_SIG_GTDT, hyperv_timer_init); --1.8.3.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
Sunil Muthuswamy
Reviewed-byRE: [PATCH v8 3/6] arm64: hyperv: Add kexec and panic handlers
Quoted 8 lines
(quoted diff) +6
-1+EXPORT_SYMBOL_GPL(hv_setup_crash_handler); + +void hv_remove_crash_handler(void) +{ +} +EXPORT_SYMBOL_GPL(hv_remove_crash_handler); --1.8.3.1