target-arm queue
Subsystems (4)
[PULL 01/36] hw/intc/armv7m_nvic: Rebuild hflags on reset
In reply to Peter MaydellSome of an M-profile CPU's cached hflags state depends on state that's in our NVIC object. We already do an hflags rebuild when the NVIC registers are written, but we also need to do this on NVIC reset, because there's no guarantee that this will happen before the CPU reset.
This fixes an assertion due to mismatched hflags which happens if the CPU is reset from inside a HardFault handler.
Message-id: [email protected]
--- hw/intc/armv7m_nvic.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/intc/armv7m_nvic.c +6 -0
@@ -2593,6 +2593,12 @@ static void armv7m_nvic_reset(DeviceState *dev) s->itns[i] = true; } } + +/* +* We updated state that affects the CPU's MMUidx and thus its hflags; +* and we can't guarantee that we run before the CPU reset function. +*/ +arm_rebuild_hflags (&s->cpu->env); }static void nvic_systick_trigger (void *opaque,int n,int level)
Signature · 1 line
2.20.1
[PULL 02/36] target/arm: Update hflags in trans_CPS_v7m()
In reply to Peter MaydellFor M-profile CPUs, the FAULTMASK value affects the CPU's MMU index (it changes the NegPri bit). We update the hflags after calls to the v7m_msr helper in trans_MSR_v7m() but forgot to do so in trans_CPS_v7m().
Message-id: [email protected]
--- target/arm/translate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
target/arm/translate.c +4 -1
@@ -10590,7 +10590,7 @@ static bool trans_CPS(DisasContext *s, arg_CPS *a)static bool trans_CPS_v7m (DisasContext *s,arg_CPS_v7m *a) { -TCGv_i32 tmp, addr; +TCGv_i32 tmp, addr, el;if (!arm_dc_feature (s,ARM_FEATURE_M )) {return false;
@@ -10613,6 +10613,9 @@ static bool trans_CPS_v7m(DisasContext *s, arg_CPS_v7m *a)gen_helper_v7m_msr (cpu_env, addr, tmp);tcg_temp_free_i32 (addr); } + el =tcg_const_i32 (s->current_el); +gen_helper_rebuild_hflags_m32 (cpu_env, el); +tcg_temp_free_i32 (el);tcg_temp_free_i32 (tmp);gen_lookup_tb (s);return true;
Signature · 1 line
2.20.1
[PULL 05/36] aspeed/smc: Add some tracing
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
Message-id: [email protected]
--- Makefile.objs | 1 + hw/ssi/aspeed_smc.c | 17 +++++++++++++++++ hw/ssi/trace-events | 9 +++++++++ 3 files changed, 27 insertions(+) create mode 100644 hw/ssi/trace-events
Makefile.objs +1 -0
@@ -175,6 +175,7 @@ trace-events-subdirs += hw/scsi trace-events-subdirs += hw/sd trace-events-subdirs += hw/sparc trace-events-subdirs += hw/sparc64 +trace-events-subdirs += hw/ssi trace-events-subdirs += hw/timer trace-events-subdirs += hw/tpm trace-events-subdirs += hw/usb
hw/ssi/aspeed_smc.c +17 -0
@@ -31,6 +31,7 @@#include "qapi/error.h" #include "exec/address-spaces.h" #include "qemu/units.h" +#include "trace.h" #include "hw/irq.h" #include "hw/qdev-properties.h"
@@ -513,6 +514,8 @@ static void aspeed_smc_flash_set_segment(AspeedSMCState *s, int cs, s->ctrl->reg_to_segment (s, new, &seg); +trace_aspeed_smc_flash_set_segment (cs, new, seg.addr, seg.addr + seg.size); +/* The start address of CS0 is read-only */ if (cs ==0 && seg.addr != s->ctrl->flash_window_base) { qemu_log_mask(LOG_GUEST_ERROR,
@@ -753,6 +756,8 @@ static uint64_t aspeed_smc_flash_read(void *opaque, hwaddr addr, unsigned size) __func__, aspeed_smc_flash_mode(fl)); } +trace_aspeed_smc_flash_read (fl->id, addr, size, ret, +aspeed_smc_flash_mode (fl));return ret; }
@@ -808,6 +813,9 @@ static bool aspeed_smc_do_snoop(AspeedSMCFlash *fl, uint64_t data,AspeedSMCState *s = fl->controller;uint8_t addr_width =aspeed_smc_flash_is_4byte (fl) ?4 :3 ; +trace_aspeed_smc_do_snoop (fl->id, s->snoop_index, s->snoop_dummies, + (uint8_t ) data &0xff ); +if (s->snoop_index ==SNOOP_OFF ) {return false;/* Do nothing */
@@ -858,6 +866,9 @@ static void aspeed_smc_flash_write(void *opaque, hwaddr addr, uint64_t data,AspeedSMCState *s = fl->controller;int i; +trace_aspeed_smc_flash_write (fl->id, addr, size, data, +aspeed_smc_flash_mode (fl)); +if (!aspeed_smc_is_writable (fl)) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: flash is not writable at 0x%" HWADDR_PRIx"\n" , __func__, addr);
@@ -972,6 +983,9 @@ static uint64_t aspeed_smc_read(void *opaque, hwaddr addr, unsigned int size) (s->ctrl->has_dma && addr == R_DMA_CHECKSUM) || (addr >= R_SEG_ADDR0 && addr < R_SEG_ADDR0 + s->ctrl->max_slaves) || (addr >= s->r_ctrl0 && addr < s->r_ctrl0 + s->ctrl->max_slaves)) { + + trace_aspeed_smc_read(addr, size, s->regs[addr]); + return s->regs[addr]; } else { qemu_log_mask(LOG_UNIMP, "%s: not implemented: 0x%" HWADDR_PRIx "\n",
@@ -1091,6 +1105,7 @@ static void aspeed_smc_dma_checksum(AspeedSMCState *s) __func__, s->regs[R_DMA_FLASH_ADDR]);return ; } +trace_aspeed_smc_dma_checksum (s->regs[R_DMA_FLASH_ADDR ], data);/* * When the DMA is on-going, the DMA registers are updated
@@ -1225,6 +1240,8 @@ static void aspeed_smc_write(void *opaque, hwaddr addr, uint64_t data, addr >>=2 ; +trace_aspeed_smc_write (addr, size, data); + if (addr == s->r_conf || (addr >= s->r_timings && addr < s->r_timings + s->ctrl->nregs_timings) ||
hw/ssi/trace-events new file +9 -0
@@ -0,0 +1,9 @@ +# aspeed_smc.c + +aspeed_smc_flash_set_segment(int cs, uint64_t reg, uint64_t start, uint64_t end) "CS%d segreg=0x%"PRIx64" [ 0x%"PRIx64" - 0x%"PRIx64" ]" +aspeed_smc_flash_read(int cs, uint64_t addr, uint32_t size, uint64_t data, int mode) "CS%d @0x%" PRIx64 " size %u: 0x%" PRIx64" mode:%d" +aspeed_smc_do_snoop(int cs, int index, int dummies, int data) "CS%d index:0x%x dummies:%d data:0x%x" +aspeed_smc_flash_write(int cs, uint64_t addr, uint32_t size, uint64_t data, int mode) "CS%d @0x%" PRIx64 " size %u: 0x%" PRIx64" mode:%d" +aspeed_smc_read(uint64_t addr, uint32_t size, uint64_t data) "@0x%" PRIx64 " size %u: 0x%" PRIx64 +aspeed_smc_dma_checksum(uint32_t addr, uint32_t data) "0x%08x: 0x%08x" +aspeed_smc_write(uint64_t addr, uint32_t size, uint64_t data) "@0x%" PRIx64 " size %u: 0x%" PRIx64
Signature · 1 line
2.20.1
[PULL 04/36] target/arm: Fix some comment typos
In reply to Peter MaydellFix a couple of comment typos.
Message-id: [email protected]
--- target/arm/helper.c | 2 +- target/arm/translate.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
target/arm/helper.c +1 -1
@@ -12490,7 +12490,7 @@ void HELPER(rebuild_hflags_m32)(CPUARMState *env, int el)/* * If we have triggered a EL state change we can't rely on the -* translator having passed it too us, we need to recompute. +* translator having passed it to us, we need to recompute. */ void HELPER (rebuild_hflags_a32_newel )(CPUARMState *env) {
target/arm/translate.c +1 -1
@@ -7296,7 +7296,7 @@ static int disas_coproc_insn(DisasContext *s, uint32_t insn)if (!isread && !(ri->type &ARM_CP_SUPPRESS_TB_END )) {/* -* A write to any coprocessor regiser that ends a TB +* A write to any coprocessor register that ends a TB * must rebuild the hflags for the next TB. */ TCGv_i32 tcg_el =tcg_const_i32 (s->current_el);
Signature · 1 line
2.20.1
[PULL 10/36] hw/arm/fsl-imx25: Wire up eSDHC controllers
In reply to Peter MaydellFrom: Guenter Roeck <[email protected]>
Wire up eSDHC controllers in fsl-imx25. For imx25-pdk, connect drives provided on the command line to available eSDHC controllers.
This patch enables booting the imx25-pdk emulation from SD card.
Message-id: [email protected]
--- include/hw/arm/fsl-imx25.h | 9 +++++++++ hw/arm/fsl-imx25.c | 32 ++++++++++++++++++++++++++++++++ hw/arm/imx25_pdk.c | 16 ++++++++++++++++ 3 files changed, 57 insertions(+)
include/hw/arm/fsl-imx25.h +9 -0
@@ -27,6 +27,7 @@#include "hw/misc/imx_rngc.h" #include "hw/i2c/imx_i2c.h" #include "hw/gpio/imx_gpio.h" +#include "hw/sd/sdhci.h" #include "exec/memory.h" #include "target/arm/cpu.h"
@@ -38,6 +39,7 @@#define FSL_IMX25_NUM_EPITS 2#define FSL_IMX25_NUM_I2CS 3#define FSL_IMX25_NUM_GPIOS 4 +#define FSL_IMX25_NUM_ESDHCS 2 typedef struct FslIMX25State { /*< private >*/
@@ -54,6 +56,7 @@ typedef struct FslIMX25State {IMXRNGCState rngc;IMXI2CState i2c[FSL_IMX25_NUM_I2CS ];IMXGPIOState gpio[FSL_IMX25_NUM_GPIOS ]; +SDHCIState esdhc[FSL_IMX25_NUM_ESDHCS ];MemoryRegion rom[2 ];MemoryRegion iram;MemoryRegion iram_alias;
@@ -215,6 +218,10 @@ typedef struct FslIMX25State {#define FSL_IMX25_GPIO3_SIZE 0x4000#define FSL_IMX25_RNGC_ADDR 0x53FB0000#define FSL_IMX25_RNGC_SIZE 0x4000 +#define FSL_IMX25_ESDHC1_ADDR 0x53FB4000 +#define FSL_IMX25_ESDHC1_SIZE 0x4000 +#define FSL_IMX25_ESDHC2_ADDR 0x53FB8000 +#define FSL_IMX25_ESDHC2_SIZE 0x4000#define FSL_IMX25_GPIO1_ADDR 0x53FCC000#define FSL_IMX25_GPIO1_SIZE 0x4000#define FSL_IMX25_GPIO2_ADDR 0x53FD0000
@@ -250,5 +257,7 @@ typedef struct FslIMX25State {#define FSL_IMX25_GPIO2_IRQ 51#define FSL_IMX25_GPIO3_IRQ 16#define FSL_IMX25_GPIO4_IRQ 23 +#define FSL_IMX25_ESDHC1_IRQ 9 +#define FSL_IMX25_ESDHC2_IRQ 8#endif /* FSL_IMX25_H */
hw/arm/fsl-imx25.c +32 -0
@@ -31,6 +31,8 @@#include "hw/qdev-properties.h" #include "chardev/char.h" +#define IMX25_ESDHC_CAPABILITIES 0x07e20000 +static void fsl_imx25_init (Object *obj) {FslIMX25State *s =FSL_IMX25 (obj);
@@ -74,6 +76,11 @@ static void fsl_imx25_init(Object *obj)sysbus_init_child_obj (obj,"gpio[*]" , &s->gpio[i],sizeof (s->gpio[i]),TYPE_IMX_GPIO ); } + +for (i =0 ; i <FSL_IMX25_NUM_ESDHCS ; i++) { +sysbus_init_child_obj (obj,"sdhc[*]" , &s->esdhc[i],sizeof (s->esdhc[i]), +TYPE_IMX_USDHC ); + } }static void fsl_imx25_realize (DeviceState *dev,Error **errp)
@@ -246,6 +253,31 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) gpio_table[i].irq)); } +/* Initialize all SDHC */ +for (i =0 ; i <FSL_IMX25_NUM_ESDHCS ; i++) { +static const struct { +hwaddr addr; +unsigned int irq; + } esdhc_table[FSL_IMX25_NUM_ESDHCS ] = { + {FSL_IMX25_ESDHC1_ADDR ,FSL_IMX25_ESDHC1_IRQ }, + {FSL_IMX25_ESDHC2_ADDR ,FSL_IMX25_ESDHC2_IRQ }, + }; + +object_property_set_uint (OBJECT (&s->esdhc[i]),2 ,"sd-spec-version" , + &err); +object_property_set_uint (OBJECT (&s->esdhc[i]),IMX25_ESDHC_CAPABILITIES , +"capareg" , &err); +object_property_set_bool (OBJECT (&s->esdhc[i]), true,"realized" , &err); +if (err) { +error_propagate (errp, err); +return ; + } +sysbus_mmio_map (SYS_BUS_DEVICE (&s->esdhc[i]),0 , esdhc_table[i].addr); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->esdhc[i]),0 , +qdev_get_gpio_in (DEVICE (&s->avic), + esdhc_table[i].irq)); + } +/* initialize 2 x 16 KB ROM */ memory_region_init_rom (&s->rom[0 ],NULL ,"imx25.rom0" ,FSL_IMX25_ROM0_SIZE , &err);
hw/arm/imx25_pdk.c +16 -0
@@ -26,6 +26,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "cpu.h" +#include "hw/qdev-properties.h" #include "hw/arm/fsl-imx25.h" #include "hw/boards.h" #include "qemu/error-report.h"
@@ -120,6 +121,21 @@ static void imx25_pdk_init(MachineState *machine) imx25_pdk_binfo.board_id =1771 , imx25_pdk_binfo.nb_cpus =1 ; +for (i =0 ; i <FSL_IMX25_NUM_ESDHCS ; i++) { +BusState *bus; +DeviceState *carddev; +DriveInfo *di; +BlockBackend *blk; + + di =drive_get_next (IF_SD ); + blk = di ?blk_by_legacy_dinfo (di) :NULL ; + bus =qdev_get_child_bus (DEVICE (&s->soc.esdhc[i]),"sd-bus" ); + carddev =qdev_create (bus,TYPE_SD_CARD ); +qdev_prop_set_drive (carddev,"drive" , blk, &error_fatal); +object_property_set_bool (OBJECT (carddev), true, +"realized" , &error_fatal); + } +/* * We test explicitly for qtest here as it is not done (yet?) in * arm_load_kernel(). Without this the "make check" command would
Signature · 1 line
2.20.1
arm queue; dunno if this will be the last before softfreeze or not, but anyway probably the last large one. New orangepi-pc board model is the big item here.
thanks
-- PMM
The following changes since commit 67d9ef7d541c3d21a25796c51c26da096a433565:
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-docs-20200312' into staging (2020-03-12 15:20:52 +0000)
are available in the Git repository at:
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200312
for you to fetch changes up to aca53be34ac3e7cac5f39396a51a338860a5a837:
target/arm: kvm: Inject events at the last stage of sync (2020-03-12 16:31:10 +0000)
----------------------------------------------------------------
target-arm queue:
* Fix various bugs that might result in an assert() due to incorrect hflags for M-profile CPUs
* Fix Aspeed SMC Controller user-mode select handling
* Report correct (with-tag) address in fault address register when TBI is enabled
* cubieboard: make sure SOC object isn't leaked
* fsl-imx25: Wire up eSDHC controllers
* fsl-imx25: Wire up USB controllers
* New board model: orangepi-pc (OrangePi PC)
* ARM/KVM: if user doesn't select GIC version and the host kernel can only provide GICv3, use that, rather than defaulting to "fail because GICv2 isn't possible"
* kvm: Only do KVM_SET_VCPU_EVENTS at the last stage of sync
----------------------------------------------------------------
Beata Michalska (1):
target/arm: kvm: Inject events at the last stage of sync
Cédric Le Goater (2):
aspeed/smc: Add some tracing aspeed/smc: Fix User mode select/unselect scheme
Eric Auger (6):
hw/arm/virt: Document 'max' value in gic-version property description hw/arm/virt: Introduce VirtGICType enum type
hw/arm/virt: Introduce finalize_gic_version() target/arm/kvm: Let kvm_arm_vgic_probe() return a bitmap hw/arm/virt: kvm: Restructure finalize_gic_version() hw/arm/virt: kvm: allow gicv3 by default if v2 cannot work
Guenter Roeck (2):
hw/arm/fsl-imx25: Wire up eSDHC controllers
hw/arm/fsl-imx25: Wire up USB controllers
Igor Mammedov (1):
hw/arm/cubieboard: make sure SOC object isn't leaked
Niek Linnenbank (13):
hw/arm: add Allwinner H3 System-on-Chip hw/arm: add Xunlong Orange Pi PC machine hw/arm/allwinner-h3: add Clock Control Unit hw/arm/allwinner-h3: add USB host controller hw/arm/allwinner-h3: add System Control module hw/arm/allwinner: add CPU Configuration module hw/arm/allwinner: add Security Identifier device hw/arm/allwinner: add SD/MMC host controller hw/arm/allwinner-h3: add EMAC ethernet device hw/arm/allwinner-h3: add Boot ROM support hw/arm/allwinner-h3: add SDRAM controller device hw/arm/allwinner: add RTC device support
docs: add Orange Pi PC document
Peter Maydell (4):
hw/intc/armv7m_nvic: Rebuild hflags on reset target/arm: Update hflags in trans_CPS_v7m() target/arm: Recalculate hflags correctly after writes to CONTROL target/arm: Fix some comment typos
Philippe Mathieu-Daudé (5):
tests/boot_linux_console: Add a quick test for the OrangePi PC board tests/boot_linux_console: Add initrd test for the Orange Pi PC board tests/boot_linux_console: Add a SD card test for the OrangePi PC board tests/boot_linux_console: Add a SLOW test booting Ubuntu on OrangePi PC tests/boot_linux_console: Test booting NetBSD via U-Boot on OrangePi PC
Richard Henderson (2):
target/arm: Check addresses for disabled regimes target/arm: Disable clean_data_tbi for system mode
Makefile.objs | 1 + hw/arm/Makefile.objs | 1 + hw/misc/Makefile.objs | 5 + hw/net/Makefile.objs | 1 + hw/rtc/Makefile.objs | 1 + hw/sd/Makefile.objs | 1 + hw/usb/hcd-ehci.h | 1 + include/hw/arm/allwinner-a10.h | 4 + include/hw/arm/allwinner-h3.h | 161 ++++++ include/hw/arm/fsl-imx25.h | 18 + include/hw/arm/virt.h | 12 +- include/hw/misc/allwinner-cpucfg.h | 52 ++ include/hw/misc/allwinner-h3-ccu.h | 66 +++ include/hw/misc/allwinner-h3-dramc.h | 106 ++++ include/hw/misc/allwinner-h3-sysctrl.h | 67 +++ include/hw/misc/allwinner-sid.h | 60 +++ include/hw/net/allwinner-sun8i-emac.h | 99 ++++ include/hw/rtc/allwinner-rtc.h | 134 +++++ include/hw/sd/allwinner-sdhost.h | 135 +++++ target/arm/helper.h | 1 + target/arm/kvm_arm.h | 3 + hw/arm/allwinner-a10.c | 19 + hw/arm/allwinner-h3.c | 465 ++++++++++++++++++ hw/arm/cubieboard.c | 18 + hw/arm/fsl-imx25.c | 56 +++ hw/arm/imx25_pdk.c | 16 + hw/arm/orangepi.c | 130 +++++ hw/arm/virt.c | 145 ++++-- hw/intc/armv7m_nvic.c | 6 + hw/misc/allwinner-cpucfg.c | 282 +++++++++++ hw/misc/allwinner-h3-ccu.c | 242 +++++++++ hw/misc/allwinner-h3-dramc.c | 358 ++++++++++++++ hw/misc/allwinner-h3-sysctrl.c | 140 ++++++ hw/misc/allwinner-sid.c | 168 +++++++ hw/net/allwinner-sun8i-emac.c | 871 +++++++++++++++++++++++++++++++++ hw/rtc/allwinner-rtc.c | 411 ++++++++++++++++ hw/sd/allwinner-sdhost.c | 854 ++++++++++++++++++++++++++++++++ hw/ssi/aspeed_smc.c | 56 ++- hw/usb/hcd-ehci-sysbus.c | 17 + target/arm/helper.c | 49 +- target/arm/kvm.c | 14 +- target/arm/kvm32.c | 15 +- target/arm/kvm64.c | 15 +- target/arm/translate-a64.c | 11 + target/arm/translate.c | 14 +- MAINTAINERS | 9 + default-configs/arm-softmmu.mak | 1 + docs/system/arm/orangepi.rst | 253 ++++++++++ docs/system/target-arm.rst | 2 + hw/arm/Kconfig | 12 + hw/misc/trace-events | 19 + hw/net/Kconfig | 3 + hw/net/trace-events | 10 + hw/rtc/trace-events | 4 + hw/sd/trace-events | 7 + hw/ssi/trace-events | 10 + tests/acceptance/boot_linux_console.py | 230 +++++++++ 57 files changed, 5787 insertions(+), 74 deletions(-) create mode 100644 include/hw/arm/allwinner-h3.h create mode 100644 include/hw/misc/allwinner-cpucfg.h create mode 100644 include/hw/misc/allwinner-h3-ccu.h create mode 100644 include/hw/misc/allwinner-h3-dramc.h create mode 100644 include/hw/misc/allwinner-h3-sysctrl.h create mode 100644 include/hw/misc/allwinner-sid.h create mode 100644 include/hw/net/allwinner-sun8i-emac.h create mode 100644 include/hw/rtc/allwinner-rtc.h create mode 100644 include/hw/sd/allwinner-sdhost.h create mode 100644 hw/arm/allwinner-h3.c create mode 100644 hw/arm/orangepi.c create mode 100644 hw/misc/allwinner-cpucfg.c create mode 100644 hw/misc/allwinner-h3-ccu.c create mode 100644 hw/misc/allwinner-h3-dramc.c create mode 100644 hw/misc/allwinner-h3-sysctrl.c create mode 100644 hw/misc/allwinner-sid.c create mode 100644 hw/net/allwinner-sun8i-emac.c create mode 100644 hw/rtc/allwinner-rtc.c create mode 100644 hw/sd/allwinner-sdhost.c create mode 100644 docs/system/arm/orangepi.rst create mode 100644 hw/ssi/trace-events
[PULL 06/36] aspeed/smc: Fix User mode select/unselect scheme
From: Cédric Le Goater <[email protected]>
The Aspeed SMC Controller can operate in different modes : Read, Fast Read, Write and User modes. When the User mode is configured, it selects automatically the SPI slave device until the CE_STOP_ACTIVE bit is set to 1. When any other modes are configured the device is unselected. The HW logic handles the chip select automatically when the flash is accessed through its AHB window.
When configuring the CEx Control Register, the User mode logic to select and unselect the slave is incorrect and data corruption can be seen on machines using two chips, witherspoon and romulus.
Rework the handler setting the CEx Control Register to fix this issue.
Message-id: [email protected]
--- hw/ssi/aspeed_smc.c | 39 +++++++++++++++++++++++---------------- hw/ssi/trace-events | 1 + 2 files changed, 24 insertions(+), 16 deletions(-)
hw/ssi/aspeed_smc.c +23 -16
@@ -639,27 +639,23 @@ static inline int aspeed_smc_flash_is_4byte(const AspeedSMCFlash *fl) } } -static inline bool aspeed_smc_is_ce_stop_active (const AspeedSMCFlash *fl) +static void aspeed_smc_flash_do_select (AspeedSMCFlash *fl,bool unselect) { -const AspeedSMCState *s = fl->controller; +AspeedSMCState *s = fl->controller; -return s->regs[s->r_ctrl0 + fl->id] &CTRL_CE_STOP_ACTIVE ; +trace_aspeed_smc_flash_select (fl->id, unselect ?"un" :"" ); + +qemu_set_irq (s->cs_lines[fl->id], unselect); }static void aspeed_smc_flash_select (AspeedSMCFlash *fl) { -AspeedSMCState *s = fl->controller; - - s->regs[s->r_ctrl0 + fl->id] &= ~CTRL_CE_STOP_ACTIVE ; -qemu_set_irq (s->cs_lines[fl->id],aspeed_smc_is_ce_stop_active (fl)); +aspeed_smc_flash_do_select (fl, false); }static void aspeed_smc_flash_unselect (AspeedSMCFlash *fl) { -AspeedSMCState *s = fl->controller; - - s->regs[s->r_ctrl0 + fl->id] |=CTRL_CE_STOP_ACTIVE ; -qemu_set_irq (s->cs_lines[fl->id],aspeed_smc_is_ce_stop_active (fl)); +aspeed_smc_flash_do_select (fl, true); } static uint32_t aspeed_smc_check_segment_addr(const AspeedSMCFlash *fl,
@@ -911,13 +907,25 @@ static const MemoryRegionOps aspeed_smc_flash_ops = { }, }; -static void aspeed_smc_flash_update_cs (AspeedSMCFlash *fl) +static void aspeed_smc_flash_update_ctrl (AspeedSMCFlash *fl,uint32_t value) {AspeedSMCState *s = fl->controller; +bool unselect; - s->snoop_index =aspeed_smc_is_ce_stop_active (fl) ?SNOOP_OFF :SNOOP_START ; +/* User mode selects the CS, other modes unselect */ + unselect = (value &CTRL_CMD_MODE_MASK ) !=CTRL_USERMODE ; -qemu_set_irq (s->cs_lines[fl->id],aspeed_smc_is_ce_stop_active (fl)); +/* A change of CTRL_CE_STOP_ACTIVE from 0 to 1, unselects the CS */ +if (!(s->regs[s->r_ctrl0 + fl->id] &CTRL_CE_STOP_ACTIVE ) && + value &CTRL_CE_STOP_ACTIVE ) { + unselect = true; + } + + s->regs[s->r_ctrl0 + fl->id] = value; + + s->snoop_index = unselect ?SNOOP_OFF :SNOOP_START ; + +aspeed_smc_flash_do_select (fl, unselect); }static void aspeed_smc_reset (DeviceState *d)
@@ -1249,8 +1257,7 @@ static void aspeed_smc_write(void *opaque, hwaddr addr, uint64_t data, s->regs[addr] = value; }else if (addr >= s->r_ctrl0 && addr < s->r_ctrl0 + s->num_cs) {int cs = addr - s->r_ctrl0; - s->regs[addr] = value; -aspeed_smc_flash_update_cs (&s->flashes[cs]); +aspeed_smc_flash_update_ctrl (&s->flashes[cs], value); }else if (addr >=R_SEG_ADDR0 && addr <R_SEG_ADDR0 + s->ctrl->max_slaves) {int cs = addr -R_SEG_ADDR0 ;
hw/ssi/trace-events +1 -0
@@ -7,3 +7,4 @@ aspeed_smc_flash_write(int cs, uint64_t addr, uint32_t size, uint64_t data, int aspeed_smc_read(uint64_t addr, uint32_t size, uint64_t data) "@0x%" PRIx64 " size %u: 0x%" PRIx64 aspeed_smc_dma_checksum(uint32_t addr, uint32_t data) "0x%08x: 0x%08x" aspeed_smc_write(uint64_t addr, uint32_t size, uint64_t data) "@0x%" PRIx64 " size %u: 0x%" PRIx64 +aspeed_smc_flash_select(int cs, const char *prefix) "CS%d %sselect"
Signature · 1 line
2.20.1
[PULL 11/36] hw/arm/fsl-imx25: Wire up USB controllers
In reply to Peter MaydellFrom: Guenter Roeck <[email protected]>
i.MX25 supports two USB controllers. Let's wire them up.
With this patch, imx25-pdk can boot from both USB ports.
Message-id: [email protected]
--- include/hw/arm/fsl-imx25.h | 9 +++++++++ hw/arm/fsl-imx25.c | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+)
include/hw/arm/fsl-imx25.h +9 -0
@@ -28,6 +28,7 @@#include "hw/i2c/imx_i2c.h" #include "hw/gpio/imx_gpio.h" #include "hw/sd/sdhci.h" +#include "hw/usb/chipidea.h" #include "exec/memory.h" #include "target/arm/cpu.h"
@@ -40,6 +41,7 @@#define FSL_IMX25_NUM_I2CS 3#define FSL_IMX25_NUM_GPIOS 4#define FSL_IMX25_NUM_ESDHCS 2 +#define FSL_IMX25_NUM_USBS 2 typedef struct FslIMX25State { /*< private >*/
@@ -57,6 +59,7 @@ typedef struct FslIMX25State {IMXI2CState i2c[FSL_IMX25_NUM_I2CS ];IMXGPIOState gpio[FSL_IMX25_NUM_GPIOS ];SDHCIState esdhc[FSL_IMX25_NUM_ESDHCS ]; +ChipideaState usb[FSL_IMX25_NUM_USBS ];MemoryRegion rom[2 ];MemoryRegion iram;MemoryRegion iram_alias;
@@ -226,6 +229,10 @@ typedef struct FslIMX25State {#define FSL_IMX25_GPIO1_SIZE 0x4000#define FSL_IMX25_GPIO2_ADDR 0x53FD0000#define FSL_IMX25_GPIO2_SIZE 0x4000 +#define FSL_IMX25_USB1_ADDR 0x53FF4000 +#define FSL_IMX25_USB1_SIZE 0x0200 +#define FSL_IMX25_USB2_ADDR 0x53FF4400 +#define FSL_IMX25_USB2_SIZE 0x0200#define FSL_IMX25_AVIC_ADDR 0x68000000#define FSL_IMX25_AVIC_SIZE 0x4000#define FSL_IMX25_IRAM_ADDR 0x78000000
@@ -259,5 +266,7 @@ typedef struct FslIMX25State {#define FSL_IMX25_GPIO4_IRQ 23#define FSL_IMX25_ESDHC1_IRQ 9#define FSL_IMX25_ESDHC2_IRQ 8 +#define FSL_IMX25_USB1_IRQ 37 +#define FSL_IMX25_USB2_IRQ 35#endif /* FSL_IMX25_H */
hw/arm/fsl-imx25.c +24 -0
@@ -81,6 +81,12 @@ static void fsl_imx25_init(Object *obj)sysbus_init_child_obj (obj,"sdhc[*]" , &s->esdhc[i],sizeof (s->esdhc[i]),TYPE_IMX_USDHC ); } + +for (i =0 ; i <FSL_IMX25_NUM_USBS ; i++) { +sysbus_init_child_obj (obj,"usb[*]" , &s->usb[i],sizeof (s->usb[i]), +TYPE_CHIPIDEA ); + } + }static void fsl_imx25_realize (DeviceState *dev,Error **errp)
@@ -278,6 +284,24 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) esdhc_table[i].irq)); } +/* USB */ +for (i =0 ; i <FSL_IMX25_NUM_USBS ; i++) { +static const struct { +hwaddr addr; +unsigned int irq; + } usb_table[FSL_IMX25_NUM_USBS ] = { + {FSL_IMX25_USB1_ADDR ,FSL_IMX25_USB1_IRQ }, + {FSL_IMX25_USB2_ADDR ,FSL_IMX25_USB2_IRQ }, + }; + +object_property_set_bool (OBJECT (&s->usb[i]), true,"realized" , + &error_abort); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->usb[i]),0 , usb_table[i].addr); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->usb[i]),0 , +qdev_get_gpio_in (DEVICE (&s->avic), + usb_table[i].irq)); + } +/* initialize 2 x 16 KB ROM */ memory_region_init_rom (&s->rom[0 ],NULL ,"imx25.rom0" ,FSL_IMX25_ROM0_SIZE , &err);
Signature · 1 line
2.20.1
[PULL 13/36] hw/arm: add Xunlong Orange Pi PC machine
In reply to Peter MaydellFrom: Niek Linnenbank <[email protected]>
The Xunlong Orange Pi PC is an Allwinner H3 System on Chip based embedded computer with mainline support in both U-Boot and Linux. The board comes with a Quad Core Cortex A7 @ 1.3GHz, 1GiB RAM, 100Mbit ethernet, USB, SD/MMC, USB, HDMI and various other I/O. This commit add support for the Xunlong Orange Pi PC machine.
Message-id: [email protected]
--- hw/arm/Makefile.objs | 2 +- hw/arm/orangepi.c | 92 ++++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 hw/arm/orangepi.c
hw/arm/Makefile.objs +1 -1
@@ -35,7 +35,7 @@ obj-$(CONFIG_DIGIC) += digic.o obj-$(CONFIG_OMAP) += omap1.o omap2.o obj-$(CONFIG_STRONGARM) += strongarm.o obj-$(CONFIG_ALLWINNER_A10) += allwinner-a10.o cubieboard.o -obj-$(CONFIG_ALLWINNER_H3) += allwinner-h3.o +obj-$(CONFIG_ALLWINNER_H3) += allwinner-h3.o orangepi.o obj-$(CONFIG_RASPI) += bcm2835_peripherals.o bcm2836.o raspi.o obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o obj-$(CONFIG_STM32F405_SOC) += stm32f405_soc.o
hw/arm/orangepi.c new file +92 -0
92 lines not on this page · raw message
MAINTAINERS +1 -0
@@ -498,6 +498,7 @@ L: [email protected] S: Maintained F: hw/*/allwinner-h3* F: include/hw/*/allwinner-h3* +F: hw/arm/orangepi.c ARM PrimeCell and CMSDK devices M: Peter Maydell <[email protected]>
Signature · 1 line
2.20.1
[PULL 03/36] target/arm: Recalculate hflags correctly after writes to CONTROL
In reply to Peter MaydellA write to the CONTROL register can change our current EL (by writing to the nPRIV bit). That means that we can't assume that s->current_el is still valid in trans_MSR_v7m() when we try to rebuild the hflags.
Add a new helper rebuild_hflags_m32_newel() which, like the existing rebuild_hflags_a32_newel(), recalculates the current EL from scratch, and use it in trans_MSR_v7m().
This fixes an assertion about an hflags mismatch when the guest changes privilege by writing to CONTROL.
Message-id: [email protected]
--- target/arm/helper.h | 1 + target/arm/helper.c | 12 ++++++++++++ target/arm/translate.c | 7 +++---- 3 files changed, 16 insertions(+), 4 deletions(-)
target/arm/helper.h +1 -0
@@ -90,6 +90,7 @@ DEF_HELPER_4(msr_banked, void, env, i32, i32, i32) DEF_HELPER_2(get_user_reg, i32, env, i32) DEF_HELPER_3(set_user_reg, void, env, i32, i32) +DEF_HELPER_FLAGS_1(rebuild_hflags_m32_newel, TCG_CALL_NO_RWG, void, env) DEF_HELPER_FLAGS_2(rebuild_hflags_m32, TCG_CALL_NO_RWG, void, env, int) DEF_HELPER_FLAGS_1(rebuild_hflags_a32_newel, TCG_CALL_NO_RWG, void, env)DEF_HELPER_FLAGS_2 (rebuild_hflags_a32,TCG_CALL_NO_RWG , void, env, int)
target/arm/helper.c +12 -0
@@ -12468,6 +12468,18 @@ void arm_rebuild_hflags(CPUARMState *env) env->hflags =rebuild_hflags_internal (env); } +/* +* If we have triggered a EL state change we can't rely on the +* translator having passed it to us, we need to recompute. +*/ +void HELPER (rebuild_hflags_m32_newel )(CPUARMState *env) +{ +int el =arm_current_el (env); +int fp_el =fp_exception_el (env, el); +ARMMMUIdx mmu_idx =arm_mmu_idx_el (env, el); + env->hflags =rebuild_hflags_m32 (env, fp_el, mmu_idx); +} +void HELPER (rebuild_hflags_m32 )(CPUARMState *env,int el) {int fp_el =fp_exception_el (env, el);
target/arm/translate.c +3 -4
@@ -8551,7 +8551,7 @@ static bool trans_MRS_v7m(DisasContext *s, arg_MRS_v7m *a)static bool trans_MSR_v7m (DisasContext *s,arg_MSR_v7m *a) { -TCGv_i32 addr, reg, el; +TCGv_i32 addr, reg;if (!arm_dc_feature (s,ARM_FEATURE_M )) {return false;
@@ -8561,9 +8561,8 @@ static bool trans_MSR_v7m(DisasContext *s, arg_MSR_v7m *a)gen_helper_v7m_msr (cpu_env, addr, reg);tcg_temp_free_i32 (addr);tcg_temp_free_i32 (reg); - el =tcg_const_i32 (s->current_el); -gen_helper_rebuild_hflags_m32 (cpu_env, el); -tcg_temp_free_i32 (el); +/* If we wrote to CONTROL, the EL might have changed */ +gen_helper_rebuild_hflags_m32_newel (cpu_env);gen_lookup_tb (s);return true; }
Signature · 1 line
2.20.1
[PULL 08/36] target/arm: Disable clean_data_tbi for system mode
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
We must include the tag in the FAR_ELx register when raising an addressing exception. Which means that we should not clear out the tag during translation.
We cannot at present comply with this for user mode, so we retain the clean_data_tbi function for the moment, though it no longer does what it says on the tin for system mode. This function is to be replaced with MTE, so don't worry about the slight misnaming.
Message-id: [email protected]
--- target/arm/translate-a64.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
target/arm/translate-a64.c +11 -0
@@ -228,7 +228,18 @@ static void gen_a64_set_pc(DisasContext *s, TCGv_i64 src)static TCGv_i64 clean_data_tbi (DisasContext *s,TCGv_i64 addr) {TCGv_i64 clean =new_tmp_a64 (s); +/* +* In order to get the correct value in the FAR_ELx register, +* we must present the memory subsystem with the "dirty" address +* including the TBI. In system mode we can make this work via +* the TLB, dropping the TBI during translation. But for user-only +* mode we don't have that option, and must remove the top byte now. +*/ +#ifdef CONFIG_USER_ONLY gen_top_byte_ignore (s, clean, addr, s->tbid); +#else +tcg_gen_mov_i64 (clean, addr); +#endif return clean; }
Signature · 1 line
2.20.1
[PULL 16/36] hw/arm/allwinner-h3: add System Control module
In reply to Peter MaydellFrom: Niek Linnenbank <[email protected]>
The Allwinner H3 System on Chip has an System Control module that provides system wide generic controls and device information. This commit adds support for the Allwinner H3 System Control module.
Message-id: [email protected]
--- hw/misc/Makefile.objs | 1 + include/hw/arm/allwinner-h3.h | 3 + include/hw/misc/allwinner-h3-sysctrl.h | 67 ++++++++++++ hw/arm/allwinner-h3.c | 9 +- hw/misc/allwinner-h3-sysctrl.c | 140 +++++++++++++++++++++++++ 5 files changed, 219 insertions(+), 1 deletion(-) create mode 100644 include/hw/misc/allwinner-h3-sysctrl.h create mode 100644 hw/misc/allwinner-h3-sysctrl.c
hw/misc/Makefile.objs +1 -0
@@ -29,6 +29,7 @@ common-obj-$(CONFIG_MACIO) += macio/ common-obj-$(CONFIG_IVSHMEM_DEVICE) += ivshmem.o common-obj-$(CONFIG_ALLWINNER_H3) += allwinner-h3-ccu.o +common-obj-$(CONFIG_ALLWINNER_H3) += allwinner-h3-sysctrl.o common-obj-$(CONFIG_REALVIEW) += arm_sysctl.o common-obj-$(CONFIG_NSERIES) += cbus.o common-obj-$(CONFIG_ECCMEMCTL) += eccmemctl.o
include/hw/arm/allwinner-h3.h +3 -0
@@ -40,6 +40,7 @@#include "hw/timer/allwinner-a10-pit.h" #include "hw/intc/arm_gic.h" #include "hw/misc/allwinner-h3-ccu.h" +#include "hw/misc/allwinner-h3-sysctrl.h" #include "target/arm/cpu.h" /**
@@ -56,6 +57,7 @@ enum {AW_H3_SRAM_A1 ,AW_H3_SRAM_A2 ,AW_H3_SRAM_C , +AW_H3_SYSCTRL ,AW_H3_EHCI0 ,AW_H3_OHCI0 , AW_H3_EHCI1,
@@ -108,6 +110,7 @@ typedef struct AwH3State {const hwaddr *memmap;AwA10PITState timer;AwH3ClockCtlState ccu; +AwH3SysCtrlState sysctrl;GICState gic;MemoryRegion sram_a1;MemoryRegion sram_a2;
include/hw/misc/allwinner-h3-sysctrl.h new file +67 -0
67 lines not on this page · raw message
hw/arm/allwinner-h3.c +8 -1
@@ -37,6 +37,7 @@ const hwaddr allwinner_h3_memmap[] = { [AW_H3_SRAM_A1] = 0x00000000, [AW_H3_SRAM_A2] = 0x00044000, [AW_H3_SRAM_C] = 0x00010000, + [AW_H3_SYSCTRL] = 0x01c00000, [AW_H3_EHCI0] = 0x01c1a000, [AW_H3_OHCI0] = 0x01c1a400, [AW_H3_EHCI1] = 0x01c1b000,
@@ -66,7 +67,6 @@ struct AwH3Unimplemented { } unimplemented[] = { { "d-engine", 0x01000000, 4 * MiB }, { "d-inter", 0x01400000, 128 * KiB }, - { "syscon", 0x01c00000, 4 * KiB }, { "dma", 0x01c02000, 4 * KiB }, { "nfdc", 0x01c03000, 4 * KiB }, { "ts", 0x01c06000, 4 * KiB },
@@ -192,6 +192,9 @@ static void allwinner_h3_init(Object *obj)sysbus_init_child_obj (obj,"ccu" , &s->ccu,sizeof (s->ccu),TYPE_AW_H3_CCU ); + +sysbus_init_child_obj (obj,"sysctrl" , &s->sysctrl,sizeof (s->sysctrl), +TYPE_AW_H3_SYSCTRL ); }static void allwinner_h3_realize (DeviceState *dev,Error **errp)
@@ -301,6 +304,10 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)qdev_init_nofail (DEVICE (&s->ccu));sysbus_mmio_map (SYS_BUS_DEVICE (&s->ccu),0 , s->memmap[AW_H3_CCU ]); +/* System Control */ +qdev_init_nofail (DEVICE (&s->sysctrl)); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->sysctrl),0 , s->memmap[AW_H3_SYSCTRL ]); +/* Universal Serial Bus */ sysbus_create_simple(TYPE_AW_H3_EHCI, s->memmap[AW_H3_EHCI0], qdev_get_gpio_in(DEVICE(&s->gic),
hw/misc/allwinner-h3-sysctrl.c new file +140 -0
140 lines not on this page · raw message
Signature · 1 line
2.20.1
[PULL 21/36] hw/arm/allwinner-h3: add Boot ROM support
In reply to Peter MaydellFrom: Niek Linnenbank <[email protected]>
A real Allwinner H3 SoC contains a Boot ROM which is the first code that runs right after the SoC is powered on.
The Boot ROM is responsible for loading user code (e.g. a bootloader) from any of the supported external devices and writing the downloaded code to internal SRAM. After loading the SoC begins executing the code written to SRAM.
This commits adds emulation of the Boot ROM firmware setup functionality by loading user code from SD card in the A1 SRAM. While the A1 SRAM is 64KiB, we limit the size to 32KiB because the real H3 Boot ROM also rejects sizes larger than 32KiB. For reference, this behaviour is documented by the Linux Sunxi project wiki at:
https://linux-sunxi.org/BROM#U-Boot_SPL_limitations
Message-id: [email protected]
--- include/hw/arm/allwinner-h3.h | 21 +++++++++++++++++++++ hw/arm/allwinner-h3.c | 17 +++++++++++++++++ hw/arm/orangepi.c | 5 +++++ 3 files changed, 43 insertions(+)
include/hw/arm/allwinner-h3.h +21 -0
@@ -46,6 +46,7 @@#include "hw/sd/allwinner-sdhost.h" #include "hw/net/allwinner-sun8i-emac.h" #include "target/arm/cpu.h" +#include "sysemu/block-backend.h" /** * Allwinner H3 device list
@@ -129,4 +130,24 @@ typedef struct AwH3State { MemoryRegion sram_c; } AwH3State; +/** +* Emulate Boot ROM firmware setup functionality. +* +* A real Allwinner H3 SoC contains a Boot ROM +* which is the first code that runs right after +* the SoC is powered on. The Boot ROM is responsible +* for loading user code (e.g. a bootloader) from any +* of the supported external devices and writing the +* downloaded code to internal SRAM. After loading the SoC +* begins executing the code written to SRAM. +* +* This function emulates the Boot ROM by copying 32 KiB +* of data from the given block device and writes it to +* the start of the first internal SRAM memory. +* +* @s: Allwinner H3 state object pointer +* @blk: Block backend device object pointer +*/ +void allwinner_h3_bootrom_setup (AwH3State *s,BlockBackend *blk); +#endif /* HW_ARM_ALLWINNER_H3_H */
hw/arm/allwinner-h3.c +17 -0
@@ -29,6 +29,7 @@#include "hw/char/serial.h" #include "hw/misc/unimp.h" #include "hw/usb/hcd-ehci.h" +#include "hw/loader.h" #include "sysemu/sysemu.h" #include "hw/arm/allwinner-h3.h"
@@ -170,6 +171,22 @@ enum {AW_H3_GIC_NUM_SPI =128 }; +void allwinner_h3_bootrom_setup (AwH3State *s,BlockBackend *blk) +{ +const int64_t rom_size =32 * KiB; + g_autofree uint8_t *buffer = g_new0(uint8_t, rom_size); + +if (blk_pread (blk,8 * KiB, buffer, rom_size) <0 ) { +error_setg (&error_fatal,"%s: failed to read BlockBackend data" , + __func__); +return ; + } + +rom_add_blob ("allwinner-h3.bootrom" , buffer, rom_size, + rom_size, s->memmap[AW_H3_SRAM_A1 ], +NULL ,NULL ,NULL ,NULL , false); +} +static void allwinner_h3_init (Object *obj) {AwH3State *s =AW_H3 (obj);
hw/arm/orangepi.c +5 -0
@@ -97,6 +97,11 @@ static void orangepi_init(MachineState *machine)memory_region_add_subregion (get_system_memory (), h3->memmap[AW_H3_SDRAM ], machine->ram); +/* Load target kernel or start using BootROM */ +if (!machine->kernel_filename &&blk_is_available (blk)) { +/* Use Boot ROM to copy data from SD card to SRAM */ +allwinner_h3_bootrom_setup (h3, blk); + } orangepi_binfo.loader_start = h3->memmap[AW_H3_SDRAM ]; orangepi_binfo.ram_size = machine->ram_size;arm_load_kernel (ARM_CPU (first_cpu), machine, &orangepi_binfo);
Signature · 1 line
2.20.1
[PULL 07/36] target/arm: Check addresses for disabled regimes
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
We fail to validate the upper bits of a virtual address on a translation disabled regime, as per AArch64.TranslateAddressS1Off.
Message-id: [email protected]
--- target/arm/helper.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
target/arm/helper.c +34 -1
@@ -11780,7 +11780,40 @@ bool get_phys_addr(CPUARMState *env, target_ulong address,/* Definitely a real MMU, not an MPU */ if (regime_translation_disabled (env, mmu_idx)) { -/* MMU disabled. */ +/* +* MMU disabled. S1 addresses within aa64 translation regimes are +* still checked for bounds -- see AArch64.TranslateAddressS1Off. +*/ +if (mmu_idx != ARMMMUIdx_Stage2) { +int r_el =regime_el (env, mmu_idx); +if (arm_el_is_aa64 (env, r_el)) { +int pamax =arm_pamax (env_archcpu (env)); +uint64_t tcr = env->cp15.tcr_el[r_el].raw_tcr; +int addrtop, tbi; + + tbi =aa64_va_parameter_tbi (tcr, mmu_idx); +if (access_type ==MMU_INST_FETCH ) { + tbi &= ~aa64_va_parameter_tbid (tcr, mmu_idx); + } + tbi = (tbi >>extract64 (address,55 ,1 )) &1 ; + addrtop = (tbi ?55 :63 ); + +if (extract64 (address, pamax, addrtop - pamax +1 ) !=0 ) { + fi->type = ARMFault_AddressSize; + fi->level =0 ; + fi->stage2 = false; +return 1 ; + } + +/* +* When TBI is disabled, we've just validated that all of the +* bits above PAMax are zero, so logically we only need to +* clear the top byte for TBI. But it's clearer to follow +* the pseudocode set of addrdesc.paddress. +*/ + address =extract64 (address,0 ,52 ); + } + } *phys_ptr = address; *prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; *page_size =TARGET_PAGE_SIZE ;
Signature · 1 line
2.20.1
[PULL 24/36] tests/boot_linux_console: Add a quick test for the OrangePi PC board
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
This test boots a Linux kernel on a OrangePi PC board and verify the serial output is working.
The kernel image and DeviceTree blob are built by the Armbian project (based on Debian):
https://www.armbian.com/orange-pi-pc/
If ARM is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:arm" tags.
Alternatively, this test can be run using:
$ make check-venv $ ./tests/venv/bin/avocado --show=console,app run -t machine:orangepi-pc tests/acceptance/boot_linux_console.py JOB ID : 2e4d15eceb13c33672af406f08171e6e9de1414a JOB LOG : ~/job-results/job-2019-12-17T05.46-2e4d15e/job.log (1/1) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi: console: Uncompressing Linux... done, booting the kernel. console: Booting Linux on physical CPU 0x0 console: Linux version 4.20.7-sunxi ([email protected]) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #5.75 SMP Fri Feb 8 09:02:10 CET 2019 console: CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=50c5387d console: CPU: div instructions available: patching division code console: CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache console: OF: fdt: Machine model: Xunlong Orange Pi PC console: Memory policy: Data cache writealloc console: OF: reserved mem: failed to allocate memory for node 'cma@4a000000' console: cma: Failed to reserve 128 MiB console: psci: probing for conduit method from DT. console: psci: PSCIv0.2 detected in firmware. console: psci: Using standard PSCI v0.2 function IDs console: psci: Trusted OS migration not required console: random: get_random_bytes called from start_kernel+0x8d/0x3c2 with crng_init=0 console: percpu: Embedded 18 pages/cpu @(ptrval) s41228 r8192 d24308 u73728 console: Built 1 zonelists, mobility grouping on. Total pages: 32480 console: Kernel command line: printk.time=0 console=ttyS0,115200 PASS (8.59 s) JOB TIME : 8.81 s
Message-id: [email protected]
--- tests/acceptance/boot_linux_console.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
tests/acceptance/boot_linux_console.py +25 -0
@@ -507,6 +507,31 @@ class BootLinuxConsole(Test): exec_command_and_wait_for_pattern(self, 'reboot', 'reboot: Restarting system') + def test_arm_orangepi(self): + """ + :avocado: tags=arch:arm + :avocado: tags=machine:orangepi-pc + """ + deb_url = ('https://apt.armbian.com/pool/main/l/' + 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') + deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + kernel_path = self.extract_from_deb(deb_path, + '/boot/vmlinuz-4.20.7-sunxi') + dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb' + dtb_path = self.extract_from_deb(deb_path, dtb_path) + + self.vm.set_console() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyS0,115200n8 ' + 'earlycon=uart,mmio32,0x1c28000') + self.vm.add_args('-kernel', kernel_path, + '-dtb', dtb_path, + '-append', kernel_command_line) + self.vm.launch() + console_pattern = 'Kernel command line: %s' % kernel_command_line + self.wait_for_console_pattern(console_pattern) + def test_s390x_s390_ccw_virtio(self): """ :avocado: tags=arch:s390x
Signature · 1 line
2.20.1
[PULL 18/36] hw/arm/allwinner: add Security Identifier device
In reply to Peter MaydellFrom: Niek Linnenbank <[email protected]>
The Security Identifier device found in various Allwinner System on Chip designs gives applications a per-board unique identifier. This commit adds support for the Allwinner Security Identifier using a 128-bit UUID value as input.
Message-id: [email protected]
--- hw/misc/Makefile.objs | 1 + include/hw/arm/allwinner-h3.h | 3 + include/hw/misc/allwinner-sid.h | 60 ++++++++++++ hw/arm/allwinner-h3.c | 11 ++- hw/arm/orangepi.c | 8 ++ hw/misc/allwinner-sid.c | 168 ++++++++++++++++++++++++++++++++ hw/misc/trace-events | 4 + 7 files changed, 254 insertions(+), 1 deletion(-) create mode 100644 include/hw/misc/allwinner-sid.h create mode 100644 hw/misc/allwinner-sid.c
hw/misc/Makefile.objs +1 -0
@@ -31,6 +31,7 @@ common-obj-$(CONFIG_IVSHMEM_DEVICE) += ivshmem.o common-obj-$(CONFIG_ALLWINNER_H3) += allwinner-h3-ccu.o obj-$(CONFIG_ALLWINNER_H3) += allwinner-cpucfg.o common-obj-$(CONFIG_ALLWINNER_H3) += allwinner-h3-sysctrl.o +common-obj-$(CONFIG_ALLWINNER_H3) += allwinner-sid.o common-obj-$(CONFIG_REALVIEW) += arm_sysctl.o common-obj-$(CONFIG_NSERIES) += cbus.o common-obj-$(CONFIG_ECCMEMCTL) += eccmemctl.o
include/hw/arm/allwinner-h3.h +3 -0
@@ -42,6 +42,7 @@#include "hw/misc/allwinner-h3-ccu.h" #include "hw/misc/allwinner-cpucfg.h" #include "hw/misc/allwinner-h3-sysctrl.h" +#include "hw/misc/allwinner-sid.h" #include "target/arm/cpu.h" /**
@@ -59,6 +60,7 @@ enum {AW_H3_SRAM_A2 ,AW_H3_SRAM_C ,AW_H3_SYSCTRL , +AW_H3_SID ,AW_H3_EHCI0 ,AW_H3_OHCI0 , AW_H3_EHCI1,
@@ -114,6 +116,7 @@ typedef struct AwH3State {AwH3ClockCtlState ccu;AwCpuCfgState cpucfg;AwH3SysCtrlState sysctrl; +AwSidState sid;GICState gic;MemoryRegion sram_a1;MemoryRegion sram_a2;
include/hw/misc/allwinner-sid.h new file +60 -0
60 lines not on this page · raw message
hw/arm/allwinner-h3.c +10 -1
@@ -38,6 +38,7 @@ const hwaddr allwinner_h3_memmap[] = { [AW_H3_SRAM_A2] = 0x00044000, [AW_H3_SRAM_C] = 0x00010000, [AW_H3_SYSCTRL] = 0x01c00000, + [AW_H3_SID] = 0x01c14000, [AW_H3_EHCI0] = 0x01c1a000, [AW_H3_OHCI0] = 0x01c1a400, [AW_H3_EHCI1] = 0x01c1b000,
@@ -78,7 +79,6 @@ struct AwH3Unimplemented { { "mmc0", 0x01c0f000, 4 * KiB }, { "mmc1", 0x01c10000, 4 * KiB }, { "mmc2", 0x01c11000, 4 * KiB }, - { "sid", 0x01c14000, 1 * KiB }, { "crypto", 0x01c15000, 4 * KiB }, { "msgbox", 0x01c17000, 4 * KiB }, { "spinlock", 0x01c18000, 4 * KiB },
@@ -198,6 +198,11 @@ static void allwinner_h3_init(Object *obj)sysbus_init_child_obj (obj,"cpucfg" , &s->cpucfg,sizeof (s->cpucfg),TYPE_AW_CPUCFG ); + +sysbus_init_child_obj (obj,"sid" , &s->sid,sizeof (s->sid), +TYPE_AW_SID ); +object_property_add_alias (obj,"identifier" ,OBJECT (&s->sid), +"identifier" , &error_abort); }static void allwinner_h3_realize (DeviceState *dev,Error **errp)
@@ -315,6 +320,10 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)qdev_init_nofail (DEVICE (&s->cpucfg));sysbus_mmio_map (SYS_BUS_DEVICE (&s->cpucfg),0 , s->memmap[AW_H3_CPUCFG ]); +/* Security Identifier */ +qdev_init_nofail (DEVICE (&s->sid)); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->sid),0 , s->memmap[AW_H3_SID ]); +/* Universal Serial Bus */ sysbus_create_simple(TYPE_AW_H3_EHCI, s->memmap[AW_H3_EHCI0], qdev_get_gpio_in(DEVICE(&s->gic),
hw/arm/orangepi.c +8 -0
@@ -65,6 +65,14 @@ static void orangepi_init(MachineState *machine)object_property_set_int (OBJECT (h3),24 *1000 *1000 ,"clk1-freq" , &error_abort); +/* Setup SID properties. Currently using a default fixed SID identifier. */ +if (qemu_uuid_is_null (&h3->sid.identifier)) { +qdev_prop_set_string (DEVICE (h3),"identifier" , +"02c00081-1111-2222-3333-000044556677" ); + }else if (ldl_be_p (&h3->sid.identifier.data[0 ]) !=0x02c00081 ) { +warn_report ("Security Identifier value does not include H3 prefix" ); + } +/* Mark H3 object realized */ object_property_set_bool (OBJECT (h3), true,"realized" , &error_abort);
hw/misc/allwinner-sid.c new file +168 -0
168 lines not on this page · raw message
hw/misc/trace-events +4 -0
@@ -5,6 +5,10 @@ allwinner_cpucfg_cpu_reset(uint8_t cpu_id, uint32_t reset_addr) "id %u, reset_ad allwinner_cpucfg_read(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 allwinner_cpucfg_write(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +# allwinner-sid.c +allwinner_sid_read(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +allwinner_sid_write(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 + # eccmemctl.c ecc_mem_writel_mer(uint32_t val) "Write memory enable 0x%08x" ecc_mem_writel_mdr(uint32_t val) "Write memory delay 0x%08x"
Signature · 1 line
2.20.1
[PULL 09/36] hw/arm/cubieboard: make sure SOC object isn't leaked
In reply to Peter MaydellFrom: Igor Mammedov <[email protected]>
SOC object returned by object_new() is leaked in current code. Set SOC parent explicitly to board and then unref to SOC object to make sure that refererence returned by object_new() is taken care of.
The SOC object will be kept alive by its parent (machine) and will be automatically freed when MachineState is destroyed.
Message-id: [email protected]
--- hw/arm/cubieboard.c | 3 +++ 1 file changed, 3 insertions(+)
hw/arm/cubieboard.c +3 -0
@@ -54,6 +54,9 @@ static void cubieboard_init(MachineState *machine) } a10 =AW_A10 (object_new (TYPE_AW_A10 )); +object_property_add_child (OBJECT (machine),"soc" ,OBJECT (a10), + &error_abort); +object_unref (OBJECT (a10));object_property_set_int (OBJECT (&a10->emac),1 ,"phy-addr" , &err);if (err !=NULL ) {
Signature · 1 line
2.20.1
[PULL 22/36] hw/arm/allwinner-h3: add SDRAM controller device
In reply to Peter MaydellFrom: Niek Linnenbank <[email protected]>
In the Allwinner H3 SoC the SDRAM controller is responsible for interfacing with the external Synchronous Dynamic Random Access Memory (SDRAM). Types of memory that the SDRAM controller supports are DDR2/DDR3 and capacities of up to 2GiB. This commit adds emulation support of the Allwinner H3 SDRAM controller.
Message-id: [email protected]
--- hw/misc/Makefile.objs | 1 + include/hw/arm/allwinner-h3.h | 5 + include/hw/misc/allwinner-h3-dramc.h | 106 ++++++++ hw/arm/allwinner-h3.c | 19 +- hw/arm/orangepi.c | 6 + hw/misc/allwinner-h3-dramc.c | 358 +++++++++++++++++++++++++++ hw/misc/trace-events | 10 + 7 files changed, 502 insertions(+), 3 deletions(-) create mode 100644 include/hw/misc/allwinner-h3-dramc.h create mode 100644 hw/misc/allwinner-h3-dramc.c
hw/misc/Makefile.objs +1 -0
@@ -30,6 +30,7 @@ common-obj-$(CONFIG_IVSHMEM_DEVICE) += ivshmem.o common-obj-$(CONFIG_ALLWINNER_H3) += allwinner-h3-ccu.o obj-$(CONFIG_ALLWINNER_H3) += allwinner-cpucfg.o +common-obj-$(CONFIG_ALLWINNER_H3) += allwinner-h3-dramc.o common-obj-$(CONFIG_ALLWINNER_H3) += allwinner-h3-sysctrl.o common-obj-$(CONFIG_ALLWINNER_H3) += allwinner-sid.o common-obj-$(CONFIG_REALVIEW) += arm_sysctl.o
include/hw/arm/allwinner-h3.h +5 -0
@@ -41,6 +41,7 @@#include "hw/intc/arm_gic.h" #include "hw/misc/allwinner-h3-ccu.h" #include "hw/misc/allwinner-cpucfg.h" +#include "hw/misc/allwinner-h3-dramc.h" #include "hw/misc/allwinner-h3-sysctrl.h" #include "hw/misc/allwinner-sid.h" #include "hw/sd/allwinner-sdhost.h"
@@ -80,6 +81,9 @@ enum {AW_H3_UART2 ,AW_H3_UART3 ,AW_H3_EMAC , +AW_H3_DRAMCOM , +AW_H3_DRAMCTL , +AW_H3_DRAMPHY ,AW_H3_GIC_DIST ,AW_H3_GIC_CPU , AW_H3_GIC_HYP,
@@ -120,6 +124,7 @@ typedef struct AwH3State {AwA10PITState timer;AwH3ClockCtlState ccu;AwCpuCfgState cpucfg; +AwH3DramCtlState dramc;AwH3SysCtrlState sysctrl;AwSidState sid;AwSdHostState mmc0;
include/hw/misc/allwinner-h3-dramc.h new file +106 -0
106 lines not on this page · raw message
hw/arm/allwinner-h3.c +16 -3
@@ -56,6 +56,9 @@ const hwaddr allwinner_h3_memmap[] = { [AW_H3_UART2] = 0x01c28800, [AW_H3_UART3] = 0x01c28c00, [AW_H3_EMAC] = 0x01c30000, + [AW_H3_DRAMCOM] = 0x01c62000, + [AW_H3_DRAMCTL] = 0x01c63000, + [AW_H3_DRAMPHY] = 0x01c65000, [AW_H3_GIC_DIST] = 0x01c81000, [AW_H3_GIC_CPU] = 0x01c82000, [AW_H3_GIC_HYP] = 0x01c84000,
@@ -110,9 +113,6 @@ struct AwH3Unimplemented { { "scr", 0x01c2c400, 1 * KiB }, { "gpu", 0x01c40000, 64 * KiB }, { "hstmr", 0x01c60000, 4 * KiB }, - { "dramcom", 0x01c62000, 4 * KiB }, - { "dramctl0", 0x01c63000, 4 * KiB }, - { "dramphy0", 0x01c65000, 4 * KiB }, { "spi0", 0x01c68000, 4 * KiB }, { "spi1", 0x01c69000, 4 * KiB }, { "csi", 0x01cb0000, 320 * KiB },
@@ -228,6 +228,13 @@ static void allwinner_h3_init(Object *obj)sysbus_init_child_obj (obj,"emac" , &s->emac,sizeof (s->emac),TYPE_AW_SUN8I_EMAC ); + +sysbus_init_child_obj (obj,"dramc" , &s->dramc,sizeof (s->dramc), +TYPE_AW_H3_DRAMC ); +object_property_add_alias (obj,"ram-addr" ,OBJECT (&s->dramc), +"ram-addr" , &error_abort); +object_property_add_alias (obj,"ram-size" ,OBJECT (&s->dramc), +"ram-size" , &error_abort); }static void allwinner_h3_realize (DeviceState *dev,Error **errp)
@@ -412,6 +419,12 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_UART3 ), 115200, serial_hd(3), DEVICE_NATIVE_ENDIAN); +/* DRAMC */ +qdev_init_nofail (DEVICE (&s->dramc)); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->dramc),0 , s->memmap[AW_H3_DRAMCOM ]); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->dramc),1 , s->memmap[AW_H3_DRAMCTL ]); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->dramc),2 , s->memmap[AW_H3_DRAMPHY ]); +/* Unimplemented devices */ for (i =0 ; i <ARRAY_SIZE (unimplemented); i++) { create_unimplemented_device(unimplemented[i].device_name,
hw/arm/orangepi.c +6 -0
@@ -80,6 +80,12 @@ static void orangepi_init(MachineState *machine)/* Setup EMAC properties */ object_property_set_int (OBJECT (&h3->emac),1 ,"phy-addr" , &error_abort); +/* DRAMC */ +object_property_set_uint (OBJECT (h3), h3->memmap[AW_H3_SDRAM ], +"ram-addr" , &error_abort); +object_property_set_int (OBJECT (h3), machine->ram_size / MiB,"ram-size" , + &error_abort); +/* Mark H3 object realized */ object_property_set_bool (OBJECT (h3), true,"realized" , &error_abort);
hw/misc/allwinner-h3-dramc.c new file +358 -0
358 lines not on this page · raw message
hw/misc/trace-events +10 -0
@@ -5,6 +5,16 @@ allwinner_cpucfg_cpu_reset(uint8_t cpu_id, uint32_t reset_addr) "id %u, reset_ad allwinner_cpucfg_read(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 allwinner_cpucfg_write(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +# allwinner-h3-dramc.c +allwinner_h3_dramc_rowmirror_disable(void) "Disable row mirror" +allwinner_h3_dramc_rowmirror_enable(uint64_t addr) "Enable row mirror: addr 0x%" PRIx64 +allwinner_h3_dramcom_read(uint64_t offset, uint64_t data, unsigned size) "Read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +allwinner_h3_dramcom_write(uint64_t offset, uint64_t data, unsigned size) "Write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +allwinner_h3_dramctl_read(uint64_t offset, uint64_t data, unsigned size) "Read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +allwinner_h3_dramctl_write(uint64_t offset, uint64_t data, unsigned size) "Write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +allwinner_h3_dramphy_read(uint64_t offset, uint64_t data, unsigned size) "Read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +allwinner_h3_dramphy_write(uint64_t offset, uint64_t data, unsigned size) "write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 + # allwinner-sid.c allwinner_sid_read(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 allwinner_sid_write(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32
Signature · 1 line
2.20.1
[PULL 32/36] hw/arm/virt: Introduce finalize_gic_version()
In reply to Peter MaydellFrom: Eric Auger <[email protected]>
Let's move the code which freezes which gic-version to be applied in a dedicated function. We also now set by default the VIRT_GIC_VERSION_NO_SET. This eventually turns into the legacy v2 choice in the finalize() function.
Message-id: [email protected]
--- include/hw/arm/virt.h | 1 + hw/arm/virt.c | 54 ++++++++++++++++++++++++++----------------- 2 files changed, 34 insertions(+), 21 deletions(-)
include/hw/arm/virt.h +1 -0
@@ -100,6 +100,7 @@ typedef enum VirtGICType {VIRT_GIC_VERSION_HOST ,VIRT_GIC_VERSION_2 ,VIRT_GIC_VERSION_3 , +VIRT_GIC_VERSION_NOSEL , } VirtGICType; typedef struct MemMapEntry {
hw/arm/virt.c +33 -21
72 lines not on this page · raw message
Signature · 1 line
2.20.1
[PULL 20/36] hw/arm/allwinner-h3: add EMAC ethernet device
In reply to Peter MaydellFrom: Niek Linnenbank <[email protected]>
The Allwinner Sun8i System on Chip family includes an Ethernet MAC (EMAC) which provides 10M/100M/1000M Ethernet connectivity. This commit adds support for the Allwinner EMAC from the Sun8i family (H2+, H3, A33, etc), including emulation for the following functionality:
* DMA transfers
* MII interface
* Transmit CRC calculation
Message-id: [email protected]
--- hw/net/Makefile.objs | 1 + include/hw/arm/allwinner-h3.h | 3 + include/hw/net/allwinner-sun8i-emac.h | 99 +++ hw/arm/allwinner-h3.c | 16 +- hw/arm/orangepi.c | 3 + hw/net/allwinner-sun8i-emac.c | 871 ++++++++++++++++++++++++++ hw/arm/Kconfig | 1 + hw/net/Kconfig | 3 + hw/net/trace-events | 10 + 9 files changed, 1006 insertions(+), 1 deletion(-) create mode 100644 include/hw/net/allwinner-sun8i-emac.h create mode 100644 hw/net/allwinner-sun8i-emac.c
hw/net/Makefile.objs +1 -0
@@ -23,6 +23,7 @@ common-obj-$(CONFIG_XGMAC) += xgmac.o common-obj-$(CONFIG_MIPSNET) += mipsnet.o common-obj-$(CONFIG_XILINX_AXI) += xilinx_axienet.o common-obj-$(CONFIG_ALLWINNER_EMAC) += allwinner_emac.o +common-obj-$(CONFIG_ALLWINNER_SUN8I_EMAC) += allwinner-sun8i-emac.o common-obj-$(CONFIG_IMX_FEC) += imx_fec.o common-obj-$(CONFIG_CADENCE) += cadence_gem.o
include/hw/arm/allwinner-h3.h +3 -0
@@ -44,6 +44,7 @@#include "hw/misc/allwinner-h3-sysctrl.h" #include "hw/misc/allwinner-sid.h" #include "hw/sd/allwinner-sdhost.h" +#include "hw/net/allwinner-sun8i-emac.h" #include "target/arm/cpu.h" /**
@@ -77,6 +78,7 @@ enum {AW_H3_UART1 ,AW_H3_UART2 ,AW_H3_UART3 , +AW_H3_EMAC ,AW_H3_GIC_DIST ,AW_H3_GIC_CPU , AW_H3_GIC_HYP,
@@ -120,6 +122,7 @@ typedef struct AwH3State {AwH3SysCtrlState sysctrl;AwSidState sid;AwSdHostState mmc0; +AwSun8iEmacState emac;GICState gic;MemoryRegion sram_a1;MemoryRegion sram_a2;
include/hw/net/allwinner-sun8i-emac.h new file +99 -0
99 lines not on this page · raw message
hw/arm/allwinner-h3.c +15 -1
@@ -54,6 +54,7 @@ const hwaddr allwinner_h3_memmap[] = { [AW_H3_UART1] = 0x01c28400, [AW_H3_UART2] = 0x01c28800, [AW_H3_UART3] = 0x01c28c00, + [AW_H3_EMAC] = 0x01c30000, [AW_H3_GIC_DIST] = 0x01c81000, [AW_H3_GIC_CPU] = 0x01c82000, [AW_H3_GIC_HYP] = 0x01c84000,
@@ -106,7 +107,6 @@ struct AwH3Unimplemented { { "twi1", 0x01c2b000, 1 * KiB }, { "twi2", 0x01c2b400, 1 * KiB }, { "scr", 0x01c2c400, 1 * KiB }, - { "emac", 0x01c30000, 64 * KiB }, { "gpu", 0x01c40000, 64 * KiB }, { "hstmr", 0x01c60000, 4 * KiB }, { "dramcom", 0x01c62000, 4 * KiB },
@@ -162,6 +162,7 @@ enum {AW_H3_GIC_SPI_OHCI2 =77 ,AW_H3_GIC_SPI_EHCI3 =78 ,AW_H3_GIC_SPI_OHCI3 =79 , + AW_H3_GIC_SPI_EMAC = 82 };/* Allwinner H3 general constants */
@@ -207,6 +208,9 @@ static void allwinner_h3_init(Object *obj)sysbus_init_child_obj (obj,"mmc0" , &s->mmc0,sizeof (s->mmc0),TYPE_AW_SDHOST_SUN5I ); + +sysbus_init_child_obj (obj,"emac" , &s->emac,sizeof (s->emac), +TYPE_AW_SUN8I_EMAC ); }static void allwinner_h3_realize (DeviceState *dev,Error **errp)
@@ -337,6 +341,16 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)object_property_add_alias (OBJECT (s),"sd-bus" ,OBJECT (&s->mmc0),"sd-bus" , &error_abort); +/* EMAC */ +if (nd_table[0 ].used) { +qemu_check_nic_model (&nd_table[0 ],TYPE_AW_SUN8I_EMAC ); +qdev_set_nic_properties (DEVICE (&s->emac), &nd_table[0 ]); + } +qdev_init_nofail (DEVICE (&s->emac)); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->emac),0 , s->memmap[AW_H3_EMAC ]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->emac),0 , +qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_EMAC )); +/* Universal Serial Bus */ sysbus_create_simple(TYPE_AW_H3_EHCI, s->memmap[AW_H3_EHCI0], qdev_get_gpio_in(DEVICE(&s->gic),
hw/arm/orangepi.c +3 -0
@@ -77,6 +77,9 @@ static void orangepi_init(MachineState *machine)warn_report ("Security Identifier value does not include H3 prefix" ); } +/* Setup EMAC properties */ +object_property_set_int (OBJECT (&h3->emac),1 ,"phy-addr" , &error_abort); +/* Mark H3 object realized */ object_property_set_bool (OBJECT (h3), true,"realized" , &error_abort);
hw/net/allwinner-sun8i-emac.c new file +871 -0
871 lines not on this page · raw message
hw/arm/Kconfig +1 -0
@@ -300,6 +300,7 @@ config ALLWINNER_A10 config ALLWINNER_H3 bool select ALLWINNER_A10_PIT + select ALLWINNER_SUN8I_EMAC select SERIAL select ARM_TIMER select ARM_GIC
hw/net/Kconfig +3 -0
@@ -79,6 +79,9 @@ config MIPSNET config ALLWINNER_EMAC bool +config ALLWINNER_SUN8I_EMAC + bool + config IMX_FEC bool
hw/net/trace-events +10 -0
@@ -1,5 +1,15 @@ # See docs/devel/tracing.txt for syntax documentation. +# allwinner-sun8i-emac.c +allwinner_sun8i_emac_mii_write_reg(uint32_t reg, uint32_t value) "MII write: reg=0x%" PRIx32 " value=0x%" PRIx32 +allwinner_sun8i_emac_mii_read_reg(uint32_t reg, uint32_t value) "MII read: reg=0x%" PRIx32 " value=0x%" PRIx32 +allwinner_sun8i_emac_receive(uint32_t desc, uint32_t paddr, uint32_t bytes) "RX packet: desc=0x%" PRIx32 " paddr=0x%" PRIx32 " bytes=%" PRIu32 +allwinner_sun8i_emac_transmit(uint32_t desc, uint32_t paddr, uint32_t bytes) "TX packet: desc=0x%" PRIx32 " paddr=0x%" PRIx32 " bytes=%" PRIu32 +allwinner_sun8i_emac_reset(void) "HW reset" +allwinner_sun8i_emac_set_link(bool active) "Set link: active=%u" +allwinner_sun8i_emac_read(uint64_t offset, uint64_t val) "MMIO read: offset=0x%" PRIx64 " value=0x%" PRIx64 +allwinner_sun8i_emac_write(uint64_t offset, uint64_t val) "MMIO write: offset=0x%" PRIx64 " value=0x%" PRIx64 + # etraxfs_eth.c mdio_phy_read(int regnum, uint16_t value) "read phy_reg:%d value:0x%04x" mdio_phy_write(int regnum, uint16_t value) "write phy_reg:%d value:0x%04x"
Signature · 1 line
2.20.1
[PULL 12/36] hw/arm: add Allwinner H3 System-on-Chip
In reply to Peter MaydellFrom: Niek Linnenbank <[email protected]>
The Allwinner H3 is a System on Chip containing four ARM Cortex A7 processor cores. Features and specifications include DDR2/DDR3 memory, SD/MMC storage cards, 10/100/1000Mbit Ethernet, USB 2.0, HDMI and various I/O modules. This commit adds support for the Allwinner H3 System on Chip.
Message-id: [email protected]
--- hw/arm/Makefile.objs | 1 + include/hw/arm/allwinner-h3.h | 106 +++++++++++ hw/arm/allwinner-h3.c | 327 ++++++++++++++++++++++++++++++++ MAINTAINERS | 7 + default-configs/arm-softmmu.mak | 1 + hw/arm/Kconfig | 8 + 6 files changed, 450 insertions(+) create mode 100644 include/hw/arm/allwinner-h3.h create mode 100644 hw/arm/allwinner-h3.c
hw/arm/Makefile.objs +1 -0
@@ -35,6 +35,7 @@ obj-$(CONFIG_DIGIC) += digic.o obj-$(CONFIG_OMAP) += omap1.o omap2.o obj-$(CONFIG_STRONGARM) += strongarm.o obj-$(CONFIG_ALLWINNER_A10) += allwinner-a10.o cubieboard.o +obj-$(CONFIG_ALLWINNER_H3) += allwinner-h3.o obj-$(CONFIG_RASPI) += bcm2835_peripherals.o bcm2836.o raspi.o obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o obj-$(CONFIG_STM32F405_SOC) += stm32f405_soc.o
include/hw/arm/allwinner-h3.h new file +106 -0
106 lines not on this page · raw message
hw/arm/allwinner-h3.c new file +327 -0
327 lines not on this page · raw message
MAINTAINERS +7 -0
@@ -492,6 +492,13 @@ F: hw/*/allwinner* F: include/hw/*/allwinner* F: hw/arm/cubieboard.c +Allwinner-h3 +M: Niek Linnenbank <[email protected]> +L: [email protected] +S: Maintained +F: hw/*/allwinner-h3* +F: include/hw/*/allwinner-h3* + ARM PrimeCell and CMSDK devices M: Peter Maydell <[email protected]> L: [email protected]
default-configs/arm-softmmu.mak +1 -0
@@ -41,3 +41,4 @@ CONFIG_FSL_IMX25=y CONFIG_FSL_IMX7=y CONFIG_FSL_IMX6UL=y CONFIG_SEMIHOSTING=y +CONFIG_ALLWINNER_H3=y
hw/arm/Kconfig +8 -0
@@ -297,6 +297,14 @@ config ALLWINNER_A10 select SERIAL select UNIMP +config ALLWINNER_H3 + bool + select ALLWINNER_A10_PIT + select SERIAL + select ARM_TIMER + select ARM_GIC + select UNIMP + config RASPI bool select FRAMEBUFFER
Signature · 1 line
2.20.1
[PULL 19/36] hw/arm/allwinner: add SD/MMC host controller
In reply to Peter MaydellFrom: Niek Linnenbank <[email protected]>
The Allwinner System on Chip families sun4i and above contain an integrated storage controller for Secure Digital (SD) and Multi Media Card (MMC) interfaces. This commit adds support for the Allwinner SD/MMC storage controller with the following emulated features:
* DMA transfers
* Direct FIFO I/O
* Short/Long format command responses
* Auto-Stop command (CMD12)
* Insert & remove card detection
The following boards are extended with the SD host controller:
* Cubieboard (hw/arm/cubieboard.c)
* Orange Pi PC (hw/arm/orangepi.c)
Message-id: [email protected]
--- hw/sd/Makefile.objs | 1 + include/hw/arm/allwinner-a10.h | 2 + include/hw/arm/allwinner-h3.h | 3 + include/hw/sd/allwinner-sdhost.h | 135 +++++ hw/arm/allwinner-a10.c | 11 + hw/arm/allwinner-h3.c | 15 +- hw/arm/cubieboard.c | 15 + hw/arm/orangepi.c | 16 + hw/sd/allwinner-sdhost.c | 854 +++++++++++++++++++++++++++++++ hw/arm/Kconfig | 1 + hw/sd/trace-events | 7 + 11 files changed, 1059 insertions(+), 1 deletion(-) create mode 100644 include/hw/sd/allwinner-sdhost.h create mode 100644 hw/sd/allwinner-sdhost.c
hw/sd/Makefile.objs +1 -0
@@ -4,6 +4,7 @@ common-obj-$(CONFIG_SD) += sd.o core.o sdmmc-internal.o common-obj-$(CONFIG_SDHCI) += sdhci.o common-obj-$(CONFIG_SDHCI_PCI) += sdhci-pci.o +common-obj-$(CONFIG_ALLWINNER_H3) += allwinner-sdhost.o common-obj-$(CONFIG_MILKYMIST) += milkymist-memcard.o common-obj-$(CONFIG_OMAP) += omap_mmc.o common-obj-$(CONFIG_PXA2XX) += pxa2xx_mmci.o
include/hw/arm/allwinner-a10.h +2 -0
@@ -7,6 +7,7 @@#include "hw/timer/allwinner-a10-pit.h" #include "hw/intc/allwinner-a10-pic.h" #include "hw/net/allwinner_emac.h" +#include "hw/sd/allwinner-sdhost.h" #include "hw/ide/ahci.h" #include "hw/usb/hcd-ohci.h" #include "hw/usb/hcd-ehci.h"
@@ -31,6 +32,7 @@ typedef struct AwA10State {AwA10PICState intc;AwEmacState emac;AllwinnerAHCIState sata; +AwSdHostState mmc0;MemoryRegion sram_a;EHCISysBusState ehci[AW_A10_NUM_USB ];OHCISysBusState ohci[AW_A10_NUM_USB ];
include/hw/arm/allwinner-h3.h +3 -0
@@ -43,6 +43,7 @@#include "hw/misc/allwinner-cpucfg.h" #include "hw/misc/allwinner-h3-sysctrl.h" #include "hw/misc/allwinner-sid.h" +#include "hw/sd/allwinner-sdhost.h" #include "target/arm/cpu.h" /**
@@ -60,6 +61,7 @@ enum {AW_H3_SRAM_A2 ,AW_H3_SRAM_C ,AW_H3_SYSCTRL , +AW_H3_MMC0 ,AW_H3_SID ,AW_H3_EHCI0 , AW_H3_OHCI0,
@@ -117,6 +119,7 @@ typedef struct AwH3State {AwCpuCfgState cpucfg;AwH3SysCtrlState sysctrl;AwSidState sid; +AwSdHostState mmc0;GICState gic;MemoryRegion sram_a1;MemoryRegion sram_a2;
include/hw/sd/allwinner-sdhost.h new file +135 -0
135 lines not on this page · raw message
hw/arm/allwinner-a10.c +11 -0
@@ -27,6 +27,7 @@#include "hw/boards.h" #include "hw/usb/hcd-ohci.h" +#define AW_A10_MMC0_BASE 0x01c0f000#define AW_A10_PIC_REG_BASE 0x01c20400#define AW_A10_PIT_REG_BASE 0x01c20c00#define AW_A10_UART0_REG_BASE 0x01c28000
@@ -64,6 +65,9 @@ static void aw_a10_init(Object *obj) sizeof(s->ohci[i]), TYPE_SYSBUS_OHCI); } } + +sysbus_init_child_obj (obj,"mmc0" , &s->mmc0,sizeof (s->mmc0), +TYPE_AW_SDHOST_SUN4I ); }static void aw_a10_realize (DeviceState *dev,Error **errp)
@@ -164,6 +168,13 @@ static void aw_a10_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in(dev, 64 + i)); } } + +/* SD/MMC */ +qdev_init_nofail (DEVICE (&s->mmc0)); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->mmc0),0 ,AW_A10_MMC0_BASE ); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->mmc0),0 ,qdev_get_gpio_in (dev,32 )); +object_property_add_alias (OBJECT (s),"sd-bus" ,OBJECT (&s->mmc0), +"sd-bus" , &error_abort); }static void aw_a10_class_init (ObjectClass *oc,void *data)
hw/arm/allwinner-h3.c +14 -1
@@ -38,6 +38,7 @@ const hwaddr allwinner_h3_memmap[] = { [AW_H3_SRAM_A2] = 0x00044000, [AW_H3_SRAM_C] = 0x00010000, [AW_H3_SYSCTRL] = 0x01c00000, + [AW_H3_MMC0] = 0x01c0f000, [AW_H3_SID] = 0x01c14000, [AW_H3_EHCI0] = 0x01c1a000, [AW_H3_OHCI0] = 0x01c1a400,
@@ -76,7 +77,6 @@ struct AwH3Unimplemented { { "lcd0", 0x01c0c000, 4 * KiB }, { "lcd1", 0x01c0d000, 4 * KiB }, { "ve", 0x01c0e000, 4 * KiB }, - { "mmc0", 0x01c0f000, 4 * KiB }, { "mmc1", 0x01c10000, 4 * KiB }, { "mmc2", 0x01c11000, 4 * KiB }, { "crypto", 0x01c15000, 4 * KiB },
@@ -153,6 +153,7 @@ enum {AW_H3_GIC_SPI_UART3 =3 ,AW_H3_GIC_SPI_TIMER0 =18 ,AW_H3_GIC_SPI_TIMER1 =19 , +AW_H3_GIC_SPI_MMC0 =60 ,AW_H3_GIC_SPI_EHCI0 =72 ,AW_H3_GIC_SPI_OHCI0 =73 , AW_H3_GIC_SPI_EHCI1 = 74,
@@ -203,6 +204,9 @@ static void allwinner_h3_init(Object *obj) TYPE_AW_SID);object_property_add_alias (obj,"identifier" ,OBJECT (&s->sid),"identifier" , &error_abort); + +sysbus_init_child_obj (obj,"mmc0" , &s->mmc0,sizeof (s->mmc0), +TYPE_AW_SDHOST_SUN5I ); }static void allwinner_h3_realize (DeviceState *dev,Error **errp)
@@ -324,6 +328,15 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)qdev_init_nofail (DEVICE (&s->sid));sysbus_mmio_map (SYS_BUS_DEVICE (&s->sid),0 , s->memmap[AW_H3_SID ]); +/* SD/MMC */ +qdev_init_nofail (DEVICE (&s->mmc0)); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->mmc0),0 , s->memmap[AW_H3_MMC0 ]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->mmc0),0 , +qdev_get_gpio_in (DEVICE (&s->gic),AW_H3_GIC_SPI_MMC0 )); + +object_property_add_alias (OBJECT (s),"sd-bus" ,OBJECT (&s->mmc0), +"sd-bus" , &error_abort); +/* Universal Serial Bus */ sysbus_create_simple(TYPE_AW_H3_EHCI, s->memmap[AW_H3_EHCI0], qdev_get_gpio_in(DEVICE(&s->gic),
hw/arm/cubieboard.c +15 -0
@@ -22,6 +22,7 @@#include "sysemu/sysemu.h" #include "hw/sysbus.h" #include "hw/boards.h" +#include "hw/qdev-properties.h" #include "hw/arm/allwinner-a10.h" static struct arm_boot_info cubieboard_binfo = {
@@ -33,6 +34,10 @@ static void cubieboard_init(MachineState *machine) {AwA10State *a10;Error *err =NULL ; +DriveInfo *di; +BlockBackend *blk; +BusState *bus; +DeviceState *carddev;/* BIOS is not supported by this board */ if (bios_name) {
@@ -82,6 +87,16 @@ static void cubieboard_init(MachineState *machine)exit (1 ); } +/* Retrieve SD bus */ + di =drive_get_next (IF_SD ); + blk = di ?blk_by_legacy_dinfo (di) :NULL ; + bus =qdev_get_child_bus (DEVICE (a10),"sd-bus" ); + +/* Plug in SD card */ + carddev =qdev_create (bus,TYPE_SD_CARD ); +qdev_prop_set_drive (carddev,"drive" , blk, &error_fatal); +object_property_set_bool (OBJECT (carddev), true,"realized" , &error_fatal); +memory_region_add_subregion (get_system_memory (),AW_A10_SDRAM_BASE , machine->ram);
hw/arm/orangepi.c +16 -0
@@ -35,6 +35,10 @@ static struct arm_boot_info orangepi_binfo = {static void orangepi_init (MachineState *machine) {AwH3State *h3; +DriveInfo *di; +BlockBackend *blk; +BusState *bus; +DeviceState *carddev;/* BIOS is not supported by this board */ if (bios_name) {
@@ -76,6 +80,16 @@ static void orangepi_init(MachineState *machine)/* Mark H3 object realized */ object_property_set_bool (OBJECT (h3), true,"realized" , &error_abort); +/* Retrieve SD bus */ + di =drive_get_next (IF_SD ); + blk = di ?blk_by_legacy_dinfo (di) :NULL ; + bus =qdev_get_child_bus (DEVICE (h3),"sd-bus" ); + +/* Plug in SD card */ + carddev =qdev_create (bus,TYPE_SD_CARD ); +qdev_prop_set_drive (carddev,"drive" , blk, &error_fatal); +object_property_set_bool (OBJECT (carddev), true,"realized" , &error_fatal); +/* SDRAM */ memory_region_add_subregion (get_system_memory (), h3->memmap[AW_H3_SDRAM ], machine->ram);
@@ -89,6 +103,8 @@ static void orangepi_machine_init(MachineClass *mc) { mc->desc ="Orange Pi PC" ; mc->init = orangepi_init; + mc->block_default_type =IF_SD ; + mc->units_per_default_bus =1 ; mc->min_cpus =AW_H3_NUM_CPUS ; mc->max_cpus =AW_H3_NUM_CPUS ; mc->default_cpus =AW_H3_NUM_CPUS ;
hw/sd/allwinner-sdhost.c new file +854 -0
854 lines not on this page · raw message
hw/arm/Kconfig +1 -0
@@ -306,6 +306,7 @@ config ALLWINNER_H3 select UNIMP select USB_OHCI select USB_EHCI_SYSBUS + select SD config RASPI bool
hw/sd/trace-events +7 -0
@@ -1,5 +1,12 @@ # See docs/devel/tracing.txt for syntax documentation. +# allwinner-sdhost.c +allwinner_sdhost_set_inserted(bool inserted) "inserted %u" +allwinner_sdhost_process_desc(uint64_t desc_addr, uint32_t desc_size, bool is_write, uint32_t max_bytes) "desc_addr 0x%" PRIx64 " desc_size %" PRIu32 " is_write %u max_bytes %" PRIu32 +allwinner_sdhost_read(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +allwinner_sdhost_write(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +allwinner_sdhost_update_irq(uint32_t irq) "IRQ bits 0x%" PRIx32 + # bcm2835_sdhost.c bcm2835_sdhost_read(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u" bcm2835_sdhost_write(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %u"
Signature · 1 line
2.20.1
[PULL 35/36] hw/arm/virt: kvm: allow gicv3 by default if v2 cannot work
In reply to Peter MaydellFrom: Eric Auger <[email protected]>
At the moment if the end-user does not specify the gic-version along with KVM acceleration, v2 is set by default. However most of the systems now have GICv3 and sometimes they do not support GICv2 compatibility.
This patch keeps the default v2 selection in all cases except in the KVM accelerated mode when either
- the host does not support GICv2 in-kernel emulation or
- number of VCPUS exceeds 8.
Those cases did not work anyway so we do not break any compatibility. Now we get v3 selected in such a case.
Message-id: [email protected]
--- hw/arm/virt.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
hw/arm/virt.c +16 -1
@@ -1543,6 +1543,8 @@ static void virt_set_memmap(VirtMachineState *vms)*/ static void finalize_gic_version (VirtMachineState *vms) { +unsigned int max_cpus =MACHINE (vms)->smp.max_cpus; +if (kvm_enabled ()) {int probe_bitmap;
@@ -1582,7 +1584,20 @@ static void finalize_gic_version(VirtMachineState *vms) }return ;case VIRT_GIC_VERSION_NOSEL : - vms->gic_version =VIRT_GIC_VERSION_2 ; +if ((probe_bitmap &KVM_ARM_VGIC_V2 ) && max_cpus <=GIC_NCPU ) { + vms->gic_version =VIRT_GIC_VERSION_2 ; + }else if (probe_bitmap &KVM_ARM_VGIC_V3 ) { +/* +* in case the host does not support v2 in-kernel emulation or +* the end-user requested more than 8 VCPUs we now default +* to v3. In any case defaulting to v2 would be broken. +*/ + vms->gic_version =VIRT_GIC_VERSION_3 ; + }else if (max_cpus >GIC_NCPU ) { +error_report ("host only supports in-kernel GICv2 emulation " +"but more than 8 vcpus are requested" ); +exit (1 ); + }break ;case VIRT_GIC_VERSION_2 :case VIRT_GIC_VERSION_3 :
Signature · 1 line
2.20.1
[PULL 25/36] tests/boot_linux_console: Add initrd test for the Orange Pi PC board
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
This test boots a Linux kernel on a OrangePi PC board and verify the serial output is working.
The kernel image and DeviceTree blob are built by the Armbian project (based on Debian):
https://www.armbian.com/orange-pi-pc/
The cpio image used comes from the linux-build-test project:
https://github.com/groeck/linux-build-test
If ARM is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:arm" tags.
Alternatively, this test can be run using:
$ avocado --show=console run -t machine:orangepi-pc tests/acceptance/boot_linux_console.py console: Uncompressing Linux... done, booting the kernel. console: Booting Linux on physical CPU 0x0 console: Linux version 4.20.7-sunxi ([email protected]) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #5.75 SMP Fri Feb 8 09:02:10 CET 2019 console: CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=50c5387d console: CPU: div instructions available: patching division code console: CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache console: OF: fdt: Machine model: Xunlong Orange Pi PC [...] console: Trying to unpack rootfs image as initramfs... console: Freeing initrd memory: 3256K console: Freeing unused kernel memory: 1024K console: Run /init as init process console: mount: mounting devtmpfs on /dev failed: Device or resource busy console: Starting logging: OK console: Initializing random number generator... random: dd: uninitialized urandom read (512 bytes read) console: done. console: Starting network: OK console: Found console ttyS0 console: Linux version 4.20.7-sunxi ([email protected]) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #5.75 SMP Fri Feb 8 09:02:10 CET 2019 console: Boot successful. console: cat /proc/cpuinfo console: / # cat /proc/cpuinfo console: processor : 0 console: model name : ARMv7 Processor rev 5 (v7l) console: BogoMIPS : 125.00 console: Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm console: CPU implementer : 0x41 console: CPU architecture: 7 console: CPU variant : 0x0 console: CPU part : 0xc07 console: CPU revision : 5 [...] console: processor : 3 console: model name : ARMv7 Processor rev 5 (v7l) console: BogoMIPS : 125.00 console: Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm console: CPU implementer : 0x41 console: CPU architecture: 7 console: CPU variant : 0x0 console: CPU part : 0xc07 console: CPU revision : 5 console: Hardware : Allwinner sun8i Family console: Revision : 0000 console: Serial : 0000000000000000 console: cat /proc/iomem console: / # cat /proc/iomem console: 01000000-010fffff : clock@1000000 console: 01c00000-01c00fff : system-control@1c00000 console: 01c02000-01c02fff : dma-controller@1c02000 [...] console: reboot console: / # reboot console: / # Found console ttyS0 console: Stopping network: OK console: hrtimer: interrupt took 21852064 ns console: Saving random seed... random: dd: uninitialized urandom read (512 bytes read) console: done. console: Stopping logging: OK console: umount: devtmpfs busy - remounted read-only console: umount: can't unmount /: Invalid argument console: The system is going down NOW! console: Sent SIGTERM to all processes console: Sent SIGKILL to all processes console: Requesting system reboot console: reboot: Restarting system PASS (48.32 s) JOB TIME : 49.16 s
Message-id: [email protected]
--- tests/acceptance/boot_linux_console.py | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
tests/acceptance/boot_linux_console.py +40 -0
@@ -532,6 +532,46 @@ class BootLinuxConsole(Test): console_pattern = 'Kernel command line: %s' % kernel_command_line self.wait_for_console_pattern(console_pattern) + def test_arm_orangepi_initrd(self): + """ + :avocado: tags=arch:arm + :avocado: tags=machine:orangepi-pc + """ + deb_url = ('https://apt.armbian.com/pool/main/l/' + 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') + deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + kernel_path = self.extract_from_deb(deb_path, + '/boot/vmlinuz-4.20.7-sunxi') + dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb' + dtb_path = self.extract_from_deb(deb_path, dtb_path) + initrd_url = ('https://github.com/groeck/linux-build-test/raw/' + '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' + 'arm/rootfs-armv7a.cpio.gz') + initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c' + initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) + initrd_path = os.path.join(self.workdir, 'rootfs.cpio') + archive.gzip_uncompress(initrd_path_gz, initrd_path) + + self.vm.set_console() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyS0,115200 ' + 'panic=-1 noreboot') + self.vm.add_args('-kernel', kernel_path, + '-dtb', dtb_path, + '-initrd', initrd_path, + '-append', kernel_command_line, + '-no-reboot') + self.vm.launch() + self.wait_for_console_pattern('Boot successful.') + + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', + 'Allwinner sun8i Family') + exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', + 'system-control@1c00000') + exec_command_and_wait_for_pattern(self, 'reboot', + 'reboot: Restarting system') + def test_s390x_s390_ccw_virtio(self): """ :avocado: tags=arch:s390x
Signature · 1 line
2.20.1
[PULL 15/36] hw/arm/allwinner-h3: add USB host controller
In reply to Peter MaydellFrom: Niek Linnenbank <[email protected]>
The Allwinner H3 System on Chip contains multiple USB 2.0 bus connections which provide software access using the Enhanced Host Controller Interface (EHCI) and Open Host Controller Interface (OHCI) interfaces. This commit adds support for both interfaces in the Allwinner H3 System on Chip.
Message-id: [email protected]
--- hw/usb/hcd-ehci.h | 1 + include/hw/arm/allwinner-h3.h | 8 +++++++ hw/arm/allwinner-h3.c | 44 +++++++++++++++++++++++++++++++++++ hw/usb/hcd-ehci-sysbus.c | 17 ++++++++++++++ hw/arm/Kconfig | 2 ++ 5 files changed, 72 insertions(+)
hw/usb/hcd-ehci.h +1 -0
@@ -342,6 +342,7 @@ typedef struct EHCIPCIState {#define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb"#define TYPE_PLATFORM_EHCI "platform-ehci-usb"#define TYPE_EXYNOS4210_EHCI "exynos4210-ehci-usb" +#define TYPE_AW_H3_EHCI "aw-h3-ehci-usb"#define TYPE_TEGRA2_EHCI "tegra2-ehci-usb"#define TYPE_PPC4xx_EHCI "ppc4xx-ehci-usb"#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb"
include/hw/arm/allwinner-h3.h +8 -0
@@ -56,6 +56,14 @@ enum {AW_H3_SRAM_A1 ,AW_H3_SRAM_A2 ,AW_H3_SRAM_C , +AW_H3_EHCI0 , +AW_H3_OHCI0 , +AW_H3_EHCI1 , +AW_H3_OHCI1 , +AW_H3_EHCI2 , +AW_H3_OHCI2 , +AW_H3_EHCI3 , +AW_H3_OHCI3 ,AW_H3_CCU ,AW_H3_PIT , AW_H3_UART0,
hw/arm/allwinner-h3.c +44 -0
68 lines not on this page · raw message
hw/usb/hcd-ehci-sysbus.c +17 -0
@@ -131,6 +131,22 @@ static const TypeInfo ehci_exynos4210_type_info = { .class_init = ehci_exynos4210_class_init, }; +static void ehci_aw_h3_class_init (ObjectClass *oc,void *data) +{ +SysBusEHCIClass *sec =SYS_BUS_EHCI_CLASS (oc); +DeviceClass *dc =DEVICE_CLASS (oc); + + sec->capsbase =0x0 ; + sec->opregbase =0x10 ; +set_bit (DEVICE_CATEGORY_USB , dc->categories); +} + +static const TypeInfo ehci_aw_h3_type_info = { + .name =TYPE_AW_H3_EHCI , + .parent =TYPE_SYS_BUS_EHCI , + .class_init = ehci_aw_h3_class_init, +}; +static void ehci_tegra2_class_init (ObjectClass *oc,void *data) {SysBusEHCIClass *sec =SYS_BUS_EHCI_CLASS (oc);
@@ -252,6 +268,7 @@ static void ehci_sysbus_register_types(void)type_register_static (&ehci_type_info);type_register_static (&ehci_platform_type_info);type_register_static (&ehci_exynos4210_type_info); +type_register_static (&ehci_aw_h3_type_info);type_register_static (&ehci_tegra2_type_info);type_register_static (&ehci_ppc4xx_type_info);type_register_static (&ehci_fusbh200_type_info);
hw/arm/Kconfig +2 -0
@@ -304,6 +304,8 @@ config ALLWINNER_H3 select ARM_TIMER select ARM_GIC select UNIMP + select USB_OHCI + select USB_EHCI_SYSBUS config RASPI bool
Signature · 1 line
2.20.1
[PULL 26/36] tests/boot_linux_console: Add a SD card test for the OrangePi PC board
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
The kernel image and DeviceTree blob are built by the Armbian project (based on Debian):
https://www.armbian.com/orange-pi-pc/
The SD image is from the kernelci.org project:
https://kernelci.org/faq/#the-code
If ARM is a target being built, "make check-acceptance" will automatically include this test by the use of the "arch:arm" tags.
Alternatively, this test can be run using:
$ avocado --show=console run -t machine:orangepi-pc tests/acceptance/boot_linux_console.py console: Uncompressing Linux... done, booting the kernel. console: Booting Linux on physical CPU 0x0 console: Linux version 4.20.7-sunxi ([email protected]) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #5.75 SMP Fri Feb 8 09:02:10 CET 2019 console: CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=50c5387d [...] console: sunxi-wdt 1c20ca0.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0) console: sunxi-mmc 1c0f000.mmc: Linked as a consumer to regulator.2 console: sunxi-mmc 1c0f000.mmc: Got CD GPIO console: ledtrig-cpu: registered to indicate activity on CPUs console: hidraw: raw HID events driver (C) Jiri Kosina console: usbcore: registered new interface driver usbhid console: usbhid: USB HID core driver console: Initializing XFRM netlink socket console: sunxi-mmc 1c0f000.mmc: initialized, max. request size: 16384 KB console: NET: Registered protocol family 10 console: mmc0: host does not support reading read-only switch, assuming write-enable console: mmc0: Problem switching card into high-speed mode! console: mmc0: new SD card at address 4567 console: mmcblk0: mmc0:4567 QEMU! 60.0 MiB [...] console: EXT4-fs (mmcblk0): mounting ext2 file system using the ext4 subsystem console: EXT4-fs (mmcblk0): mounted filesystem without journal. Opts: (null) console: VFS: Mounted root (ext2 filesystem) on device 179:0. console: Run /sbin/init as init process console: EXT4-fs (mmcblk0): re-mounted. Opts: block_validity,barrier,user_xattr,acl console: Starting syslogd: OK console: Starting klogd: OK console: Populating /dev using udev: udevd[203]: starting version 3.2.7 console: /bin/sh: can't access tty; job control turned off console: cat /proc/partitions console: / # cat /proc/partitions console: major minor #blocks name console: 1 0 4096 ram0 console: 1 1 4096 ram1 console: 1 2 4096 ram2 console: 1 3 4096 ram3 console: 179 0 61440 mmcblk0 console: reboot console: / # reboot console: umount: devtmpfs busy - remounted read-only console: EXT4-fs (mmcblk0): re-mounted. Opts: (null) console: The system is going down NOW! console: Sent SIGTERM to all processes console: Sent SIGKILL to all processes console: Requesting system reboot console: reboot: Restarting system JOB TIME : 68.64 s
Message-id: [email protected]
--- tests/acceptance/boot_linux_console.py | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
tests/acceptance/boot_linux_console.py +47 -0
@@ -572,6 +572,53 @@ class BootLinuxConsole(Test): exec_command_and_wait_for_pattern(self, 'reboot', 'reboot: Restarting system') + def test_arm_orangepi_sd(self): + """ + :avocado: tags=arch:arm + :avocado: tags=machine:orangepi-pc + """ + deb_url = ('https://apt.armbian.com/pool/main/l/' + 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') + deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + kernel_path = self.extract_from_deb(deb_path, + '/boot/vmlinuz-4.20.7-sunxi') + dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb' + dtb_path = self.extract_from_deb(deb_path, dtb_path) + rootfs_url = ('http://storage.kernelci.org/images/rootfs/buildroot/' + 'kci-2019.02/armel/base/rootfs.ext2.xz') + rootfs_hash = '692510cb625efda31640d1de0a8d60e26040f061' + rootfs_path_xz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash) + rootfs_path = os.path.join(self.workdir, 'rootfs.cpio') + archive.lzma_uncompress(rootfs_path_xz, rootfs_path) + + self.vm.set_console() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyS0,115200 ' + 'root=/dev/mmcblk0 rootwait rw ' + 'panic=-1 noreboot') + self.vm.add_args('-kernel', kernel_path, + '-dtb', dtb_path, + '-drive', 'file=' + rootfs_path + ',if=sd,format=raw', + '-append', kernel_command_line, + '-no-reboot') + self.vm.launch() + shell_ready = "/bin/sh: can't access tty; job control turned off" + self.wait_for_console_pattern(shell_ready) + + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', + 'Allwinner sun8i Family') + exec_command_and_wait_for_pattern(self, 'cat /proc/partitions', + 'mmcblk0') + exec_command_and_wait_for_pattern(self, 'ifconfig eth0 up', + 'eth0: Link is Up') + exec_command_and_wait_for_pattern(self, 'udhcpc eth0', + 'udhcpc: lease of 10.0.2.15 obtained') + exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2', + '3 packets transmitted, 3 packets received, 0% packet loss') + exec_command_and_wait_for_pattern(self, 'reboot', + 'reboot: Restarting system') + def test_s390x_s390_ccw_virtio(self): """ :avocado: tags=arch:s390x
Signature · 1 line
2.20.1
[PULL 27/36] tests/boot_linux_console: Add a SLOW test booting Ubuntu on OrangePi PC
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
This test boots Ubuntu Bionic on a OrangePi PC board.
As it requires 1GB of storage, and is slow, this test is disabled on automatic CI testing.
It is useful for workstation testing. Currently Avocado timeouts too quickly, so we can't run userland commands.
The kernel image and DeviceTree blob are built by the Armbian project (based on Debian):
https://www.armbian.com/orange-pi-pc/
The Ubuntu image is downloaded from:
https://dl.armbian.com/orangepipc/Bionic_current
This test can be run using:
$ AVOCADO_ALLOW_LARGE_STORAGE=yes \
avocado --show=app,console run -t machine:orangepi-pc \
tests/acceptance/boot_linux_console.py
console: U-Boot SPL 2019.04-armbian (Nov 18 2019 - 23:08:35 +0100)
console: DRAM: 1024 MiB
console: Failed to set core voltage! Can't set CPU frequency
console: Trying to boot from MMC1
console: U-Boot 2019.04-armbian (Nov 18 2019 - 23:08:35 +0100) Allwinner Technology
console: CPU: Allwinner H3 (SUN8I 0000)
console: Model: Xunlong Orange Pi PC
console: DRAM: 1 GiB
console: MMC: mmc@1c0f000: 0
[...]
console: Uncompressing Linux... done, booting the kernel.
console: Booting Linux on physical CPU 0x0
console: Linux version 5.3.9-sunxi (root@builder) (gcc version 8.3.0 (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36))) #19.11.3 SMP Mon Nov 18 18:49:43 CET 2019
console: CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=50c5387d
console: CPU: div instructions available: patching division code
console: CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
console: OF: fdt: Machine model: Xunlong Orange Pi PC
[...]
console: EXT4-fs (mmcblk0p1): mounted filesystem with writeback data mode. Opts: (null)
console: done.
console: Begin: Running /scripts/local-bottom ... done.
console: Begin: Running /scripts/init-bottom ... done.
console: systemd[1]: systemd 237 running in system mode. (...)
console: systemd[1]: Detected architecture arm.
console: Welcome to Ubuntu 18.04.3 LTS!
console: systemd[1]: Set hostname to <orangepipc>.Message-id: [email protected]
--- tests/acceptance/boot_linux_console.py | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
tests/acceptance/boot_linux_console.py +48 -0
@@ -19,7 +19,13 @@ from avocado_qemu import exec_command_and_wait_for_pattern from avocado_qemu import wait_for_console_pattern from avocado.utils import process from avocado.utils import archive +from avocado.utils.path import find_command, CmdNotFoundError +P7ZIP_AVAILABLE = True +try: + find_command('7z') +except CmdNotFoundError: + P7ZIP_AVAILABLE = False class BootLinuxConsole(Test): """
@@ -619,6 +625,48 @@ class BootLinuxConsole(Test): exec_command_and_wait_for_pattern(self, 'reboot', 'reboot: Restarting system') + @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') + @skipUnless(P7ZIP_AVAILABLE, '7z not installed') + def test_arm_orangepi_bionic(self): + """ + :avocado: tags=arch:arm + :avocado: tags=machine:orangepi-pc + """ + + # This test download a 196MB compressed image and expand it to 932MB... + image_url = ('https://dl.armbian.com/orangepipc/archive/' + 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.7z') + image_hash = '196a8ffb72b0123d92cea4a070894813d305c71e' + image_path_7z = self.fetch_asset(image_url, asset_hash=image_hash) + image_name = 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img' + image_path = os.path.join(self.workdir, image_name) + process.run("7z e -o%s %s" % (self.workdir, image_path_7z)) + + self.vm.set_console() + self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw', + '-nic', 'user', + '-no-reboot') + self.vm.launch() + + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyS0,115200 ' + 'loglevel=7 ' + 'nosmp ' + 'systemd.default_timeout_start_sec=9000 ' + 'systemd.mask=armbian-zram-config.service ' + 'systemd.mask=armbian-ramlog.service') + + self.wait_for_console_pattern('U-Boot SPL') + self.wait_for_console_pattern('Autoboot in ') + exec_command_and_wait_for_pattern(self, ' ', '=>') + exec_command_and_wait_for_pattern(self, "setenv extraargs '" + + kernel_command_line + "'", '=>') + exec_command_and_wait_for_pattern(self, 'boot', 'Starting kernel ...'); + + self.wait_for_console_pattern('systemd[1]: Set hostname ' + + 'to <orangepipc>') + self.wait_for_console_pattern('Starting Load Kernel Modules...') + def test_s390x_s390_ccw_virtio(self): """ :avocado: tags=arch:s390x
Signature · 1 line
2.20.1
[PULL 14/36] hw/arm/allwinner-h3: add Clock Control Unit
In reply to Peter MaydellFrom: Niek Linnenbank <[email protected]>
The Clock Control Unit is responsible for clock signal generation, configuration and distribution in the Allwinner H3 System on Chip. This commit adds support for the Clock Control Unit which emulates a simple read/write register interface.
Message-id: [email protected]
--- hw/misc/Makefile.objs | 1 + include/hw/arm/allwinner-h3.h | 3 + include/hw/misc/allwinner-h3-ccu.h | 66 ++++++++ hw/arm/allwinner-h3.c | 9 +- hw/misc/allwinner-h3-ccu.c | 242 +++++++++++++++++++++++++++++ 5 files changed, 320 insertions(+), 1 deletion(-) create mode 100644 include/hw/misc/allwinner-h3-ccu.h create mode 100644 hw/misc/allwinner-h3-ccu.c
hw/misc/Makefile.objs +1 -0
@@ -28,6 +28,7 @@ common-obj-$(CONFIG_MACIO) += macio/ common-obj-$(CONFIG_IVSHMEM_DEVICE) += ivshmem.o +common-obj-$(CONFIG_ALLWINNER_H3) += allwinner-h3-ccu.o common-obj-$(CONFIG_REALVIEW) += arm_sysctl.o common-obj-$(CONFIG_NSERIES) += cbus.o common-obj-$(CONFIG_ECCMEMCTL) += eccmemctl.o
include/hw/arm/allwinner-h3.h +3 -0
@@ -39,6 +39,7 @@#include "hw/arm/boot.h" #include "hw/timer/allwinner-a10-pit.h" #include "hw/intc/arm_gic.h" +#include "hw/misc/allwinner-h3-ccu.h" #include "target/arm/cpu.h" /**
@@ -55,6 +56,7 @@ enum {AW_H3_SRAM_A1 ,AW_H3_SRAM_A2 ,AW_H3_SRAM_C , +AW_H3_CCU ,AW_H3_PIT ,AW_H3_UART0 , AW_H3_UART1,
@@ -97,6 +99,7 @@ typedef struct AwH3State {ARMCPU cpus[AW_H3_NUM_CPUS ];const hwaddr *memmap;AwA10PITState timer; +AwH3ClockCtlState ccu;GICState gic;MemoryRegion sram_a1;MemoryRegion sram_a2;
include/hw/misc/allwinner-h3-ccu.h new file +66 -0
66 lines not on this page · raw message
hw/arm/allwinner-h3.c +8 -1
@@ -36,6 +36,7 @@ const hwaddr allwinner_h3_memmap[] = { [AW_H3_SRAM_A1] = 0x00000000, [AW_H3_SRAM_A2] = 0x00044000, [AW_H3_SRAM_C] = 0x00010000, + [AW_H3_CCU] = 0x01c20000, [AW_H3_PIT] = 0x01c20c00, [AW_H3_UART0] = 0x01c28000, [AW_H3_UART1] = 0x01c28400,
@@ -77,7 +78,6 @@ struct AwH3Unimplemented { { "usb2-phy", 0x01c1c000, 4 * KiB }, { "usb3-phy", 0x01c1d000, 4 * KiB }, { "smc", 0x01c1e000, 4 * KiB }, - { "ccu", 0x01c20000, 1 * KiB }, { "pio", 0x01c20800, 1 * KiB }, { "owa", 0x01c21000, 1 * KiB }, { "pwm", 0x01c21400, 1 * KiB },
@@ -172,6 +172,9 @@ static void allwinner_h3_init(Object *obj) "clk0-freq", &error_abort);object_property_add_alias (obj,"clk1-freq" ,OBJECT (&s->timer),"clk1-freq" , &error_abort); + +sysbus_init_child_obj (obj,"ccu" , &s->ccu,sizeof (s->ccu), +TYPE_AW_H3_CCU ); }static void allwinner_h3_realize (DeviceState *dev,Error **errp)
@@ -277,6 +280,10 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)memory_region_add_subregion (get_system_memory (), s->memmap[AW_H3_SRAM_C ], &s->sram_c); +/* Clock Control Unit */ +qdev_init_nofail (DEVICE (&s->ccu)); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->ccu),0 , s->memmap[AW_H3_CCU ]); +/* UART0. For future clocktree API: All UARTS are connected to APB2_CLK. */ serial_mm_init(get_system_memory(), s->memmap[AW_H3_UART0], 2, qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_UART0),
hw/misc/allwinner-h3-ccu.c new file +242 -0
242 lines not on this page · raw message
Signature · 1 line
2.20.1
[PULL 23/36] hw/arm/allwinner: add RTC device support
In reply to Peter MaydellFrom: Niek Linnenbank <[email protected]>
Allwinner System-on-Chips usually contain a Real Time Clock (RTC) for non-volatile system date and time keeping. This commit adds a generic Allwinner RTC device that supports the RTC devices found in Allwinner SoC family sun4i (A10), sun7i (A20) and sun6i and newer (A31, H2+, H3, etc). The following RTC functionality and features are implemented:
* Year-Month-Day read/write
* Hour-Minute-Second read/write
* General Purpose storage
The following boards are extended with the RTC device:
* Cubieboard (hw/arm/cubieboard.c)
* Orange Pi PC (hw/arm/orangepi.c)
Message-id: [email protected]
--- hw/rtc/Makefile.objs | 1 + include/hw/arm/allwinner-a10.h | 2 + include/hw/arm/allwinner-h3.h | 3 + include/hw/rtc/allwinner-rtc.h | 134 +++++++++++ hw/arm/allwinner-a10.c | 8 + hw/arm/allwinner-h3.c | 9 +- hw/rtc/allwinner-rtc.c | 411 +++++++++++++++++++++++++++++++++ hw/rtc/trace-events | 4 + 8 files changed, 571 insertions(+), 1 deletion(-) create mode 100644 include/hw/rtc/allwinner-rtc.h create mode 100644 hw/rtc/allwinner-rtc.c
hw/rtc/Makefile.objs +1 -0
@@ -12,3 +12,4 @@ obj-$(CONFIG_MC146818RTC) += mc146818rtc.o common-obj-$(CONFIG_SUN4V_RTC) += sun4v-rtc.o common-obj-$(CONFIG_ASPEED_SOC) += aspeed_rtc.o common-obj-$(CONFIG_GOLDFISH_RTC) += goldfish_rtc.o +common-obj-$(CONFIG_ALLWINNER_H3) += allwinner-rtc.o
include/hw/arm/allwinner-a10.h +2 -0
@@ -11,6 +11,7 @@#include "hw/ide/ahci.h" #include "hw/usb/hcd-ohci.h" #include "hw/usb/hcd-ehci.h" +#include "hw/rtc/allwinner-rtc.h" #include "target/arm/cpu.h"
@@ -33,6 +34,7 @@ typedef struct AwA10State {AwEmacState emac;AllwinnerAHCIState sata;AwSdHostState mmc0; +AwRtcState rtc;MemoryRegion sram_a;EHCISysBusState ehci[AW_A10_NUM_USB ];OHCISysBusState ohci[AW_A10_NUM_USB ];
include/hw/arm/allwinner-h3.h +3 -0
@@ -46,6 +46,7 @@#include "hw/misc/allwinner-sid.h" #include "hw/sd/allwinner-sdhost.h" #include "hw/net/allwinner-sun8i-emac.h" +#include "hw/rtc/allwinner-rtc.h" #include "target/arm/cpu.h" #include "sysemu/block-backend.h"
@@ -88,6 +89,7 @@ enum {AW_H3_GIC_CPU ,AW_H3_GIC_HYP ,AW_H3_GIC_VCPU , +AW_H3_RTC ,AW_H3_CPUCFG , AW_H3_SDRAM };
@@ -129,6 +131,7 @@ typedef struct AwH3State {AwSidState sid;AwSdHostState mmc0;AwSun8iEmacState emac; +AwRtcState rtc;GICState gic;MemoryRegion sram_a1;MemoryRegion sram_a2;
include/hw/rtc/allwinner-rtc.h new file +134 -0
134 lines not on this page · raw message
hw/arm/allwinner-a10.c +8 -0
@@ -35,6 +35,7 @@#define AW_A10_EHCI_BASE 0x01c14000#define AW_A10_OHCI_BASE 0x01c14400#define AW_A10_SATA_BASE 0x01c18000 +#define AW_A10_RTC_BASE 0x01c20d00static void aw_a10_init (Object *obj) {
@@ -68,6 +69,9 @@ static void aw_a10_init(Object *obj)sysbus_init_child_obj (obj,"mmc0" , &s->mmc0,sizeof (s->mmc0),TYPE_AW_SDHOST_SUN4I ); + +sysbus_init_child_obj (obj,"rtc" , &s->rtc,sizeof (s->rtc), +TYPE_AW_RTC_SUN4I ); }static void aw_a10_realize (DeviceState *dev,Error **errp)
@@ -175,6 +179,10 @@ static void aw_a10_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->mmc0),0 ,qdev_get_gpio_in (dev,32 ));object_property_add_alias (OBJECT (s),"sd-bus" ,OBJECT (&s->mmc0),"sd-bus" , &error_abort); + +/* RTC */ +qdev_init_nofail (DEVICE (&s->rtc)); +sysbus_mmio_map_overlap (SYS_BUS_DEVICE (&s->rtc),0 ,AW_A10_RTC_BASE ,10 ); }static void aw_a10_class_init (ObjectClass *oc,void *data)
hw/arm/allwinner-h3.c +8 -1
@@ -63,6 +63,7 @@ const hwaddr allwinner_h3_memmap[] = { [AW_H3_GIC_CPU] = 0x01c82000, [AW_H3_GIC_HYP] = 0x01c84000, [AW_H3_GIC_VCPU] = 0x01c86000, + [AW_H3_RTC] = 0x01f00000, [AW_H3_CPUCFG] = 0x01f01c00, [AW_H3_SDRAM] = 0x40000000 };
@@ -118,7 +119,6 @@ struct AwH3Unimplemented { { "csi", 0x01cb0000, 320 * KiB }, { "tve", 0x01e00000, 64 * KiB }, { "hdmi", 0x01ee0000, 128 * KiB }, - { "rtc", 0x01f00000, 1 * KiB }, { "r_timer", 0x01f00800, 1 * KiB }, { "r_intc", 0x01f00c00, 1 * KiB }, { "r_wdog", 0x01f01000, 1 * KiB },
@@ -235,6 +235,9 @@ static void allwinner_h3_init(Object *obj) "ram-addr", &error_abort);object_property_add_alias (obj,"ram-size" ,OBJECT (&s->dramc),"ram-size" , &error_abort); + +sysbus_init_child_obj (obj,"rtc" , &s->rtc,sizeof (s->rtc), +TYPE_AW_RTC_SUN6I ); }static void allwinner_h3_realize (DeviceState *dev,Error **errp)
@@ -425,6 +428,10 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)sysbus_mmio_map (SYS_BUS_DEVICE (&s->dramc),1 , s->memmap[AW_H3_DRAMCTL ]);sysbus_mmio_map (SYS_BUS_DEVICE (&s->dramc),2 , s->memmap[AW_H3_DRAMPHY ]); +/* RTC */ +qdev_init_nofail (DEVICE (&s->rtc)); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->rtc),0 , s->memmap[AW_H3_RTC ]); +/* Unimplemented devices */ for (i =0 ; i <ARRAY_SIZE (unimplemented); i++) { create_unimplemented_device(unimplemented[i].device_name,
hw/rtc/allwinner-rtc.c new file +411 -0
411 lines not on this page · raw message
hw/rtc/trace-events +4 -0
@@ -1,5 +1,9 @@ # See docs/devel/tracing.txt for syntax documentation. +# allwinner-rtc.c +allwinner_rtc_read(uint64_t addr, uint64_t value) "addr 0x%" PRIx64 " value 0x%" PRIx64 +allwinner_rtc_write(uint64_t addr, uint64_t value) "addr 0x%" PRIx64 " value 0x%" PRIx64 + # sun4v-rtc.c sun4v_rtc_read(uint64_t addr, uint64_t value) "read: addr 0x%" PRIx64 " value 0x%" PRIx64 sun4v_rtc_write(uint64_t addr, uint64_t value) "write: addr 0x%" PRIx64 " value 0x%" PRIx64
Signature · 1 line
2.20.1
[PULL 30/36] hw/arm/virt: Document 'max' value in gic-version property description
In reply to Peter MaydellFrom: Eric Auger <[email protected]>
Mention 'max' value in the gic-version property description.
Message-id: [email protected]
--- hw/arm/virt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/arm/virt.c +2 -1
@@ -2146,7 +2146,8 @@ static void virt_instance_init(Object *obj) virt_set_gic_version, NULL);object_property_set_description (obj,"gic-version" ,"Set GIC version. " -"Valid values are 2, 3 and host" ,NULL ); +"Valid values are 2, 3, host and max" , +NULL ); vms->highmem_ecam = !vmc->no_highmem_ecam;
Signature · 1 line
2.20.1
[PULL 17/36] hw/arm/allwinner: add CPU Configuration module
In reply to Peter MaydellFrom: Niek Linnenbank <[email protected]>
Various Allwinner System on Chip designs contain multiple processors that can be configured and reset using the generic CPU Configuration module interface. This commit adds support for the Allwinner CPU configuration interface which emulates the following features:
* CPU reset
* CPU status
Message-id: [email protected]
--- hw/misc/Makefile.objs | 1 + include/hw/arm/allwinner-h3.h | 3 + include/hw/misc/allwinner-cpucfg.h | 52 ++++++ hw/arm/allwinner-h3.c | 9 +- hw/misc/allwinner-cpucfg.c | 282 +++++++++++++++++++++++++++++ hw/misc/trace-events | 5 + 6 files changed, 351 insertions(+), 1 deletion(-) create mode 100644 include/hw/misc/allwinner-cpucfg.h create mode 100644 hw/misc/allwinner-cpucfg.c
hw/misc/Makefile.objs +1 -0
@@ -29,6 +29,7 @@ common-obj-$(CONFIG_MACIO) += macio/ common-obj-$(CONFIG_IVSHMEM_DEVICE) += ivshmem.o common-obj-$(CONFIG_ALLWINNER_H3) += allwinner-h3-ccu.o +obj-$(CONFIG_ALLWINNER_H3) += allwinner-cpucfg.o common-obj-$(CONFIG_ALLWINNER_H3) += allwinner-h3-sysctrl.o common-obj-$(CONFIG_REALVIEW) += arm_sysctl.o common-obj-$(CONFIG_NSERIES) += cbus.o
include/hw/arm/allwinner-h3.h +3 -0
@@ -40,6 +40,7 @@#include "hw/timer/allwinner-a10-pit.h" #include "hw/intc/arm_gic.h" #include "hw/misc/allwinner-h3-ccu.h" +#include "hw/misc/allwinner-cpucfg.h" #include "hw/misc/allwinner-h3-sysctrl.h" #include "target/arm/cpu.h"
@@ -76,6 +77,7 @@ enum {AW_H3_GIC_CPU ,AW_H3_GIC_HYP ,AW_H3_GIC_VCPU , +AW_H3_CPUCFG , AW_H3_SDRAM };
@@ -110,6 +112,7 @@ typedef struct AwH3State {const hwaddr *memmap;AwA10PITState timer;AwH3ClockCtlState ccu; +AwCpuCfgState cpucfg;AwH3SysCtrlState sysctrl;GICState gic;MemoryRegion sram_a1;
include/hw/misc/allwinner-cpucfg.h new file +52 -0
52 lines not on this page · raw message
hw/arm/allwinner-h3.c +8 -1
@@ -56,6 +56,7 @@ const hwaddr allwinner_h3_memmap[] = { [AW_H3_GIC_CPU] = 0x01c82000, [AW_H3_GIC_HYP] = 0x01c84000, [AW_H3_GIC_VCPU] = 0x01c86000, + [AW_H3_CPUCFG] = 0x01f01c00, [AW_H3_SDRAM] = 0x40000000 };
@@ -122,7 +123,6 @@ struct AwH3Unimplemented { { "r_wdog", 0x01f01000, 1 * KiB }, { "r_prcm", 0x01f01400, 1 * KiB }, { "r_twd", 0x01f01800, 1 * KiB }, - { "r_cpucfg", 0x01f01c00, 1 * KiB }, { "r_cir-rx", 0x01f02000, 1 * KiB }, { "r_twi", 0x01f02400, 1 * KiB }, { "r_uart", 0x01f02800, 1 * KiB },
@@ -195,6 +195,9 @@ static void allwinner_h3_init(Object *obj)sysbus_init_child_obj (obj,"sysctrl" , &s->sysctrl,sizeof (s->sysctrl),TYPE_AW_H3_SYSCTRL ); + +sysbus_init_child_obj (obj,"cpucfg" , &s->cpucfg,sizeof (s->cpucfg), +TYPE_AW_CPUCFG ); }static void allwinner_h3_realize (DeviceState *dev,Error **errp)
@@ -308,6 +311,10 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)qdev_init_nofail (DEVICE (&s->sysctrl));sysbus_mmio_map (SYS_BUS_DEVICE (&s->sysctrl),0 , s->memmap[AW_H3_SYSCTRL ]); +/* CPU Configuration */ +qdev_init_nofail (DEVICE (&s->cpucfg)); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->cpucfg),0 , s->memmap[AW_H3_CPUCFG ]); +/* Universal Serial Bus */ sysbus_create_simple(TYPE_AW_H3_EHCI, s->memmap[AW_H3_EHCI0], qdev_get_gpio_in(DEVICE(&s->gic),
hw/misc/allwinner-cpucfg.c new file +282 -0
282 lines not on this page · raw message
hw/misc/trace-events +5 -0
@@ -1,5 +1,10 @@ # See docs/devel/tracing.txt for syntax documentation. +# allwinner-cpucfg.c +allwinner_cpucfg_cpu_reset(uint8_t cpu_id, uint32_t reset_addr) "id %u, reset_addr 0x%" PRIu32 +allwinner_cpucfg_read(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +allwinner_cpucfg_write(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 + # eccmemctl.c ecc_mem_writel_mer(uint32_t val) "Write memory enable 0x%08x" ecc_mem_writel_mdr(uint32_t val) "Write memory delay 0x%08x"
Signature · 1 line
2.20.1
[PULL 31/36] hw/arm/virt: Introduce VirtGICType enum type
In reply to Peter MaydellFrom: Eric Auger <[email protected]>
We plan to introduce yet another value for the gic version (nosel). As we already use exotic values such as 0 and -1, let's introduce a dedicated enum type and let vms->gic_version take this type.
Message-id: [email protected]
--- include/hw/arm/virt.h | 11 +++++++++-- hw/arm/virt.c | 30 +++++++++++++++--------------- 2 files changed, 24 insertions(+), 17 deletions(-)
include/hw/arm/virt.h +9 -2
@@ -95,6 +95,13 @@ typedef enum VirtIOMMUType {VIRT_IOMMU_VIRTIO , } VirtIOMMUType; +typedef enum VirtGICType { +VIRT_GIC_VERSION_MAX , +VIRT_GIC_VERSION_HOST , +VIRT_GIC_VERSION_2 , +VIRT_GIC_VERSION_3 , +}VirtGICType ; + typedef struct MemMapEntry { hwaddr base; hwaddr size;
@@ -123,7 +130,7 @@ typedef struct {bool highmem_ecam;bool its;bool virt; -int32_t gic_version; +VirtGICType gic_version;VirtIOMMUType iommu;uint16_t virtio_iommu_bdf;struct arm_boot_info bootinfo;
@@ -162,7 +169,7 @@ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms)uint32_t redist0_capacity = vms->memmap[VIRT_GIC_REDIST ].size /GICV3_REDIST_SIZE ; -assert (vms->gic_version ==3 ); +assert (vms->gic_version ==VIRT_GIC_VERSION_3 );return vms->smp_cpus > redist0_capacity ?2 :1 ; }
hw/arm/virt.c +15 -15
@@ -299,7 +299,7 @@ static void fdt_add_timer_nodes(const VirtMachineState *vms) irqflags =GIC_FDT_IRQ_FLAGS_EDGE_LO_HI ; } -if (vms->gic_version ==2 ) { +if (vms->gic_version ==VIRT_GIC_VERSION_2 ) { irqflags =deposit32 (irqflags,GIC_FDT_IRQ_PPI_CPU_START ,GIC_FDT_IRQ_PPI_CPU_WIDTH , (1 << vms->smp_cpus) -1 );
@@ -440,7 +440,7 @@ static void fdt_add_gic_node(VirtMachineState *vms)qemu_fdt_setprop_cell (vms->fdt, nodename,"#address-cells" ,0x2 );qemu_fdt_setprop_cell (vms->fdt, nodename,"#size-cells" ,0x2 );qemu_fdt_setprop (vms->fdt, nodename,"ranges" ,NULL ,0 ); -if (vms->gic_version ==3 ) { +if (vms->gic_version ==VIRT_GIC_VERSION_3 ) {int nb_redist_regions =virt_gicv3_redist_region_count (vms); qemu_fdt_setprop_string(vms->fdt, nodename, "compatible",
@@ -519,7 +519,7 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) } } -if (vms->gic_version ==2 ) { +if (vms->gic_version ==VIRT_GIC_VERSION_2 ) { irqflags =deposit32 (irqflags,GIC_FDT_IRQ_PPI_CPU_START ,GIC_FDT_IRQ_PPI_CPU_WIDTH , (1 << vms->smp_cpus) -1 );
@@ -1470,7 +1470,7 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx)* purposes are to make TCG consistent (with 64-bit KVM hosts) * and to improve SGI efficiency. */ -if (vms->gic_version ==3 ) { +if (vms->gic_version ==VIRT_GIC_VERSION_3 ) { clustersz =GICV3_TARGETLIST_BITS ; }else { clustersz =GIC_TARGETLIST_BITS ;
@@ -1561,15 +1561,15 @@ static void machvirt_init(MachineState *machine)/* We can probe only here because during property set * KVM is not available yet */ -if (vms->gic_version <=0 ) { -/* "host" or "max" */ +if (vms->gic_version ==VIRT_GIC_VERSION_HOST || + vms->gic_version ==VIRT_GIC_VERSION_MAX ) {if (!kvm_enabled ()) { -if (vms->gic_version ==0 ) { +if (vms->gic_version ==VIRT_GIC_VERSION_HOST ) {error_report ("gic-version=host requires KVM" );exit (1 ); }else {/* "max": currently means 3 for TCG */ - vms->gic_version =3 ; + vms->gic_version =VIRT_GIC_VERSION_3 ; } }else { vms->gic_version =kvm_arm_vgic_probe ();
@@ -1628,7 +1628,7 @@ static void machvirt_init(MachineState *machine)/* The maximum number of CPUs depends on the GIC version, or on how * many redistributors we can fit into the memory map. */ -if (vms->gic_version ==3 ) { +if (vms->gic_version ==VIRT_GIC_VERSION_3 ) { virt_max_cpus = vms->memmap[VIRT_GIC_REDIST ].size /GICV3_REDIST_SIZE ; virt_max_cpus +=
@@ -1856,7 +1856,7 @@ static void virt_set_its(Object *obj, bool value, Error **errp)static char *virt_get_gic_version (Object *obj,Error **errp) {VirtMachineState *vms =VIRT_MACHINE (obj); -const char *val = vms->gic_version ==3 ?"3" :"2" ; +const char *val = vms->gic_version ==VIRT_GIC_VERSION_3 ?"3" :"2" ;return g_strdup (val); }
@@ -1866,13 +1866,13 @@ static void virt_set_gic_version(Object *obj, const char *value, Error **errp)VirtMachineState *vms =VIRT_MACHINE (obj);if (!strcmp (value,"3" )) { - vms->gic_version =3 ; + vms->gic_version =VIRT_GIC_VERSION_3 ; }else if (!strcmp (value,"2" )) { - vms->gic_version =2 ; + vms->gic_version =VIRT_GIC_VERSION_2 ; }else if (!strcmp (value,"host" )) { - vms->gic_version =0 ;/* Will probe later */ + vms->gic_version =VIRT_GIC_VERSION_HOST ;/* Will probe later */ }else if (!strcmp (value,"max" )) { - vms->gic_version =-1 ;/* Will probe later */ + vms->gic_version =VIRT_GIC_VERSION_MAX ;/* Will probe later */ }else {error_setg (errp,"Invalid gic-version value" );error_append_hint (errp,"Valid values are 3, 2, host, max.\n" );
@@ -2141,7 +2141,7 @@ static void virt_instance_init(Object *obj)"physical address space above 32 bits" , NULL);/* Default GIC type is v2 */ - vms->gic_version =2 ; + vms->gic_version =VIRT_GIC_VERSION_2 ;object_property_add_str (obj,"gic-version" , virt_get_gic_version, virt_set_gic_version,NULL ); object_property_set_description(obj, "gic-version",
Signature · 1 line
2.20.1
[PULL 28/36] tests/boot_linux_console: Test booting NetBSD via U-Boot on OrangePi PC
In reply to Peter MaydellFrom: Philippe Mathieu-Daudé <[email protected]>
This test boots U-Boot then NetBSD (stored on a SD card) on a OrangePi PC board.
As it requires ~1.3GB of storage, it is disabled by default.
U-Boot is built by the Debian project [1], and the SD card image is provided by the NetBSD organization [2].
Once the compressed SD card image is downloaded (304MB) and extracted, this test is fast:
$ AVOCADO_ALLOW_LARGE_STORAGE=yes \
avocado --show=app,console run -t machine:orangepi-pc \
tests/acceptance/boot_linux_console.py
console: U-Boot SPL 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +0000)
console: DRAM: 1024 MiB
console: U-Boot 2020.01+dfsg-1 (Jan 08 2020 - 08:19:44 +0000) Allwinner Technology
console: CPU: Allwinner H3 (SUN8I 0000)
console: scanning bus usb@1c1b000 for devices... 1 USB Device(s) found
console: scanning bus usb@1c1d000 for devices... 1 USB Device(s) found
console: scanning usb for storage devices... 0 Storage Device(s) found
console: Hit any key to stop autoboot: 0
console: => setenv bootargs root=ld0a
console: => setenv kernel netbsd-GENERIC.ub
console: => setenv fdtfile dtb/sun8i-h3-orangepi-pc.dtb
console: => boot
console: ## Booting kernel from Legacy Image at 42000000 ...
console: Image Name: NetBSD/earmv7hf 9.0_RC1
console: Image Type: ARM Linux Kernel Image (no loading done) (uncompressed)
console: XIP Kernel Image (no loading done)
console: Loading Device Tree to 49ff6000, end 49fffe01 ... OK
console: Starting kernel ...
console: [ 1.0000000] NetBSD/evbarm (fdt) booting ...
console: [ 1.0000000] NetBSD 9.0 (GENERIC) #0: Fri Feb 14 00:06:28 UTC 2020
console: [ 1.0000000] [email protected]:/usr/src/sys/arch/evbarm/compile/GENERIC
console: [ 1.0000000] total memory = 1024 MB
console: [ 1.0000000] avail memory = 1003 MB
console: [ 1.0000000] armfdt0 (root)
console: [ 1.0000000] simplebus0 at armfdt0: Xunlong Orange Pi PC
console: [ 1.0000000] cpu0 at cpus0: Cortex-A7 r0p5 (Cortex V7A core)
console: [ 1.0000000] cpu0: DC enabled IC enabled WB enabled LABT branch prediction enabled
console: [ 1.0000000] cpu0: 32KB/64B 2-way L1 VIPT Instruction cache
console: [ 1.0000000] cpu0: 32KB/64B 2-way write-back-locking-C L1 PIPT Data cache
console: [ 1.0000000] cpu0: 2304KB/64B 16-way write-through L2 PIPT Unified cache
console: [ 1.0000000] vfp0 at cpu0: NEON MPE (VFP 3.0+), rounding, NaN propagation, denormals
...
console: [ 2.3812082] sdmmc0: SD card status: 4-bit, C0
console: [ 2.3812082] ld0 at sdmmc0: <0xaa:0x5859:QEMU!:0x01:0xdeadbeef:0x062>
console: [ 2.4012856] ld0: 1226 MB, 622 cyl, 64 head, 63 sec, 512 bytes/sect x 2511872 sectors
console: [ 2.5321222] ld0: 4-bit width, High-Speed/SDR25, 50.000 MHz
console: [ 3.1068718] WARNING: 4 errors while detecting hardware; check system log.
console: [ 3.1179868] boot device: ld0
console: [ 3.1470623] root on ld0a dumps on ld0b
console: [ 3.2464436] root file system type: ffs
console: [ 3.2897123] kern.module.path=/stand/evbarm/9.0/modules
console: Mon Feb 17 20:33:35 UTC 2020
console: Starting root file system check:
PASS (35.96 s)
RESULTS : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME : 36.09 sNote, this test only took ~65 seconds to run on Travis-CI, see: [3].
This test is based on a description from Niek Linnenbank from [4].
[1] https://wiki.debian.org/InstallingDebianOn/Allwinner#Creating_a_bootable_SD_Card_with_u-boot
[2] https://wiki.netbsd.org/ports/evbarm/allwinner/
[3] https://travis-ci.org/philmd/qemu/jobs/638823612#L3778
[4] https://www.mail-archive.com/[email protected]/msg669347.html
Message-id: [email protected]
--- tests/acceptance/boot_linux_console.py | 70 ++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)
tests/acceptance/boot_linux_console.py +70 -0
@@ -16,6 +16,7 @@ import shutil from avocado import skipUnless from avocado_qemu import Test from avocado_qemu import exec_command_and_wait_for_pattern +from avocado_qemu import interrupt_interactive_console_until_pattern from avocado_qemu import wait_for_console_pattern from avocado.utils import process from avocado.utils import archive
@@ -667,6 +668,75 @@ class BootLinuxConsole(Test): 'to <orangepipc>') self.wait_for_console_pattern('Starting Load Kernel Modules...') + @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') + def test_arm_orangepi_uboot_netbsd9(self): + """ + :avocado: tags=arch:arm + :avocado: tags=machine:orangepi-pc + """ + # This test download a 304MB compressed image and expand it to 1.3GB... + deb_url = ('http://snapshot.debian.org/archive/debian/' + '20200108T145233Z/pool/main/u/u-boot/' + 'u-boot-sunxi_2020.01%2Bdfsg-1_armhf.deb') + deb_hash = 'f67f404a80753ca3d1258f13e38f2b060e13db99' + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + # We use the common OrangePi PC 'plus' build of U-Boot for our secondary + # program loader (SPL). We will then set the path to the more specific + # OrangePi "PC" device tree blob with 'setenv fdtfile' in U-Boot prompt, + # before to boot NetBSD. + uboot_path = '/usr/lib/u-boot/orangepi_plus/u-boot-sunxi-with-spl.bin' + uboot_path = self.extract_from_deb(deb_path, uboot_path) + image_url = ('https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/' + 'evbarm-earmv7hf/binary/gzimg/armv7.img.gz') + image_hash = '2babb29d36d8360adcb39c09e31060945259917a' + image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash) + image_path = os.path.join(self.workdir, 'armv7.img') + image_drive_args = 'if=sd,format=raw,snapshot=on,file=' + image_path + archive.gzip_uncompress(image_path_gz, image_path) + + # dd if=u-boot-sunxi-with-spl.bin of=armv7.img bs=1K seek=8 conv=notrunc + with open(uboot_path, 'rb') as f_in: + with open(image_path, 'r+b') as f_out: + f_out.seek(8 * 1024) + shutil.copyfileobj(f_in, f_out) + + # Extend image, to avoid that NetBSD thinks the partition + # inside the image is larger than device size itself + f_out.seek(0, 2) + f_out.seek(64 * 1024 * 1024, 1) + f_out.write(bytearray([0x00])) + + self.vm.set_console() + self.vm.add_args('-nic', 'user', + '-drive', image_drive_args, + '-global', 'allwinner-rtc.base-year=2000', + '-no-reboot') + self.vm.launch() + wait_for_console_pattern(self, 'U-Boot 2020.01+dfsg-1') + interrupt_interactive_console_until_pattern(self, + 'Hit any key to stop autoboot:', + 'switch to partitions #0, OK') + + exec_command_and_wait_for_pattern(self, '', '=>') + cmd = 'setenv bootargs root=ld0a' + exec_command_and_wait_for_pattern(self, cmd, '=>') + cmd = 'setenv kernel netbsd-GENERIC.ub' + exec_command_and_wait_for_pattern(self, cmd, '=>') + cmd = 'setenv fdtfile dtb/sun8i-h3-orangepi-pc.dtb' + exec_command_and_wait_for_pattern(self, cmd, '=>') + cmd = ("setenv bootcmd 'fatload mmc 0:1 ${kernel_addr_r} ${kernel}; " + "fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}; " + "fdt addr ${fdt_addr_r}; " + "bootm ${kernel_addr_r} - ${fdt_addr_r}'") + exec_command_and_wait_for_pattern(self, cmd, '=>') + + exec_command_and_wait_for_pattern(self, 'boot', + 'Booting kernel from Legacy Image') + wait_for_console_pattern(self, 'Starting kernel ...') + wait_for_console_pattern(self, 'NetBSD 9.0 (GENERIC)') + # Wait for user-space + wait_for_console_pattern(self, 'Starting root file system check') + def test_s390x_s390_ccw_virtio(self): """ :avocado: tags=arch:s390x
Signature · 1 line
2.20.1
[PULL 34/36] hw/arm/virt: kvm: Restructure finalize_gic_version()
In reply to Peter MaydellFrom: Eric Auger <[email protected]>
Restructure the finalize_gic_version with switch cases and clearly separate the following cases:
- KVM mode / in-kernel irqchip
- KVM mode / userspace irqchip
- TCG mode
In KVM mode / in-kernel irqchip , we explictly check whether the chosen version is supported by the host. If the end-user explicitly sets v2/v3 and this is not supported by the host, then the user gets an explicit error message. Note that for old kernels where the CREATE_DEVICE ioctl doesn't exist then we will now fail if the user specifically asked for gicv2, where previously we (probably) would have succeeded.
In KVM mode / userspace irqchip we immediatly output an error in case the end-user explicitly selected v3. Also we warn the end-user about the unexpected usage of gic-version=host in that case as only userspace GICv2 is supported.
Message-id: [email protected]
--- hw/arm/virt.c | 88 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 67 insertions(+), 21 deletions(-)
hw/arm/virt.c +67 -21
@@ -1543,33 +1543,79 @@ static void virt_set_memmap(VirtMachineState *vms)*/ static void finalize_gic_version (VirtMachineState *vms) { -if (vms->gic_version ==VIRT_GIC_VERSION_HOST || - vms->gic_version ==VIRT_GIC_VERSION_MAX ) { -if (!kvm_enabled ()) { -if (vms->gic_version ==VIRT_GIC_VERSION_HOST ) { -error_report ("gic-version=host requires KVM" ); -exit (1 ); - }else { -/* "max": currently means 3 for TCG */ - vms->gic_version =VIRT_GIC_VERSION_3 ; - } - }else { -int probe_bitmap =kvm_arm_vgic_probe (); +if (kvm_enabled ()) { +int probe_bitmap; -if (!probe_bitmap) { +if (!kvm_irqchip_in_kernel ()) { +switch (vms->gic_version) { +case VIRT_GIC_VERSION_HOST : +warn_report ( +"gic-version=host not relevant with kernel-irqchip=off " +"as only userspace GICv2 is supported. Using v2 ..." ); +return ; +case VIRT_GIC_VERSION_MAX : +case VIRT_GIC_VERSION_NOSEL : + vms->gic_version =VIRT_GIC_VERSION_2 ; +return ; +case VIRT_GIC_VERSION_2 : +return ; +case VIRT_GIC_VERSION_3 :error_report ( -"Unable to determine GIC version supported by host" ); +"gic-version=3 is not supported with kernel-irqchip=off" );exit (1 ); - }else { -if (probe_bitmap &KVM_ARM_VGIC_V3 ) { - vms->gic_version =VIRT_GIC_VERSION_3 ; - }else { - vms->gic_version =VIRT_GIC_VERSION_2 ; - } } } - }else if (vms->gic_version ==VIRT_GIC_VERSION_NOSEL ) { + + probe_bitmap =kvm_arm_vgic_probe (); +if (!probe_bitmap) { +error_report ("Unable to determine GIC version supported by host" ); +exit (1 ); + } + +switch (vms->gic_version) { +case VIRT_GIC_VERSION_HOST : +case VIRT_GIC_VERSION_MAX : +if (probe_bitmap &KVM_ARM_VGIC_V3 ) { + vms->gic_version =VIRT_GIC_VERSION_3 ; + }else { + vms->gic_version =VIRT_GIC_VERSION_2 ; + } +return ; +case VIRT_GIC_VERSION_NOSEL : + vms->gic_version =VIRT_GIC_VERSION_2 ; +break ; +case VIRT_GIC_VERSION_2 : +case VIRT_GIC_VERSION_3 : +break ; + } + +/* Check chosen version is effectively supported by the host */ +if (vms->gic_version ==VIRT_GIC_VERSION_2 && + !(probe_bitmap &KVM_ARM_VGIC_V2 )) { +error_report ("host does not support in-kernel GICv2 emulation" ); +exit (1 ); + }else if (vms->gic_version ==VIRT_GIC_VERSION_3 && + !(probe_bitmap &KVM_ARM_VGIC_V3 )) { +error_report ("host does not support in-kernel GICv3 emulation" ); +exit (1 ); + } +return ; + } + +/* TCG mode */ +switch (vms->gic_version) { +case VIRT_GIC_VERSION_NOSEL : vms->gic_version =VIRT_GIC_VERSION_2 ; +break ; +case VIRT_GIC_VERSION_MAX : + vms->gic_version =VIRT_GIC_VERSION_3 ; +break ; +case VIRT_GIC_VERSION_HOST : +error_report ("gic-version=host requires KVM" ); +exit (1 ); +case VIRT_GIC_VERSION_2 : +case VIRT_GIC_VERSION_3 : +break ; } }
Signature · 1 line
2.20.1
[PULL 29/36] docs: add Orange Pi PC document
In reply to Peter MaydellFrom: Niek Linnenbank <[email protected]>
The Xunlong Orange Pi PC machine is a functional ARM machine based on the Allwinner H3 System-on-Chip. It supports mainline Linux, U-Boot, NetBSD and is covered by acceptance tests.
This commit adds a documentation text file with a description of the machine and instructions for the user.
Message-id: [email protected] [PMM: moved file into docs/system/arm to match the reorg of the arm target part of the docs; tweaked heading to match other boards]
--- MAINTAINERS | 1 + docs/system/arm/orangepi.rst | 253 +++++++++++++++++++++++++++++++++++ docs/system/target-arm.rst | 2 + 3 files changed, 256 insertions(+) create mode 100644 docs/system/arm/orangepi.rst
MAINTAINERS +1 -0
@@ -499,6 +499,7 @@ S: Maintained F: hw/*/allwinner-h3* F: include/hw/*/allwinner-h3* F: hw/arm/orangepi.c +F: docs/system/orangepi.rst ARM PrimeCell and CMSDK devices M: Peter Maydell <[email protected]>
docs/system/arm/orangepi.rst new file +253 -0
253 lines not on this page · raw message
docs/system/target-arm.rst +2 -0
@@ -68,6 +68,7 @@ undocumented; you can get a complete list by running ``qemu-system-aarch64 --machine help``. .. toctree:: + :maxdepth: 1 arm/integratorcp arm/versatile
@@ -78,6 +79,7 @@ undocumented; you can get a complete list by running arm/stellaris arm/musicpal arm/sx1 + arm/orangepi Arm CPU features ================
Signature · 1 line
2.20.1
[PULL 36/36] target/arm: kvm: Inject events at the last stage of sync
In reply to Peter MaydellFrom: Beata Michalska <[email protected]>
KVM_SET_VCPU_EVENTS might actually lead to vcpu registers being modified. As such this should be the last step of sync to avoid potential overwriting of whatever changes KVM might have done.
Message-id: [email protected]
--- target/arm/kvm32.c | 15 ++++++++++----- target/arm/kvm64.c | 15 ++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-)
target/arm/kvm32.c +10 -5
@@ -409,17 +409,22 @@ int kvm_arch_put_registers(CPUState *cs, int level)return ret; } - ret =kvm_put_vcpu_events (cpu); -if (ret) { -return ret; - } -write_cpustate_to_list (cpu, true);if (!write_list_to_kvmstate (cpu, level)) {return EINVAL ; } +/* +* Setting VCPU events should be triggered after syncing the registers +* to avoid overwriting potential changes made by KVM upon calling +* KVM_SET_VCPU_EVENTS ioctl +*/ + ret =kvm_put_vcpu_events (cpu); +if (ret) { +return ret; + } +kvm_arm_sync_mpstate_to_kvm (cpu);return ret;
target/arm/kvm64.c +10 -5
@@ -1094,17 +1094,22 @@ int kvm_arch_put_registers(CPUState *cs, int level)return ret; } - ret =kvm_put_vcpu_events (cpu); -if (ret) { -return ret; - } -write_cpustate_to_list (cpu, true);if (!write_list_to_kvmstate (cpu, level)) {return -EINVAL ; } +/* +* Setting VCPU events should be triggered after syncing the registers +* to avoid overwriting potential changes made by KVM upon calling +* KVM_SET_VCPU_EVENTS ioctl +*/ + ret =kvm_put_vcpu_events (cpu); +if (ret) { +return ret; + } +kvm_arm_sync_mpstate_to_kvm (cpu);return ret;
Signature · 1 line
2.20.1
[PULL 33/36] target/arm/kvm: Let kvm_arm_vgic_probe() return a bitmap
In reply to Peter MaydellFrom: Eric Auger <[email protected]>
Convert kvm_arm_vgic_probe() so that it returns a bitmap of supported in-kernel emulation VGIC versions instead of the max version: at the moment values can be v2 and v3. This allows to expose the case where the host GICv3 also supports GICv2 emulation. This will be useful to choose the default version in KVM accelerated mode.
Message-id: [email protected]
--- target/arm/kvm_arm.h | 3 +++ hw/arm/virt.c | 11 +++++++++-- target/arm/kvm.c | 14 ++++++++------ 3 files changed, 20 insertions(+), 8 deletions(-)
target/arm/kvm_arm.h +3 -0
@@ -15,6 +15,9 @@#include "exec/memory.h" #include "qemu/error-report.h" +#define KVM_ARM_VGIC_V2 (1 << 0) +#define KVM_ARM_VGIC_V3 (1 << 1) +/** * kvm_arm_vcpu_init: * @cs: CPUState
hw/arm/virt.c +9 -2
@@ -1554,11 +1554,18 @@ static void finalize_gic_version(VirtMachineState *vms) vms->gic_version =VIRT_GIC_VERSION_3 ; } }else { - vms->gic_version =kvm_arm_vgic_probe (); -if (!vms->gic_version) { +int probe_bitmap =kvm_arm_vgic_probe (); + +if (!probe_bitmap) {error_report ("Unable to determine GIC version supported by host" );exit (1 ); + }else { +if (probe_bitmap &KVM_ARM_VGIC_V3 ) { + vms->gic_version =VIRT_GIC_VERSION_3 ; + }else { + vms->gic_version =VIRT_GIC_VERSION_2 ; + } } } }else if (vms->gic_version ==VIRT_GIC_VERSION_NOSEL ) {
target/arm/kvm.c +8 -6
@@ -874,15 +874,17 @@ int kvm_arch_irqchip_create(KVMState *s)int kvm_arm_vgic_probe (void ) { +int val =0 ; +if (kvm_create_device (kvm_state,KVM_DEV_TYPE_ARM_VGIC_V3 , true) ==0 ) { -return 3 ; - }else if (kvm_create_device (kvm_state, -KVM_DEV_TYPE_ARM_VGIC_V2 , true) ==0 ) { -return 2 ; - }else { -return 0 ; + val |=KVM_ARM_VGIC_V3 ; } +if (kvm_create_device (kvm_state, +KVM_DEV_TYPE_ARM_VGIC_V2 , true) ==0 ) { + val |=KVM_ARM_VGIC_V2 ; + } +return val; }int kvm_arm_set_irq (int cpu,int irqtype,int irq,int level)
Signature · 1 line
2.20.1
Peter Maydell
AppliedQuoted 20 lines · Peter Maydell
arm queue; dunno if this will be the last before softfreeze or not, but anyway probably the last large one. New orangepi-pc board model is the big item here.
thanks
-- PMMThe following changes since commit
67d9ef7d541c3d21a25796c51c26da096a433565:Merge remote-tracking branch 'remotes/pmaydell/tags/pull-docs-20200312' into staging (2020-03-12 15:20:52 +0000)
are available in the Git repository at:
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200312
for you to fetch changes up to
aca53be34ac3e7cac5f39396a51a338860a5a837:target/arm: kvm: Inject events at the last stage of sync (2020-03-12 16:31:10 +0000)
Quoted 15 lines
----------------------------------------------------------------
target-arm queue:
* Fix various bugs that might result in anassert()due to incorrect hflags for M-profile CPUs
* Fix Aspeed SMC Controller user-mode select handling
* Report correct (with-tag) address in fault address register when TBI is enabled
* cubieboard: make sure SOC object isn't leaked
* fsl-imx25: Wire up eSDHC controllers
* fsl-imx25: Wire up USB controllers
* New board model: orangepi-pc (OrangePi PC)
* ARM/KVM: if user doesn't select GIC version and the host kernel can only provide GICv3, use that, rather than defaulting to "fail because GICv2 isn't possible"
* kvm: Only doKVM_SET_VCPU_EVENTSat the last stage of sync
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/5.0
for any user-visible changes.
-- PMM
Re: [PULL 21/36] hw/arm/allwinner-h3: add Boot ROM support
In reply to Peter MaydellQuoted 16 lines · Peter Maydell
From: Niek Linnenbank <[email protected]>
A real Allwinner H3 SoC contains a Boot ROM which is the first code that runs right after the SoC is powered on.
The Boot ROM is responsible for loading user code (e.g. a bootloader) from any of the supported external devices and writing the downloaded code to internal SRAM. After loading the SoC begins executing the code written to SRAM.This commits adds emulation of the Boot ROM firmware setup functionality by loading user code from SD card in the A1 SRAM. While the A1 SRAM is 64KiB, we limit the size to 32KiB because the real H3 Boot ROM also rejects sizes larger than 32KiB. For reference, this behaviour is documented by the Linux Sunxi project wiki at:
Quoted 6 lines
https://linux-sunxi.org/BROM#U-Boot_SPL_limitations
Signed-off-by Niek Linnenbank <[email protected]>Reviewed-by Alex Bennée <[email protected]>Message-id: [email protected]
Signed-off-by Peter Maydell <[email protected]>
Hi; Coverity (CID 1421882) points out a possible NULL pointer dereference in this change:
hw/arm/orangepi.c static void orangepi_init(MachineState *machine) · line 104
Quoted 13 lines
hw/arm/orangepi.c +5
-0@@ -97,6 +97,11 @@ static void orangepi_init(MachineState *machine)memory_region_add_subregion (get_system_memory (), h3->memmap[AW_H3_SDRAM ], machine->ram); +/* Load target kernel or start using BootROM */ +if (!machine->kernel_filename &&blk_is_available (blk)) { +/* Use Boot ROM to copy data from SD card to SRAM */ +allwinner_h3_bootrom_setup (h3, blk); + }
blk_is_available() assumes its argument is non-NULL, but earlier in the function we set up blk with:
blk = di ? blk_by_legacy_dinfo(di) : NULL;
so it can be NULL here.
Could you send a patch to fix this, please? Probably just adding '&& blk' in the middle of the condition is sufficient.
thanks
-- PMM
Re: [PULL 22/36] hw/arm/allwinner-h3: add SDRAM controller device
In reply to Peter MaydellQuoted 8 lines · Peter Maydell
From: Niek Linnenbank <[email protected]>
In the Allwinner H3 SoC the SDRAM controller is responsible for interfacing with the external Synchronous Dynamic Random Access Memory (SDRAM). Types of memory that the SDRAM controller supports are DDR2/DDR3 and capacities of up to 2GiB. This commit adds emulation support of the Allwinner H3 SDRAM controller.
Hi; Coverity has flagged a possible issue with this patch (CID 1421912):
Quoted 24 lines
hw/misc/allwinner-h3-dramc.c new file +24
-0+static void allwinner_h3_dramc_map_rows (AwH3DramCtlState *s,uint8_t row_bits, +uint8_t bank_bits,uint16_t page_size) +{ +/* +* This function simulates row addressing behavior when bootloader +* software attempts to detect the amount of available SDRAM. In U-Boot +* the controller is configured with the widest row addressing available. +* Then a pattern is written to RAM at an offset on the row boundary size. +* If the value read back equals the value read back from the +* start of RAM, the bootloader knows the amount of row bits. +* +* This function inserts a mirrored memory region when the configured row +* bits are not matching the actual emulated memory, to simulate the +* same behavior on hardware as expected by the bootloader. +*/ +uint8_t row_bits_actual =0 ; + +/* Calculate the actual row bits using the ram_size property */ +for (uint8_t i =8 ; i <12 ; i++) { +if (1 << i == s->ram_size) { + row_bits_actual = i +3 ; +break ; + } + }
hw/misc/allwinner-h3-dramc.c line 89
Quoted 10 lines
hw/misc/allwinner-h3-dramc.c new file +10
-0+ +if (s->ram_size == (1 << (row_bits -3 ))) { +/* When row bits is the expected value, remove the mirror */ +memory_region_set_enabled (&s->row_mirror_alias, false); +trace_allwinner_h3_dramc_rowmirror_disable (); + + }else if (row_bits_actual) { +/* Row bits not matching ram_size, install the rows mirror */ +hwaddr row_mirror = s->ram_addr + ((1 << (row_bits_actual + + bank_bits)) * page_size);
In this calculation we do the multiply as a signed 32-bit operation, which then gets sign-extended to 64 bits for the addition; that means that if the multiply result is greater than 0x7fffffff then the upper bits of the result will all be 1s. Is this a "can't happen" situation, or should we be using "1ULL" to force a 64-bit multiply?
thanks
-- PMM
Re: [PULL 21/36] hw/arm/allwinner-h3: add Boot ROM support
In reply to Peter MaydellHi Peter,
Quoted 44 lines · Peter Maydell
Quoted 10 lines · Peter Maydell
From: Niek Linnenbank <[email protected]>
A real Allwinner H3 SoC contains a Boot ROM which is the first code that runs right after the SoC is powered on.
The Boot ROM is responsible for loading user code (e.g. a bootloader) from any of the supported external devices and writing the downloaded code to internal SRAM. After loading the SoC begins executing the code written to SRAM.Quoted 3 lines
This commits adds emulation of the Boot ROM firmware setup functionality by loading user code from SD card in the A1 SRAM. While the A1 SRAM is 64KiB, we limit the size to 32KiB because the real H3 Boot ROM also
rejects
Quoted 9 lines
sizes larger than 32KiB. For reference, this behaviour is documented by the Linux Sunxi project wiki at:
https://linux-sunxi.org/BROM#U-Boot_SPL_limitations
Signed-off-by Niek Linnenbank <[email protected]>Reviewed-by Alex Bennée <[email protected]>Message-id: [email protected]
Signed-off-by Peter Maydell <[email protected]>Hi; Coverity (CID 1421882) points out a possible NULL pointer dereference in this change:
hw/arm/orangepi.c static void orangepi_init(MachineState *machine) · line 97
Quoted 6 lines
hw/arm/orangepi.c +0
-0@@ -97,6 +97,11 @@ static void orangepi_init(MachineState *machine) memory_region_add_subregion(get_system_memory(),h3->memmap[AW_H3_SDRAM],
hw/arm/orangepi.c static void orangepi_init(MachineState *machine) · line 104
Quoted 7 lines
hw/arm/orangepi.c +5
-0machine->ram); +/* Load target kernel or start using BootROM */ +if (!machine->kernel_filename &&blk_is_available (blk)) { +/* Use Boot ROM to copy data from SD card to SRAM */ +allwinner_h3_bootrom_setup (h3, blk); + }
Quoted 7 lines
blk_is_available()assumes its argument is non-NULL, but earlier in the function we set up blk with:blk = di ? blk_by_legacy_dinfo(di) : NULL;so it can be NULL here.
Right, indeed.
Quoted 2 lines
Could you send a patch to fix this, please? Probably
just adding '&& blk' in the middle of the condition
Quoted 2 lines
is sufficient.
Sure, I'll make a small patch for this, and also the other one you reported for the SDRAM controller.
By the way, I do not have the coverity tool unfortunately. So I can't really check myself
if any of the other Allwinner H3 files also have warnings that can be fixed..
But if coverity finds more, just let me know, and I'll look into it.
Regards,
Niek
Quoted 4 lines
thanks
-- PMM
Signature · 1 line
Niek Linnenbank
Re: [PULL 21/36] hw/arm/allwinner-h3: add Boot ROM support
Quoted 3 lines · Niek Linnenbank
By the way, I do not have the coverity tool unfortunately. So I can't really check myself if any of the other Allwinner H3 files also have warnings that can be fixed.. But if coverity finds more, just let me know, and I'll look into it.
Yeah, we only have Coverity as an online tool, so it just runs once code gets into master, and then we fix stuff after the fact. Either I or somebody else will usually go through the reported new issues when we get a new run and alert relevant people.
thanks
-- PMM
Re: [PULL 22/36] hw/arm/allwinner-h3: add SDRAM controller device
In reply to Peter MaydellHi Peter,
Quoted 56 lines · Peter Maydell
Quoted 8 lines · Peter Maydell
From: Niek Linnenbank <[email protected]>
In the Allwinner H3 SoC the SDRAM controller is responsible for interfacing with the external Synchronous Dynamic Random Access Memory (SDRAM). Types of memory that the SDRAM controller supports are DDR2/DDR3 and capacities of up to 2GiB. This commit adds emulation support of the Allwinner H3 SDRAM controller.
Hi; Coverity has flagged a possible issue with this patch (CID 1421912):
Quoted 1 line
+static void allwinner_h3_dramc_map_rows(AwH3DramCtlState *s,
uint8_t
row_bits,Quoted 1 line
+
uint8_tbank_bits,uint16_t
page_size)hw/misc/allwinner-h3-dramc.c
Quoted 4 lines
hw/misc/allwinner-h3-dramc.c new file +4
-0+{ +/* +* This function simulates row addressing behavior when bootloader +* software attempts to detect the amount of available SDRAM. In U-Boot
Quoted 1 line
+ * the controller is configured with the widest row addressing
available.
Quoted 1 line
+ * Then a pattern is written to RAM at an offset on the row
boundary size.
hw/misc/allwinner-h3-dramc.c
Quoted 4 lines
hw/misc/allwinner-h3-dramc.c new file +4
-0+* If the value read back equals the value read back from the +* start of RAM, the bootloader knows the amount of row bits. +* +* This function inserts a mirrored memory region when the configured row
Quoted 12 lines
hw/misc/allwinner-h3-dramc.c new file +12
-0+* bits are not matching the actual emulated memory, to simulate the +* same behavior on hardware as expected by the bootloader. +*/ +uint8_t row_bits_actual =0 ; + +/* Calculate the actual row bits using the ram_size property */ +for (uint8_t i =8 ; i <12 ; i++) { +if (1 << i == s->ram_size) { + row_bits_actual = i +3 ; +break ; + } + }hw/misc/allwinner-h3-dramc.c
Quoted 10 lines
hw/misc/allwinner-h3-dramc.c new file +10
-0+ +if (s->ram_size == (1 << (row_bits -3 ))) { +/* When row bits is the expected value, remove the mirror */ +memory_region_set_enabled (&s->row_mirror_alias, false); +trace_allwinner_h3_dramc_rowmirror_disable (); + + }else if (row_bits_actual) { +/* Row bits not matching ram_size, install the rows mirror */ + hwaddr row_mirror = s->ram_addr + ((1 << (row_bits_actual + + bank_bits)) *
page_size);
Quoted 6 lines
In this calculation we do the multiply as a signed 32-bit operation, which then gets sign-extended to 64 bits for the addition; that means that if the multiply result is greater than
0x7fffffffthen the upper bits of the result will all be 1s. Is this a "can't happen" situation, or should we be using "1ULL" to force a 64-bit multiply?
The allwinner_h3_dramcom_write() function invokes this function when the 'Control' register
is written. Basically allwinner_h3_dramc_map_rows() needs to insert a memory region such
that the bootloader can detect the amount of RAM. Currently U-Boot only searches up to page_size
values up to 8192, so in practise that would not trigger a result greater than 0x7fffffff.
However in theory, the Control register can indeed be written with larger page_size values.
So to be safe, I'll just make a small patch to replace the 1 with 1UL, thanks!
Regards,
Niek
Quoted 4 lines
thanks
-- PMM
Signature · 1 line
Niek Linnenbank
Re: [PULL 22/36] hw/arm/allwinner-h3: add SDRAM controller device
Quoted 9 lines · Niek Linnenbank
Quoted 5 lines · Peter Maydell
In this calculation we do the multiply as a signed 32-bit operation, which then gets sign-extended to 64 bits for the addition; that means that if the multiply result is greater than
0x7fffffffthen the upper bits of the result will all be 1s. Is this a "can't happen" situation, or should we be using "1ULL" to force a 64-bit multiply?However in theory, the Control register can indeed be written with larger
page_sizevalues. So to be safe, I'll just make a small patch to replace the 1 with 1UL, thanks!
"1ULL", not "1UL". The former guarantees you a 64-bit constant, the latter does not: it depends on the size of 'long' on the host. (Usually using "UL" suffixes in QEMU is a bug, because either 32 bits was fine, in which case "U" or no suffix would have done, or you really needed 64 bits, in which case you need "ULL". There are some exceptions where the code really is working with "long" values.)
thanks
-- PMM