Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1485040
| From | Luiz Capitulino <lcapitulino@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/6] kvm: x86: add tsc_offset field to struct kvm_vcpu_arch |
| Date | 2016-09-16 16:30 +0200 |
| Message-ID | <si2jo-5SZ-39@gated-at.bofh.it> (permalink) |
| References | <si2jn-5SZ-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
A future commit will want to easily read a vCPU's TSC offset,
so we store it in struct kvm_arch_vcpu_arch for easy access.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
arch/x86/include/asm/kvm_host.h | 1 +
arch/x86/kvm/x86.c | 10 ++++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 4c738c2..9b36a31 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -568,6 +568,7 @@ struct kvm_vcpu_arch {
struct kvm_steal_time steal;
} st;
+ u64 tsc_offset;
u64 last_guest_tsc;
u64 last_host_tsc;
u64 tsc_offset_adjustment;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 19f9f9e..cda4ca5 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1413,6 +1413,12 @@ u64 kvm_read_l1_tsc(struct kvm_vcpu *vcpu, u64 host_tsc)
}
EXPORT_SYMBOL_GPL(kvm_read_l1_tsc);
+static void kvm_vcpu_write_tsc_offset(struct kvm_vcpu *vcpu, u64 offset)
+{
+ kvm_x86_ops->write_tsc_offset(vcpu, offset);
+ vcpu->arch.tsc_offset = offset;
+}
+
void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr)
{
struct kvm *kvm = vcpu->kvm;
@@ -1522,7 +1528,7 @@ void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr)
if (guest_cpuid_has_tsc_adjust(vcpu) && !msr->host_initiated)
update_ia32_tsc_adjust_msr(vcpu, offset);
- kvm_x86_ops->write_tsc_offset(vcpu, offset);
+ kvm_vcpu_write_tsc_offset(vcpu, offset);
raw_spin_unlock_irqrestore(&kvm->arch.tsc_write_lock, flags);
spin_lock(&kvm->arch.pvclock_gtod_sync_lock);
@@ -2750,7 +2756,7 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
if (check_tsc_unstable()) {
u64 offset = kvm_compute_tsc_offset(vcpu,
vcpu->arch.last_guest_tsc);
- kvm_x86_ops->write_tsc_offset(vcpu, offset);
+ kvm_vcpu_write_tsc_offset(vcpu, offset);
vcpu->arch.tsc_catchup = 1;
}
/*
--
2.5.5
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 0/6] kvm: x86: export TSC information to user-space Luiz Capitulino <lcapitulino@redhat.com> - 2016-09-16 16:30 +0200
[PATCH 1/6] kvm: x86: add tsc_offset field to struct kvm_vcpu_arch Luiz Capitulino <lcapitulino@redhat.com> - 2016-09-16 16:30 +0200
[PATCH 3/6] kvm: kvm_destroy_vm_debugfs(): check debugfs_stat_data pointer Luiz Capitulino <lcapitulino@redhat.com> - 2016-09-16 16:30 +0200
[PATCH 4/6] kvm: add stubs for arch specific debugfs support Luiz Capitulino <lcapitulino@redhat.com> - 2016-09-16 16:30 +0200
[PATCH 2/6] kvm: x86: drop read_tsc_offset() Luiz Capitulino <lcapitulino@redhat.com> - 2016-09-16 16:30 +0200
Re: [PATCH 2/6] kvm: x86: drop read_tsc_offset() Paolo Bonzini <pbonzini@redhat.com> - 2016-09-19 17:40 +0200
Re: [PATCH 2/6] kvm: x86: drop read_tsc_offset() Jim Mattson <jmattson@google.com> - 2016-09-20 00:20 +0200
Re: [PATCH 2/6] kvm: x86: drop read_tsc_offset() Paolo Bonzini <pbonzini@redhat.com> - 2016-09-20 07:40 +0200
Re: [PATCH 2/6] kvm: x86: drop read_tsc_offset() Paolo Bonzini <pbonzini@redhat.com> - 2016-09-21 17:30 +0200
Re: [PATCH 2/6] kvm: x86: drop read_tsc_offset() Jim Mattson <jmattson@google.com> - 2016-09-21 17:40 +0200
Re: [PATCH 2/6] kvm: x86: drop read_tsc_offset() Jim Mattson <jmattson@google.com> - 2016-09-21 17:30 +0200
Re: [PATCH 2/6] kvm: x86: drop read_tsc_offset() Jim Mattson <jmattson@google.com> - 2016-09-19 17:40 +0200
Re: [PATCH v2 0/6] kvm: x86: export TSC information to user-space Paolo Bonzini <pbonzini@redhat.com> - 2016-09-16 17:00 +0200
Re: [PATCH v2 0/6] kvm: x86: export TSC information to user-space Luiz Capitulino <lcapitulino@redhat.com> - 2016-09-16 17:00 +0200
Re: [PATCH v2 0/6] kvm: x86: export TSC information to user-space Paolo Bonzini <pbonzini@redhat.com> - 2016-09-16 17:10 +0200
Re: [PATCH v2 0/6] kvm: x86: export TSC information to user-space Luiz Capitulino <lcapitulino@redhat.com> - 2016-09-16 17:20 +0200
csiph-web