rust: hpet: fix decoding of timer registers
PATCH 1/1 rust: hpet: fix decoding of timer registers
Due to a missing "& 0x18", timer registers are not decoded correctly. This breaks the tests/functional/test_x86_64_tuxrun.py functional test.
--- rust/hw/timer/hpet/src/hpet.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
rust/hw/timer/hpet/src/hpet.rs +1 -1
@@ -776,7 +776,7 @@ fn decode(&self, mut addr: hwaddr, size: u32) -> HPETAddrDecode {let timer_id:usize = ((addr -0x100 ) /0x20 )as usize ;if timer_id <= self.num_timers.get () {// TODO: Add trace point - trace_hpet_ram_[read|write]_timer_id(timer_id) -TimerRegister ::try_from (addr) +TimerRegister ::try_from (addr &0x18 ) .map (|reg|HPETRegister ::Timer (&self.timers[timer_id], reg)) }else {// TODO: Add trace point - trace_hpet_timer_id_out_of_range(timer_id)
Signature · 1 line
2.49.0
Quoted 17 lines · Paolo Bonzini
Due to a missing "&
0x18", timer registers are not decoded correctly. This breaks thetests/functional/test_x86_64_tuxrun.pyfunctional test.Fixes 519088b7cf6 ("rust: hpet: decode HPET registers into enums", 2025-03-06)Reported-by Peter Maydell <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>--- rust/hw/timer/hpet/src/hpet.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)rust/hw/timer/hpet/src/hpet.rs +0
-0
rust/hw/timer/hpet/src/hpet.rs fn decode(&self, mut addr: hwaddr, size: u32) -> HPETAddrDecode {
Quoted 9 lines
rust/hw/timer/hpet/src/hpet.rs +1
-2@@ -776,7 +776,7 @@ fn decode(&self, mut addr: hwaddr, size: u32) -> HPETAddrDecode {let timer_id:usize = ((addr -0x100 ) /0x20 )as usize ;if timer_id <= self.num_timers.get () {// TODO: Add trace point - trace_hpet_ram_[read|write]_timer_id(timer_id) -TimerRegister ::try_from (addr) +TimerRegister ::try_from (addr &0x18 ) .map (|reg|HPETRegister ::Timer (&self.timers[timer_id], reg)) }else {// TODO: Add trace point - trace_hpet_timer_id_out_of_range(timer_id) --
If I understand the code correctly I think you could also write this as "addr & 0x1f" which might be a little nicer as it then lines up with the "/ 0x20".
thanks
-- PMM
Quoted 6 lines · Peter Maydell
Tested-by Peter Maydell <[email protected]>Reviewed-by Peter Maydell <[email protected]>If I understand the code correctly I think you could also write this as "addr &
0x1f" which might be a little nicer as it then lines up with the "/0x20".
Yeah, I was undecided between that and 0x18... in the end I went with 0x18 because bits 0-1 are clear (due to alignment) and bit 2 is cleared above, and the TimerRegister enum also has "0x18" in the comment.
Paolo