Skip to contentSkip to conversation

pl031: Update last RTCLR value on write in case it's read back

PATCH In review Jessica Clarke 3 participants 3 messages Feb 22, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pl031: Update last RTCLR value on write in case it's read back

The PL031 allows you to read RTCLR, which is meant to give you the last value written. PL031State has an lr field which is used when reading from RTCLR, and is present in the VM migration state, but we never actually update it, so it always reads as its initial 0 value.

---
 hw/rtc/pl031.c | 1 +
 1 file changed, 1 insertion(+)
hw/rtc/pl031.c +1 -0
index 837b0bdf9b..563bb4b446 100644
@@ -141,6 +141,7 @@ static void pl031_write(void * opaque, hwaddr offset,
         g_autofree const char *qom_path = object_get_canonical_path(opaque);
         struct tm tm;
 
+        s->lr = value;
         s->tick_offset += value - pl031_get_count(s);
 
         qemu_get_timedate(&tm, s->tick_offset);
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Jessica Clarke

The PL031 allows you to read RTCLR, which is meant to give you the last value written. PL031State has an lr field which is used when reading from RTCLR, and is present in the VM migration state, but we never actually update it, so it always reads as its initial 0 value.

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#2 lore raw
In reply to Jessica Clarke
Quoted 8 lines · Jessica Clarke

The PL031 allows you to read RTCLR, which is meant to give you the last value written. PL031State has an lr field which is used when reading from RTCLR, and is present in the VM migration state, but we never actually update it, so it always reads as its initial 0 value.

---

Thanks for the patch -- looks like this bug has been present since the first version of the pl031 emulation was added back in 2007... Applied to target-arm.next.

-- PMM