aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/vmx.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kvm/vmx.c')
-rw-r--r--arch/x86/kvm/vmx.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 03df703c8f2..97b64543d4e 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1748,6 +1748,21 @@ static u64 guest_read_tsc(void)
1748} 1748}
1749 1749
1750/* 1750/*
1751 * Like guest_read_tsc, but always returns L1's notion of the timestamp
1752 * counter, even if a nested guest (L2) is currently running.
1753 */
1754u64 vmx_read_l1_tsc(struct kvm_vcpu *vcpu)
1755{
1756 u64 host_tsc, tsc_offset;
1757
1758 rdtscll(host_tsc);
1759 tsc_offset = is_guest_mode(vcpu) ?
1760 to_vmx(vcpu)->nested.vmcs01_tsc_offset :
1761 vmcs_read64(TSC_OFFSET);
1762 return host_tsc + tsc_offset;
1763}
1764
1765/*
1751 * Empty call-back. Needs to be implemented when VMX enables the SET_TSC_KHZ 1766 * Empty call-back. Needs to be implemented when VMX enables the SET_TSC_KHZ
1752 * ioctl. In this case the call-back should update internal vmx state to make 1767 * ioctl. In this case the call-back should update internal vmx state to make
1753 * the changes effective. 1768 * the changes effective.
@@ -7010,6 +7025,7 @@ static struct kvm_x86_ops vmx_x86_ops = {
7010 .write_tsc_offset = vmx_write_tsc_offset, 7025 .write_tsc_offset = vmx_write_tsc_offset,
7011 .adjust_tsc_offset = vmx_adjust_tsc_offset, 7026 .adjust_tsc_offset = vmx_adjust_tsc_offset,
7012 .compute_tsc_offset = vmx_compute_tsc_offset, 7027 .compute_tsc_offset = vmx_compute_tsc_offset,
7028 .read_l1_tsc = vmx_read_l1_tsc,
7013 7029
7014 .set_tdp_cr3 = vmx_set_cr3, 7030 .set_tdp_cr3 = vmx_set_cr3,
7015 7031