Drivers: hv: vmbus: Enable kexec and other misc cleanup
Subsystems (4)
v2 cover Drivers: hv: vmbus: Enable kexec and other misc cleanup
In addition to enabling kexec, this patch-set has a bunch of miscellaneous fixes.
In this version of the patch-set; I have fixed up the subject line for couple of patches (Greg)
Alex Ng (1):
Drivers: hv: balloon: Enable dynamic memory protocol negotiation with
Windows 10 hosts
K. Y. Srinivasan (1):
Drivers: hv: vmbus: Permit sending of packets without payload
Vitaly Kuznetsov (8):
cpu-hotplug: export cpu_hotplug_enable/cpu_hotplug_disable
Drivers: hv: vmbus: use cpu_hotplug_enable/disable
Drivers: hv: vmbus: remove hv_synic_free_cpu() call from
hv_synic_cleanup()
Drivers: hv: vmbus: add special kexec handler
Drivers: hv: don't do hypercalls when hypercall_page is NULL
Drivers: hv: vmbus: use 'die' notification chain instead of 'panic'
Drivers: hv: kvp: check kzalloc return value
Drivers: hv: fcopy: dynamically allocate smsg_out in
fcopy_send_data()
Documentation/power/suspend-and-cpuhotplug.txt | 6 +- arch/x86/include/asm/mshyperv.h | 2 + arch/x86/kernel/cpu/mshyperv.c | 30 +++++++++ drivers/hv/channel.c | 4 +- drivers/hv/hv.c | 15 +++-- drivers/hv/hv_balloon.c | 26 ++++++-- drivers/hv/hv_fcopy.c | 21 ++++--- drivers/hv/hv_kvp.c | 3 + drivers/hv/vmbus_drv.c | 76 +++++++++--------------- kernel/cpu.c | 13 +++-- 10 files changed, 119 insertions(+), 77 deletions(-)
Signature · 1 line
1.7.4.1
PATCH v2 1/10 cpu-hotplug: export cpu_hotplug_enable/cpu_hotplug_disable
From: Vitaly Kuznetsov <[email protected]>
Loaded Hyper-V module will use these functions to disable CPU hotplug under certain circumstances. Convert cpu_hotplug_disabled to a counter (protected by cpu_add_remove_lock) to support e.g. disable -> disable -> enable call sequences.
--- Documentation/power/suspend-and-cpuhotplug.txt | 6 +++--- kernel/cpu.c | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-)
Documentation/power/suspend-and-cpuhotplug.txt +3 -3
@@ -72,7 +72,7 @@ More details follow: | v Disable regular cpu hotplug - by setting cpu_hotplug_disabled=1 + by increasing cpu_hotplug_disabled | v Release cpu_add_remove_lock
@@ -89,7 +89,7 @@ Resuming back is likewise, with the counterparts being (in the order of execution during resume): * enable_nonboot_cpus() which involves: | Acquire cpu_add_remove_lock - | Reset cpu_hotplug_disabled to 0, thereby enabling regular cpu hotplug + | Decrease cpu_hotplug_disabled, thereby enabling regular cpu hotplug | Call _cpu_up() [for all those cpus in the frozen_cpus mask, in a loop] | Release cpu_add_remove_lock v
@@ -120,7 +120,7 @@ after the entire cycle is complete (i.e., suspend + resume). Acquire cpu_add_remove_lock | v - If cpu_hotplug_disabled is 1 + If cpu_hotplug_disabled > 0 return gracefully | |
kernel/cpu.c +8 -5
@@ -190,17 +190,19 @@ void cpu_hotplug_done(void)void cpu_hotplug_disable (void ) {cpu_maps_update_begin (); - cpu_hotplug_disabled =1 ; + cpu_hotplug_disabled++;cpu_maps_update_done (); } +EXPORT_SYMBOL_GPL (cpu_hotplug_disable);void cpu_hotplug_enable (void ) {cpu_maps_update_begin (); - cpu_hotplug_disabled =0 ; +if (cpu_hotplug_disabled) + cpu_hotplug_disabled--;cpu_maps_update_done (); } - +EXPORT_SYMBOL_GPL (cpu_hotplug_enable);#endif /* CONFIG_HOTPLUG_CPU */ /* Need to know about CPUs going up/down? */
@@ -600,7 +602,7 @@ int disable_nonboot_cpus(void)if (!error) {BUG_ON (num_online_cpus () >1 );/* Make sure the CPUs won't be enabled by someone else */ - cpu_hotplug_disabled =1 ; + cpu_hotplug_disabled++; }else {pr_err ("Non-boot CPUs are not disabled\n" ); }
@@ -622,7 +624,8 @@ void __ref enable_nonboot_cpus(void)/* Allow everyone to use the CPU hotplug again */ cpu_maps_update_begin (); - cpu_hotplug_disabled =0 ; +if (cpu_hotplug_disabled) + cpu_hotplug_disabled--;if (cpumask_empty (frozen_cpus)) goto out;
Signature · 1 line
1.7.4.1
PATCH v2 2/10 Drivers: hv: vmbus: use cpu_hotplug_enable/disable
From: Vitaly Kuznetsov <[email protected]>
Commit e513229b4c38 ("Drivers: hv: vmbus: prevent cpu offlining on newer hypervisors") was altering smp_ops.cpu_disable to prevent CPU offlining. We can bo better by using cpu_hotplug_enable/disable functions instead of such hard-coding.
--- drivers/hv/vmbus_drv.c | 38 ++++---------------------------------- 1 files changed, 4 insertions(+), 34 deletions(-)
drivers/hv/vmbus_drv.c +4 -34
@@ -763,38 +763,6 @@ static void vmbus_isr(void) } } -#ifdef CONFIG_HOTPLUG_CPU -static int hyperv_cpu_disable (void ) -{ -return -ENOSYS ; -} - -static void hv_cpu_hotplug_quirk (bool vmbus_loaded) -{ -static void *previous_cpu_disable; - -/* -* Offlining a CPU when running on newer hypervisors (WS2012R2, Win8, -* ...) is not supported at this moment as channel interrupts are -* distributed across all of them. -*/ - -if ((vmbus_proto_version ==VERSION_WS2008 ) || - (vmbus_proto_version ==VERSION_WIN7 )) -return ; - -if (vmbus_loaded) { - previous_cpu_disable = smp_ops.cpu_disable; - smp_ops.cpu_disable = hyperv_cpu_disable; -pr_notice ("CPU offlining is not supported by hypervisor\n" ); - }else if (previous_cpu_disable) - smp_ops.cpu_disable = previous_cpu_disable; -} -#else -static void hv_cpu_hotplug_quirk (bool vmbus_loaded) -{ -} -#endif /* * vmbus_bus_init -Main vmbus driver initialization routine.
@@ -836,7 +804,8 @@ static int vmbus_bus_init(int irq)if (ret) goto err_alloc; -hv_cpu_hotplug_quirk (true); +if (vmbus_proto_version >VERSION_WIN7 ) +cpu_hotplug_disable ();/* * Only register if the crash MSRs are available
@@ -1121,7 +1090,8 @@ static void __exit vmbus_exit(void)smp_call_function_single (cpu, hv_synic_cleanup,NULL ,1 ); }acpi_bus_unregister_driver (&vmbus_acpi_driver); -hv_cpu_hotplug_quirk (false); +if (vmbus_proto_version >VERSION_WIN7 ) +cpu_hotplug_enable (); }
Signature · 1 line
1.7.4.1
PATCH v2 3/10 Drivers: hv: vmbus: remove hv_synic_free_cpu() call from hv_synic_cleanup()
In reply to K. Y. SrinivasanFrom: Vitaly Kuznetsov <[email protected]>
We already have hv_synic_free() which frees all per-cpu pages for all CPUs, let's remove the hv_synic_free_cpu() call from hv_synic_cleanup() so it will be possible to do separate cleanup (writing to MSRs) and final freeing. This is going to be used to assist kexec.
--- drivers/hv/hv.c | 2 -- drivers/hv/vmbus_drv.c | 1 + 2 files changed, 1 insertions(+), 2 deletions(-)
drivers/hv/hv.c +0 -2
@@ -530,6 +530,4 @@ void hv_synic_cleanup(void *arg)rdmsrl (HV_X64_MSR_SCONTROL , sctrl.as_uint64); sctrl.enable =0 ;wrmsrl (HV_X64_MSR_SCONTROL , sctrl.as_uint64); - -hv_synic_free_cpu (cpu); }
drivers/hv/vmbus_drv.c +1 -0
@@ -1089,6 +1089,7 @@ static void __exit vmbus_exit(void)tasklet_kill (hv_context.event_dpc[cpu]);smp_call_function_single (cpu, hv_synic_cleanup,NULL ,1 ); } +hv_synic_free ();acpi_bus_unregister_driver (&vmbus_acpi_driver);if (vmbus_proto_version >VERSION_WIN7 )cpu_hotplug_enable ();
Signature · 1 line
1.7.4.1
PATCH v2 4/10 Drivers: hv: vmbus: add special kexec handler
In reply to K. Y. SrinivasanFrom: Vitaly Kuznetsov <[email protected]>
When general-purpose kexec (not kdump) is being performed in Hyper-V guest the newly booted kernel fails with an MCE error coming from the host. It is the same error which was fixed in the "Drivers: hv: vmbus: Implement the protocol for tearing down vmbus state" commit - monitor pages remain special and when they're being written to (as the new kernel doesn't know these pages are special) bad things happen. We need to perform some minimalistic cleanup before booting a new kernel on kexec. To do so we need to register a special machine_ops.shutdown handler to be executed before the native_machine_shutdown(). Registering a shutdown notification handler via the register_reboot_notifier() call is not sufficient as it happens to early for our purposes. machine_ops is not being exported to modules (and I don't think we want to export it) so let's do this in mshyperv.c
The minimalistic cleanup consists of cleaning up clockevents, synic MSRs, guest os id MSR, and hypercall MSR.
Kdump doesn't require all this stuff as it lives in a separate memory space.
--- arch/x86/include/asm/mshyperv.h | 2 ++ arch/x86/kernel/cpu/mshyperv.c | 30 ++++++++++++++++++++++++++++++ drivers/hv/vmbus_drv.c | 14 ++++++++++++++ 3 files changed, 46 insertions(+), 0 deletions(-)
arch/x86/include/asm/mshyperv.h +2 -0
@@ -20,4 +20,6 @@ void hyperv_vector_handler(struct pt_regs *regs);void hv_setup_vmbus_irq (void (*handler)(void ));void hv_remove_vmbus_irq (void ); +void hv_setup_kexec_handler (void (*handler)(void )); +void hv_remove_kexec_handler (void );#endif
arch/x86/kernel/cpu/mshyperv.c +30 -0
@@ -18,6 +18,9 @@#include <linux/efi.h> #include <linux/interrupt.h> #include <linux/irq.h> +#ifdef CONFIG_KEXEC +#include <linux/kexec.h> +#endif #include <asm/processor.h> #include <asm/hypervisor.h> #include <asm/hyperv.h>
@@ -28,12 +31,14 @@#include <asm/i8259.h> #include <asm/apic.h> #include <asm/timer.h> +#include <asm/reboot.h> struct ms_hyperv_info ms_hyperv;EXPORT_SYMBOL_GPL (ms_hyperv);#if IS_ENABLED (CONFIG_HYPERV )static void (*vmbus_handler)(void ); +static void (*hv_kexec_handler)(void );void hyperv_vector_handler (struct pt_regs *regs) {
@@ -69,6 +74,28 @@ void hv_remove_vmbus_irq(void) }EXPORT_SYMBOL_GPL (hv_setup_vmbus_irq);EXPORT_SYMBOL_GPL (hv_remove_vmbus_irq); + +void hv_setup_kexec_handler (void (*handler)(void )) +{ + hv_kexec_handler = handler; +} +EXPORT_SYMBOL_GPL (hv_setup_kexec_handler); + +void hv_remove_kexec_handler (void ) +{ +/* We have no way to deallocate the interrupt gate */ + hv_kexec_handler =NULL ; +} +EXPORT_SYMBOL_GPL (hv_remove_kexec_handler); + +static void hv_machine_shutdown (void ) +{ +#ifdef CONFIG_KEXEC +if (kexec_in_progress && hv_kexec_handler) +hv_kexec_handler (); +#endif +native_machine_shutdown (); +}#endif static uint32_t __init ms_hyperv_platform (void )
@@ -143,6 +170,9 @@ static void __init ms_hyperv_init_platform(void) no_timer_check =1 ;#endif +#if IS_ENABLED (CONFIG_HYPERV ) + machine_ops.shutdown = hv_machine_shutdown; +#endif }const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
drivers/hv/vmbus_drv.c +14 -0
@@ -1029,6 +1029,17 @@ static struct acpi_driver vmbus_acpi_driver = { }, }; +static void hv_kexec_handler (void ) +{ +int cpu; + +hv_synic_clockevents_cleanup (); +vmbus_initiate_unload (); +for_each_online_cpu (cpu) +smp_call_function_single (cpu, hv_synic_cleanup,NULL ,1 ); +hv_cleanup (); +}; +static int __init hv_acpi_init (void ) {int ret, t;
@@ -1061,6 +1072,8 @@ static int __init hv_acpi_init(void)if (ret) goto cleanup; +hv_setup_kexec_handler (hv_kexec_handler); +return 0 ; cleanup:
@@ -1073,6 +1086,7 @@ static void __exit vmbus_exit(void) {int cpu; +hv_remove_kexec_handler (); vmbus_connection.conn_state =DISCONNECTED ;hv_synic_clockevents_cleanup ();vmbus_disconnect ();
Signature · 1 line
1.7.4.1
Re: [PATCH V2 04/10] Drivers: hv: vmbus: add special kexec handler
arch/x86/kernel/cpu/mshyperv.c line 23
Quoted 8 lines · K. Y. Srinivasan
+++
b/arch/x86/kernel/cpu/mshyperv.carch/x86/kernel/cpu/mshyperv.c +3
-0@@ -18,6 +18,9 @@#include <linux/efi.h> #include <linux/interrupt.h> #include <linux/irq.h> +#ifdef CONFIG_KEXEC +#include <linux/kexec.h> +#endif
Is this #ifdef required?
Olaf
Re: [PATCH V2 04/10] Drivers: hv: vmbus: add special kexec handler
Quoted 13 lines · Olaf Hering
arch/x86/kernel/cpu/mshyperv.c line 23
Quoted 8 lines · K. Y. Srinivasan
+++
b/arch/x86/kernel/cpu/mshyperv.carch/x86/kernel/cpu/mshyperv.c +3
-0@@ -18,6 +18,9 @@#include <linux/efi.h> #include <linux/interrupt.h> #include <linux/irq.h> +#ifdef CONFIG_KEXEC +#include <linux/kexec.h> +#endif Is this #ifdef required?
No, it's not, but other parts of the same patch do (e.g. there is no kexec_in_progress without CONFIG_KEXEC). We can probably omit #ifdef here but I'm not sure it makes sense.
Signature · 1 line
Vitaly
Re: [PATCH V2 04/10] Drivers: hv: vmbus: add special kexec handler
Quoted 16 lines · Vitaly Kuznetsov
Quoted 13 lines · Olaf Hering
arch/x86/kernel/cpu/mshyperv.c line 23
Quoted 8 lines · K. Y. Srinivasan
+++
b/arch/x86/kernel/cpu/mshyperv.carch/x86/kernel/cpu/mshyperv.c +3
-0@@ -18,6 +18,9 @@#include <linux/efi.h> #include <linux/interrupt.h> #include <linux/irq.h> +#ifdef CONFIG_KEXEC +#include <linux/kexec.h> +#endif Is this #ifdef required?
Quoted 3 lines
No, it's not, but other parts of the same patch do (e.g. there is no
kexec_in_progresswithoutCONFIG_KEXEC). We can probably omit #ifdef here but I'm not sure it makes sense.
No #ifdef should be in a .c file if at all possible, so please remove them all if you can. If not, then work to fix up the .h file properly so that you can.
thanks,
greg k-h
PATCH v2 5/10 Drivers: hv: don't do hypercalls when hypercall_page is NULL
In reply to K. Y. SrinivasanFrom: Vitaly Kuznetsov <[email protected]>
At the very late stage of kexec a driver (which are not being unloaded) can try to post a message or signal an event. This will crash the kernel as we already did hv_cleanup() and the hypercall page is NULL.
Move all common (between 32 and 64 bit code) declarations to the beginning of the do_hypercall() function. Unfortunately we have to write the !hypercall_page check twice to not mix declarations and code.
--- drivers/hv/hv.c | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-)
drivers/hv/hv.c +8 -5
@@ -93,11 +93,14 @@ static int query_hypervisor_info(void)*/ static u64 do_hypercall (u64 control,void *input,void *output) { -#ifdef CONFIG_X86_64 -u64 hv_status =0 ;u64 input_address = (input) ?virt_to_phys (input) :0 ;u64 output_address = (output) ?virt_to_phys (output) :0 ;void *hypercall_page = hv_context.hypercall_page; +#ifdef CONFIG_X86_64 +u64 hv_status =0 ; + +if (!hypercall_page) +return (u64 )ULLONG_MAX ; __asm__ __volatile__("mov %0, %%r8" : :"r" (output_address) :"r8" ); __asm__ __volatile__("call *%3" : "=a" (hv_status) :
@@ -112,13 +115,13 @@ static u64 do_hypercall(u64 control, void *input, void *output)u32 control_lo = control &0xFFFFFFFF ;u32 hv_status_hi =1 ;u32 hv_status_lo =1 ; -u64 input_address = (input) ?virt_to_phys (input) :0 ;u32 input_address_hi = input_address >>32 ;u32 input_address_lo = input_address &0xFFFFFFFF ; -u64 output_address = (output) ?virt_to_phys (output) :0 ;u32 output_address_hi = output_address >>32 ;u32 output_address_lo = output_address &0xFFFFFFFF ; -void *hypercall_page = hv_context.hypercall_page; + +if (!hypercall_page) +return (u64 )ULLONG_MAX ; __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi), "=a"(hv_status_lo) : "d" (control_hi),
Signature · 1 line
1.7.4.1
PATCH v2 6/10 Drivers: hv: vmbus: use 'die' notification chain instead of 'panic'
In reply to K. Y. SrinivasanFrom: Vitaly Kuznetsov <[email protected]>
current_pt_regs() returns regs of the userspace process and in case of kernel crash this is not what we need to report. E.g. when we trigger crash with sysrq we see the following:
...
RIP: 0010:[<ffffffff815b8696>] [<ffffffff815b8696>] sysrq_handle_crash+0x16/0x20 RSP: 0018:ffff8800db0a7d88 EFLAGS: 00010246 RAX: 000000000000000f RBX: ffffffff820a0660 RCX: 0000000000000000
...
at the same time current_pt_regs() give us:
ip=7f899ea7e9e0, ax=ffffffffffffffda, bx=26c81a0, cx=7f899ea7e9e0, ... These registers come from the userspace process triggered the crash. As we don't even know which process it was this information is rather useless.
When kernel crash happens proper regs are being passed to all receivers on the die_chain (and panic_notifier_list is being notified with the string passed to panic() only). Let's move our Hyper-V MSR reporter there. This change has the following implication: when panic() is called manually from some other part of kernel we won't be reporting crash to the hypervisor (but we have no valuable information to report anyway).
--- drivers/hv/vmbus_drv.c | 23 ++++++++++------------- 1 files changed, 10 insertions(+), 13 deletions(-)
drivers/hv/vmbus_drv.c +10 -13
@@ -39,6 +39,7 @@#include <asm/mshyperv.h> #include <linux/notifier.h> #include <linux/ptrace.h> +#include <linux/kdebug.h> #include "hyperv_vmbus.h" static struct acpi_device *hv_acpi_dev;
@@ -48,12 +49,11 @@ static struct completion probe_event;static int irq; -static int hyperv_panic_event (struct notifier_block *nb, -unsigned long event,void *ptr) +static int hyperv_die_event (struct notifier_block *nb,unsigned long val, +void *args) { -struct pt_regs *regs; - - regs =current_pt_regs (); +struct die_args *die = (struct die_args *)args; +struct pt_regs *regs = die->regs;wrmsrl (HV_X64_MSR_CRASH_P0 , regs->ip);wrmsrl (HV_X64_MSR_CRASH_P1 , regs->ax);
@@ -68,8 +68,8 @@ static int hyperv_panic_event(struct notifier_block *nb,return NOTIFY_DONE ; } -static struct notifier_block hyperv_panic_block = { - .notifier_call = hyperv_panic_event, +static struct notifier_block hyperv_die_block = { + .notifier_call = hyperv_die_event, };struct resource hyperv_mmio = {
@@ -811,8 +811,7 @@ static int vmbus_bus_init(int irq)* Only register if the crash MSRs are available */ if (ms_hyperv.features &HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE ) { -atomic_notifier_chain_register (&panic_notifier_list, - &hyperv_panic_block); +register_die_notifier (&hyperv_die_block); }vmbus_request_offers ();
@@ -1093,10 +1092,8 @@ static void __exit vmbus_exit(void)hv_remove_vmbus_irq ();tasklet_kill (&msg_dpc);vmbus_free_channels (); -if (ms_hyperv.features &HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE ) { -atomic_notifier_chain_unregister (&panic_notifier_list, - &hyperv_panic_block); - } +if (ms_hyperv.features &HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE ) +unregister_die_notifier (&hyperv_die_block);bus_unregister (&hv_bus);hv_cleanup ();for_each_online_cpu (cpu) {
Signature · 1 line
1.7.4.1
Re: [PATCH V2 06/10] Drivers: hv: vmbus: use 'die' notification chain instead of 'panic'
Quoted 15 lines · K. Y. Srinivasan
From: Vitaly Kuznetsov <[email protected]>
current_pt_regs()returns regs of the userspace process and in case of kernel crash this is not what we need to report. E.g. when we trigger crash with sysrq we see the following:
...RIP: 0010:[<ffffffff815b8696>] [<ffffffff815b8696>] sysrq_handle_crash+0x16/0x20 RSP: 0018:ffff8800db0a7d88 EFLAGS: 00010246 RAX: 000000000000000f RBX: ffffffff820a0660 RCX: 0000000000000000...
at the same timecurrent_pt_regs()give us:
ip=7f899ea7e9e0, ax=ffffffffffffffda, bx=26c81a0, cx=7f899ea7e9e0, ... These registers come from the userspace process triggered the crash. As we don't even know which process it was this information is rather useless.
Quoted 6 lines
When kernel crash happens proper regs are being passed to all receivers on the
die_chain(andpanic_notifier_listis being notified with the string passed topanic()only). Let's move our Hyper-V MSR reporter there. This change has the following implication: whenpanic()is called manually from some other part of kernel we won't be reporting crash to the hypervisor (but we have no valuable information to report anyway).
We can, actually, do better: we can has this reporter in _both_ notification chains (with a static preventng double reporting). In this case we'll have panics reported on e.g BUG_ON()
As this patch is still not merged I'll fix and resend instead of creating a separate patch.
Signature · 1 line
Vitaly
PATCH v2 7/10 Drivers: hv: kvp: check kzalloc return value
In reply to K. Y. SrinivasanFrom: Vitaly Kuznetsov <[email protected]>
kzalloc() return value check was accidentally lost in 11bc3a5fa91f:
"Drivers: hv: kvp: convert to hv_utils_transport" commit.
We don't need to reset kvp_transaction.state here as we have the kvp_timeout_func() timeout function and in case we're in OOM situation it is preferable to wait.
--- drivers/hv/hv_kvp.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/hv/hv_kvp.c +3 -0
@@ -353,6 +353,9 @@ kvp_send_key(struct work_struct *dummy)return ; message =kzalloc (sizeof (*message),GFP_KERNEL ); +if (!message) +return ; + message->kvp_hdr.operation = operation; message->kvp_hdr.pool = pool; in_msg = kvp_transaction.kvp_msg;
Signature · 1 line
1.7.4.1
PATCH v2 8/10 Drivers: hv: fcopy: dynamically allocate smsg_out in fcopy_send_data()
In reply to K. Y. SrinivasanFrom: Vitaly Kuznetsov <[email protected]>
struct hv_start_fcopy is too big to be on stack on i386, the following warning is reported:
Quoted 1 line
Quoted 1 line
drivers/hv/hv_fcopy.c:159:1: warning: the frame size of 1088 bytes is larger than 1024 bytes [-Wframe-larger-than=]
--- drivers/hv/hv_fcopy.c | 21 +++++++++++++-------- 1 files changed, 13 insertions(+), 8 deletions(-)
drivers/hv/hv_fcopy.c +13 -8
@@ -116,7 +116,7 @@ static int fcopy_handle_handshake(u32 version)static void fcopy_send_data (struct work_struct *dummy) { -struct hv_start_fcopy smsg_out; +struct hv_start_fcopy *smsg_out =NULL ;int operation = fcopy_transaction.fcopy_msg->operation;struct hv_start_fcopy *smsg_in;void *out_src;
@@ -136,21 +136,24 @@ static void fcopy_send_data(struct work_struct *dummy)switch (operation) {case START_FILE_COPY : out_len =sizeof (struct hv_start_fcopy ); -memset (&smsg_out,0 , out_len); - smsg_out.hdr.operation = operation; + smsg_out =kzalloc (sizeof (*smsg_out),GFP_KERNEL ); +if (!smsg_out) +return ; + + smsg_out->hdr.operation = operation; smsg_in = (struct hv_start_fcopy *)fcopy_transaction.fcopy_msg;utf16s_to_utf8s ((wchar_t *)smsg_in->file_name,W_MAX_PATH ,UTF16_LITTLE_ENDIAN , - (__u8 *)&smsg_out.file_name,W_MAX_PATH -1 ); + (__u8 *)&smsg_out->file_name,W_MAX_PATH -1 );utf16s_to_utf8s ((wchar_t *)smsg_in->path_name,W_MAX_PATH ,UTF16_LITTLE_ENDIAN , - (__u8 *)&smsg_out.path_name,W_MAX_PATH -1 ); + (__u8 *)&smsg_out->path_name,W_MAX_PATH -1 ); - smsg_out.copy_flags = smsg_in->copy_flags; - smsg_out.file_size = smsg_in->file_size; - out_src = &smsg_out; + smsg_out->copy_flags = smsg_in->copy_flags; + smsg_out->file_size = smsg_in->file_size; + out_src = smsg_out;break ;default :
@@ -168,6 +171,8 @@ static void fcopy_send_data(struct work_struct *dummy) fcopy_transaction.state =HVUTIL_READY ; } } +kfree (smsg_out); +return ; }
Signature · 1 line
1.7.4.1
PATCH v2 9/10 Drivers: hv: balloon: Enable dynamic memory protocol negotiation with Windows 10 hosts
In reply to K. Y. SrinivasanFrom: Alex Ng <[email protected]>
Support Win10 protocol for Dynamic Memory. Thia patch allows guests on Win10 hosts to hot-add memory even when dynamic memory is not enabled on the guest.
--- drivers/hv/hv_balloon.c | 26 ++++++++++++++++++++------ 1 files changed, 20 insertions(+), 6 deletions(-)
drivers/hv/hv_balloon.c +20 -6
@@ -62,11 +62,13 @@enum {DYNMEM_PROTOCOL_VERSION_1 =DYNMEM_MAKE_VERSION (0 ,3 ),DYNMEM_PROTOCOL_VERSION_2 =DYNMEM_MAKE_VERSION (1 ,0 ), +DYNMEM_PROTOCOL_VERSION_3 =DYNMEM_MAKE_VERSION (2 ,0 ),DYNMEM_PROTOCOL_VERSION_WIN7 =DYNMEM_PROTOCOL_VERSION_1 ,DYNMEM_PROTOCOL_VERSION_WIN8 =DYNMEM_PROTOCOL_VERSION_2 , +DYNMEM_PROTOCOL_VERSION_WIN10 =DYNMEM_PROTOCOL_VERSION_3 , -DYNMEM_PROTOCOL_VERSION_CURRENT =DYNMEM_PROTOCOL_VERSION_WIN8 +DYNMEM_PROTOCOL_VERSION_CURRENT =DYNMEM_PROTOCOL_VERSION_WIN10 };
@@ -1296,13 +1298,25 @@ static void version_resp(struct hv_dynmem_device *dm,if (dm->next_version ==0 ) goto version_error; - dm->next_version =0 ;memset (&version_req,0 ,sizeof (struct dm_version_request )); version_req.hdr.type =DM_VERSION_REQUEST ; version_req.hdr.size =sizeof (struct dm_version_request ); version_req.hdr.trans_id =atomic_inc_return (&trans_id); - version_req.version.version =DYNMEM_PROTOCOL_VERSION_WIN7 ; - version_req.is_last_attempt =1 ; + version_req.version.version = dm->next_version; + +/* +* Set the next version to try in case current version fails. +* Win7 protocol ought to be the last one to try. +*/ +switch (version_req.version.version) { +case DYNMEM_PROTOCOL_VERSION_WIN8 : + dm->next_version =DYNMEM_PROTOCOL_VERSION_WIN7 ; + version_req.is_last_attempt =0 ; +break ; +default : + dm->next_version =0 ; + version_req.is_last_attempt =1 ; + } ret = vmbus_sendpacket(dm->dev->channel, &version_req, sizeof(struct dm_version_request),
@@ -1442,7 +1456,7 @@ static int balloon_probe(struct hv_device *dev, dm_device.dev = dev; dm_device.state =DM_INITIALIZING ; - dm_device.next_version =DYNMEM_PROTOCOL_VERSION_WIN7 ; + dm_device.next_version =DYNMEM_PROTOCOL_VERSION_WIN8 ;init_completion (&dm_device.host_event);init_completion (&dm_device.config_event);INIT_LIST_HEAD (&dm_device.ha_region_list);
@@ -1474,7 +1488,7 @@ static int balloon_probe(struct hv_device *dev, version_req.hdr.type =DM_VERSION_REQUEST ; version_req.hdr.size =sizeof (struct dm_version_request ); version_req.hdr.trans_id =atomic_inc_return (&trans_id); - version_req.version.version =DYNMEM_PROTOCOL_VERSION_WIN8 ; + version_req.version.version =DYNMEM_PROTOCOL_VERSION_WIN10 ; version_req.is_last_attempt =0 ; ret = vmbus_sendpacket(dev->channel, &version_req,
Signature · 1 line
1.7.4.1
PATCH v2 10/10 Drivers: hv: vmbus: Permit sending of packets without payload
In reply to K. Y. SrinivasanThe guest may have to send a completion packet back to the host. To support this usage, permit sending a packet without a payload - we would be only sending the descriptor in this case.
--- drivers/hv/channel.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/hv/channel.c +3 -1
@@ -601,6 +601,7 @@ int vmbus_sendpacket_ctl(struct vmbus_channel *channel, void *buffer,u64 aligned_data =0 ;int ret;bool signal = false; +int num_vecs = ((bufferlen !=0 ) ?3 :1 );/* Setup the descriptor */
@@ -618,7 +619,8 @@ int vmbus_sendpacket_ctl(struct vmbus_channel *channel, void *buffer, bufferlist[2 ].iov_base = &aligned_data; bufferlist[2 ].iov_len = (packetlen_aligned - packetlen); - ret =hv_ringbuffer_write (&channel->outbound, bufferlist,3 , &signal); + ret =hv_ringbuffer_write (&channel->outbound, bufferlist, num_vecs, + &signal);/* * Signalling the host is conditional on many factors:
Signature · 1 line
1.7.4.1
Re: [PATCH V2 01/10] cpu-hotplug: export cpu_hotplug_enable/cpu_hotplug_disable
In reply to K. Y. SrinivasanQuoted 7 lines · K. Y. Srinivasan
From: Vitaly Kuznetsov <[email protected]>
Loaded Hyper-V module will use these functions to disable CPU hotplug under certain circumstances. Convert
cpu_hotplug_disabledto a counter (protected bycpu_add_remove_lock) to support e.g. disable -> disable -> enable call sequences.
Quoted 6 lines
Signed-off-by Vitaly Kuznetsov <[email protected]>Signed-off-by K. Y. Srinivasan <[email protected]>--- Documentation/power/suspend-and-cpuhotplug.txt | 6 +++--- kernel/cpu.c | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-)
This changes the logic a bit, so I need an ack from the maintainers of the CPU hotplug code before I can accept this...
thanks,
greg k-h