From: Michael Tokarev <mjt@tls.msk.ru>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: KVM list <kvm@vger.kernel.org>, Avi Kivity <avi@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
qemu-devel <qemu-devel@nongnu.org>
Subject: Re: TSC in qem[-kvm] 1.1+ and in-kernel irqchip
Date: Fri, 10 Aug 2012 01:36:32 +0400 [thread overview]
Message-ID: <50242D60.40703@msgid.tls.msk.ru> (raw)
In-Reply-To: <20120809204748.GA32346@amt.cnet>
On 10.08.2012 00:47, Marcelo Tosatti wrote:
[]
>>> calibrate_tsc (void)
>>> {
>>> /* First calibrate the TSC rate (relative, not absolute time). */
>>> grub_uint64_t start_tsc;
>>> grub_uint64_t end_tsc;
>>>
>>> start_tsc = grub_get_tsc ();
>>> grub_pit_wait (0xffff);
>>> end_tsc = grub_get_tsc ();
>>>
>>> tsc_ticks_per_ms = grub_divmod64 (end_tsc - start_tsc, 55, 0);
>>> }
>>
>> Emulation of grub_pit_wait sequence by in-kernel PIT is probably broken.
This is grub_pit_wait():
#define TIMER2_REG_CONTROL 0x42
#define TIMER_REG_COMMAND 0x43
#define TIMER2_REG_LATCH 0x61
#define TIMER2_SELECT 0x80
#define TIMER_ENABLE_LSB 0x20
#define TIMER_ENABLE_MSB 0x10
#define TIMER2_LATCH 0x20
#define TIMER2_SPEAKER 0x02
#define TIMER2_GATE 0x01
void
grub_pit_wait (grub_uint16_t tics)
{
/* Disable timer2 gate and speaker. */
grub_outb (grub_inb (TIMER2_REG_LATCH) & ~ (TIMER2_SPEAKER | TIMER2_GATE),
TIMER2_REG_LATCH);
/* Set tics. */
grub_outb (TIMER2_SELECT | TIMER_ENABLE_LSB | TIMER_ENABLE_MSB, TIMER_REG_COMMAND);
grub_outb (tics & 0xff, TIMER2_REG_CONTROL);
grub_outb (tics >> 8, TIMER2_REG_CONTROL);
/* Enable timer2 gate, keep speaker disabled. */
grub_outb ((grub_inb (TIMER2_REG_LATCH) & ~ TIMER2_SPEAKER) | TIMER2_GATE,
TIMER2_REG_LATCH);
/* Wait. */
while ((grub_inb (TIMER2_REG_LATCH) & TIMER2_LATCH) == 0x00);
/* Disable timer2 gate and speaker. */
grub_outb (grub_inb (TIMER2_REG_LATCH) & ~ (TIMER2_SPEAKER | TIMER2_GATE),
TIMER2_REG_LATCH);
}
>> QEMU PIT emulation is also affected by miscalibration.
>>
>> Please provide steps to reproduce.
>
> I mean verbose on the steps (does it happen always when setting timeout=10000,
> how to set timeout=10000, etc).
untested:
mkdir /tmp/grub
cd /tmp/grub
mkdir boot boot/grub
cat > boot/grub/grub.cfg <<EOF
set timeout=10000
menuentry 'test' {
echo "booted:"; read line
}
EOF
grub-mkrescue -o ../grub.iso .
kvm -cdrom ../grub.iso
This should show a menu with single entry "test",
and wait for 10000 seconds, with a countdown.
10000 is enough to actually see it -- with reasonable
timeout it isn't easy to see that it displays the
menu, instead it immediately goes to the booting,
displaying the "booted:" line.
kvm -cdrom ../grub.iso -cpu host,-tsc
kvm -cdrom ../grub.iso -no-kvm-irqchip
...
-- these works fine.
Tried with grub from debian wheezy (1.99-22.1) and
from ubuntu 12.04, but i guess it should be the
same with various versions of grub.
Thanks!
/mjt
WARNING: multiple messages have this Message-ID (diff)
From: Michael Tokarev <mjt@tls.msk.ru>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>, Avi Kivity <avi@redhat.com>,
KVM list <kvm@vger.kernel.org>, Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] TSC in qem[-kvm] 1.1+ and in-kernel irqchip
Date: Fri, 10 Aug 2012 01:36:32 +0400 [thread overview]
Message-ID: <50242D60.40703@msgid.tls.msk.ru> (raw)
In-Reply-To: <20120809204748.GA32346@amt.cnet>
On 10.08.2012 00:47, Marcelo Tosatti wrote:
[]
>>> calibrate_tsc (void)
>>> {
>>> /* First calibrate the TSC rate (relative, not absolute time). */
>>> grub_uint64_t start_tsc;
>>> grub_uint64_t end_tsc;
>>>
>>> start_tsc = grub_get_tsc ();
>>> grub_pit_wait (0xffff);
>>> end_tsc = grub_get_tsc ();
>>>
>>> tsc_ticks_per_ms = grub_divmod64 (end_tsc - start_tsc, 55, 0);
>>> }
>>
>> Emulation of grub_pit_wait sequence by in-kernel PIT is probably broken.
This is grub_pit_wait():
#define TIMER2_REG_CONTROL 0x42
#define TIMER_REG_COMMAND 0x43
#define TIMER2_REG_LATCH 0x61
#define TIMER2_SELECT 0x80
#define TIMER_ENABLE_LSB 0x20
#define TIMER_ENABLE_MSB 0x10
#define TIMER2_LATCH 0x20
#define TIMER2_SPEAKER 0x02
#define TIMER2_GATE 0x01
void
grub_pit_wait (grub_uint16_t tics)
{
/* Disable timer2 gate and speaker. */
grub_outb (grub_inb (TIMER2_REG_LATCH) & ~ (TIMER2_SPEAKER | TIMER2_GATE),
TIMER2_REG_LATCH);
/* Set tics. */
grub_outb (TIMER2_SELECT | TIMER_ENABLE_LSB | TIMER_ENABLE_MSB, TIMER_REG_COMMAND);
grub_outb (tics & 0xff, TIMER2_REG_CONTROL);
grub_outb (tics >> 8, TIMER2_REG_CONTROL);
/* Enable timer2 gate, keep speaker disabled. */
grub_outb ((grub_inb (TIMER2_REG_LATCH) & ~ TIMER2_SPEAKER) | TIMER2_GATE,
TIMER2_REG_LATCH);
/* Wait. */
while ((grub_inb (TIMER2_REG_LATCH) & TIMER2_LATCH) == 0x00);
/* Disable timer2 gate and speaker. */
grub_outb (grub_inb (TIMER2_REG_LATCH) & ~ (TIMER2_SPEAKER | TIMER2_GATE),
TIMER2_REG_LATCH);
}
>> QEMU PIT emulation is also affected by miscalibration.
>>
>> Please provide steps to reproduce.
>
> I mean verbose on the steps (does it happen always when setting timeout=10000,
> how to set timeout=10000, etc).
untested:
mkdir /tmp/grub
cd /tmp/grub
mkdir boot boot/grub
cat > boot/grub/grub.cfg <<EOF
set timeout=10000
menuentry 'test' {
echo "booted:"; read line
}
EOF
grub-mkrescue -o ../grub.iso .
kvm -cdrom ../grub.iso
This should show a menu with single entry "test",
and wait for 10000 seconds, with a countdown.
10000 is enough to actually see it -- with reasonable
timeout it isn't easy to see that it displays the
menu, instead it immediately goes to the booting,
displaying the "booted:" line.
kvm -cdrom ../grub.iso -cpu host,-tsc
kvm -cdrom ../grub.iso -no-kvm-irqchip
...
-- these works fine.
Tried with grub from debian wheezy (1.99-22.1) and
from ubuntu 12.04, but i guess it should be the
same with various versions of grub.
Thanks!
/mjt
next prev parent reply other threads:[~2012-08-09 21:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-09 18:27 TSC in qem[-kvm] 1.1+ and in-kernel irqchip Michael Tokarev
2012-08-09 18:27 ` [Qemu-devel] " Michael Tokarev
2012-08-09 19:06 ` Marcelo Tosatti
2012-08-09 19:06 ` [Qemu-devel] " Marcelo Tosatti
[not found] ` <20120809204748.GA32346@amt.cnet>
2012-08-09 21:36 ` Michael Tokarev [this message]
2012-08-09 21:36 ` Michael Tokarev
2012-08-10 7:33 ` Gleb Natapov
2012-08-10 7:33 ` Gleb Natapov
2012-08-10 9:24 ` Michael Tokarev
2012-08-10 9:24 ` Michael Tokarev
2012-08-12 8:10 ` Gleb Natapov
2012-08-12 8:10 ` [Qemu-devel] " Gleb Natapov
2012-08-12 9:24 ` Michael Tokarev
2012-08-12 9:24 ` [Qemu-devel] " Michael Tokarev
2012-08-13 13:07 ` Jan Kiszka
2012-08-13 13:07 ` [Qemu-devel] " Jan Kiszka
2012-08-13 13:16 ` Michael Tokarev
2012-08-13 13:16 ` Michael Tokarev
2012-08-13 13:41 ` Jan Kiszka
2012-08-13 13:41 ` Jan Kiszka
2012-08-13 18:18 ` [PATCH uq/master] kvm: i8254: Finish time conversion fix Jan Kiszka
2012-08-13 18:18 ` [Qemu-devel] " Jan Kiszka
2012-08-13 18:40 ` Michael Tokarev
2012-08-13 18:40 ` [Qemu-devel] " Michael Tokarev
2012-08-14 7:41 ` Jan Kiszka
2012-08-14 7:41 ` [Qemu-devel] " Jan Kiszka
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=50242D60.40703@msgid.tls.msk.ru \
--to=mjt@tls.msk.ru \
--cc=avi@redhat.com \
--cc=kraxel@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.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.