hw: Fix some minor arm buglets
Subsystems (3)
cover hw: Fix some minor arm buglets
This patchset fixes a handful of minor arm buglets reported recently, not because they're important (they're all very dull AI-located "bugs") but because I had a spare 30 minutes at the end of a Friday :-)
thanks
-- PMM
Peter Maydell (4):
hw/misc/bcm2835_control.c: Don't assert on local timer zero reload
value
hw/arm/integratorcp: Use LOG_UNIMP rather than hw_error() hw/display/exynos4210_fimd: Use LOG_GUEST_ERROR instead of hw_error() hw/display/exynos4210_fimd: Assume display surface is 32bpp
hw/arm/integratorcp.c | 16 ++++++--- hw/display/exynos4210_fimd.c | 69 ++++-------------------------------- hw/intc/bcm2836_control.c | 15 ++++++-- 3 files changed, 30 insertions(+), 70 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/4 hw/misc/bcm2835_control.c: Don't assert on local timer zero reload value
The bcm2836 local timer has a basic "counts down, fires at zero, and reloads to programmed value to count down again" functionality, as documented in
https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2836/QA7_rev3.4.pdf
The documentation is very sparse and doesn't say what actually happens if the guest programs the reload value to zero. Currently we trip an assert in this case.
Instead, log this as a guest error and disable the timer (which seems a reasonable guess -- effectively the timer will stop counting).
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3395
--- hw/intc/bcm2836_control.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
hw/intc/bcm2836_control.c +12 -3
@@ -197,12 +197,21 @@ static void bcm2836_control_local_timer_set_next(void *opaque) {BCM2836ControlState *s = opaque;uint64_t next_event; +uint64_t reload_value =LOCALTIMER_VALUE (s->local_timer_control); -assert (LOCALTIMER_VALUE (s->local_timer_control) >0 ); +if (reload_value ==0 ) { +/* +* Spec doesn't say what happens in this case; treat as a +* guest error and stop the timer running. +*/ +qemu_log_mask (LOG_GUEST_ERROR ,"%s: local timer reload value is 0\n" , + __func__); +timer_del (&s->timer); +return ; + } next_event =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ) + -muldiv64 (LOCALTIMER_VALUE (s->local_timer_control), -NANOSECONDS_PER_SECOND ,LOCALTIMER_FREQ ); +muldiv64 (reload_value,NANOSECONDS_PER_SECOND ,LOCALTIMER_FREQ );timer_mod (&s->timer, next_event); }
Signature · 1 line
2.43.0
Re: [PATCH 1/4] hw/misc/bcm2835_control.c: Don't assert on local timer zero reload value
Quoted 9 lines · Peter Maydell
The bcm2836 local timer has a basic "counts down, fires at zero, and reloads to programmed value to count down again" functionality, as documented in
https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2836/QA7_rev3.4.pdfThe documentation is very sparse and doesn't say what actually happens if the guest programs the reload value to zero. Currently we trip an assert in this case.
Quoted 8 lines
Instead, log this as a guest error and disable the timer (which seems a reasonable guess -- effectively the timer will stop counting).
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3395
Signed-off-by Peter Maydell <[email protected]>--- hw/intc/bcm2836_control.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
The alternate interpretation is that the timer continually raises interrupts, in which case logging a guest error would be doubly appropriate.
Anyway,
r~
Quoted 30 lines
hw/intc/bcm2836_control.c +12
-3@@ -197,12 +197,21 @@ static void bcm2836_control_local_timer_set_next(void *opaque) {BCM2836ControlState *s = opaque;uint64_t next_event; +uint64_t reload_value =LOCALTIMER_VALUE (s->local_timer_control); -assert (LOCALTIMER_VALUE (s->local_timer_control) >0 ); +if (reload_value ==0 ) { +/* +* Spec doesn't say what happens in this case; treat as a +* guest error and stop the timer running. +*/ +qemu_log_mask (LOG_GUEST_ERROR ,"%s: local timer reload value is 0\n" , + __func__); +timer_del (&s->timer); +return ; + } next_event =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ) + -muldiv64 (LOCALTIMER_VALUE (s->local_timer_control), -NANOSECONDS_PER_SECOND ,LOCALTIMER_FREQ ); +muldiv64 (reload_value,NANOSECONDS_PER_SECOND ,LOCALTIMER_FREQ );timer_mod (&s->timer, next_event); }
PATCH 2/4 hw/arm/integratorcp: Use LOG_UNIMP rather than hw_error()
In reply to Peter MaydellThe integratorcp board has some onboard registers which can be used to raise IRQ and FIQ to the CPU; these outputs are supposed to be ORed together with the main ones from the PIC. We've never implemented this obscure bit of functionality, and instead call hw_error() if the guest does try to raise an interrupt this way.
Replace the hw_error() call with the more modern way to note unimplemented QEMU behaviour, a LOG_UNIMP log.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3406
--- hw/arm/integratorcp.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
hw/arm/integratorcp.c +11 -5
@@ -23,7 +23,6 @@#include "qemu/log.h" #include "qemu/error-report.h" #include "hw/char/pl011.h" -#include "hw/core/hw-error.h" #include "hw/core/irq.h" #include "hw/sd/sd.h" #include "qom/object.h"
@@ -178,10 +177,17 @@ static void integratorcm_set_ctrl(IntegratorCMState *s, uint32_t value)static void integratorcm_update (IntegratorCMState *s) { -/* ??? The CPU irq/fiq is raised when either the core module or base PIC -are active. */ -if (s->int_level & (s->irq_enabled | s->fiq_enabled)) -hw_error ("Core module interrupt\n" ); +/* +* ??? The CPU irq/fiq is raised when either the core module or base PIC +* are active. To implement this we would need to run these signals +* through an OR gate with the PIC outputs. In practice guests don't +* use this, which is intended for an external debugger. +*/ +if (s->int_level & (s->irq_enabled | s->fiq_enabled)) { +qemu_log_mask (LOG_UNIMP , +"%s: raising IRQ/FIQ via core module registers is not implemented\n" , + __func__); + } } static void integratorcm_write(void *opaque, hwaddr offset,
Signature · 1 line
2.43.0
Re: [PATCH 2/4] hw/arm/integratorcp: Use LOG_UNIMP rather than hw_error()
Quoted 6 lines · Peter Maydell
The integratorcp board has some onboard registers which can be used to raise IRQ and FIQ to the CPU; these outputs are supposed to be ORed together with the main ones from the PIC. We've never implemented this obscure bit of functionality, and instead call
hw_error()if the guest does try to raise an interrupt this way.
Quoted 8 lines
Replace the
hw_error()call with the more modern way to note unimplemented QEMU behaviour, aLOG_UNIMPlog.Resolves:https://gitlab.com/qemu-project/qemu/-/work_items/3406
Signed-off-by Peter Maydell<[email protected]>--- hw/arm/integratorcp.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
r~
PATCH 3/4 hw/display/exynos4210_fimd: Use LOG_GUEST_ERROR instead of hw_error()
In reply to Peter MaydellThe exynos4210_fimd device model uses hw_error() in several places for "the guest set this register field to something out of range"; update to the more modern LOG_GUEST_ERROR.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3405
--- hw/display/exynos4210_fimd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
hw/display/exynos4210_fimd.c +5 -2
@@ -533,7 +533,8 @@ exynos4210_fimd_palette_format(Exynos4210fimdState *s, int window) ((s->wpalcon[1 ] >>FIMD_WPAL_W4PAL_L_SHT ) &FIMD_WPAL_W4PAL_L );break ;default : -hw_error ("exynos4210.fimd: incorrect window number %d\n" , window); +qemu_log_mask (LOG_GUEST_ERROR , +"exynos4210.fimd: incorrect window number %d\n" , window); ret =0 ;break ; }
@@ -757,7 +758,9 @@ exynos4210_fimd_blend_pixel(Exynos4210fimdWindow *w, rgba p_bg, rgba *ret) blend_param[i] =FIMD_1_MINUS_COLOR (bg_color);break ;default : -hw_error ("exynos4210.fimd: blend equation coef illegal value\n" ); +qemu_log_mask (LOG_GUEST_ERROR , +"exynos4210.fimd: blend equation coef illegal value\n" ); + blend_param[i] =0 ;break ; } }
Signature · 1 line
2.43.0
Re: [PATCH 3/4] hw/display/exynos4210_fimd: Use LOG_GUEST_ERROR instead of hw_error()
Quoted 9 lines · Peter Maydell
The
exynos4210_fimddevice model useshw_error()in several places for "the guest set this register field to something out of range"; update to the more modernLOG_GUEST_ERROR.Resolves:https://gitlab.com/qemu-project/qemu/-/work_items/3405
Signed-off-by Peter Maydell<[email protected]>--- hw/display/exynos4210_fimd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
r~
PATCH 4/4 hw/display/exynos4210_fimd: Assume display surface is 32bpp
In reply to Peter MaydellFor a long time QEMU has guaranteed that the console surface is 32bpp and not anything else. This old display device still has code assuming it might be something else. Remove the code that made put_pixel_toqemu a function pointer indirection, and use put_to_qemufb_pixel32() directly.
This removes the last hw_error() in this file.
--- hw/display/exynos4210_fimd.c | 62 ++---------------------------------- 1 file changed, 2 insertions(+), 60 deletions(-)
hw/display/exynos4210_fimd.c +2 -60
@@ -24,7 +24,6 @@#include "qemu/osdep.h" #include "hw/core/qdev-properties.h" -#include "hw/core/hw-error.h" #include "hw/core/irq.h" #include "hw/core/sysbus.h" #include "exec/cpu-common.h"
@@ -867,37 +866,6 @@ static void draw_line_mapcolor(Exynos4210fimdWindow *w, uint8_t *src, }/* Write RGB to QEMU's GraphicConsole framebuffer */ - -static int put_to_qemufb_pixel8 (const rgba p,uint8_t *d) -{ -uint32_t pixel =rgb_to_pixel8 (p.r, p.g, p.b); - *(uint8_t *)d = pixel; -return 1 ; -} - -static int put_to_qemufb_pixel15 (const rgba p,uint8_t *d) -{ -uint32_t pixel =rgb_to_pixel15 (p.r, p.g, p.b); - *(uint16_t *)d = pixel; -return 2 ; -} - -static int put_to_qemufb_pixel16 (const rgba p,uint8_t *d) -{ -uint32_t pixel =rgb_to_pixel16 (p.r, p.g, p.b); - *(uint16_t *)d = pixel; -return 2 ; -} - -static int put_to_qemufb_pixel24 (const rgba p,uint8_t *d) -{ -uint32_t pixel =rgb_to_pixel24 (p.r, p.g, p.b); - *(uint8_t *)d++ = (pixel >>0 ) &0xFF ; - *(uint8_t *)d++ = (pixel >>8 ) &0xFF ; - *(uint8_t *)d++ = (pixel >>16 ) &0xFF ; -return 3 ; -} -static int put_to_qemufb_pixel32 (const rgba p,uint8_t *d) {uint32_t pixel =rgb_to_pixel24 (p.r, p.g, p.b);
@@ -905,32 +873,6 @@ static int put_to_qemufb_pixel32(const rgba p, uint8_t *d)return 4 ; } -/* Routine to copy pixel from internal buffer to QEMU buffer */ -static int (*put_pixel_toqemu)(const rgba p,uint8_t *pixel); -static inline void fimd_update_putpix_qemu (int bpp) -{ -switch (bpp) { -case 8 : - put_pixel_toqemu = put_to_qemufb_pixel8; -break ; -case 15 : - put_pixel_toqemu = put_to_qemufb_pixel15; -break ; -case 16 : - put_pixel_toqemu = put_to_qemufb_pixel16; -break ; -case 24 : - put_pixel_toqemu = put_to_qemufb_pixel24; -break ; -case 32 : - put_pixel_toqemu = put_to_qemufb_pixel32; -break ; -default : -hw_error ("exynos4210.fimd: unsupported BPP (%d)" , bpp); -break ; - } -} -/* Routine to copy a line from internal frame buffer to QEMU display */ static void fimd_copy_line_toqemu (int width,uint8_t *src,uint8_t *dst) {
@@ -938,7 +880,7 @@ static void fimd_copy_line_toqemu(int width, uint8_t *src, uint8_t *dst)do { src +=get_pixel_ifb (src, &p); - dst +=put_pixel_toqemu (p, dst); + dst +=put_to_qemufb_pixel32 (p, dst); }while (--width); }
@@ -1336,7 +1278,7 @@ static bool exynos4210_fimd_update(void *opaque)int bpp; bpp =surface_bits_per_pixel (surface); -fimd_update_putpix_qemu (bpp); +assert (bpp ==32 ); bpp = (bpp +1 ) >>3 ; d =surface_data (surface);for (line = first_line; line <= last_line; line++) {
Signature · 1 line
2.43.0
Re: [PATCH 4/4] hw/display/exynos4210_fimd: Assume display surface is 32bpp
Quoted 6 lines · Peter Maydell
For a long time QEMU has guaranteed that the console surface is 32bpp and not anything else. This old display device still has code assuming it might be something else. Remove the code that made
put_pixel_toqemua function pointer indirection, and useput_to_qemufb_pixel32()directly.
Quoted 6 lines
This removes the last
hw_error()in this file.Signed-off-by Peter Maydell<[email protected]>--- hw/display/exynos4210_fimd.c | 62 ++---------------------------------- 1 file changed, 2 insertions(+), 60 deletions(-)
r~