Merge tag 'hyperv-fixes-signed-20210915' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 16 Sep 2021 00:18:56 +0000 (17:18 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 16 Sep 2021 00:18:56 +0000 (17:18 -0700)
Pull hyperv fixes from Wei Liu:

 - Fix kernel crash caused by uio driver (Vitaly Kuznetsov)

 - Remove on-stack cpumask from HV APIC code (Wei Liu)

* tag 'hyperv-fixes-signed-20210915' of git://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux:
  x86/hyperv: remove on-stack cpumask from hv_send_ipi_mask_allbutself
  asm-generic/hyperv: provide cpumask_to_vpset_noself
  Drivers: hv: vmbus: Fix kernel crash upon unbinding a device from uio_hv_generic driver

1  2 
include/asm-generic/mshyperv.h

@@@ -22,7 -22,6 +22,7 @@@
  #include <linux/atomic.h>
  #include <linux/bitops.h>
  #include <linux/cpumask.h>
 +#include <linux/nmi.h>
  #include <asm/ptrace.h>
  #include <asm/hyperv-tlfs.h>
  
@@@ -39,9 -38,6 +39,9 @@@ struct ms_hyperv_info 
  };
  extern struct ms_hyperv_info ms_hyperv;
  
 +extern void  __percpu  **hyperv_pcpu_input_arg;
 +extern void  __percpu  **hyperv_pcpu_output_arg;
 +
  extern u64 hv_do_hypercall(u64 control, void *inputaddr, void *outputaddr);
  extern u64 hv_do_fast_hypercall8(u16 control, u64 input8);
  
@@@ -155,8 -151,6 +155,8 @@@ void hv_remove_crash_handler(void)
  extern int vmbus_interrupt;
  extern int vmbus_irq;
  
 +extern bool hv_root_partition;
 +
  #if IS_ENABLED(CONFIG_HYPERV)
  /*
   * Hypervisor's notion of virtual processor ID is different from
  extern u32 *hv_vp_index;
  extern u32 hv_max_vp_index;
  
 +extern u64 (*hv_read_reference_counter)(void);
 +
  /* Sentinel value for an uninitialized entry in hv_vp_index array */
  #define VP_INVAL      U32_MAX
  
 +int __init hv_common_init(void);
 +void __init hv_common_free(void);
 +int hv_common_cpu_init(unsigned int cpu);
 +int hv_common_cpu_die(unsigned int cpu);
 +
  void *hv_alloc_hyperv_page(void);
  void *hv_alloc_hyperv_zeroed_page(void);
  void hv_free_hyperv_page(unsigned long addr);
@@@ -197,10 -184,12 +197,12 @@@ static inline int hv_cpu_number_to_vp_n
        return hv_vp_index[cpu_number];
  }
  
- static inline int cpumask_to_vpset(struct hv_vpset *vpset,
-                                   const struct cpumask *cpus)
+ static inline int __cpumask_to_vpset(struct hv_vpset *vpset,
+                                   const struct cpumask *cpus,
+                                   bool exclude_self)
  {
        int cpu, vcpu, vcpu_bank, vcpu_offset, nr_bank = 1;
+       int this_cpu = smp_processor_id();
  
        /* valid_bank_mask can represent up to 64 banks */
        if (hv_max_vp_index / 64 >= 64)
         * Some banks may end up being empty but this is acceptable.
         */
        for_each_cpu(cpu, cpus) {
+               if (exclude_self && cpu == this_cpu)
+                       continue;
                vcpu = hv_cpu_number_to_vp_number(cpu);
                if (vcpu == VP_INVAL)
                        return -1;
        return nr_bank;
  }
  
+ static inline int cpumask_to_vpset(struct hv_vpset *vpset,
+                                   const struct cpumask *cpus)
+ {
+       return __cpumask_to_vpset(vpset, cpus, false);
+ }
+ static inline int cpumask_to_vpset_noself(struct hv_vpset *vpset,
+                                   const struct cpumask *cpus)
+ {
+       WARN_ON_ONCE(preemptible());
+       return __cpumask_to_vpset(vpset, cpus, true);
+ }
  void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die);
  bool hv_is_hyperv_initialized(void);
  bool hv_is_hibernation_supported(void);