mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-24 10:17:28 +00:00
hv: vmx: add vpid support
Enable VMX vpid ctrl and assign an unique vpid to each vcpu so that VMX transitions are not required to invalidate any linear mappings or combined mappings. SDM Vol 3 - 28.3.3.3 If EPT is in use, the logical processor associates all mappings it creates with the value of bits 51:12 of current EPTP. If a VMM uses different EPTP values for different guests, it may use the same VPID for those guests. Doing so cannot result in one guest using translations that pertain to the other. In our UOS, the trusty world and normal world are using different EPTP. So we can use the same VPID for it. Signed-off-by: Li, Fei1 <fei1.li@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
@@ -83,6 +83,8 @@ int create_vcpu(int cpu_id, struct vm *vm, struct vcpu **rtn_vcpu_handle)
|
||||
}
|
||||
#endif
|
||||
|
||||
vcpu->arch_vcpu.vpid = allocate_vpid();
|
||||
|
||||
/* Allocate VMCS region for this VCPU */
|
||||
vcpu->arch_vcpu.vmcs = alloc_page();
|
||||
ASSERT(vcpu->arch_vcpu.vmcs != NULL, "");
|
||||
@@ -145,6 +147,15 @@ int start_vcpu(struct vcpu *vcpu)
|
||||
pr_info("VM %d Starting VCPU %d",
|
||||
vcpu->vm->attr.id, vcpu->vcpu_id);
|
||||
|
||||
if (vcpu->arch_vcpu.vpid)
|
||||
exec_vmwrite(VMX_VPID, vcpu->arch_vcpu.vpid);
|
||||
|
||||
/*
|
||||
* A power-up or a reset invalidates all linear mappings,
|
||||
* guest-physical mappings, and combined mappings
|
||||
*/
|
||||
flush_vpid_global();
|
||||
|
||||
/* Set vcpu launched */
|
||||
vcpu->launched = true;
|
||||
|
||||
|
Reference in New Issue
Block a user