provide disable clock functionality.
Subsystems (4)
cover provide disable clock functionality.
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/
PATCH 1/2 use per cpu variables instead of a vector
replace hv_clock vector in kvmclock with a percpu variable that is cacheline aligned.
--- arch/x86/kernel/kvmclock.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
arch/x86/kernel/kvmclock.c +5 -4
@@ -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).fieldstatic 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); }
Signature · 7 lines
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/
PATCH 2/2 disable kvm clock unless addr's LSB is set.
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
--- arch/x86/kernel/kvmclock.c | 2 +- arch/x86/kvm/x86.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-)
arch/x86/kernel/kvmclock.c +1 -1
@@ -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);
arch/x86/kvm/x86.c +8 -1
@@ -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 );
Signature · 7 lines
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/
Re: [PATCH 2/2] [PATCH] disable kvm clock unless addr's LSB is set.
Quoted 32 lines · 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 <[email protected]>--- arch/x86/kernel/kvmclock.c | 2 +- arch/x86/kvm/x86.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-)arch/x86/kernel/kvmclock.c +1
-1@@ -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);arch/x86/kvm/x86.c +0
-0
arch/x86/kvm/x86.c int kvm_set_msr_common(struct kvm_vcpu * · line 596
Quoted 6 lines
arch/x86/kvm/x86.c +3
-0@@ -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/
Avi Kivity
AppliedQuoted 4 lines · Glauber Costa
Avi,
Hope this is better
Applied, thanks.
Signature · 7 lines
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/