* [PATCH 0/2] provide disable clock functionality. @ 2008-03-06 14:45 Glauber Costa 2008-03-06 14:45 ` [PATCH 1/2] [PATCH] use per cpu variables instead of a vector Glauber Costa 2008-03-07 9:05 ` [PATCH 0/2] provide disable clock functionality Avi Kivity 0 siblings, 2 replies; 5+ messages in thread From: Glauber Costa @ 2008-03-06 14:45 UTC (permalink / raw) To: kvm-devel; +Cc: chrisw, avi Avi, Hope this is better ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] [PATCH] use per cpu variables instead of a vector 2008-03-06 14:45 [PATCH 0/2] provide disable clock functionality Glauber Costa @ 2008-03-06 14:45 ` Glauber Costa 2008-03-06 14:45 ` [PATCH 2/2] [PATCH] disable kvm clock unless addr's LSB is set Glauber Costa 2008-03-07 9:05 ` [PATCH 0/2] provide disable clock functionality Avi Kivity 1 sibling, 1 reply; 5+ messages in thread From: Glauber Costa @ 2008-03-06 14:45 UTC (permalink / raw) To: kvm-devel; +Cc: chrisw, avi, Glauber Costa replace hv_clock vector in kvmclock with a percpu variable that is cacheline aligned. Signed-off-by: Glauber Costa <gcosta@redhat.com> --- arch/x86/kernel/kvmclock.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c index 9c4a0f4..7c481a3 100644 --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c @@ -20,6 +20,7 @@ #include <linux/clocksource.h> #include <linux/kvm_para.h> #include <asm/arch_hooks.h> #include <asm/msr.h> +#include <linux/percpu.h> #define KVM_SCALE 22 @@ -33,8 +34,8 @@ static int parse_no_kvmclock(char *arg) early_param("no-kvmclock", parse_no_kvmclock); /* The hypervisor will put information about time periodically here */ -static struct kvm_vcpu_time_info hv_clock[NR_CPUS]; -#define get_clock(cpu, field) hv_clock[cpu].field +static DEFINE_PER_CPU_SHARED_ALIGNED(struct kvm_vcpu_time_info, hv_clock); +#define get_clock(cpu, field) per_cpu(hv_clock, cpu).field static inline u64 kvm_get_delta(u64 last_tsc) { @@ -124,8 +125,8 @@ static int kvm_register_clock(void) { int cpu = smp_processor_id(); int low, high; - low = (int)__pa(&hv_clock[cpu]); - high = ((u64)__pa(&hv_clock[cpu]) >> 32); + low = (int)__pa(&per_cpu(hv_clock, cpu)); + high = ((u64)__pa(&per_cpu(hv_clock, cpu)) >> 32); return native_write_msr_safe(MSR_KVM_SYSTEM_TIME, low, high); } -- 1.4.2 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] [PATCH] disable kvm clock unless addr's LSB is set. 2008-03-06 14:45 ` [PATCH 1/2] [PATCH] use per cpu variables instead of a vector Glauber Costa @ 2008-03-06 14:45 ` Glauber Costa 2008-03-08 3:39 ` Yang, Sheng 0 siblings, 1 reply; 5+ messages in thread From: Glauber Costa @ 2008-03-06 14:45 UTC (permalink / raw) To: kvm-devel; +Cc: chrisw, avi, Glauber Costa Use LSB of the address passed through the msr to enable/disable the clock. Setting it to 1 enables it, setting it to 0 disables it. As the guest data structures are aligned anyway, this won't be a problem, as this bit is free. Guest is changed accordingly Signed-off-by: Glauber Costa <gcosta@redhat.com> --- arch/x86/kernel/kvmclock.c | 2 +- arch/x86/kvm/x86.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c index 7c481a3..f654a12 100644 --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c @@ -125,7 +125,7 @@ static int kvm_register_clock(void) { int cpu = smp_processor_id(); int low, high; - low = (int)__pa(&per_cpu(hv_clock, cpu)); + low = (int)__pa(&per_cpu(hv_clock, cpu)) | 1; high = ((u64)__pa(&per_cpu(hv_clock, cpu)) >> 32); return native_write_msr_safe(MSR_KVM_SYSTEM_TIME, low, high); diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 6abd784..64beff6 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -591,8 +591,15 @@ int kvm_set_msr_common(struct kvm_vcpu * if (vcpu->arch.time_page) kvm_release_page_dirty(vcpu->arch.time_page); + /* we verify if the enable bit is set... */ + if (!(data & 1)) { + vcpu->arch.time = NULL; + break; + } + vcpu->arch.time = data & PAGE_MASK; - vcpu->arch.time_offset = data & ~PAGE_MASK; + /* ...but clean it before doing the actual write */ + vcpu->arch.time_offset = data & ~(PAGE_MASK | 1); vcpu->arch.hv_clock.tsc_to_system_mul = clocksource_khz2mult(tsc_khz, 22); -- 1.4.2 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] [PATCH] disable kvm clock unless addr's LSB is set. 2008-03-06 14:45 ` [PATCH 2/2] [PATCH] disable kvm clock unless addr's LSB is set Glauber Costa @ 2008-03-08 3:39 ` Yang, Sheng 0 siblings, 0 replies; 5+ messages in thread From: Yang, Sheng @ 2008-03-08 3:39 UTC (permalink / raw) To: kvm-devel; +Cc: chrisw, avi, Glauber Costa On Thursday 06 March 2008 22:45:44 Glauber Costa wrote: > Use LSB of the address passed through the msr to enable/disable > the clock. Setting it to 1 enables it, setting it to 0 disables it. > > As the guest data structures are aligned anyway, this > won't be a problem, as this bit is free. > > Guest is changed accordingly > > Signed-off-by: Glauber Costa <gcosta@redhat.com> > --- > arch/x86/kernel/kvmclock.c | 2 +- > arch/x86/kvm/x86.c | 9 ++++++++- > 2 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c > index 7c481a3..f654a12 100644 > --- a/arch/x86/kernel/kvmclock.c > +++ b/arch/x86/kernel/kvmclock.c > @@ -125,7 +125,7 @@ static int kvm_register_clock(void) > { > int cpu = smp_processor_id(); > int low, high; > - low = (int)__pa(&per_cpu(hv_clock, cpu)); > + low = (int)__pa(&per_cpu(hv_clock, cpu)) | 1; > high = ((u64)__pa(&per_cpu(hv_clock, cpu)) >> 32); > > return native_write_msr_safe(MSR_KVM_SYSTEM_TIME, low, high); > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index 6abd784..64beff6 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -591,8 +591,15 @@ int kvm_set_msr_common(struct kvm_vcpu * > if (vcpu->arch.time_page) > kvm_release_page_dirty(vcpu->arch.time_page); > > + /* we verify if the enable bit is set... */ > + if (!(data & 1)) { > + vcpu->arch.time = NULL; This line made compiler complaining... Thanks Yang, Sheng ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] provide disable clock functionality. 2008-03-06 14:45 [PATCH 0/2] provide disable clock functionality Glauber Costa 2008-03-06 14:45 ` [PATCH 1/2] [PATCH] use per cpu variables instead of a vector Glauber Costa @ 2008-03-07 9:05 ` Avi Kivity 1 sibling, 0 replies; 5+ messages in thread From: Avi Kivity @ 2008-03-07 9:05 UTC (permalink / raw) To: Glauber Costa; +Cc: kvm-devel, chrisw Glauber Costa wrote: > Avi, > > Hope this is better > Applied, thanks. -- Any sufficiently difficult bug is indistinguishable from a feature. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-03-08 3:39 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-03-06 14:45 [PATCH 0/2] provide disable clock functionality Glauber Costa 2008-03-06 14:45 ` [PATCH 1/2] [PATCH] use per cpu variables instead of a vector Glauber Costa 2008-03-06 14:45 ` [PATCH 2/2] [PATCH] disable kvm clock unless addr's LSB is set Glauber Costa 2008-03-08 3:39 ` Yang, Sheng 2008-03-07 9:05 ` [PATCH 0/2] provide disable clock functionality Avi Kivity
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.