|
|
@@ -421,7 +421,6 @@ struct nested_vmx {
|
|
|
/* vmcs02_list cache of VMCSs recently used to run L2 guests */
|
|
|
struct list_head vmcs02_pool;
|
|
|
int vmcs02_num;
|
|
|
- u64 vmcs01_tsc_offset;
|
|
|
bool change_vmcs01_virtual_x2apic_mode;
|
|
|
/* L2 must run next, and mustn't decide to exit to L1. */
|
|
|
bool nested_run_pending;
|
|
|
@@ -2604,20 +2603,6 @@ static u64 guest_read_tsc(struct kvm_vcpu *vcpu)
|
|
|
return kvm_scale_tsc(vcpu, host_tsc) + tsc_offset;
|
|
|
}
|
|
|
|
|
|
-/*
|
|
|
- * Like guest_read_tsc, but always returns L1's notion of the timestamp
|
|
|
- * counter, even if a nested guest (L2) is currently running.
|
|
|
- */
|
|
|
-static u64 vmx_read_l1_tsc(struct kvm_vcpu *vcpu, u64 host_tsc)
|
|
|
-{
|
|
|
- u64 tsc_offset;
|
|
|
-
|
|
|
- tsc_offset = is_guest_mode(vcpu) ?
|
|
|
- to_vmx(vcpu)->nested.vmcs01_tsc_offset :
|
|
|
- vmcs_read64(TSC_OFFSET);
|
|
|
- return host_tsc + tsc_offset;
|
|
|
-}
|
|
|
-
|
|
|
/*
|
|
|
* writes 'offset' into guest's timestamp counter offset register
|
|
|
*/
|
|
|
@@ -2631,7 +2616,6 @@ static void vmx_write_tsc_offset(struct kvm_vcpu *vcpu, u64 offset)
|
|
|
* to the newly set TSC to get L2's TSC.
|
|
|
*/
|
|
|
struct vmcs12 *vmcs12;
|
|
|
- to_vmx(vcpu)->nested.vmcs01_tsc_offset = offset;
|
|
|
/* recalculate vmcs02.TSC_OFFSET: */
|
|
|
vmcs12 = get_vmcs12(vcpu);
|
|
|
vmcs_write64(TSC_OFFSET, offset +
|
|
|
@@ -2644,19 +2628,6 @@ static void vmx_write_tsc_offset(struct kvm_vcpu *vcpu, u64 offset)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void vmx_adjust_tsc_offset_guest(struct kvm_vcpu *vcpu, s64 adjustment)
|
|
|
-{
|
|
|
- u64 offset = vmcs_read64(TSC_OFFSET);
|
|
|
-
|
|
|
- vmcs_write64(TSC_OFFSET, offset + adjustment);
|
|
|
- if (is_guest_mode(vcpu)) {
|
|
|
- /* Even when running L2, the adjustment needs to apply to L1 */
|
|
|
- to_vmx(vcpu)->nested.vmcs01_tsc_offset += adjustment;
|
|
|
- } else
|
|
|
- trace_kvm_write_tsc_offset(vcpu->vcpu_id, offset,
|
|
|
- offset + adjustment);
|
|
|
-}
|
|
|
-
|
|
|
static bool guest_cpuid_has_vmx(struct kvm_vcpu *vcpu)
|
|
|
{
|
|
|
struct kvm_cpuid_entry2 *best = kvm_find_cpuid_entry(vcpu, 1, 0);
|
|
|
@@ -10061,9 +10032,9 @@ static void prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
|
|
|
|
|
|
if (vmcs12->cpu_based_vm_exec_control & CPU_BASED_USE_TSC_OFFSETING)
|
|
|
vmcs_write64(TSC_OFFSET,
|
|
|
- vmx->nested.vmcs01_tsc_offset + vmcs12->tsc_offset);
|
|
|
+ vcpu->arch.tsc_offset + vmcs12->tsc_offset);
|
|
|
else
|
|
|
- vmcs_write64(TSC_OFFSET, vmx->nested.vmcs01_tsc_offset);
|
|
|
+ vmcs_write64(TSC_OFFSET, vcpu->arch.tsc_offset);
|
|
|
if (kvm_has_tsc_control)
|
|
|
decache_tsc_multiplier(vmx);
|
|
|
|
|
|
@@ -10293,8 +10264,6 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
|
|
|
|
|
|
enter_guest_mode(vcpu);
|
|
|
|
|
|
- vmx->nested.vmcs01_tsc_offset = vmcs_read64(TSC_OFFSET);
|
|
|
-
|
|
|
if (!(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS))
|
|
|
vmx->nested.vmcs01_debugctl = vmcs_read64(GUEST_IA32_DEBUGCTL);
|
|
|
|
|
|
@@ -10818,7 +10787,7 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason,
|
|
|
load_vmcs12_host_state(vcpu, vmcs12);
|
|
|
|
|
|
/* Update any VMCS fields that might have changed while L2 ran */
|
|
|
- vmcs_write64(TSC_OFFSET, vmx->nested.vmcs01_tsc_offset);
|
|
|
+ vmcs_write64(TSC_OFFSET, vcpu->arch.tsc_offset);
|
|
|
if (vmx->hv_deadline_tsc == -1)
|
|
|
vmcs_clear_bits(PIN_BASED_VM_EXEC_CONTROL,
|
|
|
PIN_BASED_VMX_PREEMPTION_TIMER);
|
|
|
@@ -11339,8 +11308,6 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_init = {
|
|
|
.has_wbinvd_exit = cpu_has_vmx_wbinvd_exit,
|
|
|
|
|
|
.write_tsc_offset = vmx_write_tsc_offset,
|
|
|
- .adjust_tsc_offset_guest = vmx_adjust_tsc_offset_guest,
|
|
|
- .read_l1_tsc = vmx_read_l1_tsc,
|
|
|
|
|
|
.set_tdp_cr3 = vmx_set_cr3,
|
|
|
|