[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 06/10] hvm/hpet: comparator can only change when master clock is enabled.



On 04/15/14 03:05, Jan Beulich wrote:
On 14.04.14 at 21:50, <dslutz@xxxxxxxxxxx> wrote:
On 04/14/14 11:07, Jan Beulich wrote:
As to the change - I'm not sure: The quoted description from the
specification cal also be read to mean that interrupt generation is
optional, but comparator increment will always happen. As long as
this can't be clarified, I'd prefer to stay with the code as is.
I think the code needs to change to match the spec.

#define timer_enabled(h, n) (timer_config(h, n) & HPET_TN_ENABLE)

vs

#define hpet_enabled(h) (h->hpet.config & HPET_CFG_ENABLE)


The change uses hpet_enabled() (I.E. Overall Enable).
Correct. But do we really need this? When the HPET is globally
disabled, hpet_read_maincounter() returns a fixed value, and
hence - due to the comparators not changing either -
hpet_get_comparator() will too even without the addition. So if
at all, the change would be mostly for documentation purposes.

We do need this.  hpet_get_comparator() does not return a
fixed value.  Without this change it will always adjust to
hpet_read_maincounter().  Here is an example using the
manual test code:


dcs-xen-54:~/xen/tools/tests/vhpet>gdb --args ./test_vhpet 0 3 0 1 0x13
GNU gdb (GDB) 7.6.2.20140108-cvs
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/don/xen/tools/tests/vhpet/test_vhpet...done.
(gdb) b hpet.c:128
Breakpoint 1 at 0x400ac1: file hpet.c, line 128.
(gdb) r
Starting program: /home/don/xen/tools/tests/vhpet/./test_vhpet 0 3 0 1 0x13
warning: no loadable sections found in added symbol-file system-supplied DSO at 
0x7ffff7ffd000
test_vhpet 1.0
hvm_clock_cost=0 hpet_mult=3 hpet_add=0 tick_count=1 debug=0x13

skip_load=1
    HPET: capability 0xf424008086a201 config 0()
          isr 0 counter 0(0)
          timer0 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer0 period 0(0) fsb 0
          timer1 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer1 period 0(0) fsb 0
          timer2 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer2 period 0(0) fsb 0
    HPET: capability 0xf424008086a201 config 0()
          isr 0 counter 0(0)
          timer0 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer0 period 0(0) fsb 0
          timer1 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer1 period 0(0) fsb 0
          timer2 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer2 period 0(0) fsb 0
skip_load
    HPET: capability 0xf424008086a201 config 0()
          isr 0 counter 0(0)
          timer0 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer0 period 0(0) fsb 0
          timer1 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer1 period 0(0) fsb 0
          timer2 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer2 period 0(0) fsb 0

mc64=0x108a8(67,752) mc_offset=0x10898(67,736)

hvm_guest_time=0x10(16)
    HPET: capability 0xf424008086a201 config 0()
          isr 0 counter 0x108a8(67,752)
          timer0 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer0 period 0(0) fsb 0
          timer1 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer1 period 0(0) fsb 0
          timer2 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer2 period 0(0) fsb 0
    HPET: capability 0xf424008086a201 config 0()
          isr 0 counter 0x108a8(67,752)
          timer0 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer0 period 0(0) fsb 0
          timer1 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer1 period 0(0) fsb 0
          timer2 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer2 period 0(0) fsb 0
skip_load
    HPET: capability 0xf424008086a201 config 0()
          isr 0 counter 0x108a8(67,752)
          timer0 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer0 period 0(0) fsb 0
          timer1 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer1 period 0(0) fsb 0
          timer2 config 0xf0000000000030() cmp 0xffffffffffffffff(-1)
          timer2 period 0(0) fsb 0

Breakpoint 1, hpet_read64 (h=0x604d68 <dom1+8>, addr=264) at hpet.c:128
128             return hpet_get_comparator(h, HPET_TN(CMP, addr), 
guest_time_hpet(h));
(gdb) c
Continuing.
hpet_writel: HPET_TN_SETVAL cmp=0x3e514(255,252) timer=0

Breakpoint 1, hpet_read64 (h=0x604d68 <dom1+8>, addr=264) at hpet.c:128
128             return hpet_get_comparator(h, HPET_TN(CMP, addr), 
guest_time_hpet(h));
(gdb) c
Continuing.
hpet_writel: period=0xf424(62,500) timer=0

Breakpoint 1, hpet_read64 (h=0x604d68 <dom1+8>, addr=264) at hpet.c:128
128             return hpet_get_comparator(h, HPET_TN(CMP, addr), 
guest_time_hpet(h));
(gdb) b hpet_get_comparator
Breakpoint 2 at 0x400839: file hpet.c, line 87.
(gdb) c
Continuing.

Breakpoint 2, hpet_get_comparator (h=0x604d68 <dom1+8>, tn=0, guest_time=1) at 
hpet.c:87
87          comparator = h->hpet.comparator64[tn];
(gdb) n
88          if ( timer_is_periodic(h, tn) )
(gdb)
91              uint64_t period = h->hpet.period[tn];
(gdb)
92              if (period)
(gdb)
94                  elapsed = hpet_read_maincounter(h, guest_time) +
(gdb)
95                      period - 1 - comparator;
(gdb)
94                  elapsed = hpet_read_maincounter(h, guest_time) +
(gdb)
96                  comparator += (elapsed / period) * period;
(gdb) p comparator
$1 = 255252
(gdb) p/x comparator
$2 = 0x3e514
(gdb) p elapsed
$3 = 18446744073709426615
(gdb) p/x elapsed
$4 = 0xfffffffffffe17b7
(gdb) p elapsed / period
$5 = 295147905179350
(gdb) p/x elapsed / period
$6 = 0x10c6f7a0b5ed6
(gdb) p 295147905179350 * period
$7 = 18446744073709375000
(gdb) p/x 295147905179350 * period
$8 = 0xfffffffffffd4e18
(gdb) n
97                  h->hpet.comparator64[tn] = comparator;
(gdb) p comparator
$9 = 78636
(gdb) p/x comparator
$10 = 0x1332c
(gdb)


     -Don Slutz




Jan



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.