target/sparc: Use explicit big-endian LD/ST API
v3 cover target/sparc: Use explicit big-endian LD/ST API
SPARC is big-endian. Use the explicit 'big'
endianness instead of the 'native' one.
Forbid further uses of legacy APIs.
tag: https://gitlab.com/philmd/qemu/-/tags/endian_sparc-v3
CI: https://gitlab.com/philmd/qemu/-/pipelines/2231223066
Philippe Mathieu-Daudé (9):
hw/sparc: Mark SPARC-specific peripherals as big-endian hw/sparc: Use explicit big-endian LD/ST API target/sparc: Replace MO_TE -> MO_BE
target/sparc: Use explicit big-endian LD/ST API target/sparc: Use big-endian variant of cpu_ld/st_data*() target/sparc: Inline translator_ldl()
target/sparc: Inline cpu_ldl_code() call in cpu_do_interrupt() target/sparc: Simplify gdbstub sparc_cpu_gdb_write_register() configs/targets: Forbid SPARC to use legacy native endianness APIs
configs/targets/sparc-linux-user.mak | 1 + configs/targets/sparc-softmmu.mak | 1 + configs/targets/sparc32plus-linux-user.mak | 1 + configs/targets/sparc64-linux-user.mak | 1 + configs/targets/sparc64-softmmu.mak | 1 + hw/audio/cs4231.c | 2 +- hw/char/grlib_apbuart.c | 2 +- hw/display/cg3.c | 2 +- hw/display/tcx.c | 14 ++--- hw/dma/sparc32_dma.c | 2 +- hw/intc/grlib_irqmp.c | 2 +- hw/intc/slavio_intctl.c | 4 +- hw/misc/eccmemctl.c | 2 +- hw/misc/slavio_misc.c | 16 +++--- hw/rtc/sun4v-rtc.c | 2 +- hw/sparc/leon3.c | 42 +++++++-------- hw/sparc/sun4m.c | 6 +-- hw/sparc64/sun4u.c | 6 +-- hw/timer/grlib_gptimer.c | 2 +- hw/timer/slavio_timer.c | 2 +- target/sparc/gdbstub.c | 12 +---- target/sparc/int32_helper.c | 4 +- target/sparc/ldst_helper.c | 48 ++++++++--------- target/sparc/mmu_helper.c | 32 ++++++------ target/sparc/translate.c | 60 +++++++++++----------- 25 files changed, 134 insertions(+), 133 deletions(-)
Signature · 1 line
2.52.0
PATCH v3 1/9 hw/sparc: Mark SPARC-specific peripherals as big-endian
These devices are only used by the SPARC target, which is only built as big-endian. Therefore the DEVICE_NATIVE_ENDIAN definition expand to DEVICE_BIG_ENDIAN (besides, the DEVICE_LITTLE_ENDIAN case isn't tested). Simplify directly using DEVICE_BIG_ENDIAN.
--- hw/audio/cs4231.c | 2 +- hw/char/grlib_apbuart.c | 2 +- hw/display/cg3.c | 2 +- hw/display/tcx.c | 14 +++++++------- hw/dma/sparc32_dma.c | 2 +- hw/intc/grlib_irqmp.c | 2 +- hw/intc/slavio_intctl.c | 4 ++-- hw/misc/eccmemctl.c | 2 +- hw/misc/slavio_misc.c | 16 ++++++++-------- hw/rtc/sun4v-rtc.c | 2 +- hw/timer/grlib_gptimer.c | 2 +- hw/timer/slavio_timer.c | 2 +- 12 files changed, 26 insertions(+), 26 deletions(-)
hw/audio/cs4231.c +1 -1
@@ -135,7 +135,7 @@ static void cs_mem_write(void *opaque, hwaddr addr,static const MemoryRegionOps cs_mem_ops = { .read = cs_mem_read, .write = cs_mem_write, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , };static const VMStateDescription vmstate_cs4231 = {
hw/char/grlib_apbuart.c +1 -1
@@ -242,7 +242,7 @@ static void grlib_apbuart_write(void *opaque, hwaddr addr,static const MemoryRegionOps grlib_apbuart_ops = { .write = grlib_apbuart_write, .read = grlib_apbuart_read, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , };static void grlib_apbuart_realize (DeviceState *dev,Error **errp)
hw/display/cg3.c +1 -1
@@ -265,7 +265,7 @@ static void cg3_reg_write(void *opaque, hwaddr addr, uint64_t val,static const MemoryRegionOps cg3_reg_ops = { .read = cg3_reg_read, .write = cg3_reg_write, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =1 , .max_access_size =4 ,
hw/display/tcx.c +7 -7
@@ -452,7 +452,7 @@ static void tcx_dac_writel(void *opaque, hwaddr addr, uint64_t val,static const MemoryRegionOps tcx_dac_ops = { .read = tcx_dac_readl, .write = tcx_dac_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,
@@ -533,7 +533,7 @@ static void tcx_rstip_writel(void *opaque, hwaddr addr,static const MemoryRegionOps tcx_stip_ops = { .read = tcx_stip_readl, .write = tcx_stip_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .impl = { .min_access_size =4 , .max_access_size =4 ,
@@ -547,7 +547,7 @@ static const MemoryRegionOps tcx_stip_ops = {static const MemoryRegionOps tcx_rstip_ops = { .read = tcx_stip_readl, .write = tcx_rstip_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .impl = { .min_access_size =4 , .max_access_size =4 ,
@@ -633,7 +633,7 @@ static void tcx_rblit_writel(void *opaque, hwaddr addr,static const MemoryRegionOps tcx_blit_ops = { .read = tcx_blit_readl, .write = tcx_blit_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .impl = { .min_access_size =4 , .max_access_size =4 ,
@@ -647,7 +647,7 @@ static const MemoryRegionOps tcx_blit_ops = {static const MemoryRegionOps tcx_rblit_ops = { .read = tcx_blit_readl, .write = tcx_rblit_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .impl = { .min_access_size =4 , .max_access_size =4 ,
@@ -713,7 +713,7 @@ static void tcx_thc_writel(void *opaque, hwaddr addr,static const MemoryRegionOps tcx_thc_ops = { .read = tcx_thc_readl, .write = tcx_thc_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,
@@ -734,7 +734,7 @@ static void tcx_dummy_writel(void *opaque, hwaddr addr,static const MemoryRegionOps tcx_dummy_ops = { .read = tcx_dummy_readl, .write = tcx_dummy_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,
hw/dma/sparc32_dma.c +1 -1
@@ -230,7 +230,7 @@ static void dma_mem_write(void *opaque, hwaddr addr,static const MemoryRegionOps dma_mem_ops = { .read = dma_mem_read, .write = dma_mem_write, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,
hw/intc/grlib_irqmp.c +1 -1
@@ -330,7 +330,7 @@ static void grlib_irqmp_write(void *opaque, hwaddr addr,static const MemoryRegionOps grlib_irqmp_ops = { .read = grlib_irqmp_read, .write = grlib_irqmp_write, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,
hw/intc/slavio_intctl.c +2 -2
@@ -135,7 +135,7 @@ static void slavio_intctl_mem_writel(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_intctl_mem_ops = { .read = slavio_intctl_mem_readl, .write = slavio_intctl_mem_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,
@@ -205,7 +205,7 @@ static void slavio_intctlm_mem_writel(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_intctlm_mem_ops = { .read = slavio_intctlm_mem_readl, .write = slavio_intctlm_mem_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,
hw/misc/eccmemctl.c +1 -1
@@ -232,7 +232,7 @@ static uint64_t ecc_mem_read(void *opaque, hwaddr addr,static const MemoryRegionOps ecc_mem_ops = { .read = ecc_mem_read, .write = ecc_mem_write, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,
hw/misc/slavio_misc.c +8 -8
@@ -147,7 +147,7 @@ static uint64_t slavio_cfg_mem_readb(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_cfg_mem_ops = { .read = slavio_cfg_mem_readb, .write = slavio_cfg_mem_writeb, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =1 , .max_access_size =1 ,
@@ -177,7 +177,7 @@ static uint64_t slavio_diag_mem_readb(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_diag_mem_ops = { .read = slavio_diag_mem_readb, .write = slavio_diag_mem_writeb, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =1 , .max_access_size =1 ,
@@ -207,7 +207,7 @@ static uint64_t slavio_mdm_mem_readb(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_mdm_mem_ops = { .read = slavio_mdm_mem_readb, .write = slavio_mdm_mem_writeb, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =1 , .max_access_size =1 ,
@@ -245,7 +245,7 @@ static uint64_t slavio_aux1_mem_readb(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_aux1_mem_ops = { .read = slavio_aux1_mem_readb, .write = slavio_aux1_mem_writeb, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =1 , .max_access_size =1 ,
@@ -282,7 +282,7 @@ static uint64_t slavio_aux2_mem_readb(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_aux2_mem_ops = { .read = slavio_aux2_mem_readb, .write = slavio_aux2_mem_writeb, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =1 , .max_access_size =1 ,
@@ -310,7 +310,7 @@ static uint64_t apc_mem_readb(void *opaque, hwaddr addr,static const MemoryRegionOps apc_mem_ops = { .read = apc_mem_readb, .write = apc_mem_writeb, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =1 , .max_access_size =1 ,
@@ -355,7 +355,7 @@ static void slavio_sysctrl_mem_writel(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_sysctrl_mem_ops = { .read = slavio_sysctrl_mem_readl, .write = slavio_sysctrl_mem_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,
@@ -397,7 +397,7 @@ static void slavio_led_mem_writew(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_led_mem_ops = { .read = slavio_led_mem_readw, .write = slavio_led_mem_writew, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =2 , .max_access_size =2 ,
hw/rtc/sun4v-rtc.c +1 -1
@@ -49,7 +49,7 @@ static void sun4v_rtc_write(void *opaque, hwaddr addr,static const MemoryRegionOps sun4v_rtc_ops = { .read = sun4v_rtc_read, .write = sun4v_rtc_write, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , };void sun4v_rtc_init (hwaddr addr)
hw/timer/grlib_gptimer.c +1 -1
@@ -332,7 +332,7 @@ static void grlib_gptimer_write(void *opaque, hwaddr addr,static const MemoryRegionOps grlib_gptimer_ops = { .read = grlib_gptimer_read, .write = grlib_gptimer_write, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,
hw/timer/slavio_timer.c +1 -1
@@ -329,7 +329,7 @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_timer_mem_ops = { .read = slavio_timer_mem_readl, .write = slavio_timer_mem_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =8 ,
Signature · 1 line
2.52.0
Re: [PATCH v3 1/9] hw/sparc: Mark SPARC-specific peripherals as big-endian
Quoted 9 lines · Philippe Mathieu-Daudé
These devices are only used by the SPARC target, which is only built as big-endian. Therefore the
DEVICE_NATIVE_ENDIANdefinition expand toDEVICE_BIG_ENDIAN(besides, theDEVICE_LITTLE_ENDIANcase isn't tested). Simplify directly usingDEVICE_BIG_ENDIAN.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Quoted 299 lines
hw/audio/cs4231.c | 2 +- hw/char/grlib_apbuart.c | 2 +- hw/display/cg3.c | 2 +- hw/display/tcx.c | 14 +++++++------- hw/dma/sparc32_dma.c | 2 +- hw/intc/grlib_irqmp.c | 2 +- hw/intc/slavio_intctl.c | 4 ++-- hw/misc/eccmemctl.c | 2 +- hw/misc/slavio_misc.c | 16 ++++++++-------- hw/rtc/sun4v-rtc.c | 2 +- hw/timer/grlib_gptimer.c | 2 +- hw/timer/slavio_timer.c | 2 +- 12 files changed, 26 insertions(+), 26 deletions(-)hw/audio/cs4231.c +1
-1@@ -135,7 +135,7 @@ static void cs_mem_write(void *opaque, hwaddr addr,static const MemoryRegionOps cs_mem_ops = { .read = cs_mem_read, .write = cs_mem_write, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , };static const VMStateDescription vmstate_cs4231 = {hw/char/grlib_apbuart.c +1
-1@@ -242,7 +242,7 @@ static void grlib_apbuart_write(void *opaque, hwaddr addr,static const MemoryRegionOps grlib_apbuart_ops = { .write = grlib_apbuart_write, .read = grlib_apbuart_read, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , };static void grlib_apbuart_realize (DeviceState *dev,Error **errp)hw/display/cg3.c +1
-1@@ -265,7 +265,7 @@ static void cg3_reg_write(void *opaque, hwaddr addr, uint64_t val,static const MemoryRegionOps cg3_reg_ops = { .read = cg3_reg_read, .write = cg3_reg_write, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =1 , .max_access_size =4 ,hw/display/tcx.c +7
-7@@ -452,7 +452,7 @@ static void tcx_dac_writel(void *opaque, hwaddr addr, uint64_t val,static const MemoryRegionOps tcx_dac_ops = { .read = tcx_dac_readl, .write = tcx_dac_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,@@ -533,7 +533,7 @@ static void tcx_rstip_writel(void *opaque, hwaddr addr,static const MemoryRegionOps tcx_stip_ops = { .read = tcx_stip_readl, .write = tcx_stip_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .impl = { .min_access_size =4 , .max_access_size =4 ,@@ -547,7 +547,7 @@ static const MemoryRegionOps tcx_stip_ops = {static const MemoryRegionOps tcx_rstip_ops = { .read = tcx_stip_readl, .write = tcx_rstip_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .impl = { .min_access_size =4 , .max_access_size =4 ,@@ -633,7 +633,7 @@ static void tcx_rblit_writel(void *opaque, hwaddr addr,static const MemoryRegionOps tcx_blit_ops = { .read = tcx_blit_readl, .write = tcx_blit_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .impl = { .min_access_size =4 , .max_access_size =4 ,@@ -647,7 +647,7 @@ static const MemoryRegionOps tcx_blit_ops = {static const MemoryRegionOps tcx_rblit_ops = { .read = tcx_blit_readl, .write = tcx_rblit_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .impl = { .min_access_size =4 , .max_access_size =4 ,@@ -713,7 +713,7 @@ static void tcx_thc_writel(void *opaque, hwaddr addr,static const MemoryRegionOps tcx_thc_ops = { .read = tcx_thc_readl, .write = tcx_thc_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,@@ -734,7 +734,7 @@ static void tcx_dummy_writel(void *opaque, hwaddr addr,static const MemoryRegionOps tcx_dummy_ops = { .read = tcx_dummy_readl, .write = tcx_dummy_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,hw/dma/sparc32_dma.c +1
-1@@ -230,7 +230,7 @@ static void dma_mem_write(void *opaque, hwaddr addr,static const MemoryRegionOps dma_mem_ops = { .read = dma_mem_read, .write = dma_mem_write, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,hw/intc/grlib_irqmp.c +1
-1@@ -330,7 +330,7 @@ static void grlib_irqmp_write(void *opaque, hwaddr addr,static const MemoryRegionOps grlib_irqmp_ops = { .read = grlib_irqmp_read, .write = grlib_irqmp_write, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,hw/intc/slavio_intctl.c +2
-2@@ -135,7 +135,7 @@ static void slavio_intctl_mem_writel(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_intctl_mem_ops = { .read = slavio_intctl_mem_readl, .write = slavio_intctl_mem_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,@@ -205,7 +205,7 @@ static void slavio_intctlm_mem_writel(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_intctlm_mem_ops = { .read = slavio_intctlm_mem_readl, .write = slavio_intctlm_mem_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,hw/misc/eccmemctl.c +1
-1@@ -232,7 +232,7 @@ static uint64_t ecc_mem_read(void *opaque, hwaddr addr,static const MemoryRegionOps ecc_mem_ops = { .read = ecc_mem_read, .write = ecc_mem_write, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,hw/misc/slavio_misc.c +8
-8@@ -147,7 +147,7 @@ static uint64_t slavio_cfg_mem_readb(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_cfg_mem_ops = { .read = slavio_cfg_mem_readb, .write = slavio_cfg_mem_writeb, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =1 , .max_access_size =1 ,@@ -177,7 +177,7 @@ static uint64_t slavio_diag_mem_readb(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_diag_mem_ops = { .read = slavio_diag_mem_readb, .write = slavio_diag_mem_writeb, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =1 , .max_access_size =1 ,@@ -207,7 +207,7 @@ static uint64_t slavio_mdm_mem_readb(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_mdm_mem_ops = { .read = slavio_mdm_mem_readb, .write = slavio_mdm_mem_writeb, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =1 , .max_access_size =1 ,@@ -245,7 +245,7 @@ static uint64_t slavio_aux1_mem_readb(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_aux1_mem_ops = { .read = slavio_aux1_mem_readb, .write = slavio_aux1_mem_writeb, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =1 , .max_access_size =1 ,@@ -282,7 +282,7 @@ static uint64_t slavio_aux2_mem_readb(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_aux2_mem_ops = { .read = slavio_aux2_mem_readb, .write = slavio_aux2_mem_writeb, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =1 , .max_access_size =1 ,@@ -310,7 +310,7 @@ static uint64_t apc_mem_readb(void *opaque, hwaddr addr,static const MemoryRegionOps apc_mem_ops = { .read = apc_mem_readb, .write = apc_mem_writeb, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =1 , .max_access_size =1 ,@@ -355,7 +355,7 @@ static void slavio_sysctrl_mem_writel(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_sysctrl_mem_ops = { .read = slavio_sysctrl_mem_readl, .write = slavio_sysctrl_mem_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,@@ -397,7 +397,7 @@ static void slavio_led_mem_writew(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_led_mem_ops = { .read = slavio_led_mem_readw, .write = slavio_led_mem_writew, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =2 , .max_access_size =2 ,hw/rtc/sun4v-rtc.c +1
-1@@ -49,7 +49,7 @@ static void sun4v_rtc_write(void *opaque, hwaddr addr,static const MemoryRegionOps sun4v_rtc_ops = { .read = sun4v_rtc_read, .write = sun4v_rtc_write, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , };void sun4v_rtc_init (hwaddr addr)hw/timer/grlib_gptimer.c +1
-1@@ -332,7 +332,7 @@ static void grlib_gptimer_write(void *opaque, hwaddr addr,static const MemoryRegionOps grlib_gptimer_ops = { .read = grlib_gptimer_read, .write = grlib_gptimer_write, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =4 ,hw/timer/slavio_timer.c +1
-2@@ -329,7 +329,7 @@ static void slavio_timer_mem_writel(void *opaque, hwaddr addr,static const MemoryRegionOps slavio_timer_mem_ops = { .read = slavio_timer_mem_readl, .write = slavio_timer_mem_writel, - .endianness =DEVICE_NATIVE_ENDIAN , + .endianness =DEVICE_BIG_ENDIAN , .valid = { .min_access_size =4 , .max_access_size =8 , --2.52.0
Re: [PATCH v3 1/9] hw/sparc: Mark SPARC-specific peripherals as big-endian
In reply to Philippe Mathieu-DaudéQuoted 7 lines · Philippe Mathieu-Daudé
These devices are only used by the SPARC target, which is only built as big-endian. Therefore the
DEVICE_NATIVE_ENDIANdefinition expand toDEVICE_BIG_ENDIAN(besides, theDEVICE_LITTLE_ENDIANcase isn't tested). Simplify directly usingDEVICE_BIG_ENDIAN.Signed-off-by Philippe Mathieu-Daudé<[email protected]>
Quoted 14 lines
--- hw/audio/cs4231.c | 2 +- hw/char/grlib_apbuart.c | 2 +- hw/display/cg3.c | 2 +- hw/display/tcx.c | 14 +++++++------- hw/dma/sparc32_dma.c | 2 +- hw/intc/grlib_irqmp.c | 2 +- hw/intc/slavio_intctl.c | 4 ++-- hw/misc/eccmemctl.c | 2 +- hw/misc/slavio_misc.c | 16 ++++++++-------- hw/rtc/sun4v-rtc.c | 2 +- hw/timer/grlib_gptimer.c | 2 +- hw/timer/slavio_timer.c | 2 +- 12 files changed, 26 insertions(+), 26 deletions(-)
r~
PATCH v3 2/9 hw/sparc: Use explicit big-endian LD/ST API
In reply to Philippe Mathieu-DaudéThe SPARC architecture uses big endianness. Directly use the big-endian LD/ST API.
Mechanical change running:
$ for a in uw w l q; do \
sed -i -e "s/ld${a}_p(/ld${a}_be_p(/" \
$(git grep -wlE '(ld|st)u?[wlq]_p' hw/sparc*/);
done--- hw/sparc/leon3.c | 42 +++++++++++++++++++++--------------------- hw/sparc/sun4m.c | 6 +++--- hw/sparc64/sun4u.c | 6 +++--- 3 files changed, 27 insertions(+), 27 deletions(-)
hw/sparc/leon3.c +21 -21
@@ -78,21 +78,21 @@ typedef struct ResetData {static uint32_t *gen_store_u32 (uint32_t *code,hwaddr addr,uint32_t val) { -stl_p (code++,0x82100000 );/* mov %g0, %g1 */ -stl_p (code++,0x84100000 );/* mov %g0, %g2 */ -stl_p (code++,0x03000000 + +stl_be_p (code++,0x82100000 );/* mov %g0, %g1 */ +stl_be_p (code++,0x84100000 );/* mov %g0, %g2 */ +stl_be_p (code++,0x03000000 +extract32 (addr,10 ,22 ));/* sethi %hi(addr), %g1 */ -stl_p (code++,0x82106000 + +stl_be_p (code++,0x82106000 +extract32 (addr,0 ,10 ));/* or %g1, addr, %g1 */ -stl_p (code++,0x05000000 + +stl_be_p (code++,0x05000000 +extract32 (val,10 ,22 ));/* sethi %hi(val), %g2 */ -stl_p (code++,0x8410a000 + +stl_be_p (code++,0x8410a000 +extract32 (val,0 ,10 ));/* or %g2, val, %g2 */ -stl_p (code++,0xc4204000 );/* st %g2, [ %g1 ] */ +stl_be_p (code++,0xc4204000 );/* st %g2, [ %g1 ] */ return code; }
@@ -112,13 +112,13 @@ static void write_bootloader(void *ptr, hwaddr kernel_addr)/* If we are running on a secondary CPU, jump directly to the kernel. */ -stl_p (p++,0x85444000 );/* rd %asr17, %g2 */ -stl_p (p++,0x8530a01c );/* srl %g2, 0x1c, %g2 */ -stl_p (p++,0x80908000 );/* tst %g2 */ +stl_be_p (p++,0x85444000 );/* rd %asr17, %g2 */ +stl_be_p (p++,0x8530a01c );/* srl %g2, 0x1c, %g2 */ +stl_be_p (p++,0x80908000 );/* tst %g2 */ /* Filled below. */ sec_cpu_branch_p = p; -stl_p (p++,0x0BADC0DE );/* bne xxx */ -stl_p (p++,0x01000000 );/* nop */ +stl_be_p (p++,0x0BADC0DE );/* bne xxx */ +stl_be_p (p++,0x01000000 );/* nop */ /* Initialize the UARTs */ /* *UART_CONTROL = UART_RECEIVE_ENABLE | UART_TRANSMIT_ENABLE; */
@@ -133,17 +133,17 @@ static void write_bootloader(void *ptr, hwaddr kernel_addr) p =gen_store_u32 (p,0x80000318 ,3 );/* Now, the relative branch above can be computed. */ -stl_p (sec_cpu_branch_p,0x12800000 - + (p - sec_cpu_branch_p)); +stl_be_p (sec_cpu_branch_p,0x12800000 + + (p - sec_cpu_branch_p));/* JUMP to the entry point */ -stl_p (p++,0x82100000 );/* mov %g0, %g1 */ -stl_p (p++,0x03000000 +extract32 (kernel_addr,10 ,22 )); -/* sethi %hi(kernel_addr), %g1 */ -stl_p (p++,0x82106000 +extract32 (kernel_addr,0 ,10 )); -/* or kernel_addr, %g1 */ -stl_p (p++,0x81c04000 );/* jmp %g1 */ -stl_p (p++,0x01000000 );/* nop */ +stl_be_p (p++,0x82100000 );/* mov %g0, %g1 */ +stl_be_p (p++,0x03000000 +extract32 (kernel_addr,10 ,22 )); +/* sethi %hi(kernel_addr), %g1 */ +stl_be_p (p++,0x82106000 +extract32 (kernel_addr,0 ,10 )); +/* or kernel_addr, %g1 */ +stl_be_p (p++,0x81c04000 );/* jmp %g1 */ +stl_be_p (p++,0x01000000 );/* nop */ }static void leon3_cpu_reset (void *opaque)
hw/sparc/sun4m.c +3 -3
@@ -268,9 +268,9 @@ static unsigned long sun4m_load_kernel(const char *kernel_filename,if (*initrd_size >0 ) {for (i =0 ; i <64 *TARGET_PAGE_SIZE ; i +=TARGET_PAGE_SIZE ) { ptr =rom_ptr (KERNEL_LOAD_ADDR + i,24 ); -if (ptr &&ldl_p (ptr) ==0x48647253 ) {/* HdrS */ -stl_p (ptr +16 ,INITRD_LOAD_ADDR ); -stl_p (ptr +20 , *initrd_size); +if (ptr &&ldl_be_p (ptr) ==0x48647253 ) {/* HdrS */ +stl_be_p (ptr +16 ,INITRD_LOAD_ADDR ); +stl_be_p (ptr +20 , *initrd_size);break ; } }
hw/sparc64/sun4u.c +3 -3
@@ -206,9 +206,9 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename,if (*initrd_size >0 ) {for (i =0 ; i <64 *TARGET_PAGE_SIZE ; i +=TARGET_PAGE_SIZE ) { ptr =rom_ptr (*kernel_addr + i,32 ); -if (ptr &&ldl_p (ptr +8 ) ==0x48647253 ) {/* HdrS */ -stl_p (ptr +24 , *initrd_addr + *kernel_addr); -stl_p (ptr +28 , *initrd_size); +if (ptr &&ldl_be_p (ptr +8 ) ==0x48647253 ) {/* HdrS */ +stl_be_p (ptr +24 , *initrd_addr + *kernel_addr); +stl_be_p (ptr +28 , *initrd_size);break ; } }
Signature · 1 line
2.52.0
Re: [PATCH v3 2/9] hw/sparc: Use explicit big-endian LD/ST API
Quoted 11 lines · Philippe Mathieu-Daudé
The SPARC architecture uses big endianness. Directly use the big-endian LD/ST API.
Mechanical change running:
$ for a in uw w l q; do \ sed -i -e "s/ld${a}_p(/ld${a}_be_p(/" \ $(git grep -wlE '(ld|st)u?[wlq]_p' hw/sparc*/); done
Quoted 4 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Mark Cave-Ayland <[email protected]>Reviewed-by Chigot Clément <[email protected]>---
Quoted 121 lines
hw/sparc/leon3.c | 42 +++++++++++++++++++++--------------------- hw/sparc/sun4m.c | 6 +++--- hw/sparc64/sun4u.c | 6 +++--- 3 files changed, 27 insertions(+), 27 deletions(-)hw/sparc/leon3.c +21
-21@@ -78,21 +78,21 @@ typedef struct ResetData {static uint32_t *gen_store_u32 (uint32_t *code,hwaddr addr,uint32_t val) { -stl_p (code++,0x82100000 );/* mov %g0, %g1 */ -stl_p (code++,0x84100000 );/* mov %g0, %g2 */ -stl_p (code++,0x03000000 + +stl_be_p (code++,0x82100000 );/* mov %g0, %g1 */ +stl_be_p (code++,0x84100000 );/* mov %g0, %g2 */ +stl_be_p (code++,0x03000000 +extract32 (addr,10 ,22 ));/* sethi %hi(addr), %g1 */ -stl_p (code++,0x82106000 + +stl_be_p (code++,0x82106000 +extract32 (addr,0 ,10 ));/* or %g1, addr, %g1 */ -stl_p (code++,0x05000000 + +stl_be_p (code++,0x05000000 +extract32 (val,10 ,22 ));/* sethi %hi(val), %g2 */ -stl_p (code++,0x8410a000 + +stl_be_p (code++,0x8410a000 +extract32 (val,0 ,10 ));/* or %g2, val, %g2 */ -stl_p (code++,0xc4204000 );/* st %g2, [ %g1 ] */ +stl_be_p (code++,0xc4204000 );/* st %g2, [ %g1 ] */ return code; }@@ -112,13 +112,13 @@ static void write_bootloader(void *ptr, hwaddr kernel_addr)/* If we are running on a secondary CPU, jump directly to the kernel. */ -stl_p (p++,0x85444000 );/* rd %asr17, %g2 */ -stl_p (p++,0x8530a01c );/* srl %g2, 0x1c, %g2 */ -stl_p (p++,0x80908000 );/* tst %g2 */ +stl_be_p (p++,0x85444000 );/* rd %asr17, %g2 */ +stl_be_p (p++,0x8530a01c );/* srl %g2, 0x1c, %g2 */ +stl_be_p (p++,0x80908000 );/* tst %g2 */ /* Filled below. */ sec_cpu_branch_p = p; -stl_p (p++,0x0BADC0DE );/* bne xxx */ -stl_p (p++,0x01000000 );/* nop */ +stl_be_p (p++,0x0BADC0DE );/* bne xxx */ +stl_be_p (p++,0x01000000 );/* nop */ /* Initialize the UARTs */ /* *UART_CONTROL = UART_RECEIVE_ENABLE | UART_TRANSMIT_ENABLE; */ @@ -133,17 +133,17 @@ static void write_bootloader(void *ptr, hwaddr kernel_addr) p =gen_store_u32 (p,0x80000318 ,3 );/* Now, the relative branch above can be computed. */ -stl_p (sec_cpu_branch_p,0x12800000 - + (p - sec_cpu_branch_p)); +stl_be_p (sec_cpu_branch_p,0x12800000 + + (p - sec_cpu_branch_p));/* JUMP to the entry point */ -stl_p (p++,0x82100000 );/* mov %g0, %g1 */ -stl_p (p++,0x03000000 +extract32 (kernel_addr,10 ,22 )); -/* sethi %hi(kernel_addr), %g1 */ -stl_p (p++,0x82106000 +extract32 (kernel_addr,0 ,10 )); -/* or kernel_addr, %g1 */ -stl_p (p++,0x81c04000 );/* jmp %g1 */ -stl_p (p++,0x01000000 );/* nop */ +stl_be_p (p++,0x82100000 );/* mov %g0, %g1 */ +stl_be_p (p++,0x03000000 +extract32 (kernel_addr,10 ,22 )); +/* sethi %hi(kernel_addr), %g1 */ +stl_be_p (p++,0x82106000 +extract32 (kernel_addr,0 ,10 )); +/* or kernel_addr, %g1 */ +stl_be_p (p++,0x81c04000 );/* jmp %g1 */ +stl_be_p (p++,0x01000000 );/* nop */ }static void leon3_cpu_reset (void *opaque)hw/sparc/sun4m.c +3
-3@@ -268,9 +268,9 @@ static unsigned long sun4m_load_kernel(const char *kernel_filename,if (*initrd_size >0 ) {for (i =0 ; i <64 *TARGET_PAGE_SIZE ; i +=TARGET_PAGE_SIZE ) { ptr =rom_ptr (KERNEL_LOAD_ADDR + i,24 ); -if (ptr &&ldl_p (ptr) ==0x48647253 ) {/* HdrS */ -stl_p (ptr +16 ,INITRD_LOAD_ADDR ); -stl_p (ptr +20 , *initrd_size); +if (ptr &&ldl_be_p (ptr) ==0x48647253 ) {/* HdrS */ +stl_be_p (ptr +16 ,INITRD_LOAD_ADDR ); +stl_be_p (ptr +20 , *initrd_size);break ; } }hw/sparc64/sun4u.c +3
-4@@ -206,9 +206,9 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename,if (*initrd_size >0 ) {for (i =0 ; i <64 *TARGET_PAGE_SIZE ; i +=TARGET_PAGE_SIZE ) { ptr =rom_ptr (*kernel_addr + i,32 ); -if (ptr &&ldl_p (ptr +8 ) ==0x48647253 ) {/* HdrS */ -stl_p (ptr +24 , *initrd_addr + *kernel_addr); -stl_p (ptr +28 , *initrd_size); +if (ptr &&ldl_be_p (ptr +8 ) ==0x48647253 ) {/* HdrS */ +stl_be_p (ptr +24 , *initrd_addr + *kernel_addr); +stl_be_p (ptr +28 , *initrd_size);break ; } } --2.52.0
PATCH v3 3/9 target/sparc: Replace MO_TE -> MO_BE
In reply to Philippe Mathieu-DaudéWe only build the SPARC targets using big endianness order, therefore the MO_TE definitions expand to the big endian one. Use the latter which is more explicit.
Mechanical change running:
$ sed -i -e s/MO_TE/MO_BE/ \
$(git grep -wl MO_TE target/sparc/)--- target/sparc/ldst_helper.c | 6 ++-- target/sparc/translate.c | 58 +++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 32 deletions(-)
target/sparc/ldst_helper.c +3 -3
@@ -1169,7 +1169,7 @@ uint64_t helper_ld_code(CPUSPARCState *env, target_ulong addr, uint32_t oi)break ;case MO_16 : ret =cpu_ldw_code_mmu (env, addr, oi, ra); -if ((mop &MO_BSWAP ) !=MO_TE ) { +if ((mop &MO_BSWAP ) !=MO_BE ) { ret =bswap16 (ret); }if (mop &MO_SIGN ) {
@@ -1178,7 +1178,7 @@ uint64_t helper_ld_code(CPUSPARCState *env, target_ulong addr, uint32_t oi)break ;case MO_32 : ret =cpu_ldl_code_mmu (env, addr, oi, ra); -if ((mop &MO_BSWAP ) !=MO_TE ) { +if ((mop &MO_BSWAP ) !=MO_BE ) { ret =bswap32 (ret); }if (mop &MO_SIGN ) {
@@ -1187,7 +1187,7 @@ uint64_t helper_ld_code(CPUSPARCState *env, target_ulong addr, uint32_t oi)break ;case MO_64 : ret =cpu_ldq_code_mmu (env, addr, oi, ra); -if ((mop &MO_BSWAP ) !=MO_TE ) { +if ((mop &MO_BSWAP ) !=MO_BE ) { ret =bswap64 (ret); }break ;
target/sparc/translate.c +29 -29
187 lines not on this page · raw message
Signature · 1 line
2.52.0
Re: [PATCH v3 3/9] target/sparc: Replace MO_TE -> MO_BE
Quoted 5 lines · Philippe Mathieu-Daudé
We only build the SPARC targets using big endianness order, therefore the
MO_TEdefinitions expand to the big endian one. Use the latter which is more explicit.
Quoted 7 lines
Mechanical change running:
$ sed -i -e s/MO_TE/MO_BE/ \ $(git grep -wl MO_TE target/sparc/)Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Quoted 250 lines
target/sparc/ldst_helper.c | 6 ++-- target/sparc/translate.c | 58 +++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 32 deletions(-)target/sparc/ldst_helper.c +3
-3@@ -1169,7 +1169,7 @@ uint64_t helper_ld_code(CPUSPARCState *env, target_ulong addr, uint32_t oi)break ;case MO_16 : ret =cpu_ldw_code_mmu (env, addr, oi, ra); -if ((mop &MO_BSWAP ) !=MO_TE ) { +if ((mop &MO_BSWAP ) !=MO_BE ) { ret =bswap16 (ret); }if (mop &MO_SIGN ) {@@ -1178,7 +1178,7 @@ uint64_t helper_ld_code(CPUSPARCState *env, target_ulong addr, uint32_t oi)break ;case MO_32 : ret =cpu_ldl_code_mmu (env, addr, oi, ra); -if ((mop &MO_BSWAP ) !=MO_TE ) { +if ((mop &MO_BSWAP ) !=MO_BE ) { ret =bswap32 (ret); }if (mop &MO_SIGN ) {@@ -1187,7 +1187,7 @@ uint64_t helper_ld_code(CPUSPARCState *env, target_ulong addr, uint32_t oi)break ;case MO_64 : ret =cpu_ldq_code_mmu (env, addr, oi, ra); -if ((mop &MO_BSWAP ) !=MO_TE ) { +if ((mop &MO_BSWAP ) !=MO_BE ) { ret =bswap64 (ret); }break ;target/sparc/translate.c +29
-30@@ -1764,7 +1764,7 @@ static DisasASI resolve_asi(DisasContext *dc, int asi, MemOp memop)case ASI_FL16_SL :case ASI_FL16_P :case ASI_FL16_PL : - memop =MO_TEUW ; + memop =MO_BEUW ; type =GET_ASI_SHORT ;break ; }@@ -2215,7 +2215,7 @@ static void gen_ldda_asi(DisasContext *dc, DisasASI *da, TCGv addr, int rd)* byte swapped. We perform one 128-bit LE load, so must swap * the order of the writebacks. */ -if ((mop &MO_BSWAP ) ==MO_TE ) { +if ((mop &MO_BSWAP ) ==MO_BE ) {tcg_gen_extr_i128_i64 (lo, hi, t); }else {tcg_gen_extr_i128_i64 (hi, lo, t);@@ -2235,7 +2235,7 @@ static void gen_ldda_asi(DisasContext *dc, DisasASI *da, TCGv addr, int rd)/* Note that LE ldda acts as if each 32-bit register result is byte swapped. Having just performed one 64-bit bswap, we need now to swap the writebacks. */ -if ((da->memop &MO_BSWAP ) ==MO_TE ) { +if ((da->memop &MO_BSWAP ) ==MO_BE ) {tcg_gen_extr_i64_tl (lo, hi, tmp); }else {tcg_gen_extr_i64_tl (hi, lo, tmp);@@ -2252,7 +2252,7 @@ static void gen_ldda_asi(DisasContext *dc, DisasASI *da, TCGv addr, int rd)gen_helper_ld_code (tmp, tcg_env, addr,tcg_constant_i32 (oi));/* See above. */ -if ((da->memop &MO_BSWAP ) ==MO_TE ) { +if ((da->memop &MO_BSWAP ) ==MO_BE ) {tcg_gen_extr_i64_tl (lo, hi, tmp); }else {tcg_gen_extr_i64_tl (hi, lo, tmp);@@ -2277,7 +2277,7 @@ static void gen_ldda_asi(DisasContext *dc, DisasASI *da, TCGv addr, int rd)gen_helper_ld_asi (tmp, tcg_env, addr, r_asi, r_mop);/* See above. */ -if ((da->memop &MO_BSWAP ) ==MO_TE ) { +if ((da->memop &MO_BSWAP ) ==MO_BE ) {tcg_gen_extr_i64_tl (lo, hi, tmp); }else {tcg_gen_extr_i64_tl (hi, lo, tmp);@@ -2310,7 +2310,7 @@ static void gen_stda_asi(DisasContext *dc, DisasASI *da, TCGv addr, int rd)* byte swapped. We perform one 128-bit LE store, so must swap * the order of the construction. */ -if ((mop &MO_BSWAP ) ==MO_TE ) { +if ((mop &MO_BSWAP ) ==MO_BE ) {tcg_gen_concat_i64_i128 (t, lo, hi); }else {tcg_gen_concat_i64_i128 (t, hi, lo);@@ -2329,7 +2329,7 @@ static void gen_stda_asi(DisasContext *dc, DisasASI *da, TCGv addr, int rd)/* Note that LE stda acts as if each 32-bit register result is byte swapped. We will perform one 64-bit LE store, so now we must swap the order of the construction. */ -if ((da->memop &MO_BSWAP ) ==MO_TE ) { +if ((da->memop &MO_BSWAP ) ==MO_BE ) {tcg_gen_concat_tl_i64 (t64, lo, hi); }else {tcg_gen_concat_tl_i64 (t64, hi, lo);@@ -2345,7 +2345,7 @@ static void gen_stda_asi(DisasContext *dc, DisasASI *da, TCGv addr, int rd)* See comments for GET_ASI_COPY above. */ { -MemOp mop =MO_TE |MO_128 |MO_ATOM_IFALIGN_PAIR ; +MemOp mop =MO_BE |MO_128 |MO_ATOM_IFALIGN_PAIR ;TCGv_i64 t8 =tcg_temp_new_i64 ();TCGv_i128 t16 =tcg_temp_new_i128 ();TCGv daddr =tcg_temp_new ();@@ -2368,7 +2368,7 @@ static void gen_stda_asi(DisasContext *dc, DisasASI *da, TCGv addr, int rd)TCGv_i64 t64 =tcg_temp_new_i64 ();/* See above. */ -if ((da->memop &MO_BSWAP ) ==MO_TE ) { +if ((da->memop &MO_BSWAP ) ==MO_BE ) {tcg_gen_concat_tl_i64 (t64, lo, hi); }else {tcg_gen_concat_tl_i64 (t64, hi, lo);@@ -4428,13 +4428,13 @@ static bool do_ld_gpr(DisasContext *dc, arg_r_r_ri_asi *a, MemOp mop)return advance_pc (dc); } -TRANS(LDUW, ALL, do_ld_gpr, a, MO_TEUL) +TRANS(LDUW, ALL, do_ld_gpr, a, MO_BEUL) TRANS(LDUB, ALL, do_ld_gpr, a, MO_UB) -TRANS(LDUH, ALL, do_ld_gpr, a, MO_TEUW) +TRANS(LDUH, ALL, do_ld_gpr, a, MO_BEUW) TRANS(LDSB, ALL, do_ld_gpr, a, MO_SB) -TRANS(LDSH, ALL, do_ld_gpr, a, MO_TESW) -TRANS(LDSW, 64, do_ld_gpr, a, MO_TESL) -TRANS(LDX, 64, do_ld_gpr, a, MO_TEUQ) +TRANS(LDSH, ALL, do_ld_gpr, a, MO_BESW) +TRANS(LDSW, 64, do_ld_gpr, a, MO_BESL) +TRANS(LDX, 64, do_ld_gpr, a, MO_BEUQ)static bool do_st_gpr (DisasContext *dc,arg_r_r_ri_asi *a,MemOp mop) {@@ -4451,10 +4451,10 @@ static bool do_st_gpr(DisasContext *dc, arg_r_r_ri_asi *a, MemOp mop)return advance_pc (dc); } -TRANS(STW, ALL, do_st_gpr, a, MO_TEUL) +TRANS(STW, ALL, do_st_gpr, a, MO_BEUL) TRANS(STB, ALL, do_st_gpr, a, MO_UB) -TRANS(STH, ALL, do_st_gpr, a, MO_TEUW) -TRANS(STX, 64, do_st_gpr, a, MO_TEUQ) +TRANS(STH, ALL, do_st_gpr, a, MO_BEUW) +TRANS(STX, 64, do_st_gpr, a, MO_BEUQ)static bool trans_LDD (DisasContext *dc,arg_r_r_ri_asi *a) {@@ -4468,7 +4468,7 @@ static bool trans_LDD(DisasContext *dc, arg_r_r_ri_asi *a)if (addr ==NULL ) {return false; } - da =resolve_asi (dc, a->asi,MO_TEUQ ); + da =resolve_asi (dc, a->asi,MO_BEUQ );gen_ldda_asi (dc, &da, addr, a->rd);return advance_pc (dc); }@@ -4485,7 +4485,7 @@ static bool trans_STD(DisasContext *dc, arg_r_r_ri_asi *a)if (addr ==NULL ) {return false; } - da =resolve_asi (dc, a->asi,MO_TEUQ ); + da =resolve_asi (dc, a->asi,MO_BEUQ );gen_stda_asi (dc, &da, addr, a->rd);return advance_pc (dc); }@@ -4516,7 +4516,7 @@ static bool trans_SWAP(DisasContext *dc, arg_r_r_ri_asi *a)if (addr ==NULL ) {return false; } - da =resolve_asi (dc, a->asi,MO_TEUL ); + da =resolve_asi (dc, a->asi,MO_BEUL ); dst =gen_dest_gpr (dc, a->rd); src =gen_load_gpr (dc, a->rd);@@ -4544,8 +4544,8 @@ static bool do_casa(DisasContext *dc, arg_r_r_ri_asi *a, MemOp mop)return advance_pc (dc); } -TRANS(CASA, CASA, do_casa, a, MO_TEUL) -TRANS(CASXA, 64, do_casa, a, MO_TEUQ) +TRANS(CASA, CASA, do_casa, a, MO_BEUL) +TRANS(CASXA, 64, do_casa, a, MO_BEUQ)static bool do_ld_fpr (DisasContext *dc,arg_r_r_ri_asi *a,MemOp sz) {@@ -4561,7 +4561,7 @@ static bool do_ld_fpr(DisasContext *dc, arg_r_r_ri_asi *a, MemOp sz)if (sz ==MO_128 &&gen_trap_float128 (dc)) {return true; } - da =resolve_asi (dc, a->asi,MO_TE | sz); + da =resolve_asi (dc, a->asi,MO_BE | sz);gen_ldf_asi (dc, &da, sz, addr, a->rd);gen_update_fprs_dirty (dc, a->rd);return advance_pc (dc);@@ -4590,7 +4590,7 @@ static bool do_st_fpr(DisasContext *dc, arg_r_r_ri_asi *a, MemOp sz)if (sz ==MO_128 &&gen_trap_float128 (dc)) {return true; } - da =resolve_asi (dc, a->asi,MO_TE | sz); + da =resolve_asi (dc, a->asi,MO_BE | sz);gen_stf_asi (dc, &da, sz, addr, a->rd);return advance_pc (dc); }@@ -4629,7 +4629,7 @@ static bool trans_STDFQ(DisasContext *dc, arg_STDFQ *a)/* Store the single element from the queue. */ TCGv_i64 fq =tcg_temp_new_i64 (); tcg_gen_ld_i64(fq, tcg_env, offsetof(CPUSPARCState, fq.d)); -tcg_gen_qemu_st_i64 (fq, addr, dc->mem_idx,MO_TEUQ |MO_ALIGN_4 ); +tcg_gen_qemu_st_i64 (fq, addr, dc->mem_idx,MO_BEUQ |MO_ALIGN_4 );/* Mark the queue empty, transitioning to fp_execute state. */ tcg_gen_st_i32(tcg_constant_i32(0), tcg_env,@@ -4655,7 +4655,7 @@ static bool trans_LDFSR(DisasContext *dc, arg_r_r_ri *a) } tmp =tcg_temp_new_i32 (); -tcg_gen_qemu_ld_i32 (tmp, addr, dc->mem_idx,MO_TEUL |MO_ALIGN ); +tcg_gen_qemu_ld_i32 (tmp, addr, dc->mem_idx,MO_BEUL |MO_ALIGN );tcg_gen_extract_i32 (cpu_fcc[0 ], tmp,FSR_FCC0_SHIFT ,2 );/* LDFSR does not change FCC[1-3]. */ @@ -4679,7 +4679,7 @@ static bool do_ldxfsr(DisasContext *dc, arg_r_r_ri *a, bool entire) } t64 =tcg_temp_new_i64 (); -tcg_gen_qemu_ld_i64 (t64, addr, dc->mem_idx,MO_TEUQ |MO_ALIGN ); +tcg_gen_qemu_ld_i64 (t64, addr, dc->mem_idx,MO_BEUQ |MO_ALIGN ); lo =tcg_temp_new_i32 (); hi = cpu_fcc[3 ];@@ -4722,8 +4722,8 @@ static bool do_stfsr(DisasContext *dc, arg_r_r_ri *a, MemOp mop)return advance_pc (dc); } -TRANS(STFSR, ALL, do_stfsr, a, MO_TEUL) -TRANS(STXFSR, 64, do_stfsr, a, MO_TEUQ) +TRANS(STFSR, ALL, do_stfsr, a, MO_BEUL) +TRANS(STXFSR, 64, do_stfsr, a, MO_BEUQ)static bool do_fc (DisasContext *dc,int rd,int32_t c) { --2.52.0
Re: [PATCH v3 3/9] target/sparc: Replace MO_TE -> MO_BE
In reply to Philippe Mathieu-DaudéQuoted 20 lines · Philippe Mathieu-Daudé
We only build the SPARC targets using big endianness order, therefore the
MO_TEdefinitions expand to the big endian one. Use the latter which is more explicit.Mechanical change running:
$ sed -i -e s/MO_TE/MO_BE/ \ $(git grep -wl MO_TE target/sparc/)Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/sparc/ldst_helper.c | 6 ++-- target/sparc/translate.c | 58 +++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 32 deletions(-)target/sparc/ldst_helper.c +0
-0
target/sparc/ldst_helper.c uint64_t helper_ld_code(CPUSPARCState *env, target_ulong addr, uint32_t oi) · line 1174
Quoted 7 lines
target/sparc/ldst_helper.c +1
-1@@ -1169,7 +1169,7 @@ uint64_t helper_ld_code(CPUSPARCState *env, target_ulong addr, uint32_t oi)break ;case MO_16 : ret =cpu_ldw_code_mmu (env, addr, oi, ra); -if ((mop &MO_BSWAP ) !=MO_TE ) { +if ((mop &MO_BSWAP ) !=MO_BE ) { ret =bswap16 (ret); }
This appears to be a bug in one of the previous changes in this area.
Since the endianness is contained in oi, cpu_ld*_code_mmu has already honored it. Swapping again makes no sense.
Everything outside helper_ld_code looks fine.
r~
PATCH v3 4/9 target/sparc: Use explicit big-endian LD/ST API
In reply to Philippe Mathieu-DaudéThe SPARC architecture uses big endianness. Directly use the big-endian LD/ST API.
Mechanical change running:
$ for a in uw w l q; do \
sed -i -e "s/ld${a}_p(/ld${a}_be_p(/" \
$(git grep -wlE '(ld|st)u?[wlq]_p' target/sparc/);
done--- target/sparc/ldst_helper.c | 36 ++++++++++++++++++------------------ target/sparc/mmu_helper.c | 32 +++++++++++++++++--------------- 2 files changed, 35 insertions(+), 33 deletions(-)
target/sparc/ldst_helper.c +18 -18
@@ -707,17 +707,17 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, MEMTXATTRS_UNSPECIFIED, &result);break ;case 2 : - ret =address_space_lduw (cs->as, access_addr, -MEMTXATTRS_UNSPECIFIED , &result); + ret =address_space_lduw_be (cs->as, access_addr, +MEMTXATTRS_UNSPECIFIED , &result);break ;default :case 4 : - ret =address_space_ldl (cs->as, access_addr, -MEMTXATTRS_UNSPECIFIED , &result); + ret =address_space_ldl_be (cs->as, access_addr, +MEMTXATTRS_UNSPECIFIED , &result);break ;case 8 : - ret =address_space_ldq (cs->as, access_addr, -MEMTXATTRS_UNSPECIFIED , &result); + ret =address_space_ldq_be (cs->as, access_addr, +MEMTXATTRS_UNSPECIFIED , &result);break ; }
@@ -878,10 +878,10 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val,MemTxResult result;hwaddr access_addr = (env->mxccregs[0 ] &0xffffffffULL ) +8 * i; - env->mxccdata[i] =address_space_ldq (cs->as, - access_addr, -MEMTXATTRS_UNSPECIFIED , - &result); + env->mxccdata[i] =address_space_ldq_be (cs->as, + access_addr, +MEMTXATTRS_UNSPECIFIED , + &result);if (result !=MEMTX_OK ) {/* TODO: investigate whether this is the right behaviour */ sparc_raise_mmu_fault(cs, access_addr, false, false,
@@ -906,8 +906,8 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val,MemTxResult result;hwaddr access_addr = (env->mxccregs[1 ] &0xffffffffULL ) +8 * i; -address_space_stq (cs->as, access_addr, env->mxccdata[i], -MEMTXATTRS_UNSPECIFIED , &result); +address_space_stq_be (cs->as, access_addr, env->mxccdata[i], +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {/* TODO: investigate whether this is the right behaviour */
@@ -1072,17 +1072,17 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val, MEMTXATTRS_UNSPECIFIED, &result);break ;case 2 : -address_space_stw (cs->as, access_addr, val, -MEMTXATTRS_UNSPECIFIED , &result); +address_space_stw_be (cs->as, access_addr, val, +MEMTXATTRS_UNSPECIFIED , &result);break ;case 4 :default : -address_space_stl (cs->as, access_addr, val, -MEMTXATTRS_UNSPECIFIED , &result); +address_space_stl_be (cs->as, access_addr, val, +MEMTXATTRS_UNSPECIFIED , &result);break ;case 8 : -address_space_stq (cs->as, access_addr, val, -MEMTXATTRS_UNSPECIFIED , &result); +address_space_stq_be (cs->as, access_addr, val, +MEMTXATTRS_UNSPECIFIED , &result);break ; }if (result !=MEMTX_OK ) {
target/sparc/mmu_helper.c +17 -15
@@ -102,7 +102,8 @@ static int get_physical_address(CPUSPARCState *env, CPUTLBEntryFull *full,/* SPARC reference MMU table walk: Context table->L1->L2->PTE */ /* Context base + context number */ pde_ptr = (env->mmuregs[1 ] <<4 ) + (env->mmuregs[2 ] <<2 ); - pde =address_space_ldl (cs->as, pde_ptr,MEMTXATTRS_UNSPECIFIED , &result); + pde =address_space_ldl_be (cs->as, pde_ptr, +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {return 4 <<2 ;/* Translation fault, L = 0 */ }
@@ -117,8 +118,8 @@ static int get_physical_address(CPUSPARCState *env, CPUTLBEntryFull *full,return 4 <<2 ;case 1 :/* L0 PDE */ pde_ptr = ((address >>22 ) & ~3 ) + ((pde & ~3 ) <<4 ); - pde =address_space_ldl (cs->as, pde_ptr, -MEMTXATTRS_UNSPECIFIED , &result); + pde =address_space_ldl_be (cs->as, pde_ptr, +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {return (1 <<8 ) | (4 <<2 );/* Translation fault, L = 1 */ }
@@ -131,8 +132,8 @@ static int get_physical_address(CPUSPARCState *env, CPUTLBEntryFull *full,return (1 <<8 ) | (4 <<2 );case 1 :/* L1 PDE */ pde_ptr = ((address &0xfc0000 ) >>16 ) + ((pde & ~3 ) <<4 ); - pde =address_space_ldl (cs->as, pde_ptr, -MEMTXATTRS_UNSPECIFIED , &result); + pde =address_space_ldl_be (cs->as, pde_ptr, +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {return (2 <<8 ) | (4 <<2 );/* Translation fault, L = 2 */ }
@@ -145,8 +146,8 @@ static int get_physical_address(CPUSPARCState *env, CPUTLBEntryFull *full,return (2 <<8 ) | (4 <<2 );case 1 :/* L2 PDE */ pde_ptr = ((address &0x3f000 ) >>10 ) + ((pde & ~3 ) <<4 ); - pde =address_space_ldl (cs->as, pde_ptr, -MEMTXATTRS_UNSPECIFIED , &result); + pde =address_space_ldl_be (cs->as, pde_ptr, +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {return (3 <<8 ) | (4 <<2 );/* Translation fault, L = 3 */ }
@@ -189,7 +190,7 @@ static int get_physical_address(CPUSPARCState *env, CPUTLBEntryFull *full,if (is_dirty) { pde |=PG_MODIFIED_MASK ; } -stl_phys (cs->as, pde_ptr, pde); +stl_be_phys (cs->as, pde_ptr, pde); }/* the page can be put in the TLB */
@@ -276,7 +277,8 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulong address, int mmulev)/* Context base + context number */ pde_ptr = (hwaddr)(env->mmuregs[1 ] <<4 ) + (env->mmuregs[2 ] <<2 ); - pde =address_space_ldl (cs->as, pde_ptr,MEMTXATTRS_UNSPECIFIED , &result); + pde =address_space_ldl_be (cs->as, pde_ptr, +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {return 0 ; }
@@ -292,8 +294,8 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulong address, int mmulev)return pde; } pde_ptr = ((address >>22 ) & ~3 ) + ((pde & ~3 ) <<4 ); - pde =address_space_ldl (cs->as, pde_ptr, -MEMTXATTRS_UNSPECIFIED , &result); + pde =address_space_ldl_be (cs->as, pde_ptr, +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {return 0 ; }
@@ -310,8 +312,8 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulong address, int mmulev)return pde; } pde_ptr = ((address &0xfc0000 ) >>16 ) + ((pde & ~3 ) <<4 ); - pde =address_space_ldl (cs->as, pde_ptr, -MEMTXATTRS_UNSPECIFIED , &result); + pde =address_space_ldl_be (cs->as, pde_ptr, +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {return 0 ; }
@@ -328,8 +330,8 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulong address, int mmulev)return pde; } pde_ptr = ((address &0x3f000 ) >>10 ) + ((pde & ~3 ) <<4 ); - pde =address_space_ldl (cs->as, pde_ptr, -MEMTXATTRS_UNSPECIFIED , &result); + pde =address_space_ldl_be (cs->as, pde_ptr, +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {return 0 ; }
Signature · 1 line
2.52.0
Quoted 6 lines · Philippe Mathieu-Daudé
The SPARC architecture uses big endianness. Directly use the big-endian LD/ST API.
Mechanical change running:
Quoted 7 lines
$ for a in uw w l q; do \ sed -i -e "s/ld${a}_p(/ld${a}_be_p(/" \ $(git grep -wlE '(ld|st)u?[wlq]_p' target/sparc/); doneSigned-off-by Philippe Mathieu-Daudé <[email protected]>---
Quoted 184 lines
target/sparc/ldst_helper.c | 36 ++++++++++++++++++------------------ target/sparc/mmu_helper.c | 32 +++++++++++++++++--------------- 2 files changed, 35 insertions(+), 33 deletions(-)target/sparc/ldst_helper.c +18
-18@@ -707,17 +707,17 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, MEMTXATTRS_UNSPECIFIED, &result);break ;case 2 : - ret =address_space_lduw (cs->as, access_addr, -MEMTXATTRS_UNSPECIFIED , &result); + ret =address_space_lduw_be (cs->as, access_addr, +MEMTXATTRS_UNSPECIFIED , &result);break ;default :case 4 : - ret =address_space_ldl (cs->as, access_addr, -MEMTXATTRS_UNSPECIFIED , &result); + ret =address_space_ldl_be (cs->as, access_addr, +MEMTXATTRS_UNSPECIFIED , &result);break ;case 8 : - ret =address_space_ldq (cs->as, access_addr, -MEMTXATTRS_UNSPECIFIED , &result); + ret =address_space_ldq_be (cs->as, access_addr, +MEMTXATTRS_UNSPECIFIED , &result);break ; }@@ -878,10 +878,10 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val,MemTxResult result;hwaddr access_addr = (env->mxccregs[0 ] &0xffffffffULL ) +8 * i; - env->mxccdata[i] =address_space_ldq (cs->as, - access_addr, -MEMTXATTRS_UNSPECIFIED , - &result); + env->mxccdata[i] =address_space_ldq_be (cs->as, + access_addr, +MEMTXATTRS_UNSPECIFIED , + &result);if (result !=MEMTX_OK ) {/* TODO: investigate whether this is the right behaviour */ sparc_raise_mmu_fault(cs, access_addr, false, false,@@ -906,8 +906,8 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val,MemTxResult result;hwaddr access_addr = (env->mxccregs[1 ] &0xffffffffULL ) +8 * i; -address_space_stq (cs->as, access_addr, env->mxccdata[i], -MEMTXATTRS_UNSPECIFIED , &result); +address_space_stq_be (cs->as, access_addr, env->mxccdata[i], +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {/* TODO: investigate whether this is the right behaviour */ @@ -1072,17 +1072,17 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, uint64_t val, MEMTXATTRS_UNSPECIFIED, &result);break ;case 2 : -address_space_stw (cs->as, access_addr, val, -MEMTXATTRS_UNSPECIFIED , &result); +address_space_stw_be (cs->as, access_addr, val, +MEMTXATTRS_UNSPECIFIED , &result);break ;case 4 :default : -address_space_stl (cs->as, access_addr, val, -MEMTXATTRS_UNSPECIFIED , &result); +address_space_stl_be (cs->as, access_addr, val, +MEMTXATTRS_UNSPECIFIED , &result);break ;case 8 : -address_space_stq (cs->as, access_addr, val, -MEMTXATTRS_UNSPECIFIED , &result); +address_space_stq_be (cs->as, access_addr, val, +MEMTXATTRS_UNSPECIFIED , &result);break ; }if (result !=MEMTX_OK ) {target/sparc/mmu_helper.c +17
-16@@ -102,7 +102,8 @@ static int get_physical_address(CPUSPARCState *env, CPUTLBEntryFull *full,/* SPARC reference MMU table walk: Context table->L1->L2->PTE */ /* Context base + context number */ pde_ptr = (env->mmuregs[1 ] <<4 ) + (env->mmuregs[2 ] <<2 ); - pde =address_space_ldl (cs->as, pde_ptr,MEMTXATTRS_UNSPECIFIED , &result); + pde =address_space_ldl_be (cs->as, pde_ptr, +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {return 4 <<2 ;/* Translation fault, L = 0 */ }@@ -117,8 +118,8 @@ static int get_physical_address(CPUSPARCState *env, CPUTLBEntryFull *full,return 4 <<2 ;case 1 :/* L0 PDE */ pde_ptr = ((address >>22 ) & ~3 ) + ((pde & ~3 ) <<4 ); - pde =address_space_ldl (cs->as, pde_ptr, -MEMTXATTRS_UNSPECIFIED , &result); + pde =address_space_ldl_be (cs->as, pde_ptr, +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {return (1 <<8 ) | (4 <<2 );/* Translation fault, L = 1 */ }@@ -131,8 +132,8 @@ static int get_physical_address(CPUSPARCState *env, CPUTLBEntryFull *full,return (1 <<8 ) | (4 <<2 );case 1 :/* L1 PDE */ pde_ptr = ((address &0xfc0000 ) >>16 ) + ((pde & ~3 ) <<4 ); - pde =address_space_ldl (cs->as, pde_ptr, -MEMTXATTRS_UNSPECIFIED , &result); + pde =address_space_ldl_be (cs->as, pde_ptr, +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {return (2 <<8 ) | (4 <<2 );/* Translation fault, L = 2 */ }@@ -145,8 +146,8 @@ static int get_physical_address(CPUSPARCState *env, CPUTLBEntryFull *full,return (2 <<8 ) | (4 <<2 );case 1 :/* L2 PDE */ pde_ptr = ((address &0x3f000 ) >>10 ) + ((pde & ~3 ) <<4 ); - pde =address_space_ldl (cs->as, pde_ptr, -MEMTXATTRS_UNSPECIFIED , &result); + pde =address_space_ldl_be (cs->as, pde_ptr, +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {return (3 <<8 ) | (4 <<2 );/* Translation fault, L = 3 */ }@@ -189,7 +190,7 @@ static int get_physical_address(CPUSPARCState *env, CPUTLBEntryFull *full,if (is_dirty) { pde |=PG_MODIFIED_MASK ; } -stl_phys (cs->as, pde_ptr, pde); +stl_be_phys (cs->as, pde_ptr, pde); }/* the page can be put in the TLB */ @@ -276,7 +277,8 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulong address, int mmulev)/* Context base + context number */ pde_ptr = (hwaddr)(env->mmuregs[1 ] <<4 ) + (env->mmuregs[2 ] <<2 ); - pde =address_space_ldl (cs->as, pde_ptr,MEMTXATTRS_UNSPECIFIED , &result); + pde =address_space_ldl_be (cs->as, pde_ptr, +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {return 0 ; }@@ -292,8 +294,8 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulong address, int mmulev)return pde; } pde_ptr = ((address >>22 ) & ~3 ) + ((pde & ~3 ) <<4 ); - pde =address_space_ldl (cs->as, pde_ptr, -MEMTXATTRS_UNSPECIFIED , &result); + pde =address_space_ldl_be (cs->as, pde_ptr, +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {return 0 ; }@@ -310,8 +312,8 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulong address, int mmulev)return pde; } pde_ptr = ((address &0xfc0000 ) >>16 ) + ((pde & ~3 ) <<4 ); - pde =address_space_ldl (cs->as, pde_ptr, -MEMTXATTRS_UNSPECIFIED , &result); + pde =address_space_ldl_be (cs->as, pde_ptr, +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {return 0 ; }@@ -328,8 +330,8 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulong address, int mmulev)return pde; } pde_ptr = ((address &0x3f000 ) >>10 ) + ((pde & ~3 ) <<4 ); - pde =address_space_ldl (cs->as, pde_ptr, -MEMTXATTRS_UNSPECIFIED , &result); + pde =address_space_ldl_be (cs->as, pde_ptr, +MEMTXATTRS_UNSPECIFIED , &result);if (result !=MEMTX_OK ) {return 0 ; } --2.52.0
Quoted 10 lines · Philippe Mathieu-Daudé
The SPARC architecture uses big endianness. Directly use the big-endian LD/ST API.
Mechanical change running:
$ for a in uw w l q; do \ sed -i -e "s/ld${a}_p(/ld${a}_be_p(/" \ $(git grep -wlE '(ld|st)u?[wlq]_p' target/sparc/); done
Quoted 5 lines
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/sparc/ldst_helper.c | 36 ++++++++++++++++++------------------ target/sparc/mmu_helper.c | 32 +++++++++++++++++--------------- 2 files changed, 35 insertions(+), 33 deletions(-)
r~
PATCH v3 5/9 target/sparc: Use big-endian variant of cpu_ld/st_data*()
In reply to Philippe Mathieu-DaudéWe only build the SPARC targets using big endianness order, therefore the cpu_ld/st_data*() definitions expand to the big endian declarations. Use the explicit big-endian variants.
Mechanical change running:
$ tgt=sparc; \
end=be; \
for op in data mmuidx_ra; do \
for ac in uw sw l q; do \
sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \
$(git grep -l cpu_ target/${tgt}/); \
done;
for ac in w l q; do \
sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \
$(git grep -l cpu_ target/${tgt}/); \
done;
done--- target/sparc/ldst_helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
target/sparc/ldst_helper.c +3 -3
@@ -1228,13 +1228,13 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, ret =cpu_ldub_data (env, addr);break ;case 2 : - ret =cpu_lduw_data (env, addr); + ret =cpu_lduw_be_data (env, addr);break ;case 4 : - ret =cpu_ldl_data (env, addr); + ret =cpu_ldl_be_data (env, addr);break ;case 8 : - ret =cpu_ldq_data (env, addr); + ret =cpu_ldq_be_data (env, addr);break ;default :g_assert_not_reached ();
Signature · 1 line
2.52.0
Re: [PATCH v3 5/9] target/sparc: Use big-endian variant of cpu_ld/st_data*()
Quoted 20 lines · Philippe Mathieu-Daudé
We only build the SPARC targets using big endianness order, therefore the cpu_ld/st_data*() definitions expand to the big endian declarations. Use the explicit big-endian variants.
Mechanical change running:
$ tgt=sparc; \ end=be; \ for op in data mmuidx_ra; do \ for ac in uw sw l q; do \ sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \ $(git grep -l cpu_ target/${tgt}/); \ done; for ac in w l q; do \ sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \ $(git grep -l cpu_ target/${tgt}/); \ done; done
Quoted 3 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Richard Henderson <[email protected]>---
Quoted 27 lines
target/sparc/ldst_helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)target/sparc/ldst_helper.c +3
-4@@ -1228,13 +1228,13 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, ret =cpu_ldub_data (env, addr);break ;case 2 : - ret =cpu_lduw_data (env, addr); + ret =cpu_lduw_be_data (env, addr);break ;case 4 : - ret =cpu_ldl_data (env, addr); + ret =cpu_ldl_be_data (env, addr);break ;case 8 : - ret =cpu_ldq_data (env, addr); + ret =cpu_ldq_be_data (env, addr);break ;default :g_assert_not_reached (); --2.52.0
Re: [PATCH v3 5/9] target/sparc: Use big-endian variant of cpu_ld/st_data*()
In reply to Philippe Mathieu-DaudéQuoted 19 lines · Philippe Mathieu-Daudé
We only build the SPARC targets using big endianness order, therefore the cpu_ld/st_data*() definitions expand to the big endian declarations. Use the explicit big-endian variants.
Mechanical change running:
$ tgt=sparc; \ end=be; \ for op in data mmuidx_ra; do \ for ac in uw sw l q; do \ sed -i -e "s/cpu_ld${ac}_${op}/cpu_ld${ac}_${end}_${op}/" \ $(git grep -l cpu_ target/${tgt}/); \ done; for ac in w l q; do \ sed -i -e "s/cpu_st${ac}_${op}/cpu_st${ac}_${end}_${op}/" \ $(git grep -l cpu_ target/${tgt}/); \ done; done
Quoted 5 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- target/sparc/ldst_helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
FWIW, this function could be re-organized to use cpu_ld*_mmu, to avoid the explicit BE load followed by an explicit bswap, for the little-endian ASIs.
r~
Quoted 22 lines
target/sparc/ldst_helper.c +3
-3@@ -1228,13 +1228,13 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr, ret =cpu_ldub_data (env, addr);break ;case 2 : - ret =cpu_lduw_data (env, addr); + ret =cpu_lduw_be_data (env, addr);break ;case 4 : - ret =cpu_ldl_data (env, addr); + ret =cpu_ldl_be_data (env, addr);break ;case 8 : - ret =cpu_ldq_data (env, addr); + ret =cpu_ldq_be_data (env, addr);break ;default :g_assert_not_reached ();
PATCH v3 6/9 target/sparc: Inline translator_ldl()
In reply to Philippe Mathieu-Daudétranslator_ldl() is defined in "exec/translator.h" as:
198 static inline uint32_t
199 translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc)
200 {
201 return translator_ldl_end(env, db, pc, MO_TE);
202 }Directly use the inlined form, expanding MO_TE -> MO_BE since we only build the SPARC targets as big-endian.
--- target/sparc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/sparc/translate.c +1 -1
@@ -5743,7 +5743,7 @@ static void sparc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)DisasContext *dc =container_of (dcbase, DisasContext, base);unsigned int insn; - insn =translator_ldl (cpu_env (cs), &dc->base, dc->pc); + insn =translator_ldl_end (cpu_env (cs), &dc->base, dc->pc,MO_BE ); dc->base.pc_next +=4 ;if (!decode (dc, insn)) {
Signature · 1 line
2.52.0
Re: [PATCH v3 6/9] target/sparc: Inline translator_ldl()
Quoted 9 lines · Philippe Mathieu-Daudé
translator_ldl()is defined in "exec/translator.h" as:198 static inline uint32_t 199 translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc) 200 { 201 return translator_ldl_end(env, db, pc, MO_TE); 202 }
Quoted 5 lines
Directly use the inlined form, expanding
MO_TE->MO_BEsince we only build the SPARC targets as big-endian.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Quoted 19 lines
target/sparc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/sparc/translate.c +1
-2@@ -5743,7 +5743,7 @@ static void sparc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)DisasContext *dc =container_of (dcbase, DisasContext, base);unsigned int insn; - insn =translator_ldl (cpu_env (cs), &dc->base, dc->pc); + insn =translator_ldl_end (cpu_env (cs), &dc->base, dc->pc,MO_BE ); dc->base.pc_next +=4 ;if (!decode (dc, insn)) { --2.52.0
Re: [PATCH v3 6/9] target/sparc: Inline translator_ldl()
In reply to Philippe Mathieu-DaudéQuoted 8 lines · Philippe Mathieu-Daudé
translator_ldl()is defined in "exec/translator.h" as:198 static inline uint32_t 199 translator_ldl(CPUArchState *env, DisasContextBase *db, vaddr pc) 200 { 201 return translator_ldl_end(env, db, pc, MO_TE); 202 }
Quoted 7 lines
Directly use the inlined form, expanding
MO_TE->MO_BEsince we only build the SPARC targets as big-endian.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/sparc/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
r~
PATCH v3 7/9 target/sparc: Inline cpu_ldl_code() call in cpu_do_interrupt()
In reply to Philippe Mathieu-DaudéIn preparation of removing the cpu_ldl_code wrapper, inline it.
Since SPARC instructions are always stored in big-endian order, replace MO_TE -> MO_BE.
--- target/sparc/int32_helper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
target/sparc/int32_helper.c +3 -1
@@ -149,9 +149,11 @@ void sparc_cpu_do_interrupt(CPUState *cs)* mimic delayed trap delivery as if by the subsequent insn. */ if (!env->fsr_qne) { +MemOpIdx oi =make_memop_idx (MO_BEUL ,cpu_mmu_index (cs, true)); + env->fsr_qne =FSR_QNE ; env->fq.s.addr = env->pc; - env->fq.s.insn =cpu_ldl_code (env, env->pc); + env->fq.s.insn =cpu_ldl_code_mmu (env, env->pc, oi,0 ); } env->pc = env->npc; env->npc = env->npc +4 ;
Signature · 1 line
2.52.0
Re: [PATCH v3 7/9] target/sparc: Inline cpu_ldl_code() call in cpu_do_interrupt()
Quoted 8 lines · Philippe Mathieu-Daudé
In preparation of removing the
cpu_ldl_codewrapper, inline it.Since SPARC instructions are always stored in big-endian order, replace
MO_TE->MO_BE.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Quoted 23 lines
target/sparc/int32_helper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)target/sparc/int32_helper.c +3
-2@@ -149,9 +149,11 @@ void sparc_cpu_do_interrupt(CPUState *cs)* mimic delayed trap delivery as if by the subsequent insn. */ if (!env->fsr_qne) { +MemOpIdx oi =make_memop_idx (MO_BEUL ,cpu_mmu_index (cs, true)); + env->fsr_qne =FSR_QNE ; env->fq.s.addr = env->pc; - env->fq.s.insn =cpu_ldl_code (env, env->pc); + env->fq.s.insn =cpu_ldl_code_mmu (env, env->pc, oi,0 ); } env->pc = env->npc; env->npc = env->npc +4 ; --2.52.0
Re: [PATCH v3 7/9] target/sparc: Inline cpu_ldl_code() call in cpu_do_interrupt()
In reply to Philippe Mathieu-DaudéQuoted 9 lines · Philippe Mathieu-Daudé
In preparation of removing the
cpu_ldl_codewrapper, inline it.Since SPARC instructions are always stored in big-endian order, replace
MO_TE->MO_BE.Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- target/sparc/int32_helper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
r~
PATCH v3 8/9 target/sparc: Simplify gdbstub sparc_cpu_gdb_write_register()
In reply to Philippe Mathieu-DaudéRather than ldtul_p() which uses the underlying 'unsigned long' size, use the ldn() variant, passing the access size as argument (evaluating TARGET_LONG_BITS / 8).
No need to use #ifdef'ry to check for TARGET_ABI32, since it is 64-bit:
$ git grep -E '(ABI32|LONG_BITS)' configs/targets/sparc* configs/targets/sparc-linux-user.mak:5:TARGET_LONG_BITS=32 configs/targets/sparc-softmmu.mak:4:TARGET_LONG_BITS=32 configs/targets/sparc32plus-linux-user.mak:2:TARGET_ABI32=y configs/targets/sparc32plus-linux-user.mak:8:TARGET_LONG_BITS=64 configs/targets/sparc64-linux-user.mak:8:TARGET_LONG_BITS=64 configs/targets/sparc64-softmmu.mak:6:TARGET_LONG_BITS=64
Directly expand to the big-endian variant (with the '_be' suffix) since we only build the SPARC targets as big-endian.
--- target/sparc/gdbstub.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
target/sparc/gdbstub.c +2 -10
@@ -112,15 +112,7 @@ int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) {SPARCCPU *cpu =SPARC_CPU (cs);CPUSPARCState *env = &cpu->env; -#if defined(TARGET_ABI32 ) -uint32_t tmp; - - tmp =ldl_p (mem_buf); -#else -target_ulong tmp; - - tmp =ldtul_p (mem_buf); -#endif +uint64_t tmp =ldn_be_p (mem_buf,TARGET_LONG_BITS /8 );if (n <8 ) {/* g0..g7 */
@@ -170,7 +162,7 @@ int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)#else else if (n < 64) {/* f0-f31 */ - tmp =ldl_p (mem_buf); + tmp =ldl_be_p (mem_buf);if (n &1 ) { env->fpr[(n -32 ) /2 ].l.lower = tmp; }else {
Signature · 1 line
2.52.0
Re: [PATCH v3 8/9] target/sparc: Simplify gdbstub sparc_cpu_gdb_write_register()
Quoted 16 lines · Philippe Mathieu-Daudé
Rather than
ldtul_p()which uses the underlying 'unsigned long' size, use theldn()variant, passing the access size as argument (evaluatingTARGET_LONG_BITS/ 8).No need to use #ifdef'ry to check for
TARGET_ABI32, since it is 64-bit:$ git grep -E '(ABI32|LONG_BITS)' configs/targets/sparc* configs/targets/sparc-linux-user.mak:5:TARGET_LONG_BITS=32 configs/targets/sparc-softmmu.mak:4:TARGET_LONG_BITS=32 configs/targets/sparc32plus-linux-user.mak:2:TARGET_ABI32=y configs/targets/sparc32plus-linux-user.mak:8:TARGET_LONG_BITS=64 configs/targets/sparc64-linux-user.mak:8:TARGET_LONG_BITS=64 configs/targets/sparc64-softmmu.mak:6:TARGET_LONG_BITS=64
Quoted 5 lines
Directly expand to the big-endian variant (with the '
_be' suffix) since we only build the SPARC targets as big-endian.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Quoted 36 lines
target/sparc/gdbstub.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)target/sparc/gdbstub.c +2
-11@@ -112,15 +112,7 @@ int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) {SPARCCPU *cpu =SPARC_CPU (cs);CPUSPARCState *env = &cpu->env; -#if defined(TARGET_ABI32 ) -uint32_t tmp; - - tmp =ldl_p (mem_buf); -#else -target_ulong tmp; - - tmp =ldtul_p (mem_buf); -#endif +uint64_t tmp =ldn_be_p (mem_buf,TARGET_LONG_BITS /8 );if (n <8 ) {/* g0..g7 */ @@ -170,7 +162,7 @@ int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)#else else if (n < 64) {/* f0-f31 */ - tmp =ldl_p (mem_buf); + tmp =ldl_be_p (mem_buf);if (n &1 ) { env->fpr[(n -32 ) /2 ].l.lower = tmp; }else { --2.52.0
Re: [PATCH v3 8/9] target/sparc: Simplify gdbstub sparc_cpu_gdb_write_register()
In reply to Philippe Mathieu-DaudéQuoted 31 lines · Philippe Mathieu-Daudé
Rather than
ldtul_p()which uses the underlying 'unsigned long' size, use theldn()variant, passing the access size as argument (evaluatingTARGET_LONG_BITS/ 8).No need to use #ifdef'ry to check for
TARGET_ABI32, since it is 64-bit:$ git grep -E '(ABI32|LONG_BITS)' configs/targets/sparc* configs/targets/sparc-linux-user.mak:5:TARGET_LONG_BITS=32 configs/targets/sparc-softmmu.mak:4:TARGET_LONG_BITS=32 configs/targets/sparc32plus-linux-user.mak:2:TARGET_ABI32=y configs/targets/sparc32plus-linux-user.mak:8:TARGET_LONG_BITS=64 configs/targets/sparc64-linux-user.mak:8:TARGET_LONG_BITS=64 configs/targets/sparc64-softmmu.mak:6:TARGET_LONG_BITS=64Directly expand to the big-endian variant (with the '
_be' suffix) since we only build the SPARC targets as big-endian.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/sparc/gdbstub.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)target/sparc/gdbstub.c +0
-0@@ -112,15 +112,7 @@ int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) {SPARCCPU *cpu =SPARC_CPU (cs);CPUSPARCState *env = &cpu->env;
target/sparc/gdbstub.c int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) · line 115
Quoted 10 lines
target/sparc/gdbstub.c +1
-9-#if defined(TARGET_ABI32 ) -uint32_t tmp; - - tmp =ldl_p (mem_buf); -#else -target_ulong tmp; - - tmp =ldtul_p (mem_buf); -#endif +uint64_t tmp =ldn_be_p (mem_buf,TARGET_LONG_BITS /8 );
No, this changes the behaviour of sparc32plus.
r~
Re: [PATCH v3 8/9] target/sparc: Simplify gdbstub sparc_cpu_gdb_write_register()
Quoted 37 lines · Richard Henderson
Quoted 36 lines · Philippe Mathieu-Daudé
Rather than
ldtul_p()which uses the underlying 'unsigned long' size, use theldn()variant, passing the access size as argument (evaluatingTARGET_LONG_BITS/ 8).No need to use #ifdef'ry to check for
TARGET_ABI32, since it is 64-bit:$ git grep -E '(ABI32|LONG_BITS)' configs/targets/sparc* configs/targets/sparc-linux-user.mak:5:TARGET_LONG_BITS=32 configs/targets/sparc-softmmu.mak:4:TARGET_LONG_BITS=32 configs/targets/sparc32plus-linux-user.mak:2:TARGET_ABI32=y configs/targets/sparc32plus-linux-user.mak:8:TARGET_LONG_BITS=64 configs/targets/sparc64-linux-user.mak:8:TARGET_LONG_BITS=64 configs/targets/sparc64-softmmu.mak:6:TARGET_LONG_BITS=64Directly expand to the big-endian variant (with the '
_be' suffix) since we only build the SPARC targets as big-endian.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
target/sparc/gdbstub.c| 12 ++----------1 file changed, 2 insertions(+), 10 deletions(-)target/sparc/gdbstub.c +0
-4@@ -112,15 +112,7 @@ int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = &cpu->env; -#if defined(TARGET_ABI32 ) - uint32_t tmp; - - tmp = ldl_p(mem_buf);
Quoted 8 lines
target/sparc/gdbstub.c int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) · line 115
Quoted 6 lines
target/sparc/gdbstub.c +1
-5-#else - target_ulong tmp; - - tmp = ldtul_p(mem_buf); -#endif + uint64_t tmp = ldn_be_p(mem_buf, TARGET_LONG_BITS / 8);No, this changes the behaviour of sparc32plus.
$ git grep TARGET_ABI32 configs/targets/sparc* configs/targets/sparc32plus-linux-user.mak:2:TARGET_ABI32=y
$ cat configs/targets/sparc32plus-linux-user.mak TARGET_ABI32=y TARGET_BIG_ENDIAN=y TARGET_LONG_BITS=64
Isn't it the same?
Re: [PATCH v3 8/9] target/sparc: Simplify gdbstub sparc_cpu_gdb_write_register()
Quoted 50 lines · Philippe Mathieu-Daudé
Quoted 37 lines · Richard Henderson
Quoted 36 lines · Philippe Mathieu-Daudé
Rather than
ldtul_p()which uses the underlying 'unsigned long' size, use theldn()variant, passing the access size as argument (evaluatingTARGET_LONG_BITS/ 8).No need to use #ifdef'ry to check for
TARGET_ABI32, since it is 64-bit:$ git grep -E '(ABI32|LONG_BITS)' configs/targets/sparc* configs/targets/sparc-linux-user.mak:5:TARGET_LONG_BITS=32 configs/targets/sparc-softmmu.mak:4:TARGET_LONG_BITS=32 configs/targets/sparc32plus-linux-user.mak:2:TARGET_ABI32=y configs/targets/sparc32plus-linux-user.mak:8:TARGET_LONG_BITS=64 configs/targets/sparc64-linux-user.mak:8:TARGET_LONG_BITS=64 configs/targets/sparc64-softmmu.mak:6:TARGET_LONG_BITS=64Directly expand to the big-endian variant (with the '
_be' suffix) since we only build the SPARC targets as big-endian.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
target/sparc/gdbstub.c| 12 ++----------1 file changed, 2 insertions(+), 10 deletions(-)target/sparc/gdbstub.c +0
-4@@ -112,15 +112,7 @@ int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = &cpu->env; -#if defined(TARGET_ABI32 ) - uint32_t tmp; - - tmp = ldl_p(mem_buf);Quoted 8 lines
target/sparc/gdbstub.c int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) · line 115
Quoted 6 lines
target/sparc/gdbstub.c +1
-5-#else - target_ulong tmp; - - tmp = ldtul_p(mem_buf); -#endif + uint64_t tmp = ldn_be_p(mem_buf, TARGET_LONG_BITS / 8);No, this changes the behaviour of sparc32plus.
$ git grep TARGET_ABI32 configs/targets/sparc* configs/targets/sparc32plus-linux-user.mak:2:TARGET_ABI32=y
Quoted 6 lines
$ cat configs/targets/sparc32plus-linux-user.mak TARGET_ABI32=y TARGET_BIG_ENDIAN=y TARGET_LONG_BITS=64Isn't it the same?
No. ABI32 uses uint32_t, not uint64_t, even with 64-bit registers.
Which is probably functionally broken, because, history.
r~
Re: [PATCH v3 8/9] target/sparc: Simplify gdbstub sparc_cpu_gdb_write_register()
Quoted 51 lines · Richard Henderson
Quoted 50 lines · Philippe Mathieu-Daudé
Quoted 37 lines · Richard Henderson
Quoted 36 lines · Philippe Mathieu-Daudé
Rather than
ldtul_p()which uses the underlying 'unsigned long' size, use theldn()variant, passing the access size as argument (evaluatingTARGET_LONG_BITS/ 8).No need to use #ifdef'ry to check for
TARGET_ABI32, since it is 64-bit:$ git grep -E '(ABI32|LONG_BITS)' configs/targets/sparc* configs/targets/sparc-linux-user.mak:5:TARGET_LONG_BITS=32 configs/targets/sparc-softmmu.mak:4:TARGET_LONG_BITS=32 configs/targets/sparc32plus-linux-user.mak:2:TARGET_ABI32=y configs/targets/sparc32plus-linux-user.mak:8:TARGET_LONG_BITS=64 configs/targets/sparc64-linux-user.mak:8:TARGET_LONG_BITS=64 configs/targets/sparc64-softmmu.mak:6:TARGET_LONG_BITS=64Directly expand to the big-endian variant (with the '
_be' suffix) since we only build the SPARC targets as big-endian.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
target/sparc/gdbstub.c| 12 ++----------1 file changed, 2 insertions(+), 10 deletions(-)target/sparc/gdbstub.c +0
-4@@ -112,15 +112,7 @@ int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) { SPARCCPU *cpu = SPARC_CPU(cs); CPUSPARCState *env = &cpu->env; -#if defined(TARGET_ABI32 ) - uint32_t tmp; - - tmp = ldl_p(mem_buf);Quoted 8 lines
target/sparc/gdbstub.c int sparc_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) · line 115
Quoted 6 lines
target/sparc/gdbstub.c +1
-5-#else - target_ulong tmp; - - tmp = ldtul_p(mem_buf); -#endif + uint64_t tmp = ldn_be_p(mem_buf, TARGET_LONG_BITS / 8);No, this changes the behaviour of sparc32plus.
$ git grep TARGET_ABI32 configs/targets/sparc* configs/targets/sparc32plus-linux-user.mak:2:TARGET_ABI32=y
Quoted 8 lines
Quoted 6 lines
$ cat configs/targets/sparc32plus-linux-user.mak TARGET_ABI32=y TARGET_BIG_ENDIAN=y TARGET_LONG_BITS=64Isn't it the same?
No. ABI32 uses
uint32_t, notuint64_t, even with 64-bit registers.
Oh right, I missed that.
Quoted 1 line
Which is probably functionally broken, because, history.
And still we maintain it...
PATCH v3 9/9 configs/targets: Forbid SPARC to use legacy native endianness APIs
In reply to Philippe Mathieu-DaudéAll SPARC-related binaries are buildable without a single use of the legacy "native endian" API. Unset the transitional TARGET_USE_LEGACY_NATIVE_ENDIAN_API definition to forbid further uses of the legacy API.
--- configs/targets/sparc-linux-user.mak | 1 + configs/targets/sparc-softmmu.mak | 1 + configs/targets/sparc32plus-linux-user.mak | 1 + configs/targets/sparc64-linux-user.mak | 1 + configs/targets/sparc64-softmmu.mak | 1 + 5 files changed, 5 insertions(+)
configs/targets/sparc-linux-user.mak +1 -0
@@ -3,3 +3,4 @@ TARGET_SYSTBL_ABI=common,32 TARGET_SYSTBL=syscall.tbl TARGET_BIG_ENDIAN=y TARGET_LONG_BITS=32 +TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
configs/targets/sparc-softmmu.mak +1 -0
@@ -1,3 +1,4 @@ TARGET_ARCH=sparc TARGET_BIG_ENDIAN=y TARGET_LONG_BITS=32 +TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
configs/targets/sparc32plus-linux-user.mak +1 -0
@@ -6,3 +6,4 @@ TARGET_SYSTBL_ABI=common,32 TARGET_SYSTBL=syscall.tbl TARGET_BIG_ENDIAN=y TARGET_LONG_BITS=64 +TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
configs/targets/sparc64-linux-user.mak +1 -0
@@ -6,3 +6,4 @@ TARGET_SYSTBL=syscall.tbl TARGET_BIG_ENDIAN=y TARGET_XML_FILES=gdb-xml/sparc64-core.xml TARGET_LONG_BITS=64 +TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
configs/targets/sparc64-softmmu.mak +1 -0
@@ -4,3 +4,4 @@ TARGET_BIG_ENDIAN=y TARGET_XML_FILES=gdb-xml/sparc64-core.xml TARGET_LONG_BITS=64 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y +TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y
Signature · 1 line
2.52.0
Re: [PATCH v3 9/9] configs/targets: Forbid SPARC to use legacy native endianness APIs
Quoted 8 lines · Philippe Mathieu-Daudé
All SPARC-related binaries are buildable without a single use of the legacy "native endian" API. Unset the transitional
TARGET_USE_LEGACY_NATIVE_ENDIAN_APIdefinition to forbid further uses of the legacy API.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Quoted 55 lines
configs/targets/sparc-linux-user.mak | 1 + configs/targets/sparc-softmmu.mak | 1 + configs/targets/sparc32plus-linux-user.mak | 1 + configs/targets/sparc64-linux-user.mak | 1 + configs/targets/sparc64-softmmu.mak | 1 + 5 files changed, 5 insertions(+)configs/targets/sparc-linux-user.mak +1
-0@@ -3,3 +3,4 @@ TARGET_SYSTBL_ABI=common,32 TARGET_SYSTBL=syscall.tbl TARGET_BIG_ENDIAN=y TARGET_LONG_BITS=32 +TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=yconfigs/targets/sparc-softmmu.mak +1
-0@@ -1,3 +1,4 @@ TARGET_ARCH=sparc TARGET_BIG_ENDIAN=y TARGET_LONG_BITS=32 +TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=yconfigs/targets/sparc32plus-linux-user.mak +1
-0@@ -6,3 +6,4 @@ TARGET_SYSTBL_ABI=common,32 TARGET_SYSTBL=syscall.tbl TARGET_BIG_ENDIAN=y TARGET_LONG_BITS=64 +TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=yconfigs/targets/sparc64-linux-user.mak +1
-0@@ -6,3 +6,4 @@ TARGET_SYSTBL=syscall.tbl TARGET_BIG_ENDIAN=y TARGET_XML_FILES=gdb-xml/sparc64-core.xml TARGET_LONG_BITS=64 +TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=yconfigs/targets/sparc64-softmmu.mak +1
-1@@ -4,3 +4,4 @@ TARGET_BIG_ENDIAN=y TARGET_XML_FILES=gdb-xml/sparc64-core.xml TARGET_LONG_BITS=64 TARGET_NOT_USING_LEGACY_LDST_PHYS_API=y +TARGET_NOT_USING_LEGACY_NATIVE_ENDIAN_API=y --2.52.0
Re: [PATCH v3 9/9] configs/targets: Forbid SPARC to use legacy native endianness APIs
In reply to Philippe Mathieu-DaudéQuoted 5 lines · Philippe Mathieu-Daudé
All SPARC-related binaries are buildable without a single use of the legacy "native endian" API. Unset the transitional
TARGET_USE_LEGACY_NATIVE_ENDIAN_APIdefinition to forbid further uses of the legacy API.
Quoted 8 lines
Signed-off-by Philippe Mathieu-Daudé<[email protected]>--- configs/targets/sparc-linux-user.mak | 1 + configs/targets/sparc-softmmu.mak | 1 + configs/targets/sparc32plus-linux-user.mak | 1 + configs/targets/sparc64-linux-user.mak | 1 + configs/targets/sparc64-softmmu.mak | 1 + 5 files changed, 5 insertions(+)
r~