All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, pbonzini@redhat.com,
	rkrcmar@redhat.com, rostedt@goodmis.org, mhiramat@kernel.org,
	mtosatti@redhat.com
Subject: [PATCH 1/6] kvm: x86: add tsc_offset field to struct kvm_vcpu_arch
Date: Fri, 16 Sep 2016 10:27:31 -0400	[thread overview]
Message-ID: <1474036056-21270-2-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1474036056-21270-1-git-send-email-lcapitulino@redhat.com>

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

  reply	other threads:[~2016-09-16 14:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-16 14:27 [PATCH v2 0/6] kvm: x86: export TSC information to user-space Luiz Capitulino
2016-09-16 14:27 ` Luiz Capitulino [this message]
2016-09-16 14:27 ` [PATCH 2/6] kvm: x86: drop read_tsc_offset() Luiz Capitulino
2016-09-19 15:30   ` Jim Mattson
2016-09-19 15:34     ` Paolo Bonzini
2016-09-19 22:18       ` Jim Mattson
2016-09-20  5:37         ` Paolo Bonzini
2016-09-21 15:19           ` Jim Mattson
2016-09-21 15:22             ` Paolo Bonzini
2016-09-21 15:31               ` Jim Mattson
2016-09-16 14:27 ` [PATCH 3/6] kvm: kvm_destroy_vm_debugfs(): check debugfs_stat_data pointer Luiz Capitulino
2016-09-16 14:27 ` [PATCH 4/6] kvm: add stubs for arch specific debugfs support Luiz Capitulino
2016-09-16 14:27 ` [PATCH 5/6] kvm: create per-vcpu dirs in debugfs Luiz Capitulino
2016-09-16 14:27 ` [PATCH 6/6] kvm: x86: export TSC information to user-space Luiz Capitulino
2016-09-16 14:56 ` [PATCH v2 0/6] " Paolo Bonzini
2016-09-16 14:59   ` Luiz Capitulino
2016-09-16 14:59     ` Paolo Bonzini
2016-09-16 15:11       ` Luiz Capitulino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1474036056-21270-2-git-send-email-lcapitulino@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.