hikalium / liumos

A toy operating system which supports NVDIMM natively.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix HPET failed on DL380 Machine

hikalium opened this issue · comments

[hikalium@dl380 ~]$ dmesg | grep hpet
[ 0.347581] clocksource: hpet: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635855245 ns
[ 0.347599] hpet clockevent registered
[ 0.527878] hpet0: at MMIO 0xfed00000, IRQs 2, 8, 0, 0, 0, 0, 0, 0
[ 0.527878] hpet0: 8 comparators, 64-bit 24.000000 MHz counter
[ 1.761155] rtc_cmos 00:00: alarms up to one month, y3k, 114 bytes nvram, hpet irqs

count_per_femto_second: 0x27BC86B
comparator_value: 0x16E35FF
femto = 10^-15
mega = 10^6
41666667 femto sec / count
24MHz
0x16E3600 count / sec

HPETのcomparator valueは適切っぽい

iLOからNMIを打ち込んだら反応したので、割り込み自体は受けられる。->もしかして: 割り込み禁止を解除できていない?

割り込み禁止が続いているわけではなさそう。STIしているので。
IOAPICへの割り込みリダイレクションが元凶かと思いきや、他のQEMU等とは変わらなかったので問題ない。
実際、HPETの割り込みを設定しないと割り込みが来なかったことから、HPETから割り込みまでのルートは正常

考えられるのは、HPETが周期カウンタモードをサポートしていない可能性。
タイマ割り込みごとにHPETを再設定したらどうなるか検証してみよう。

2.3.9.2.2 Periodic Mode

The following usage model is expected:

  1. Software clears the GLOBAL_ENABLE_CNF bit to prevent any interrupts
  2. Software Clears the main counter by writing a value of 00000000h to it.
  3. Software sets the TIMER0_VAL_SET_CNF bit.
  4. Software writes the new value in the TIMER0_COMPARATOR_VAL register
  5. Software sets the GLOBAL_ENABLE_CNF bit to enable interrupts.

As described in 10.12.2 x2APIC Register Availability:

The local APIC registers can be accessed via the MSR interface only when the local APIC has been switched to the x2APIC mode

So EOI should be sent through MSR write, not MMIO write when Local APIC is operating as x2APIC.
This might be a cause of this problem.