int kvm_riscv_gstage_vmid_init(struct kvm *kvm)
{ /* Mark the initial VMID and VMID version invalid */
kvm->arch.vmid.vmid_version = 0;
kvm->arch.vmid.vmid = 0;
return 0;
}
bool kvm_riscv_gstage_vmid_ver_changed(struct kvm_vmid *vmid)
{ if (!vmid_bits) returnfalse;
if (!kvm_riscv_gstage_vmid_ver_changed(vmid)) return;
spin_lock(&vmid_lock);
/* * We need to re-check the vmid_version here to ensure that if * another vcpu already allocated a valid vmid for this vm.
*/ if (!kvm_riscv_gstage_vmid_ver_changed(vmid)) {
spin_unlock(&vmid_lock); return;
}
/* First user of a new VMID version? */ if (unlikely(vmid_next == 0)) {
WRITE_ONCE(vmid_version, READ_ONCE(vmid_version) + 1);
vmid_next = 1;
/* * We ran out of VMIDs so we increment vmid_version and * start assigning VMIDs from 1. * * This also means existing VMIDs assignment to all Guest * instances is invalid and we have force VMID re-assignement * for all Guest instances. The Guest instances that were not * running will automatically pick-up new VMIDs because will * call kvm_riscv_gstage_vmid_update() whenever they enter * in-kernel run loop. For Guest instances that are already * running, we force VM exits on all host CPUs using IPI and * flush all Guest TLBs.
*/
on_each_cpu_mask(cpu_online_mask, __local_hfence_gvma_all,
NULL, 1);
}
if (!kvm_riscv_gstage_vmid_bits() ||
vcpu->arch.last_exit_cpu == vcpu->cpu) return;
/* * On RISC-V platforms with hardware VMID support, we share same * VMID for all VCPUs of a particular Guest/VM. This means we might * have stale G-stage TLB entries on the current Host CPU due to * some other VCPU of the same Guest which ran previously on the * current Host CPU. * * To cleanup stale TLB entries, we simply flush all G-stage TLB * entries by VMID whenever underlying Host CPU changes for a VCPU.
*/
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.