/* * Linux-specific definitions for managing interactions with Microsoft's * Hyper-V hypervisor. The definitions in this file are architecture * independent. See arch/<arch>/include/asm/mshyperv.h for definitions * that are specific to architecture <arch>. * * Definitions that are derived from Hyper-V code or headers should not go in * this file, but should instead go in the relevant files in include/hyperv. * * Copyright (C) 2019, Microsoft, Inc. * * Author : Michael Kelley <mikelley@microsoft.com>
*/
/* * On architectures where Hyper-V doesn't support AEOI (e.g., ARM64), * it doesn't provide a recommendation flag and AEOI must be disabled.
*/ staticinlinebool hv_recommend_using_aeoi(void)
{ #ifdef HV_DEPRECATING_AEOI_RECOMMENDED return !(ms_hyperv.hints & HV_DEPRECATING_AEOI_RECOMMENDED); #else returnfalse; #endif
}
/* Helper functions that provide a consistent pattern for checking Hyper-V hypercall status. */ staticinlineint hv_result(u64 status)
{ return status & HV_HYPERCALL_RESULT_MASK;
}
/* Free the message slot and signal end-of-message if required */ staticinlinevoid vmbus_signal_eom(struct hv_message *msg, u32 old_msg_type)
{ /* * On crash we're reading some other CPU's message page and we need * to be careful: this other CPU may already had cleared the header * and the host may already had delivered some other message there. * In case we blindly write msg->header.message_type we're going * to lose it. We can still lose a message of the same type but * we count on the fact that there can only be one * CHANNELMSG_UNLOAD_RESPONSE and we don't care about other messages * on crash.
*/ if (cmpxchg(&msg->header.message_type, old_msg_type,
HVMSG_NONE) != old_msg_type) return;
/* * The cmxchg() above does an implicit memory barrier to * ensure the write to MessageType (ie set to * HVMSG_NONE) happens before we read the * MessagePending and EOMing. Otherwise, the EOMing * will not deliver any more messages since there is * no empty slot
*/ if (msg->header.message_flags.msg_pending) { /* * This will cause message queue rescan to * possibly deliver another msg from the * hypervisor
*/
hv_set_msr(HV_MSR_EOM, 0);
}
}
int hv_get_hypervisor_version(union hv_hypervisor_version_info *info);
#if IS_ENABLED(CONFIG_HYPERV) /* * Hypervisor's notion of virtual processor ID is different from * Linux' notion of CPU ID. This information can only be retrieved * in the context of the calling CPU. Setup a map for easy access * to this information.
*/ 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_get_partition_id(void); void __init hv_common_free(void); void __init ms_hyperv_late_init(void); int hv_common_cpu_init(unsignedint cpu); int hv_common_cpu_die(unsignedint cpu); void hv_identify_partition_type(void);
/** * hv_cpu_number_to_vp_number() - Map CPU to VP. * @cpu_number: CPU number in Linux terms * * This function returns the mapping between the Linux processor * number and the hypervisor's virtual processor number, useful * in making hypercalls and such that talk about specific * processors. * * Return: Virtual processor number in Hyper-V terms
*/ staticinlineint hv_cpu_number_to_vp_number(int cpu_number)
{ return hv_vp_index[cpu_number];
}
/* vpset.valid_bank_mask can represent up to HV_MAX_SPARSE_VCPU_BANKS banks */ if (max_vcpu_bank >= HV_MAX_SPARSE_VCPU_BANKS) return 0;
/* * Clear all banks up to the maximum possible bank as hv_tlb_flush_ex * structs are not cleared between calls, we risk flushing unneeded * vCPUs otherwise.
*/ for (vcpu_bank = 0; vcpu_bank <= max_vcpu_bank; vcpu_bank++)
vpset->bank_contents[vcpu_bank] = 0;
/* * Some banks may end up being empty but this is acceptable.
*/
for_each_cpu(cpu, cpus) { if (func && func(cpu)) continue;
vcpu = hv_cpu_number_to_vp_number(cpu); if (vcpu == VP_INVAL) return -1;
vcpu_bank = vcpu / HV_VCPUS_PER_SPARSE_BANK;
vcpu_offset = vcpu % HV_VCPUS_PER_SPARSE_BANK;
__set_bit(vcpu_offset, (unsignedlong *)
&vpset->bank_contents[vcpu_bank]); if (vcpu_bank >= nr_bank)
nr_bank = vcpu_bank + 1;
}
vpset->valid_bank_mask = GENMASK_ULL(nr_bank - 1, 0); return nr_bank;
}
/* * Convert a Linux cpumask into a Hyper-V VPset. In the _skip variant, * 'func' is called for each CPU present in cpumask. If 'func' returns * true, that CPU is skipped -- i.e., that CPU from cpumask is *not* * added to the Hyper-V VPset. If 'func' is NULL, no CPUs are * skipped.
*/ staticinlineint cpumask_to_vpset(struct hv_vpset *vpset, conststruct cpumask *cpus)
{ return __cpumask_to_vpset(vpset, cpus, NULL);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.