Skip to content

Commit

Permalink
hw/char/pl011: ensure UARTIBRD register is 16-bit
Browse files Browse the repository at this point in the history
The PL011 TRM says that "The 16-bit integer is written to the Integer Baud Rate
Register, UARTIBRD". Updated the handling of the UARTIBRD register to ensure
only 16-bit values are written to it.

ASAN log:
==2973125==ERROR: AddressSanitizer: FPE on unknown address 0x55f72629b348 (pc 0x55f72629b348 bp 0x7fffa24d0e00 sp 0x7fffa24d0d60 T0)
    #0 0x55f72629b348 in pl011_get_baudrate hw/char/pl011.c:255:17
    #1 0x55f726298d94 in pl011_trace_baudrate_change hw/char/pl011.c:260:33
    #2 0x55f726296fc8 in pl011_write hw/char/pl011.c:378:9

Reproducer:
cat << EOF | qemu-system-aarch64 -display \
none -machine accel=qtest, -m 512M -machine realview-pb-a8 -qtest stdio
writeq 0x1000b024 0xf8000000
EOF

Signed-off-by: Zheyu Ma <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
ZheyuMa authored and Patchew Applier committed Jun 30, 2024
1 parent 3665dd6 commit 1b1411d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hw/char/pl011.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ static void pl011_write(void *opaque, hwaddr offset,
s->ilpr = value;
break;
case 9: /* UARTIBRD */
s->ibrd = value;
s->ibrd = value & 0xFFFF;
pl011_trace_baudrate_change(s);
break;
case 10: /* UARTFBRD */
Expand Down

0 comments on commit 1b1411d

Please sign in to comment.