Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-13 Thread Fred .
Add a comment about it in the source code. -#define PM_TIMER_FREQUENCY 3579545 +#define PM_TIMER_FREQUENCY 3579545 // 3.579545 MHz clock required by ACPI spec. On Mon, Aug 13, 2012 at 12:46 PM, Gleb Natapov wrote: > On Mon, Aug 13, 2012 at 12:37:11PM +0200, Gerd Hoffmann wrote: >> Hi, >> >>

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-13 Thread Gleb Natapov
On Mon, Aug 13, 2012 at 12:37:11PM +0200, Gerd Hoffmann wrote: > Hi, > > > Isnt pmtimer ioport usable? 14MHz. > > Can give it a try. 14 MHz looks wrong though, apci.h says: > > /* PM Timer ticks per second (HZ) */ > #define PM_TIMER_FREQUENCY 3579545 > > Is this fixed? Or hardware specific

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-13 Thread Gerd Hoffmann
Hi, > Isnt pmtimer ioport usable? 14MHz. Can give it a try. 14 MHz looks wrong though, apci.h says: /* PM Timer ticks per second (HZ) */ #define PM_TIMER_FREQUENCY 3579545 Is this fixed? Or hardware specific? cheers, Gerd ___ SeaBIOS mailing

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-12 Thread Avi Kivity
On 08/09/2012 10:02 PM, Marcelo Tosatti wrote: > On Thu, Aug 09, 2012 at 05:20:11PM +0300, Avi Kivity wrote: >> On 08/09/2012 05:18 PM, Gerd Hoffmann wrote: >> > Hi, >> > >> >>> So what do you suggest? The options I see are: >> >>> >> >>> (1) Use this patch (with alignment issue fixed of cour

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-12 Thread Avi Kivity
On 08/09/2012 09:59 PM, Marcelo Tosatti wrote: >> >> > +wrmsr(msr, 0); >> > +if (time.version < 2 || time.tsc_to_system_mul == 0) >> > +return 0; >> > + >> > +/* go figure tsc frequency */ >> > +khz = pvclock_tsc_khz(&time); >> > +dprintf(1, "Using kvmclock, msr 0x%x, t

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-12 Thread Avi Kivity
On 08/10/2012 11:10 AM, Gerd Hoffmann wrote: > Hi, > >>> (1) Use this patch (with alignment issue fixed of course). >>> (2) Do a full kvmclock implementation. Feels a bit like overkill. >>> (3) SeaBIOS can fallback to the PIT for timing on machines which >>> have

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-10 Thread Marcelo Tosatti
On Fri, Aug 10, 2012 at 10:10:27AM +0200, Gerd Hoffmann wrote: > Hi, > > >>> (1) Use this patch (with alignment issue fixed of course). > >>> (2) Do a full kvmclock implementation. Feels a bit like overkill. > >>> (3) SeaBIOS can fallback to the PIT for timing on machines which > >>>

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-10 Thread Gerd Hoffmann
Hi, >>> (1) Use this patch (with alignment issue fixed of course). >>> (2) Do a full kvmclock implementation. Feels a bit like overkill. >>> (3) SeaBIOS can fallback to the PIT for timing on machines which >>> have no TSC. We could do that too in case we detect kvm ... >> >> What s

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-10 Thread Gleb Natapov
On Fri, Aug 10, 2012 at 10:18:00AM +0300, Gleb Natapov wrote: > > can fix the in-kernel PIT issues with GRUB (see Michaels message) while > > testing. > > > What message exactly? > found it. -- Gleb. ___ SeaBIOS mailing list S

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-10 Thread Gleb Natapov
On Thu, Aug 09, 2012 at 04:09:13PM -0300, Marcelo Tosatti wrote: > On Thu, Aug 09, 2012 at 05:01:34PM +0300, Avi Kivity wrote: > > On 08/09/2012 04:57 PM, Gerd Hoffmann wrote: > > > Hi, > > > > > >>> +u64 kvm_tsc_khz(void) > > >>> +{ > > >>> +u32 eax, ebx, ecx, edx, msr; > > >>> +struct

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-09 Thread Marcelo Tosatti
On Thu, Aug 09, 2012 at 05:20:11PM +0300, Avi Kivity wrote: > On 08/09/2012 05:18 PM, Gerd Hoffmann wrote: > > Hi, > > > >>> So what do you suggest? The options I see are: > >>> > >>> (1) Use this patch (with alignment issue fixed of course). > >>> (2) Do a full kvmclock implementation. Fe

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-09 Thread Marcelo Tosatti
On Thu, Aug 09, 2012 at 03:53:24PM +0300, Avi Kivity wrote: > On 08/09/2012 02:57 PM, Gerd Hoffmann wrote: > > Use kvmclock for tsc calibration when running on kvm. Without this the > > tsc frequency calibrated by seabios can be *way* off in case the virtual > > machine is booted on a loaded host.

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-09 Thread Marcelo Tosatti
On Thu, Aug 09, 2012 at 05:01:34PM +0300, Avi Kivity wrote: > On 08/09/2012 04:57 PM, Gerd Hoffmann wrote: > > Hi, > > > >>> +u64 kvm_tsc_khz(void) > >>> +{ > >>> +u32 eax, ebx, ecx, edx, msr; > >>> +struct pvclock_vcpu_time_info time; > >>> +u32 addr = (u32)(&time); > >>> +u64 k

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-09 Thread Fred .
It should be kHz not khz. -msr, (u32)khz / 1000); +msr, (u32)kHz / 1000); On Thu, Aug 9, 2012 at 2:53 PM, Avi Kivity wrote: > On 08/09/2012 02:57 PM, Gerd Hoffmann wrote: >> Use kvmclock for tsc calibration when running on kvm. Without this the >> tsc frequency calibrate

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-09 Thread Avi Kivity
On 08/09/2012 04:57 PM, Gerd Hoffmann wrote: > Hi, > >>> +u64 kvm_tsc_khz(void) >>> +{ >>> +u32 eax, ebx, ecx, edx, msr; >>> +struct pvclock_vcpu_time_info time; >>> +u32 addr = (u32)(&time); >>> +u64 khz; >>> + >>> +/* check presence and figure msr number */ >>> +cpuid(K

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-09 Thread Avi Kivity
On 08/09/2012 05:18 PM, Gerd Hoffmann wrote: > Hi, > >>> So what do you suggest? The options I see are: >>> >>> (1) Use this patch (with alignment issue fixed of course). >>> (2) Do a full kvmclock implementation. Feels a bit like overkill. >>> (3) SeaBIOS can fallback to the PIT for tim

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-09 Thread Gerd Hoffmann
Hi, >> So what do you suggest? The options I see are: >> >> (1) Use this patch (with alignment issue fixed of course). >> (2) Do a full kvmclock implementation. Feels a bit like overkill. >> (3) SeaBIOS can fallback to the PIT for timing on machines which >> have no TSC. We could

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-09 Thread Avi Kivity
On 08/09/2012 05:12 PM, Gerd Hoffmann wrote: > Hi, > >>> er, the documentation says 4 bytes (so stack alignment works). I >>> distinctly remember having a large alignment requirement so we don't >>> cross a page or slot boundary... something's wrong here. >> >> case MSR_KVM_SYSTEM_TIME: {

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-09 Thread Gerd Hoffmann
Hi, >> er, the documentation says 4 bytes (so stack alignment works). I >> distinctly remember having a large alignment requirement so we don't >> cross a page or slot boundary... something's wrong here. > > case MSR_KVM_SYSTEM_TIME: { [ ... ] > So your tests worked by pure luck, but th

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-09 Thread Avi Kivity
On 08/09/2012 05:01 PM, Avi Kivity wrote: > On 08/09/2012 04:57 PM, Gerd Hoffmann wrote: >> Hi, >> +u64 kvm_tsc_khz(void) +{ +u32 eax, ebx, ecx, edx, msr; +struct pvclock_vcpu_time_info time; +u32 addr = (u32)(&time); +u64 khz; + +/* ch

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-09 Thread Gerd Hoffmann
Hi, >> +u64 kvm_tsc_khz(void) >> +{ >> +u32 eax, ebx, ecx, edx, msr; >> +struct pvclock_vcpu_time_info time; >> +u32 addr = (u32)(&time); >> +u64 khz; >> + >> +/* check presence and figure msr number */ >> +cpuid(KVM_CPUID_FEATURES, &eax, &ebx, &ecx, &edx); >> +if (ea

Re: [SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-09 Thread Avi Kivity
On 08/09/2012 02:57 PM, Gerd Hoffmann wrote: > Use kvmclock for tsc calibration when running on kvm. Without this the > tsc frequency calibrated by seabios can be *way* off in case the virtual > machine is booted on a loaded host. I've seen seabios calibrating 27 > instead of ca. 2800 MHz, result

[SeaBIOS] [PATCH] tsc: use kvmclock for calibration

2012-08-09 Thread Gerd Hoffmann
Use kvmclock for tsc calibration when running on kvm. Without this the tsc frequency calibrated by seabios can be *way* off in case the virtual machine is booted on a loaded host. I've seen seabios calibrating 27 instead of ca. 2800 MHz, resulting in timeouts being to short by factor 100. Which