Page 1 of 1

[SOLVED] Bochs and HPET: How to detect ?

Posted: Thu Mar 29, 2018 3:03 am
by wichtounet
Hi,

I've had an HPET driver working correctly for quite some time on Qemu. Before, it was not detecting any HPET in Bochs, but now Bochs added an ACPI Table for HPET and my OS detect that there is support for HPET. However, I'm having issues from Bochs telling me that I read (or write) to invalid HPET Register.

Here is what I'm doing to Detect HPET support for my OS:
  1. Check if the Table is here
  2. Check if possible to handle legacy replacement mode
  3. Check if the main counter is 64 bits
  4. Check if timer #0 is 64-bits
With Bochs, the three first tests pass without issue, but it crashes with:
Unsupported HPET read at address 0x0000fed00100
Is there any way to do a better detection so that step 4. does not fail ?
Is my HPET detection wrong ?

I was thinking to detect the number of timers, but Bochs tell me there are two counters...

Thanks

Re: Bochs and HPET: How to detect ?

Posted: Thu Mar 29, 2018 3:19 am
by linuxyne
The function hpet_read raises that error if the read size is not 4 or 8 bytes.

You may want to disassemble your binary to determine if any optimizations have caused it to contain such attempts at reading the hpet registers.

Re: Bochs and HPET: How to detect ?

Posted: Thu Mar 29, 2018 3:26 am
by wichtounet
linuxyne wrote:The function hpet_read raises that error if the read size is not 4 or 8 bytes.

You may want to disassemble your binary to determine if any optimizations have caused it to contain such attempts at reading the hpet registers.
Oh my god, you were right, I was missing a volatile!

Thanks a lot. It works now. It seems incredibly slow compared to qemu though.

I also tried patching the hpet_read function to handle small reads and it also works.

Re: Bochs and HPET: How to detect ?

Posted: Thu Mar 29, 2018 11:29 pm
by BrightLight
wichtounet wrote:I also tried patching the hpet_read function to handle small reads and it also works.
That's against the spec though. The HPET spec only allows DWORD reads/writes at DWORD-aligned boundaries, and QWORD read/writes at QWORD-aligned boundaries.

Re: Bochs and HPET: How to detect ?

Posted: Tue Apr 03, 2018 1:45 am
by wichtounet
omarrx024 wrote:
wichtounet wrote:I also tried patching the hpet_read function to handle small reads and it also works.
That's against the spec though. The HPET spec only allows DWORD reads/writes at DWORD-aligned boundaries, and QWORD read/writes at QWORD-aligned boundaries.
Thanks, I didn't know that :)