static void hyperv_flush_tlb_others(const struct cpumask *cpus, const struct flush_tlb_info *info) { int cpu, vcpu, gva_n, max_gvas; struct hv_tlb_flush **flush_pcpu; struct hv_tlb_flush *flush; u64 status = U64_MAX; unsigned long flags; trace_hyperv_mmu_flush_tlb_others(cpus, info); if (!hv_hypercall_pg) goto do_native; if (cpumask_empty(cpus)) return; local_irq_save(flags); flush_pcpu = (struct hv_tlb_flush **) this_cpu_ptr(hyperv_pcpu_input_arg); flush = *flush_pcpu; if (unlikely(!flush)) { local_irq_restore(flags); goto do_native; } if (info->mm) { /* * AddressSpace argument must match the CR3 with PCID bits * stripped out. */ flush->address_space = virt_to_phys(info->mm->pgd); flush->address_space &= CR3_ADDR_MASK; flush->flags = 0; } else { flush->address_space = 0; flush->flags = HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES; } flush->processor_mask = 0; if (cpumask_equal(cpus, cpu_present_mask)) { flush->flags |= HV_FLUSH_ALL_PROCESSORS; } else { for_each_cpu(cpu, cpus) { vcpu = hv_cpu_number_to_vp_number(cpu); if (vcpu >= 64) goto do_native; __set_bit(vcpu, (unsigned long *) &flush->processor_mask); } }
static void hyperv_flush_tlb_others(const struct cpumask *cpus, const struct flush_tlb_info *info) { int cpu, vcpu, gva_n, max_gvas; struct hv_tlb_flush **flush_pcpu; struct hv_tlb_flush *flush; u64 status = U64_MAX; unsigned long flags; trace_hyperv_mmu_flush_tlb_others(cpus, info); if (!hv_hypercall_pg) goto do_native; if (cpumask_empty(cpus)) return; local_irq_save(flags); flush_pcpu = (struct hv_tlb_flush **) this_cpu_ptr(hyperv_pcpu_input_arg); flush = *flush_pcpu; if (unlikely(!flush)) { local_irq_restore(flags); goto do_native; } if (info->mm) { /* * AddressSpace argument must match the CR3 with PCID bits * stripped out. */ flush->address_space = virt_to_phys(info->mm->pgd); flush->address_space &= CR3_ADDR_MASK; flush->flags = 0; } else { flush->address_space = 0; flush->flags = HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES; } flush->processor_mask = 0; if (cpumask_equal(cpus, cpu_present_mask)) { flush->flags |= HV_FLUSH_ALL_PROCESSORS; } else { /* * From the supplied CPU set we need to figure out if we can get * away with cheaper HVCALL_FLUSH_VIRTUAL_ADDRESS_{LIST,SPACE} * hypercalls. This is possible when the highest VP number in * the set is < 64. As VP numbers are usually in ascending order * and match Linux CPU ids, here is an optimization: we check * the VP number for the highest bit in the supplied set first * so we can quickly find out if using *_EX hypercalls is a * must. We will also check all VP numbers when walking the * supplied CPU set to remain correct in all cases. */ if (hv_cpu_number_to_vp_number(cpumask_last(cpus)) >= 64) goto do_ex_hypercall; for_each_cpu(cpu, cpus) { vcpu = hv_cpu_number_to_vp_number(cpu); if (vcpu == VP_INVAL) { local_irq_restore(flags); goto do_native; } if (vcpu >= 64) goto do_ex_hypercall; __set_bit(vcpu, (unsigned long *) &flush->processor_mask); } }