Skip to content

Commit

Permalink
Merge tag 'hyperv-fixes-signed-20210111' of git://git.kernel.org/pub/…
Browse files Browse the repository at this point in the history
…scm/linux/kernel/git/hyperv/linux

Pull hyperv fixes from Wei Liu:

  - fix kexec panic/hang (Dexuan Cui)

  - fix occasional crashes when flushing TLB (Wei Liu)

* tag 'hyperv-fixes-signed-20210111' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux:
  x86/hyperv: check cpu mask after interrupt has been disabled
  x86/hyperv: Fix kexec panic/hang issues
  • Loading branch information
torvalds committed Jan 11, 2021
2 parents 7c53f6b + ad0a6ba commit f1ee3e1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
4 changes: 4 additions & 0 deletions arch/x86/hyperv/hv_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <asm/hyperv-tlfs.h>
#include <asm/mshyperv.h>
#include <asm/idtentry.h>
#include <linux/kexec.h>
#include <linux/version.h>
#include <linux/vmalloc.h>
#include <linux/mm.h>
Expand All @@ -26,6 +27,8 @@
#include <linux/syscore_ops.h>
#include <clocksource/hyperv_timer.h>

int hyperv_init_cpuhp;

void *hv_hypercall_pg;
EXPORT_SYMBOL_GPL(hv_hypercall_pg);

Expand Down Expand Up @@ -401,6 +404,7 @@ void __init hyperv_init(void)

register_syscore_ops(&hv_syscore_ops);

hyperv_init_cpuhp = cpuhp;
return;

remove_cpuhp_state:
Expand Down
12 changes: 9 additions & 3 deletions arch/x86/hyperv/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,17 @@ static void hyperv_flush_tlb_others(const struct cpumask *cpus,
if (!hv_hypercall_pg)
goto do_native;

if (cpumask_empty(cpus))
return;

local_irq_save(flags);

/*
* Only check the mask _after_ interrupt has been disabled to avoid the
* mask changing under our feet.
*/
if (cpumask_empty(cpus)) {
local_irq_restore(flags);
return;
}

flush_pcpu = (struct hv_tlb_flush **)
this_cpu_ptr(hyperv_pcpu_input_arg);

Expand Down
2 changes: 2 additions & 0 deletions arch/x86/include/asm/mshyperv.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ static inline void hv_disable_stimer0_percpu_irq(int irq) {}


#if IS_ENABLED(CONFIG_HYPERV)
extern int hyperv_init_cpuhp;

extern void *hv_hypercall_pg;
extern void __percpu **hyperv_pcpu_input_arg;

Expand Down
18 changes: 18 additions & 0 deletions arch/x86/kernel/cpu/mshyperv.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,32 @@ static void hv_machine_shutdown(void)
{
if (kexec_in_progress && hv_kexec_handler)
hv_kexec_handler();

/*
* Call hv_cpu_die() on all the CPUs, otherwise later the hypervisor
* corrupts the old VP Assist Pages and can crash the kexec kernel.
*/
if (kexec_in_progress && hyperv_init_cpuhp > 0)
cpuhp_remove_state(hyperv_init_cpuhp);

/* The function calls stop_other_cpus(). */
native_machine_shutdown();

/* Disable the hypercall page when there is only 1 active CPU. */
if (kexec_in_progress)
hyperv_cleanup();
}

static void hv_machine_crash_shutdown(struct pt_regs *regs)
{
if (hv_crash_handler)
hv_crash_handler(regs);

/* The function calls crash_smp_send_stop(). */
native_machine_crash_shutdown(regs);

/* Disable the hypercall page when there is only 1 active CPU. */
hyperv_cleanup();
}
#endif /* CONFIG_KEXEC_CORE */
#endif /* CONFIG_HYPERV */
Expand Down
2 changes: 0 additions & 2 deletions drivers/hv/vmbus_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2550,7 +2550,6 @@ static void hv_kexec_handler(void)
/* Make sure conn_state is set as hv_synic_cleanup checks for it */
mb();
cpuhp_remove_state(hyperv_cpuhp_online);
hyperv_cleanup();
};

static void hv_crash_handler(struct pt_regs *regs)
Expand All @@ -2566,7 +2565,6 @@ static void hv_crash_handler(struct pt_regs *regs)
cpu = smp_processor_id();
hv_stimer_cleanup(cpu);
hv_synic_disable_regs(cpu);
hyperv_cleanup();
};

static int hv_synic_suspend(void)
Expand Down

0 comments on commit f1ee3e1

Please sign in to comment.