target-arm queue
Another lump of target-arm patches. I still have some patches in my to-review queue, but this is a big enough set that I wanted to send it out.
thanks
-- PMM
The following changes since commit 04bb7fe2bf55bdf66d5b7a5a719b40bbb4048178:
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20180208' into staging (2018-02-08 17:41:15 +0000)
are available in the Git repository at:
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20180209
for you to fetch changes up to bbba7757bacc9f890a3f028d328b4b429dbe78ec:
hw/core/generic-loader: Allow PC to be set on command line (2018-02-09 10:55:40 +0000)
----------------------------------------------------------------
target-arm queue:
* Support M profile derived exceptions on exception entry and exit
* Implement AArch64 v8.2 crypto insns (SHA-512, SHA-3, SM3, SM4)
* Implement working i.MX6 SD controller
* Various devices preparatory to i.MX7 support
* Preparatory patches for SVE emulation
* v8M: Fix bug in implementation of 'TT' insn
* Give useful error if user tries to use userspace GICv3 with KVM
----------------------------------------------------------------
Andrey Smirnov (10):
sdhci: Add i.MX specific subtype of SDHCI
hw: i.MX: Convert i.MX6 to use TYPE_IMX_USDHC i.MX: Add code to emulate i.MX7 CCM, PMU and ANALOG IP blocks i.MX: Add code to emulate i.MX2 watchdog IP block i.MX: Add code to emulate i.MX7 SNVS IP-block i.MX: Add code to emulate GPCv2 IP block
i.MX: Add i.MX7 GPT variant
i.MX: Add implementation of i.MX7 GPR IP block
usb: Add basic code to emulate Chipidea USB IP hw/arm: Move virt's PSCI DT fixup code to arm/boot.c
Ard Biesheuvel (5):
target/arm: implement SHA-512 instructions
target/arm: implement SHA-3 instructions
target/arm: implement SM3 instructions
target/arm: implement SM4 instructions
target/arm: enable user-mode SHA-3, SM3, SM4 and SHA-512 instruction support
Christoffer Dall (1):
target/arm/kvm: gic: Prevent creating userspace GICv3 with KVM
Peter Maydell (9):
target/arm: Add armv7m_nvic_set_pending_derived() target/arm: Split "get pending exception info" from "acknowledge it" target/arm: Add ignore_stackfaults argument to v7m_exception_taken() target/arm: Make v7M exception entry stack push check MPU target/arm: Make v7m_push_callee_stack() honour MPU target/arm: Make exception vector loads honour the SAU target/arm: Handle exceptions during exception stack pop target/arm/translate.c: Fix missing 'break' for TT insns hw/core/generic-loader: Allow PC to be set on command line
Richard Henderson (5):
target/arm: Expand vector registers for SVE
target/arm: Add predicate registers for SVE
target/arm: Add SVE to migration state
target/arm: Add ZCR_ELx
target/arm: Add SVE state to TB->FLAGS
hw/intc/Makefile.objs | 2 +- hw/misc/Makefile.objs | 4 + hw/usb/Makefile.objs | 1 + hw/sd/sdhci-internal.h | 23 ++ include/hw/intc/imx_gpcv2.h | 22 ++ include/hw/misc/imx2_wdt.h | 33 +++ include/hw/misc/imx7_ccm.h | 139 +++++++++++ include/hw/misc/imx7_gpr.h | 28 +++ include/hw/misc/imx7_snvs.h | 35 +++ include/hw/sd/sdhci.h | 13 ++ include/hw/timer/imx_gpt.h | 1 + include/hw/usb/chipidea.h | 16 ++ target/arm/cpu.h | 120 ++++++++-- target/arm/helper.h | 12 + target/arm/kvm_arm.h | 4 + target/arm/translate.h | 2 + hw/arm/boot.c | 65 ++++++ hw/arm/fsl-imx6.c | 2 +- hw/arm/virt.c | 61 ----- hw/core/generic-loader.c | 2 +- hw/intc/armv7m_nvic.c | 98 +++++++- hw/intc/imx_gpcv2.c | 125 ++++++++++ hw/misc/imx2_wdt.c | 89 +++++++ hw/misc/imx7_ccm.c | 277 ++++++++++++++++++++++ hw/misc/imx7_gpr.c | 124 ++++++++++ hw/misc/imx7_snvs.c | 83 +++++++ hw/sd/sdhci.c | 230 ++++++++++++++++++- hw/timer/imx_gpt.c | 25 ++ hw/usb/chipidea.c | 176 ++++++++++++++ linux-user/elfload.c | 19 ++ target/arm/cpu64.c | 4 + target/arm/crypto_helper.c | 277 +++++++++++++++++++++- target/arm/helper.c | 548 +++++++++++++++++++++++++++++++++++++------- target/arm/machine.c | 88 ++++++- target/arm/translate-a64.c | 350 +++++++++++++++++++++++++++- target/arm/translate.c | 8 +- hw/intc/trace-events | 5 +- hw/misc/trace-events | 4 + 38 files changed, 2928 insertions(+), 187 deletions(-) create mode 100644 include/hw/intc/imx_gpcv2.h create mode 100644 include/hw/misc/imx2_wdt.h create mode 100644 include/hw/misc/imx7_ccm.h create mode 100644 include/hw/misc/imx7_gpr.h create mode 100644 include/hw/misc/imx7_snvs.h create mode 100644 include/hw/usb/chipidea.h create mode 100644 hw/intc/imx_gpcv2.c create mode 100644 hw/misc/imx2_wdt.c create mode 100644 hw/misc/imx7_ccm.c create mode 100644 hw/misc/imx7_gpr.c create mode 100644 hw/misc/imx7_snvs.c create mode 100644 hw/usb/chipidea.c
[Qemu-devel] [PULL 11/30] target/arm: implement SM4 instructions
From: Ard Biesheuvel <[email protected]>
This implements emulation of the new SM4 instructions that have been added as an optional extension to the ARMv8 Crypto Extensions in ARM v8.2.
Message-id: [email protected]
--- target/arm/cpu.h | 1 + target/arm/helper.h | 3 ++ target/arm/crypto_helper.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++ target/arm/translate-a64.c | 8 ++++ 4 files changed, 103 insertions(+)
target/arm/cpu.h +1 -0
@@ -1344,6 +1344,7 @@ enum arm_features {ARM_FEATURE_V8_SHA512 ,/* implements SHA512 part of v8 Crypto Extensions */ ARM_FEATURE_V8_SHA3 ,/* implements SHA3 part of v8 Crypto Extensions */ ARM_FEATURE_V8_SM3 ,/* implements SM3 part of v8 Crypto Extensions */ + ARM_FEATURE_V8_SM4, /* implements SM4 part of v8 Crypto Extensions */ };static inline int arm_feature (CPUARMState *env,int feature)
target/arm/helper.h +3 -0
@@ -543,6 +543,9 @@ DEF_HELPER_FLAGS_5(crypto_sm3tt, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32, i32) DEF_HELPER_FLAGS_3(crypto_sm3partw1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) DEF_HELPER_FLAGS_3(crypto_sm3partw2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) +DEF_HELPER_FLAGS_2(crypto_sm4e, TCG_CALL_NO_RWG, void, ptr, ptr) +DEF_HELPER_FLAGS_3(crypto_sm4ekey, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) + DEF_HELPER_FLAGS_3(crc32, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) DEF_HELPER_FLAGS_3(crc32c, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32)DEF_HELPER_2 (dc_zva, void, env, i64)
target/arm/crypto_helper.c +91 -0
94 lines not on this page · raw message
target/arm/translate-a64.c +8 -0
@@ -11632,6 +11632,10 @@ static void disas_crypto_three_reg_sha512(DisasContext *s, uint32_t insn) feature =ARM_FEATURE_V8_SM3 ; genfn = gen_helper_crypto_sm3partw2;break ; +case 2 :/* SM4EKEY */ + feature =ARM_FEATURE_V8_SM4 ; + genfn = gen_helper_crypto_sm4ekey; +break ;default :unallocated_encoding (s);return ;
@@ -11705,6 +11709,10 @@ static void disas_crypto_two_reg_sha512(DisasContext *s, uint32_t insn) feature =ARM_FEATURE_V8_SHA512 ; genfn = gen_helper_crypto_sha512su0;break ; +case 1 :/* SM4E */ + feature =ARM_FEATURE_V8_SM4 ; + genfn = gen_helper_crypto_sm4e; +break ;default :unallocated_encoding (s);return ;
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 10/30] target/arm: implement SM3 instructions
In reply to Peter MaydellFrom: Ard Biesheuvel <[email protected]>
This implements emulation of the new SM3 instructions that have been added as an optional extension to the ARMv8 Crypto Extensions in ARM v8.2.
Message-id: [email protected]
--- target/arm/cpu.h | 1 + target/arm/helper.h | 4 ++ target/arm/crypto_helper.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ target/arm/translate-a64.c | 88 ++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 186 insertions(+), 3 deletions(-)
target/arm/cpu.h +1 -0
@@ -1343,6 +1343,7 @@ enum arm_features {ARM_FEATURE_SVE ,/* has Scalable Vector Extension */ ARM_FEATURE_V8_SHA512 ,/* implements SHA512 part of v8 Crypto Extensions */ ARM_FEATURE_V8_SHA3 ,/* implements SHA3 part of v8 Crypto Extensions */ + ARM_FEATURE_V8_SM3, /* implements SM3 part of v8 Crypto Extensions */ };static inline int arm_feature (CPUARMState *env,int feature)
target/arm/helper.h +4 -0
@@ -539,6 +539,10 @@ DEF_HELPER_FLAGS_3(crypto_sha512h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) DEF_HELPER_FLAGS_2(crypto_sha512su0, TCG_CALL_NO_RWG, void, ptr, ptr) DEF_HELPER_FLAGS_3(crypto_sha512su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) +DEF_HELPER_FLAGS_5(crypto_sm3tt, TCG_CALL_NO_RWG, void, ptr, ptr, ptr, i32, i32) +DEF_HELPER_FLAGS_3(crypto_sm3partw1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) +DEF_HELPER_FLAGS_3(crypto_sm3partw2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) + DEF_HELPER_FLAGS_3(crc32, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) DEF_HELPER_FLAGS_3(crc32c, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32)DEF_HELPER_2 (dc_zva, void, env, i64)
target/arm/crypto_helper.c +96 -0
99 lines not on this page · raw message
target/arm/translate-a64.c +85 -3
118 lines not on this page · raw message
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 13/30] sdhci: Add i.MX specific subtype of SDHCI
In reply to Peter MaydellFrom: Andrey Smirnov <[email protected]>
IP block found on several generations of i.MX family does not use vanilla SDHCI implementation and it comes with a number of quirks.
Introduce i.MX SDHCI subtype of SDHCI block to add code necessary to support unmodified Linux guest driver.
--- hw/sd/sdhci-internal.h | 23 +++++ include/hw/sd/sdhci.h | 13 +++ hw/sd/sdhci.c | 230 ++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 265 insertions(+), 1 deletion(-)
hw/sd/sdhci-internal.h +23 -0
@@ -84,12 +84,18 @@/* R/W Host control Register 0x0 */ #define SDHC_HOSTCTL 0x28 +#define SDHC_CTRL_LED 0x01#define SDHC_CTRL_DMA_CHECK_MASK 0x18#define SDHC_CTRL_SDMA 0x00#define SDHC_CTRL_ADMA1_32 0x08#define SDHC_CTRL_ADMA2_32 0x10#define SDHC_CTRL_ADMA2_64 0x18#define SDHC_DMA_TYPE (x) ((x) & SDHC_CTRL_DMA_CHECK_MASK) +#define SDHC_CTRL_4BITBUS 0x02 +#define SDHC_CTRL_8BITBUS 0x20 +#define SDHC_CTRL_CDTEST_INS 0x40 +#define SDHC_CTRL_CDTEST_EN 0x80 +/* R/W Power Control Register 0x0 */ #define SDHC_PWRCON 0x29
@@ -226,4 +232,21 @@ enum { sdhc_gap_write =2 /* SDHC stopped at block gap during write operation */ }; +extern const VMStateDescription sdhci_vmstate; + + +#define ESDHC_MIX_CTRL 0x48 +#define ESDHC_VENDOR_SPEC 0xc0 +#define ESDHC_DLL_CTRL 0x60 + +#define ESDHC_TUNING_CTRL 0xcc +#define ESDHC_TUNE_CTRL_STATUS 0x68 +#define ESDHC_WTMK_LVL 0x44 + +/* Undocumented register used by guests working around erratum ERR004536 */ +#define ESDHC_UNDOCUMENTED_REG27 0x6c + +#define ESDHC_CTRL_4BITBUS (0x1 << 1) +#define ESDHC_CTRL_8BITBUS (0x2 << 1) +#endif
include/hw/sd/sdhci.h +13 -0
@@ -44,6 +44,7 @@ typedef struct SDHCIState {AddressSpace sysbus_dma_as;AddressSpace *dma_as;MemoryRegion *dma_mr; +const MemoryRegionOps *io_ops;QEMUTimer *insert_timer;/* timer for 'changing' sd card. */ QEMUTimer *transfer_timer;
@@ -91,8 +92,18 @@ typedef struct SDHCIState {/* Configurable properties */ bool pending_insert_quirk;/* Quirk for Raspberry Pi card insert int */ +uint32_t quirks; } SDHCIState; +/* +* Controller does not provide transfer-complete interrupt when not +* busy. +* +* NOTE: This definition is taken out of Linux kernel and so the +* original bit number is preserved +*/ +#define SDHCI_QUIRK_NO_BUSY_IRQ BIT(14) +#define TYPE_PCI_SDHCI "sdhci-pci"#define PCI_SDHCI (obj) OBJECT_CHECK(SDHCIState, (obj), TYPE_PCI_SDHCI)
@@ -100,4 +111,6 @@ typedef struct SDHCIState {#define SYSBUS_SDHCI (obj) \ OBJECT_CHECK(SDHCIState, (obj), TYPE_SYSBUS_SDHCI) +#define TYPE_IMX_USDHC "imx-usdhc" +#endif /* SDHCI_H */
hw/sd/sdhci.c +229 -1
259 lines not on this page · raw message
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 07/30] target/arm: Handle exceptions during exception stack pop
In reply to Peter MaydellHandle possible MPU faults, SAU faults or bus errors when popping register state off the stack during exception return.
Message-id: [email protected]
--- target/arm/helper.c | 115 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 94 insertions(+), 21 deletions(-)
target/arm/helper.c +94 -21
@@ -6223,6 +6223,67 @@ pend_fault:return false; } +static bool v7m_stack_read (ARMCPU *cpu,uint32_t *dest,uint32_t addr, +ARMMMUIdx mmu_idx) +{ +CPUState *cs =CPU (cpu); +CPUARMState *env = &cpu->env; +MemTxAttrs attrs = {}; +MemTxResult txres; +target_ulong page_size; +hwaddr physaddr; +int prot; +ARMMMUFaultInfo fi; +bool secure = mmu_idx &ARM_MMU_IDX_M_S ; +int exc; +bool exc_secure; +uint32_t value; + +if (get_phys_addr (env, addr,MMU_DATA_LOAD , mmu_idx, &physaddr, + &attrs, &prot, &page_size, &fi,NULL )) { +/* MPU/SAU lookup failed */ +if (fi.type == ARMFault_QEMU_SFault) { +qemu_log_mask (CPU_LOG_INT , +"...SecureFault with SFSR.AUVIOL during unstack\n" ); + env->v7m.sfsr |=R_V7M_SFSR_AUVIOL_MASK |R_V7M_SFSR_SFARVALID_MASK ; + env->v7m.sfar = addr; + exc =ARMV7M_EXCP_SECURE ; + exc_secure = false; + }else { +qemu_log_mask (CPU_LOG_INT , +"...MemManageFault with CFSR.MUNSTKERR\n" ); + env->v7m.cfsr[secure] |=R_V7M_CFSR_MUNSTKERR_MASK ; + exc =ARMV7M_EXCP_MEM ; + exc_secure = secure; + } + goto pend_fault; + } + + value =address_space_ldl (arm_addressspace (cs, attrs), physaddr, + attrs, &txres); +if (txres !=MEMTX_OK ) { +/* BusFault trying to read the data */ +qemu_log_mask (CPU_LOG_INT ,"...BusFault with BFSR.UNSTKERR\n" ); + env->v7m.cfsr[M_REG_NS ] |=R_V7M_CFSR_UNSTKERR_MASK ; + exc =ARMV7M_EXCP_BUS ; + exc_secure = false; + goto pend_fault; + } + + *dest = value; +return true; + +pend_fault: +/* By pending the exception at this point we are making +* the IMPDEF choice "overridden exceptions pended" (see the +* MergeExcInfo() pseudocode). The other choice would be to not +* pend them now and then make a choice about which to throw away +* later if we have two derived exceptions. +*/ +armv7m_nvic_set_pending (env->nvic, exc, exc_secure); +return false; +} +/* Return true if we're using the process stack pointer (not the MSP) */ static bool v7m_using_psp (CPUARMState *env) {
@@ -6912,6 +6973,11 @@ static void do_v7m_exception_exit(ARMCPU *cpu) !return_to_handler, return_to_sp_process);uint32_t frameptr = *frame_sp_p; +bool pop_ok = true; +ARMMMUIdx mmu_idx; + + mmu_idx =arm_v7m_mmu_idx_for_secstate_and_priv (env, return_to_secure, + !return_to_handler);if (!QEMU_IS_ALIGNED (frameptr,8 ) &&arm_feature (env,ARM_FEATURE_V8 )) {
@@ -6938,29 +7004,38 @@ static void do_v7m_exception_exit(ARMCPU *cpu)return ; } - env->regs[4 ] =ldl_phys (cs->as, frameptr +0x8 ); - env->regs[5 ] =ldl_phys (cs->as, frameptr +0xc ); - env->regs[6 ] =ldl_phys (cs->as, frameptr +0x10 ); - env->regs[7 ] =ldl_phys (cs->as, frameptr +0x14 ); - env->regs[8 ] =ldl_phys (cs->as, frameptr +0x18 ); - env->regs[9 ] =ldl_phys (cs->as, frameptr +0x1c ); - env->regs[10 ] =ldl_phys (cs->as, frameptr +0x20 ); - env->regs[11 ] =ldl_phys (cs->as, frameptr +0x24 ); + pop_ok = +v7m_stack_read (cpu, &env->regs[4 ], frameptr +0x8 , mmu_idx) && +v7m_stack_read (cpu, &env->regs[4 ], frameptr +0x8 , mmu_idx) && +v7m_stack_read (cpu, &env->regs[5 ], frameptr +0xc , mmu_idx) && +v7m_stack_read (cpu, &env->regs[6 ], frameptr +0x10 , mmu_idx) && +v7m_stack_read (cpu, &env->regs[7 ], frameptr +0x14 , mmu_idx) && +v7m_stack_read (cpu, &env->regs[8 ], frameptr +0x18 , mmu_idx) && +v7m_stack_read (cpu, &env->regs[9 ], frameptr +0x1c , mmu_idx) && +v7m_stack_read (cpu, &env->regs[10 ], frameptr +0x20 , mmu_idx) && +v7m_stack_read (cpu, &env->regs[11 ], frameptr +0x24 , mmu_idx); frameptr +=0x28 ; } -/* Pop registers. TODO: make these accesses use the correct -* attributes and address space (S/NS, priv/unpriv) and handle -* memory transaction failures. -*/ - env->regs[0 ] =ldl_phys (cs->as, frameptr); - env->regs[1 ] =ldl_phys (cs->as, frameptr +0x4 ); - env->regs[2 ] =ldl_phys (cs->as, frameptr +0x8 ); - env->regs[3 ] =ldl_phys (cs->as, frameptr +0xc ); - env->regs[12 ] =ldl_phys (cs->as, frameptr +0x10 ); - env->regs[14 ] =ldl_phys (cs->as, frameptr +0x14 ); - env->regs[15 ] =ldl_phys (cs->as, frameptr +0x18 ); +/* Pop registers */ + pop_ok = pop_ok && +v7m_stack_read (cpu, &env->regs[0 ], frameptr, mmu_idx) && +v7m_stack_read (cpu, &env->regs[1 ], frameptr +0x4 , mmu_idx) && +v7m_stack_read (cpu, &env->regs[2 ], frameptr +0x8 , mmu_idx) && +v7m_stack_read (cpu, &env->regs[3 ], frameptr +0xc , mmu_idx) && +v7m_stack_read (cpu, &env->regs[12 ], frameptr +0x10 , mmu_idx) && +v7m_stack_read (cpu, &env->regs[14 ], frameptr +0x14 , mmu_idx) && +v7m_stack_read (cpu, &env->regs[15 ], frameptr +0x18 , mmu_idx) && +v7m_stack_read (cpu, &xpsr, frameptr +0x1c , mmu_idx); + +if (!pop_ok) { +/* v7m_stack_read() pended a fault, so take it (as a tail +* chained exception on the same stack frame) +*/ +v7m_exception_taken (cpu, excret, true, false); +return ; + }/* Returning from an exception with a PC with bit 0 set is defined * behaviour on v8M (bit 0 is ignored), but for v7M it was specified
@@ -6979,8 +7054,6 @@ static void do_v7m_exception_exit(ARMCPU *cpu) } } - xpsr =ldl_phys (cs->as, frameptr +0x1c ); -if (arm_feature (env,ARM_FEATURE_V8 )) {/* For v8M we have to check whether the xPSR exception field * matches the EXCRET value for return to handler/thread
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 08/30] target/arm: implement SHA-512 instructions
In reply to Peter MaydellFrom: Ard Biesheuvel <[email protected]>
This implements emulation of the new SHA-512 instructions that have been added as an optional extensions to the ARMv8 Crypto Extensions in ARM v8.2.
Message-id: [email protected]
--- target/arm/cpu.h | 1 + target/arm/helper.h | 5 +++ target/arm/crypto_helper.c | 90 ++++++++++++++++++++++++++++++++++++- target/arm/translate-a64.c | 110 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 205 insertions(+), 1 deletion(-)
target/arm/cpu.h +1 -0
@@ -1341,6 +1341,7 @@ enum arm_features {ARM_FEATURE_M_SECURITY ,/* M profile Security Extension */ ARM_FEATURE_JAZELLE ,/* has (trivial) Jazelle implementation */ ARM_FEATURE_SVE ,/* has Scalable Vector Extension */ + ARM_FEATURE_V8_SHA512, /* implements SHA512 part of v8 Crypto Extensions */ };static inline int arm_feature (CPUARMState *env,int feature)
target/arm/helper.h +5 -0
@@ -534,6 +534,11 @@ DEF_HELPER_FLAGS_3(crypto_sha256h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) DEF_HELPER_FLAGS_2(crypto_sha256su0, TCG_CALL_NO_RWG, void, ptr, ptr) DEF_HELPER_FLAGS_3(crypto_sha256su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) +DEF_HELPER_FLAGS_3(crypto_sha512h, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) +DEF_HELPER_FLAGS_3(crypto_sha512h2, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) +DEF_HELPER_FLAGS_2(crypto_sha512su0, TCG_CALL_NO_RWG, void, ptr, ptr) +DEF_HELPER_FLAGS_3(crypto_sha512su1, TCG_CALL_NO_RWG, void, ptr, ptr, ptr) + DEF_HELPER_FLAGS_3(crc32, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) DEF_HELPER_FLAGS_3(crc32c, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32)DEF_HELPER_2 (dc_zva, void, env, i64)
target/arm/crypto_helper.c +89 -1
99 lines not on this page · raw message
target/arm/translate-a64.c +110 -0
122 lines not on this page · raw message
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 15/30] i.MX: Add code to emulate i.MX7 CCM, PMU and ANALOG IP blocks
In reply to Peter MaydellFrom: Andrey Smirnov <[email protected]>
Add minimal code needed to allow upstream Linux guest to boot.
--- hw/misc/Makefile.objs | 1 + include/hw/misc/imx7_ccm.h | 139 +++++++++++++++++++++++ hw/misc/imx7_ccm.c | 277 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 417 insertions(+) create mode 100644 include/hw/misc/imx7_ccm.h create mode 100644 hw/misc/imx7_ccm.c
hw/misc/Makefile.objs +1 -0
@@ -33,6 +33,7 @@ obj-$(CONFIG_IMX) += imx31_ccm.o obj-$(CONFIG_IMX) += imx25_ccm.o obj-$(CONFIG_IMX) += imx6_ccm.o obj-$(CONFIG_IMX) += imx6_src.o +obj-$(CONFIG_IMX) += imx7_ccm.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.o
include/hw/misc/imx7_ccm.h new file +139 -0
139 lines not on this page · raw message
hw/misc/imx7_ccm.c new file +277 -0
277 lines not on this page · raw message
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 05/30] target/arm: Make v7m_push_callee_stack() honour MPU
In reply to Peter MaydellMake v7m_push_callee_stack() honour the MPU by using the new v7m_stack_write() function. We return a flag to indicate whether the pushes failed, which we can then use in v7m_exception_taken() to cause us to handle the derived exception correctly.
Message-id: [email protected]
--- target/arm/helper.c | 64 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 49 insertions(+), 15 deletions(-)
target/arm/helper.c +49 -15
@@ -6473,7 +6473,7 @@ static uint32_t arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure)return addr; } -static void v7m_push_callee_stack (ARMCPU *cpu,uint32_t lr,bool dotailchain, +static bool v7m_push_callee_stack (ARMCPU *cpu,uint32_t lr,bool dotailchain,bool ignore_faults) {/* For v8M, push the callee-saves register part of the stack frame.
@@ -6481,31 +6481,55 @@ static void v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,* In the tailchaining case this may not be the current stack. */ CPUARMState *env = &cpu->env; -CPUState *cs =CPU (cpu);uint32_t *frame_sp_p;uint32_t frameptr; +ARMMMUIdx mmu_idx; +bool stacked_ok;if (dotailchain) { - frame_sp_p =get_v7m_sp_ptr (env, true, - lr &R_V7M_EXCRET_MODE_MASK , +bool mode = lr &R_V7M_EXCRET_MODE_MASK ; +bool priv = !(env->v7m.control[M_REG_S ] &R_V7M_CONTROL_NPRIV_MASK ) || + !mode; + + mmu_idx =arm_v7m_mmu_idx_for_secstate_and_priv (env,M_REG_S , priv); + frame_sp_p =get_v7m_sp_ptr (env,M_REG_S , mode, lr &R_V7M_EXCRET_SPSEL_MASK ); }else { + mmu_idx =core_to_arm_mmu_idx (env,cpu_mmu_index (env, false)); frame_sp_p = &env->regs[13 ]; } frameptr = *frame_sp_p -0x28 ; -stl_phys (cs->as, frameptr,0xfefa125b ); -stl_phys (cs->as, frameptr +0x8 , env->regs[4 ]); -stl_phys (cs->as, frameptr +0xc , env->regs[5 ]); -stl_phys (cs->as, frameptr +0x10 , env->regs[6 ]); -stl_phys (cs->as, frameptr +0x14 , env->regs[7 ]); -stl_phys (cs->as, frameptr +0x18 , env->regs[8 ]); -stl_phys (cs->as, frameptr +0x1c , env->regs[9 ]); -stl_phys (cs->as, frameptr +0x20 , env->regs[10 ]); -stl_phys (cs->as, frameptr +0x24 , env->regs[11 ]); +/* Write as much of the stack frame as we can. A write failure may +* cause us to pend a derived exception. +*/ + stacked_ok = +v7m_stack_write (cpu, frameptr,0xfefa125b , mmu_idx, ignore_faults) && +v7m_stack_write (cpu, frameptr +0x8 , env->regs[4 ], mmu_idx, + ignore_faults) && +v7m_stack_write (cpu, frameptr +0xc , env->regs[5 ], mmu_idx, + ignore_faults) && +v7m_stack_write (cpu, frameptr +0x10 , env->regs[6 ], mmu_idx, + ignore_faults) && +v7m_stack_write (cpu, frameptr +0x14 , env->regs[7 ], mmu_idx, + ignore_faults) && +v7m_stack_write (cpu, frameptr +0x18 , env->regs[8 ], mmu_idx, + ignore_faults) && +v7m_stack_write (cpu, frameptr +0x1c , env->regs[9 ], mmu_idx, + ignore_faults) && +v7m_stack_write (cpu, frameptr +0x20 , env->regs[10 ], mmu_idx, + ignore_faults) && +v7m_stack_write (cpu, frameptr +0x24 , env->regs[11 ], mmu_idx, + ignore_faults); +/* Update SP regardless of whether any of the stack accesses failed. +* When we implement v8M stack limit checking then this attempt to +* update SP might also fail and result in a derived exception. +*/ *frame_sp_p = frameptr; + +return !stacked_ok; } static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,
@@ -6519,6 +6543,7 @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,uint32_t addr;bool targets_secure;int exc; +bool push_failed = false;armv7m_nvic_get_pending_irq_info (env->nvic, &exc, &targets_secure);
@@ -6546,8 +6571,8 @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,*/ if (lr &R_V7M_EXCRET_DCRS_MASK && !(dotailchain && (lr &R_V7M_EXCRET_ES_MASK ))) { -v7m_push_callee_stack (cpu, lr, dotailchain, - ignore_stackfaults); + push_failed =v7m_push_callee_stack (cpu, lr, dotailchain, + ignore_stackfaults); } lr |=R_V7M_EXCRET_DCRS_MASK ; }
@@ -6589,6 +6614,15 @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain, } } +if (push_failed && !ignore_stackfaults) { +/* Derived exception on callee-saves register stacking: +* we might now want to take a different exception which +* targets a different security state, so try again from the top. +*/ +v7m_exception_taken (cpu, lr, true, true); +return ; + } + addr =arm_v7m_load_vector (cpu, exc, targets_secure);/* Now we've done everything that might cause a derived exception
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 03/30] target/arm: Add ignore_stackfaults argument to v7m_exception_taken()
In reply to Peter MaydellIn the v8M architecture, if the process of taking an exception results in a further exception this is called a derived exception (for example, an MPU exception when writing the exception frame to memory). If the derived exception happens while pushing the initial stack frame, we must ignore any subsequent possible exception pushing the callee-saves registers.
In preparation for making the stack writes check for exceptions, add a return value from v7m_push_stack() and a new parameter to v7m_exception_taken(), so that the former can tell the latter that it needs to ignore failures to write to the stack. We also plumb the argument through to v7m_push_callee_stack(), which is where the code to ignore the failures will be.
(Note that the v8M ARM pseudocode structures this slightly differently:
derived exceptions cause the attempt to process the original exception to be abandoned; then at the top level it calls DerivedLateArrival to prioritize the derived exception and call TakeException from there. We choose to let the NVIC do the prioritization and continue forward with a call to TakeException which will then take either the original or the derived exception. The effect is the same, but this structure works better for QEMU because we don't have a convenient top level place to do the abandon-and-retry logic.)
Message-id: [email protected]
--- target/arm/helper.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-)
target/arm/helper.c +23 -12
@@ -6419,7 +6419,8 @@ static uint32_t arm_v7m_load_vector(ARMCPU *cpu, int exc, bool targets_secure)return addr; } -static void v7m_push_callee_stack (ARMCPU *cpu,uint32_t lr,bool dotailchain) +static void v7m_push_callee_stack (ARMCPU *cpu,uint32_t lr,bool dotailchain, +bool ignore_faults) {/* For v8M, push the callee-saves register part of the stack frame. * Compare the v8M pseudocode PushCalleeStack().
@@ -6453,7 +6454,8 @@ static void v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain) *frame_sp_p = frameptr; } -static void v7m_exception_taken (ARMCPU *cpu,uint32_t lr,bool dotailchain) +static void v7m_exception_taken (ARMCPU *cpu,uint32_t lr,bool dotailchain, +bool ignore_stackfaults) {/* Do the "take the exception" parts of exception entry, * but not the pushing of state to the stack. This is
@@ -6490,7 +6492,8 @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain)*/ if (lr &R_V7M_EXCRET_DCRS_MASK && !(dotailchain && (lr &R_V7M_EXCRET_ES_MASK ))) { -v7m_push_callee_stack (cpu, lr, dotailchain); +v7m_push_callee_stack (cpu, lr, dotailchain, + ignore_stackfaults); } lr |=R_V7M_EXCRET_DCRS_MASK ; }
@@ -6551,10 +6554,13 @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain) env->thumb = addr &1 ; } -static void v7m_push_stack (ARMCPU *cpu) +static bool v7m_push_stack (ARMCPU *cpu) {/* Do the "set up stack frame" part of exception entry, * similar to pseudocode PushStack(). +* Return true if we generate a derived exception (and so +* should ignore further stack faults trying to process +* that derived exception.) */ CPUARMState *env = &cpu->env;uint32_t xpsr =xpsr_read (env);
@@ -6574,6 +6580,8 @@ static void v7m_push_stack(ARMCPU *cpu)v7m_push (env, env->regs[2 ]);v7m_push (env, env->regs[1 ]);v7m_push (env, env->regs[0 ]); + +return false; }static void do_v7m_exception_exit (ARMCPU *cpu)
@@ -6719,7 +6727,7 @@ static void do_v7m_exception_exit(ARMCPU *cpu)if (sfault) { env->v7m.sfsr |=R_V7M_SFSR_INVER_MASK ;armv7m_nvic_set_pending (env->nvic,ARMV7M_EXCP_SECURE , false); -v7m_exception_taken (cpu, excret, true); +v7m_exception_taken (cpu, excret, true, false);qemu_log_mask (CPU_LOG_INT ,"...taking SecureFault on existing " "stackframe: failed EXC_RETURN.ES validity check\n" );return ;
@@ -6731,7 +6739,7 @@ static void do_v7m_exception_exit(ARMCPU *cpu)*/ env->v7m.cfsr[env->v7m.secure] |=R_V7M_CFSR_INVPC_MASK ;armv7m_nvic_set_pending (env->nvic,ARMV7M_EXCP_USAGE , env->v7m.secure); -v7m_exception_taken (cpu, excret, true); +v7m_exception_taken (cpu, excret, true, false);qemu_log_mask (CPU_LOG_INT ,"...taking UsageFault on existing " "stackframe: failed exception return integrity check\n" );return ;
@@ -6779,7 +6787,7 @@ static void do_v7m_exception_exit(ARMCPU *cpu)/* Take a SecureFault on the current stack */ env->v7m.sfsr |=R_V7M_SFSR_INVIS_MASK ;armv7m_nvic_set_pending (env->nvic,ARMV7M_EXCP_SECURE , false); -v7m_exception_taken (cpu, excret, true); +v7m_exception_taken (cpu, excret, true, false);qemu_log_mask (CPU_LOG_INT ,"...taking SecureFault on existing " "stackframe: failed exception return integrity " "signature check\n" );
@@ -6844,7 +6852,7 @@ static void do_v7m_exception_exit(ARMCPU *cpu)armv7m_nvic_set_pending (env->nvic,ARMV7M_EXCP_USAGE , env->v7m.secure); env->v7m.cfsr[env->v7m.secure] |=R_V7M_CFSR_INVPC_MASK ; -v7m_exception_taken (cpu, excret, true); +v7m_exception_taken (cpu, excret, true, false);qemu_log_mask (CPU_LOG_INT ,"...taking UsageFault on existing " "stackframe: failed exception return integrity " "check\n" );
@@ -6877,11 +6885,13 @@ static void do_v7m_exception_exit(ARMCPU *cpu)/* Take an INVPC UsageFault by pushing the stack again; * we know we're v7M so this is never a Secure UsageFault. */ +bool ignore_stackfaults; +assert (!arm_feature (env,ARM_FEATURE_V8 ));armv7m_nvic_set_pending (env->nvic,ARMV7M_EXCP_USAGE , false); env->v7m.cfsr[env->v7m.secure] |=R_V7M_CFSR_INVPC_MASK ; -v7m_push_stack (cpu); -v7m_exception_taken (cpu, excret, false); + ignore_stackfaults =v7m_push_stack (cpu); +v7m_exception_taken (cpu, excret, false, ignore_stackfaults);qemu_log_mask (CPU_LOG_INT ,"...taking UsageFault on new stackframe: " "failed exception return integrity check\n" );return ;
@@ -7122,6 +7132,7 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env;uint32_t lr; +bool ignore_stackfaults;arm_log_exception (cs->exception_index);
@@ -7296,8 +7307,8 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs) lr |=R_V7M_EXCRET_MODE_MASK ; } -v7m_push_stack (cpu); -v7m_exception_taken (cpu, lr, false); + ignore_stackfaults =v7m_push_stack (cpu); +v7m_exception_taken (cpu, lr, false, ignore_stackfaults);qemu_log_mask (CPU_LOG_INT ,"... as %d\n" , env->v7m.exception); }
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 18/30] i.MX: Add code to emulate GPCv2 IP block
In reply to Peter MaydellFrom: Andrey Smirnov <[email protected]>
Add minimal code needed to allow upstream Linux guest to boot.
--- hw/intc/Makefile.objs | 2 +- include/hw/intc/imx_gpcv2.h | 22 ++++++++ hw/intc/imx_gpcv2.c | 125 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 include/hw/intc/imx_gpcv2.h create mode 100644 hw/intc/imx_gpcv2.c
hw/intc/Makefile.objs +1 -1
@@ -6,7 +6,7 @@ common-obj-$(CONFIG_XILINX) += xilinx_intc.o common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-pmu-iomod-intc.o common-obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp-ipi.o common-obj-$(CONFIG_ETRAXFS) += etraxfs_pic.o -common-obj-$(CONFIG_IMX) += imx_avic.o +common-obj-$(CONFIG_IMX) += imx_avic.o imx_gpcv2.o common-obj-$(CONFIG_LM32) += lm32_pic.o common-obj-$(CONFIG_REALVIEW) += realview_gic.o common-obj-$(CONFIG_SLAVIO) += slavio_intctl.o
include/hw/intc/imx_gpcv2.h new file +22 -0
@@ -0,0 +1,22 @@ +#ifndef IMX_GPCV2_H +#define IMX_GPCV2_H + +#include "hw/sysbus.h" + +enum IMXGPCv2Registers { +GPC_NUM =0xE00 /sizeof (uint32_t ), +}; + +typedef struct IMXGPCv2State { +/*< private >*/ +SysBusDevice parent_obj; + +/*< public >*/ +MemoryRegion iomem; +uint32_t regs[GPC_NUM ]; +}IMXGPCv2State ; + +#define TYPE_IMX_GPCV2 "imx-gpcv2" +#define IMX_GPCV2 (obj) OBJECT_CHECK(IMXGPCv2State, (obj), TYPE_IMX_GPCV2) + +#endif /* IMX_GPCV2_H */
hw/intc/imx_gpcv2.c new file +125 -0
125 lines not on this page · raw message
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 01/30] target/arm: Add armv7m_nvic_set_pending_derived()
In reply to Peter MaydellIn order to support derived exceptions (exceptions generated in the course of trying to take an exception), we need to be able to handle prioritizing whether to take the original exception or the derived exception.
We do this by introducing a new function armv7m_nvic_set_pending_derived() which the exception-taking code in helper.c will call when a derived exception occurs. Derived exceptions are dealt with mostly like normal pending exceptions, so we share the implementation with the armv7m_nvic_set_pending() function.
Note that the way we structure this is significantly different from the v8M Arm ARM pseudocode: that does all the prioritization logic in the DerivedLateArrival() function, whereas we choose to let the existing "identify highest priority exception" logic do the prioritization for us. The effect is the same, though.
Message-id: [email protected]
--- target/arm/cpu.h | 13 ++++++++++ hw/intc/armv7m_nvic.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++-- hw/intc/trace-events | 2 +- 3 files changed, 80 insertions(+), 3 deletions(-)
target/arm/cpu.h +13 -0
@@ -1505,6 +1505,19 @@ static inline bool armv7m_nvic_can_take_pending_exception(void *opaque)* of architecturally banked exceptions. */ void armv7m_nvic_set_pending (void *opaque,int irq,bool secure); +/** +* armv7m_nvic_set_pending_derived: mark this derived exception as pending +* @opaque: the NVIC +* @irq: the exception number to mark pending +* @secure: false for non-banked exceptions or for the nonsecure +* version of a banked exception, true for the secure version of a banked +* exception. +* +* Similar to armv7m_nvic_set_pending(), but specifically for derived +* exceptions (exceptions generated in the course of trying to take +* a different exception). +*/ +void armv7m_nvic_set_pending_derived (void *opaque,int irq,bool secure);/** * armv7m_nvic_acknowledge_irq: make highest priority pending exception active * @opaque: the NVIC
hw/intc/armv7m_nvic.c +66 -2
87 lines not on this page · raw message
hw/intc/trace-events +1 -1
@@ -177,7 +177,7 @@ nvic_set_prio(int irq, bool secure, uint8_t prio) "NVIC set irq %d secure-bank % nvic_irq_update(int vectpending, int pendprio, int exception_prio, int level) "NVIC vectpending %d pending prio %d exception_prio %d: setting irq line to %d" nvic_escalate_prio(int irq, int irqprio, int runprio) "NVIC escalating irq %d to HardFault: insufficient priority %d >= %d" nvic_escalate_disabled(int irq) "NVIC escalating irq %d to HardFault: disabled" -nvic_set_pending(int irq, bool secure, int en, int prio) "NVIC set pending irq %d secure-bank %d (enabled: %d priority %d)" +nvic_set_pending(int irq, bool secure, bool derived, int en, int prio) "NVIC set pending irq %d secure-bank %d derived %d (enabled: %d priority %d)" nvic_clear_pending(int irq, bool secure, int en, int prio) "NVIC clear pending irq %d secure-bank %d (enabled: %d priority %d)" nvic_set_pending_level(int irq) "NVIC set pending: irq %d higher prio than vectpending: setting irq line to 1" nvic_acknowledge_irq(int irq, int prio, bool targets_secure) "NVIC acknowledge IRQ: %d now active (prio %d targets_secure %d)"
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 19/30] i.MX: Add i.MX7 GPT variant
In reply to Peter MaydellFrom: Andrey Smirnov <[email protected]>
Add minimal code needed to allow upstream Linux guest to boot.
--- include/hw/timer/imx_gpt.h | 1 + hw/timer/imx_gpt.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+)
include/hw/timer/imx_gpt.h +1 -0
@@ -77,6 +77,7 @@#define TYPE_IMX25_GPT "imx25.gpt"#define TYPE_IMX31_GPT "imx31.gpt"#define TYPE_IMX6_GPT "imx6.gpt" +#define TYPE_IMX7_GPT "imx7.gpt"#define TYPE_IMX_GPT TYPE_IMX25_GPT
hw/timer/imx_gpt.c +25 -0
@@ -113,6 +113,17 @@ static const IMXClk imx6_gpt_clocks[] = { CLK_HIGH, /* 111 reference clock */ }; +static const IMXClk imx7_gpt_clocks[] = { +CLK_NONE ,/* 000 No clock source */ +CLK_IPG ,/* 001 ipg_clk, 532MHz*/ +CLK_IPG_HIGH ,/* 010 ipg_clk_highfreq */ +CLK_EXT ,/* 011 External clock */ + CLK_32k,/* 100 ipg_clk_32k */ +CLK_HIGH ,/* 101 reference clock */ +CLK_NONE ,/* 110 not defined */ +CLK_NONE ,/* 111 not defined */ +}; +static void imx_gpt_set_freq (IMXGPTState *s) {uint32_t clksrc =extract32 (s->cr,GPT_CR_CLKSRC_SHIFT ,3 );
@@ -512,6 +523,13 @@ static void imx6_gpt_init(Object *obj) s->clocks = imx6_gpt_clocks; } +static void imx7_gpt_init (Object *obj) +{ +IMXGPTState *s =IMX_GPT (obj); + + s->clocks = imx7_gpt_clocks; +} +static const TypeInfo imx25_gpt_info = { .name =TYPE_IMX25_GPT , .parent =TYPE_SYS_BUS_DEVICE ,
@@ -532,11 +550,18 @@ static const TypeInfo imx6_gpt_info = { .instance_init = imx6_gpt_init, }; +static const TypeInfo imx7_gpt_info = { + .name =TYPE_IMX7_GPT , + .parent =TYPE_IMX25_GPT , + .instance_init = imx7_gpt_init, +}; +static void imx_gpt_register_types (void ) {type_register_static (&imx25_gpt_info);type_register_static (&imx31_gpt_info);type_register_static (&imx6_gpt_info); +type_register_static (&imx7_gpt_info); }type_init (imx_gpt_register_types)
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 14/30] hw: i.MX: Convert i.MX6 to use TYPE_IMX_USDHC
In reply to Peter MaydellFrom: Andrey Smirnov <[email protected]>
Convert i.MX6 to use TYPE_IMX_USDHC since that's what real HW comes with.
--- hw/arm/fsl-imx6.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/arm/fsl-imx6.c +1 -1
@@ -93,7 +93,7 @@ static void fsl_imx6_init(Object *obj) }for (i =0 ; i <FSL_IMX6_NUM_ESDHCS ; i++) { -object_initialize (&s->esdhc[i],sizeof (s->esdhc[i]),TYPE_SYSBUS_SDHCI ); +object_initialize (&s->esdhc[i],sizeof (s->esdhc[i]),TYPE_IMX_USDHC );qdev_set_parent_bus (DEVICE (&s->esdhc[i]),sysbus_get_default ());snprintf (name,NAME_SIZE ,"sdhc%d" , i +1 );object_property_add_child (obj, name,OBJECT (&s->esdhc[i]),NULL );
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 21/30] usb: Add basic code to emulate Chipidea USB IP
In reply to Peter MaydellFrom: Andrey Smirnov <[email protected]>
Add code to emulate Chipidea USB IP (used in i.MX SoCs). Tested to work against:
-usb -drive if=none,id=stick,file=usb.img,format=raw -device \
usb-storage,bus=usb-bus.0,drive=stick
--- hw/usb/Makefile.objs | 1 + include/hw/usb/chipidea.h | 16 +++++ hw/usb/chipidea.c | 176 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 193 insertions(+) create mode 100644 include/hw/usb/chipidea.h create mode 100644 hw/usb/chipidea.c
hw/usb/Makefile.objs +1 -0
@@ -12,6 +12,7 @@ common-obj-$(CONFIG_USB_XHCI_NEC) += hcd-xhci-nec.o common-obj-$(CONFIG_USB_MUSB) += hcd-musb.o obj-$(CONFIG_TUSB6010) += tusb6010.o +obj-$(CONFIG_IMX) += chipidea.o # emulated usb devices common-obj-$(CONFIG_USB) += dev-hub.o
include/hw/usb/chipidea.h new file +16 -0
@@ -0,0 +1,16 @@ +#ifndef CHIPIDEA_H +#define CHIPIDEA_H + +#include "hw/usb/hcd-ehci.h" + +typedef struct ChipideaState { +/*< private >*/ +EHCISysBusState parent_obj; + +MemoryRegion iomem[3 ]; +}ChipideaState ; + +#define TYPE_CHIPIDEA "usb-chipidea" +#define CHIPIDEA (obj) OBJECT_CHECK(ChipideaState, (obj), TYPE_CHIPIDEA) + +#endif /* CHIPIDEA_H */
hw/usb/chipidea.c new file +176 -0
176 lines not on this page · raw message
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 02/30] target/arm: Split "get pending exception info" from "acknowledge it"
In reply to Peter MaydellCurrently armv7m_nvic_acknowledge_irq() does three things:
* make the current highest priority pending interrupt active
* return a bool indicating whether that interrupt is targeting Secure or NonSecure state
* implicitly tell the caller which is the highest priority pending interrupt by setting env->v7m.exception
We need to split these jobs, because v7m_exception_taken() needs to know whether the pending interrupt targets Secure so it can choose to stack callee-saves registers or not, but it must not make the interrupt active until after it has done that stacking, in case the stacking causes a derived exception. Similarly, it needs to know the number of the pending interrupt so it can read the correct vector table entry before the interrupt is made active, because vector table reads might also cause a derived exception.
Create a new armv7m_nvic_get_pending_irq_info() function which simply returns information about the highest priority pending interrupt, and use it to rearrange the v7m_exception_taken() code so we don't acknowledge the exception until we've done all the things which could possibly cause a derived exception.
Message-id: [email protected]
--- target/arm/cpu.h | 19 ++++++++++++++++--- hw/intc/armv7m_nvic.c | 30 +++++++++++++++++++++++------- target/arm/helper.c | 16 ++++++++++++---- hw/intc/trace-events | 3 ++- 4 files changed, 53 insertions(+), 15 deletions(-)
target/arm/cpu.h +16 -3
@@ -1518,6 +1518,21 @@ void armv7m_nvic_set_pending(void *opaque, int irq, bool secure);* a different exception). */ void armv7m_nvic_set_pending_derived (void *opaque,int irq,bool secure); +/** +* armv7m_nvic_get_pending_irq_info: return highest priority pending +* exception, and whether it targets Secure state +* @opaque: the NVIC +* @pirq: set to pending exception number +* @ptargets_secure: set to whether pending exception targets Secure +* +* This function writes the number of the highest priority pending +* exception (the one which would be made active by +* armv7m_nvic_acknowledge_irq()) to @pirq, and sets @ptargets_secure +* to true if the current highest priority pending exception should +* be taken to Secure state, false for NS. +*/ +void armv7m_nvic_get_pending_irq_info (void *opaque,int *pirq, +bool *ptargets_secure);/** * armv7m_nvic_acknowledge_irq: make highest priority pending exception active * @opaque: the NVIC
@@ -1525,10 +1540,8 @@ void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure);* Move the current highest priority pending exception from the pending * state to the active state, and update v7m.exception to indicate that * it is the exception currently being handled. -* -* Returns: true if exception should be taken to Secure state, false for NS */ -bool armv7m_nvic_acknowledge_irq (void *opaque); +void armv7m_nvic_acknowledge_irq (void *opaque);/** * armv7m_nvic_complete_irq: complete specified interrupt or exception * @opaque: the NVIC
hw/intc/armv7m_nvic.c +23 -7
@@ -650,24 +650,20 @@ void armv7m_nvic_set_pending_derived(void *opaque, int irq, bool secure) }/* Make pending IRQ active. */ -bool armv7m_nvic_acknowledge_irq (void *opaque) +void armv7m_nvic_acknowledge_irq (void *opaque) {NVICState *s = (NVICState *)opaque;CPUARMState *env = &s->cpu->env;const int pending = s->vectpending;const int running =nvic_exec_prio (s);VecInfo *vec; -bool targets_secure;assert (pending >ARMV7M_EXCP_RESET && pending < s->num_irq);if (s->vectpending_is_s_banked) { vec = &s->sec_vectors[pending]; - targets_secure = true; }else { vec = &s->vectors[pending]; - targets_secure = !exc_is_banked (s->vectpending) && -exc_targets_secure (s, s->vectpending); }assert (vec->enabled);
@@ -675,7 +671,7 @@ bool armv7m_nvic_acknowledge_irq(void *opaque)assert (s->vectpending_prio < running); -trace_nvic_acknowledge_irq (pending, s->vectpending_prio, targets_secure); +trace_nvic_acknowledge_irq (pending, s->vectpending_prio); vec->active =1 ; vec->pending =0 ;
@@ -683,8 +679,28 @@ bool armv7m_nvic_acknowledge_irq(void *opaque)write_v7m_exception (env, s->vectpending);nvic_irq_update (s); +} + +void armv7m_nvic_get_pending_irq_info (void *opaque, +int *pirq,bool *ptargets_secure) +{ +NVICState *s = (NVICState *)opaque; +const int pending = s->vectpending; +bool targets_secure; + +assert (pending >ARMV7M_EXCP_RESET && pending < s->num_irq); + +if (s->vectpending_is_s_banked) { + targets_secure = true; + }else { + targets_secure = !exc_is_banked (pending) && +exc_targets_secure (s, pending); + } + +trace_nvic_get_pending_irq_info (pending, targets_secure); -return targets_secure; + *ptargets_secure = targets_secure; + *pirq = pending; }int armv7m_nvic_complete_irq (void *opaque,int irq,bool secure)
target/arm/helper.c +12 -4
@@ -6395,12 +6395,12 @@ static uint32_t *get_v7m_sp_ptr(CPUARMState *env, bool secure, bool threadmode, } } -static uint32_t arm_v7m_load_vector (ARMCPU *cpu,bool targets_secure) +static uint32_t arm_v7m_load_vector (ARMCPU *cpu,int exc,bool targets_secure) {CPUState *cs =CPU (cpu);CPUARMState *env = &cpu->env;MemTxResult result; -hwaddr vec = env->v7m.vecbase[targets_secure] + env->v7m.exception *4 ; +hwaddr vec = env->v7m.vecbase[targets_secure] + exc *4 ;uint32_t addr; addr = address_space_ldl(cs->as, vec,
@@ -6462,8 +6462,9 @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain)CPUARMState *env = &cpu->env;uint32_t addr;bool targets_secure; +int exc; - targets_secure =armv7m_nvic_acknowledge_irq (env->nvic); +armv7m_nvic_get_pending_irq_info (env->nvic, &exc, &targets_secure);if (arm_feature (env,ARM_FEATURE_V8 )) { if (arm_feature(env, ARM_FEATURE_M_SECURITY) &&
@@ -6531,6 +6532,14 @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain) } } + addr =arm_v7m_load_vector (cpu, exc, targets_secure); + +/* Now we've done everything that might cause a derived exception +* we can go ahead and activate whichever exception we're going to +* take (which might now be the derived exception). +*/ +armv7m_nvic_acknowledge_irq (env->nvic); +/* Switch to target security state -- must do this before writing SPSEL */ switch_v7m_security_state (env, targets_secure);write_v7m_control_spsel (env,0 );
@@ -6538,7 +6547,6 @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain)/* Clear IT bits */ env->condexec_bits =0 ; env->regs[14 ] = lr; - addr =arm_v7m_load_vector (cpu, targets_secure); env->regs[15 ] = addr &0xfffffffe ; env->thumb = addr &1 ; }
hw/intc/trace-events +2 -1
@@ -180,7 +180,8 @@ nvic_escalate_disabled(int irq) "NVIC escalating irq %d to HardFault: disabled" nvic_set_pending(int irq, bool secure, bool derived, int en, int prio) "NVIC set pending irq %d secure-bank %d derived %d (enabled: %d priority %d)" nvic_clear_pending(int irq, bool secure, int en, int prio) "NVIC clear pending irq %d secure-bank %d (enabled: %d priority %d)" nvic_set_pending_level(int irq) "NVIC set pending: irq %d higher prio than vectpending: setting irq line to 1" -nvic_acknowledge_irq(int irq, int prio, bool targets_secure) "NVIC acknowledge IRQ: %d now active (prio %d targets_secure %d)" +nvic_acknowledge_irq(int irq, int prio) "NVIC acknowledge IRQ: %d now active (prio %d)" +nvic_get_pending_irq_info(int irq, bool secure) "NVIC next IRQ %d: targets_secure: %d" nvic_complete_irq(int irq, bool secure) "NVIC complete IRQ %d (secure %d)" nvic_set_irq_level(int irq, int level) "NVIC external irq %d level set to %d" nvic_sysreg_read(uint64_t addr, uint32_t value, unsigned size) "NVIC sysreg read addr 0x%" PRIx64 " data 0x%" PRIx32 " size %u"
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 12/30] target/arm: enable user-mode SHA-3, SM3, SM4 and SHA-512 instruction support
In reply to Peter MaydellFrom: Ard Biesheuvel <[email protected]>
Add support for the new ARMv8.2 SHA-3, SM3, SM4 and SHA-512 instructions to AArch64 user mode emulation.
Message-id: [email protected]
--- linux-user/elfload.c | 19 +++++++++++++++++++ target/arm/cpu64.c | 4 ++++ 2 files changed, 23 insertions(+)
linux-user/elfload.c +19 -0
@@ -512,6 +512,21 @@ enum {ARM_HWCAP_A64_SHA1 =1 <<5 ,ARM_HWCAP_A64_SHA2 =1 <<6 ,ARM_HWCAP_A64_CRC32 =1 <<7 , +ARM_HWCAP_A64_ATOMICS =1 <<8 , +ARM_HWCAP_A64_FPHP =1 <<9 , +ARM_HWCAP_A64_ASIMDHP =1 <<10 , +ARM_HWCAP_A64_CPUID =1 <<11 , +ARM_HWCAP_A64_ASIMDRDM =1 <<12 , +ARM_HWCAP_A64_JSCVT =1 <<13 , +ARM_HWCAP_A64_FCMA =1 <<14 , +ARM_HWCAP_A64_LRCPC =1 <<15 , +ARM_HWCAP_A64_DCPOP =1 <<16 , +ARM_HWCAP_A64_SHA3 =1 <<17 , +ARM_HWCAP_A64_SM3 =1 <<18 , +ARM_HWCAP_A64_SM4 =1 <<19 , +ARM_HWCAP_A64_ASIMDDP =1 <<20 , +ARM_HWCAP_A64_SHA512 =1 <<21 , + ARM_HWCAP_A64_SVE = 1 << 22, };#define ELF_HWCAP get_elf_hwcap()
@@ -532,6 +547,10 @@ static uint32_t get_elf_hwcap(void)GET_FEATURE (ARM_FEATURE_V8_SHA1 ,ARM_HWCAP_A64_SHA1 );GET_FEATURE (ARM_FEATURE_V8_SHA256 ,ARM_HWCAP_A64_SHA2 );GET_FEATURE (ARM_FEATURE_CRC ,ARM_HWCAP_A64_CRC32 ); +GET_FEATURE (ARM_FEATURE_V8_SHA3 ,ARM_HWCAP_A64_SHA3 ); +GET_FEATURE (ARM_FEATURE_V8_SM3 ,ARM_HWCAP_A64_SM3 ); +GET_FEATURE (ARM_FEATURE_V8_SM4 ,ARM_HWCAP_A64_SM4 ); +GET_FEATURE (ARM_FEATURE_V8_SHA512 ,ARM_HWCAP_A64_SHA512 );#undef GET_FEATUREreturn hwcaps;
target/arm/cpu64.c +4 -0
@@ -224,6 +224,10 @@ static void aarch64_any_initfn(Object *obj)set_feature (&cpu->env,ARM_FEATURE_V8_AES );set_feature (&cpu->env,ARM_FEATURE_V8_SHA1 );set_feature (&cpu->env,ARM_FEATURE_V8_SHA256 ); +set_feature (&cpu->env,ARM_FEATURE_V8_SHA512 ); +set_feature (&cpu->env,ARM_FEATURE_V8_SHA3 ); +set_feature (&cpu->env,ARM_FEATURE_V8_SM3 ); +set_feature (&cpu->env,ARM_FEATURE_V8_SM4 );set_feature (&cpu->env,ARM_FEATURE_V8_PMULL );set_feature (&cpu->env,ARM_FEATURE_CRC ); cpu->ctr =0x80038003 ;/* 32 byte I and D cacheline size, VIPT icache */
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 17/30] i.MX: Add code to emulate i.MX7 SNVS IP-block
In reply to Peter MaydellFrom: Andrey Smirnov <[email protected]>
Add code to emulate SNVS IP-block. Currently only the bits needed to be able to emulate machine shutdown are implemented.
--- hw/misc/Makefile.objs | 1 + include/hw/misc/imx7_snvs.h | 35 +++++++++++++++++++ hw/misc/imx7_snvs.c | 83 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 include/hw/misc/imx7_snvs.h create mode 100644 hw/misc/imx7_snvs.c
hw/misc/Makefile.objs +1 -0
@@ -35,6 +35,7 @@ obj-$(CONFIG_IMX) += imx6_ccm.o obj-$(CONFIG_IMX) += imx6_src.o obj-$(CONFIG_IMX) += imx7_ccm.o obj-$(CONFIG_IMX) += imx2_wdt.o +obj-$(CONFIG_IMX) += imx7_snvs.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.o
include/hw/misc/imx7_snvs.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* Copyright (c) 2017, Impinj, Inc. +* +* i.MX7 SNVS block emulation code +* +* Author: Andrey Smirnov <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef IMX7_SNVS_H +#define IMX7_SNVS_H + +#include "qemu/bitops.h" +#include "hw/sysbus.h" + + +enum IMX7SNVSRegisters { +SNVS_LPCR =0x38 , +SNVS_LPCR_TOP =BIT (6 ), +SNVS_LPCR_DP_EN =BIT (5 ) +}; + +#define TYPE_IMX7_SNVS "imx7.snvs" +#define IMX7_SNVS (obj) OBJECT_CHECK(IMX7SNVSState, (obj), TYPE_IMX7_SNVS) + +typedef struct IMX7SNVSState { +/* <private> */ +SysBusDevice parent_obj; + +MemoryRegion mmio; +}IMX7SNVSState ; + +#endif /* IMX7_SNVS_H */
hw/misc/imx7_snvs.c new file +83 -0
83 lines not on this page · raw message
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 25/30] target/arm: Add SVE to migration state
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Save the high parts of the Zregs and all of the Pregs. The ZCR_ELx registers are migrated via the CP mechanism.
Message-id: [email protected]
--- target/arm/machine.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)
target/arm/machine.c +53 -0
@@ -122,6 +122,56 @@ static const VMStateDescription vmstate_iwmmxt = { } }; +#ifdef TARGET_AARCH64 +/* The expression ARM_MAX_VQ - 2 is 0 for pure AArch32 build, +* and ARMPredicateReg is actively empty. This triggers errors +* in the expansion of the VMSTATE macros. +*/ + +static bool sve_needed (void *opaque) +{ +ARMCPU *cpu = opaque; +CPUARMState *env = &cpu->env; + +return arm_feature (env,ARM_FEATURE_SVE ); +} + +/* The first two words of each Zreg is stored in VFP state. */ +static const VMStateDescription vmstate_zreg_hi_reg = { + .name ="cpu/sve/zreg_hi" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINT64_SUB_ARRAY (d, ARMVectorReg,2 ,ARM_MAX_VQ -2 ), +VMSTATE_END_OF_LIST () + } +}; + +static const VMStateDescription vmstate_preg_reg = { + .name ="cpu/sve/preg" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINT64_ARRAY (p, ARMPredicateReg,2 *ARM_MAX_VQ /8 ), +VMSTATE_END_OF_LIST () + } +}; + +static const VMStateDescription vmstate_sve = { + .name ="cpu/sve" , + .version_id =1 , + .minimum_version_id =1 , + .needed = sve_needed, + .fields = (VMStateField []) { +VMSTATE_STRUCT_ARRAY (env.vfp.zregs,ARMCPU ,32 ,0 , + vmstate_zreg_hi_reg, ARMVectorReg), +VMSTATE_STRUCT_ARRAY (env.vfp.pregs,ARMCPU ,17 ,0 , + vmstate_preg_reg, ARMPredicateReg), +VMSTATE_END_OF_LIST () + } +}; +#endif /* AARCH64 */ +static bool m_needed (void *opaque) {ARMCPU *cpu = opaque;
@@ -586,6 +636,9 @@ const VMStateDescription vmstate_arm_cpu = { &vmstate_pmsav7, &vmstate_pmsav8, &vmstate_m_security, +#ifdef TARGET_AARCH64 + &vmstate_sve, +#endif NULL } };
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 06/30] target/arm: Make exception vector loads honour the SAU
In reply to Peter MaydellMake the load of the exception vector from the vector table honour the SAU and any bus error on the load (possibly provoking a derived exception), rather than simply aborting if the load fails.
Message-id: [email protected]
--- target/arm/helper.c | 71 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 16 deletions(-)
target/arm/helper.c +55 -16
@@ -6449,28 +6449,63 @@ static uint32_t *get_v7m_sp_ptr(CPUARMState *env, bool secure, bool threadmode, } } -static uint32_t arm_v7m_load_vector (ARMCPU *cpu,int exc,bool targets_secure) +static bool arm_v7m_load_vector (ARMCPU *cpu,int exc,bool targets_secure, +uint32_t *pvec) {CPUState *cs =CPU (cpu);CPUARMState *env = &cpu->env;MemTxResult result; -hwaddr vec = env->v7m.vecbase[targets_secure] + exc *4 ; -uint32_t addr; +uint32_t addr = env->v7m.vecbase[targets_secure] + exc *4 ; +uint32_t vector_entry; +MemTxAttrs attrs = {}; +ARMMMUIdx mmu_idx; +bool exc_secure; + + mmu_idx =arm_v7m_mmu_idx_for_secstate_and_priv (env, targets_secure, true); - addr =address_space_ldl (cs->as, vec, -MEMTXATTRS_UNSPECIFIED , &result); +/* We don't do a get_phys_addr() here because the rules for vector +* loads are special: they always use the default memory map, and +* the default memory map permits reads from all addresses. +* Since there's no easy way to pass through to pmsav8_mpu_lookup() +* that we want this special case which would always say "yes", +* we just do the SAU lookup here followed by a direct physical load. +*/ + attrs.secure = targets_secure; + attrs.user = false; + +if (arm_feature (env,ARM_FEATURE_M_SECURITY )) { +V8M_SAttributes sattrs = {}; + +v8m_security_lookup (env, addr,MMU_DATA_LOAD , mmu_idx, &sattrs); +if (sattrs.ns) { + attrs.secure = false; + }else if (!targets_secure) { +/* NS access to S memory */ + goto load_fail; + } + } + + vector_entry =address_space_ldl (arm_addressspace (cs, attrs), addr, + attrs, &result);if (result !=MEMTX_OK ) { -/* Architecturally this should cause a HardFault setting HSFR.VECTTBL, -* which would then be immediately followed by our failing to load -* the entry vector for that HardFault, which is a Lockup case. -* Since we don't model Lockup, we just report this guest error -* via cpu_abort(). -*/ -cpu_abort (cs,"Failed to read from %s exception vector table " -"entry %08x\n" , targets_secure ?"secure" :"nonsecure" , - (unsigned )vec); + goto load_fail; } -return addr; + *pvec = vector_entry; +return true; + +load_fail: +/* All vector table fetch fails are reported as HardFault, with +* HFSR.VECTTBL and .FORCED set. (FORCED is set because +* technically the underlying exception is a MemManage or BusFault +* that is escalated to HardFault.) This is a terminal exception, +* so we will either take the HardFault immediately or else enter +* lockup (the latter case is handled in armv7m_nvic_set_pending_derived()). +*/ + exc_secure = targets_secure || + !(cpu->env.v7m.aircr &R_V7M_AIRCR_BFHFNMINS_MASK ); + env->v7m.hfsr |=R_V7M_HFSR_VECTTBL_MASK |R_V7M_HFSR_FORCED_MASK ; +armv7m_nvic_set_pending_derived (env->nvic,ARMV7M_EXCP_HARD , exc_secure); +return false; } static bool v7m_push_callee_stack(ARMCPU *cpu, uint32_t lr, bool dotailchain,
@@ -6623,7 +6658,11 @@ static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr, bool dotailchain,return ; } - addr =arm_v7m_load_vector (cpu, exc, targets_secure); +if (!arm_v7m_load_vector (cpu, exc, targets_secure, &addr)) { +/* Vector load failed: derived exception */ +v7m_exception_taken (cpu, lr, true, true); +return ; + }/* Now we've done everything that might cause a derived exception * we can go ahead and activate whichever exception we're going to
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 09/30] target/arm: implement SHA-3 instructions
In reply to Peter MaydellFrom: Ard Biesheuvel <[email protected]>
This implements emulation of the new SHA-3 instructions that have been added as an optional extensions to the ARMv8 Crypto Extensions in ARM v8.2.
Message-id: [email protected]
--- target/arm/cpu.h | 1 + target/arm/translate-a64.c | 148 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 145 insertions(+), 4 deletions(-)
target/arm/cpu.h +1 -0
@@ -1342,6 +1342,7 @@ enum arm_features {ARM_FEATURE_JAZELLE ,/* has (trivial) Jazelle implementation */ ARM_FEATURE_SVE ,/* has Scalable Vector Extension */ ARM_FEATURE_V8_SHA512 ,/* implements SHA512 part of v8 Crypto Extensions */ + ARM_FEATURE_V8_SHA3, /* implements SHA3 part of v8 Crypto Extensions */ };static inline int arm_feature (CPUARMState *env,int feature)
target/arm/translate-a64.c +144 -4
172 lines not on this page · raw message
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 24/30] target/arm: Add predicate registers for SVE
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Message-id: [email protected]
--- target/arm/cpu.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
target/arm/cpu.h +12 -0
@@ -188,6 +188,13 @@ typedef struct ARMVectorReg { uint64_t d[2 * ARM_MAX_VQ] QEMU_ALIGNED(16); } ARMVectorReg; +/* In AArch32 mode, predicate registers do not exist at all. */ +#ifdef TARGET_AARCH64 +typedef struct ARMPredicateReg { + uint64_t p[2 * ARM_MAX_VQ / 8] QEMU_ALIGNED(16); +}ARMPredicateReg ; +#endif + typedef struct CPUARMState { /* Regs for current mode. */
@@ -515,6 +522,11 @@ typedef struct CPUARMState {struct {ARMVectorReg zregs[32 ]; +#ifdef TARGET_AARCH64 +/* Store FFR as pregs[16] to make it easier to treat as any other. */ +ARMPredicateReg pregs[17 ]; +#endif +uint32_t xregs[16 ];/* We store these fpcsr fields separately for convenience. */ int vec_len;
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 04/30] target/arm: Make v7M exception entry stack push check MPU
In reply to Peter MaydellThe memory writes done to push registers on the stack on exception entry in M profile CPUs are supposed to go via MPU permissions checks, which may cause us to take a derived exception instead of the original one of the MPU lookup fails. We were implementing these as always-succeeds direct writes to physical memory. Rewrite v7m_push_stack() to do the necessary checks.
Message-id: [email protected]
--- target/arm/helper.c | 103 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 87 insertions(+), 16 deletions(-)
target/arm/helper.c +87 -16
@@ -6161,12 +6161,66 @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,return target_el; } -static void v7m_push (CPUARMState *env,uint32_t val) +static bool v7m_stack_write (ARMCPU *cpu,uint32_t addr,uint32_t value, +ARMMMUIdx mmu_idx,bool ignfault) { -CPUState *cs =CPU (arm_env_get_cpu (env)); +CPUState *cs =CPU (cpu); +CPUARMState *env = &cpu->env; +MemTxAttrs attrs = {}; +MemTxResult txres; +target_ulong page_size; +hwaddr physaddr; +int prot; +ARMMMUFaultInfo fi; +bool secure = mmu_idx &ARM_MMU_IDX_M_S ; +int exc; +bool exc_secure; - env->regs[13 ] -=4 ; -stl_phys (cs->as, env->regs[13 ], val); +if (get_phys_addr (env, addr,MMU_DATA_STORE , mmu_idx, &physaddr, + &attrs, &prot, &page_size, &fi,NULL )) { +/* MPU/SAU lookup failed */ +if (fi.type == ARMFault_QEMU_SFault) { +qemu_log_mask (CPU_LOG_INT , +"...SecureFault with SFSR.AUVIOL during stacking\n" ); + env->v7m.sfsr |=R_V7M_SFSR_AUVIOL_MASK |R_V7M_SFSR_SFARVALID_MASK ; + env->v7m.sfar = addr; + exc =ARMV7M_EXCP_SECURE ; + exc_secure = false; + }else { +qemu_log_mask (CPU_LOG_INT ,"...MemManageFault with CFSR.MSTKERR\n" ); + env->v7m.cfsr[secure] |=R_V7M_CFSR_MSTKERR_MASK ; + exc =ARMV7M_EXCP_MEM ; + exc_secure = secure; + } + goto pend_fault; + } +address_space_stl_le (arm_addressspace (cs, attrs), physaddr, value, + attrs, &txres); +if (txres !=MEMTX_OK ) { +/* BusFault trying to write the data */ +qemu_log_mask (CPU_LOG_INT ,"...BusFault with BFSR.STKERR\n" ); + env->v7m.cfsr[M_REG_NS ] |=R_V7M_CFSR_STKERR_MASK ; + exc =ARMV7M_EXCP_BUS ; + exc_secure = false; + goto pend_fault; + } +return true; + +pend_fault: +/* By pending the exception at this point we are making +* the IMPDEF choice "overridden exceptions pended" (see the +* MergeExcInfo() pseudocode). The other choice would be to not +* pend them now and then make a choice about which to throw away +* later if we have two derived exceptions. +* The only case when we must not pend the exception but instead +* throw it away is if we are doing the push of the callee registers +* and we've already generated a derived exception. Even in this +* case we will still update the fault status registers. +*/ +if (!ignfault) { +armv7m_nvic_set_pending_derived (env->nvic, exc, exc_secure); + } +return false; }/* Return true if we're using the process stack pointer (not the MSP) */
@@ -6562,26 +6616,43 @@ static bool v7m_push_stack(ARMCPU *cpu)* should ignore further stack faults trying to process * that derived exception.) */ +bool stacked_ok;CPUARMState *env = &cpu->env;uint32_t xpsr =xpsr_read (env); +uint32_t frameptr = env->regs[13 ]; +ARMMMUIdx mmu_idx =core_to_arm_mmu_idx (env,cpu_mmu_index (env, false));/* Align stack pointer if the guest wants that */ -if ((env->regs[13 ] &4 ) && +if ((frameptr &4 ) && (env->v7m.ccr[env->v7m.secure] &R_V7M_CCR_STKALIGN_MASK )) { - env->regs[13 ] -=4 ; + frameptr -=4 ; xpsr |=XPSR_SPREALIGN ; } -/* Switch to the handler mode. */ -v7m_push (env, xpsr); -v7m_push (env, env->regs[15 ]); -v7m_push (env, env->regs[14 ]); -v7m_push (env, env->regs[12 ]); -v7m_push (env, env->regs[3 ]); -v7m_push (env, env->regs[2 ]); -v7m_push (env, env->regs[1 ]); -v7m_push (env, env->regs[0 ]); -return false; + frameptr -=0x20 ; + +/* Write as much of the stack frame as we can. If we fail a stack +* write this will result in a derived exception being pended +* (which may be taken in preference to the one we started with +* if it has higher priority). +*/ + stacked_ok = +v7m_stack_write (cpu, frameptr, env->regs[0 ], mmu_idx, false) && +v7m_stack_write (cpu, frameptr +4 , env->regs[1 ], mmu_idx, false) && +v7m_stack_write (cpu, frameptr +8 , env->regs[2 ], mmu_idx, false) && +v7m_stack_write (cpu, frameptr +12 , env->regs[3 ], mmu_idx, false) && +v7m_stack_write (cpu, frameptr +16 , env->regs[12 ], mmu_idx, false) && +v7m_stack_write (cpu, frameptr +20 , env->regs[14 ], mmu_idx, false) && +v7m_stack_write (cpu, frameptr +24 , env->regs[15 ], mmu_idx, false) && +v7m_stack_write (cpu, frameptr +28 , xpsr, mmu_idx, false); + +/* Update SP regardless of whether any of the stack accesses failed. +* When we implement v8M stack limit checking then this attempt to +* update SP might also fail and result in a derived exception. +*/ + env->regs[13 ] = frameptr; + +return !stacked_ok; }static void do_v7m_exception_exit (ARMCPU *cpu)
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 20/30] i.MX: Add implementation of i.MX7 GPR IP block
In reply to Peter MaydellFrom: Andrey Smirnov <[email protected]>
Add minimal code needed to allow upstream Linux guest to boot.
--- hw/misc/Makefile.objs | 1 + include/hw/misc/imx7_gpr.h | 28 ++++++++++ hw/misc/imx7_gpr.c | 124 +++++++++++++++++++++++++++++++++++++++++++++ hw/misc/trace-events | 4 ++ 4 files changed, 157 insertions(+) create mode 100644 include/hw/misc/imx7_gpr.h create mode 100644 hw/misc/imx7_gpr.c
hw/misc/Makefile.objs +1 -0
@@ -36,6 +36,7 @@ obj-$(CONFIG_IMX) += imx6_src.o obj-$(CONFIG_IMX) += imx7_ccm.o obj-$(CONFIG_IMX) += imx2_wdt.o obj-$(CONFIG_IMX) += imx7_snvs.o +obj-$(CONFIG_IMX) += imx7_gpr.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.o
include/hw/misc/imx7_gpr.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* Copyright (c) 2017, Impinj, Inc. +* +* i.MX7 GPR IP block emulation code +* +* Author: Andrey Smirnov <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef IMX7_GPR_H +#define IMX7_GPR_H + +#include "qemu/bitops.h" +#include "hw/sysbus.h" + +#define TYPE_IMX7_GPR "imx7.gpr" +#define IMX7_GPR (obj) OBJECT_CHECK(IMX7GPRState, (obj), TYPE_IMX7_GPR) + +typedef struct IMX7GPRState { +/* <private> */ +SysBusDevice parent_obj; + +MemoryRegion mmio; +}IMX7GPRState ; + +#endif /* IMX7_GPR_H */
hw/misc/imx7_gpr.c new file +124 -0
124 lines not on this page · raw message
hw/misc/trace-events +4 -0
@@ -66,3 +66,7 @@ mps2_scc_cfg_read(unsigned function, unsigned device, uint32_t value) "MPS2 SCC msf2_sysreg_write(uint64_t offset, uint32_t val, uint32_t prev) "msf2-sysreg write: addr 0x%08" HWADDR_PRIx " data 0x%" PRIx32 " prev 0x%" PRIx32 msf2_sysreg_read(uint64_t offset, uint32_t val) "msf2-sysreg read: addr 0x%08" HWADDR_PRIx " data 0x%08" PRIx32 msf2_sysreg_write_pll_status(void) "Invalid write to read only PLL status register" + +#hw/misc/imx7_gpr.c +imx7_gpr_read(uint64_t offset) "addr 0x%08" HWADDR_PRIx +imx7_gpr_write(uint64_t offset, uint64_t value) "addr 0x%08" HWADDR_PRIx "value 0x%08" HWADDR_PRIx
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 29/30] target/arm/translate.c: Fix missing 'break' for TT insns
In reply to Peter MaydellThe code where we added the TT instruction was accidentally missing a 'break', which meant that after generating the code to execute the TT we would fall through to 'goto illegal_op' and generate code to take an UNDEF insn.
Message-id: [email protected]
--- target/arm/translate.c | 1 + 1 file changed, 1 insertion(+)
target/arm/translate.c +1 -0
@@ -9925,6 +9925,7 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn)tcg_temp_free_i32 (addr);tcg_temp_free_i32 (op);store_reg (s, rd, ttresp); +break ; } goto illegal_op; }
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 22/30] hw/arm: Move virt's PSCI DT fixup code to arm/boot.c
In reply to Peter MaydellFrom: Andrey Smirnov <[email protected]>
Move virt's PSCI DT fixup code to arm/boot.c and set this fixup to happen automatically for every board that doesn't mark "psci-conduit" as disabled. This way emulated boards other than "virt" that rely on PSIC for SMP could benefit from that code.
--- hw/arm/boot.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/arm/virt.c | 61 ------------------------------------------------------- 2 files changed, 65 insertions(+), 61 deletions(-)
hw/arm/boot.c +65 -0
@@ -385,6 +385,69 @@ static void set_kernel_args_old(const struct arm_boot_info *info) } } +static void fdt_add_psci_node (void *fdt) +{ +uint32_t cpu_suspend_fn; +uint32_t cpu_off_fn; +uint32_t cpu_on_fn; +uint32_t migrate_fn; +ARMCPU *armcpu =ARM_CPU (qemu_get_cpu (0 )); +const char *psci_method; +int64_t psci_conduit; + + psci_conduit =object_property_get_int (OBJECT (armcpu), +"psci-conduit" , + &error_abort); +switch (psci_conduit) { +case QEMU_PSCI_CONDUIT_DISABLED : +return ; +case QEMU_PSCI_CONDUIT_HVC : + psci_method ="hvc" ; +break ; +case QEMU_PSCI_CONDUIT_SMC : + psci_method ="smc" ; +break ; +default : +g_assert_not_reached (); + } + +qemu_fdt_add_subnode (fdt,"/psci" ); +if (armcpu->psci_version ==2 ) { +const char comp[] ="arm,psci-0.2\0arm,psci" ; +qemu_fdt_setprop (fdt,"/psci" ,"compatible" , comp,sizeof (comp)); + + cpu_off_fn =QEMU_PSCI_0_2_FN_CPU_OFF ; +if (arm_feature (&armcpu->env,ARM_FEATURE_AARCH64 )) { + cpu_suspend_fn =QEMU_PSCI_0_2_FN64_CPU_SUSPEND ; + cpu_on_fn =QEMU_PSCI_0_2_FN64_CPU_ON ; + migrate_fn =QEMU_PSCI_0_2_FN64_MIGRATE ; + }else { + cpu_suspend_fn =QEMU_PSCI_0_2_FN_CPU_SUSPEND ; + cpu_on_fn =QEMU_PSCI_0_2_FN_CPU_ON ; + migrate_fn =QEMU_PSCI_0_2_FN_MIGRATE ; + } + }else { +qemu_fdt_setprop_string (fdt,"/psci" ,"compatible" ,"arm,psci" ); + + cpu_suspend_fn =QEMU_PSCI_0_1_FN_CPU_SUSPEND ; + cpu_off_fn =QEMU_PSCI_0_1_FN_CPU_OFF ; + cpu_on_fn =QEMU_PSCI_0_1_FN_CPU_ON ; + migrate_fn =QEMU_PSCI_0_1_FN_MIGRATE ; + } + +/* We adopt the PSCI spec's nomenclature, and use 'conduit' to refer +* to the instruction that should be used to invoke PSCI functions. +* However, the device tree binding uses 'method' instead, so that is +* what we should use here. +*/ +qemu_fdt_setprop_string (fdt,"/psci" ,"method" , psci_method); + +qemu_fdt_setprop_cell (fdt,"/psci" ,"cpu_suspend" , cpu_suspend_fn); +qemu_fdt_setprop_cell (fdt,"/psci" ,"cpu_off" , cpu_off_fn); +qemu_fdt_setprop_cell (fdt,"/psci" ,"cpu_on" , cpu_on_fn); +qemu_fdt_setprop_cell (fdt,"/psci" ,"migrate" , migrate_fn); +} +/** * load_dtb() - load a device tree binary image into memory * @addr: the address to load the image at
@@ -541,6 +604,8 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo, } } +fdt_add_psci_node (fdt); +if (binfo->modify_dtb) { binfo->modify_dtb (binfo, fdt); }
hw/arm/virt.c +0 -61
73 lines not on this page · raw message
Signature · 1 line
2.16.1
Re: [Qemu-arm] [PULL, 22/30] hw/arm: Move virt's PSCI DT fixup code to arm/boot.c
On Fri, 09 Feb 2018 11:03:06 +0000,
Peter Maydell wrote:
Hi Peter, Andrey,
Quoted 100 lines
From: Andrey Smirnov <[email protected]>
Move virt's PSCI DT fixup code to
arm/boot.cand set this fixup to happen automatically for every board that doesn't mark "psci-conduit" as disabled. This way emulated boards other than "virt" that rely on PSIC for SMP could benefit from that code.Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Cc Marcel Apfelbaum <[email protected]>Cc Michael S. Tsirkin <[email protected]>Reviewed-by Peter Maydell <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Signed-off-by Peter Maydell <[email protected]>--- hw/arm/boot.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/arm/virt.c | 61 ------------------------------------------------------- 2 files changed, 65 insertions(+), 61 deletions(-)hw/arm/boot.c +63
-0@@ -385,6 +385,69 @@ static void set_kernel_args_old(const struct arm_boot_info *info) } } +static void fdt_add_psci_node (void *fdt) +{ +uint32_t cpu_suspend_fn; +uint32_t cpu_off_fn; +uint32_t cpu_on_fn; +uint32_t migrate_fn; +ARMCPU *armcpu =ARM_CPU (qemu_get_cpu (0 )); +const char *psci_method; +int64_t psci_conduit; + + psci_conduit =object_property_get_int (OBJECT (armcpu), +"psci-conduit" , + &error_abort); +switch (psci_conduit) { +case QEMU_PSCI_CONDUIT_DISABLED : +return ; +case QEMU_PSCI_CONDUIT_HVC : + psci_method ="hvc" ; +break ; +case QEMU_PSCI_CONDUIT_SMC : + psci_method ="smc" ; +break ; +default : +g_assert_not_reached (); + } + +qemu_fdt_add_subnode (fdt,"/psci" ); +if (armcpu->psci_version ==2 ) { +const char comp[] ="arm,psci-0.2\0arm,psci" ; +qemu_fdt_setprop (fdt,"/psci" ,"compatible" , comp,sizeof (comp)); + + cpu_off_fn =QEMU_PSCI_0_2_FN_CPU_OFF ; +if (arm_feature (&armcpu->env,ARM_FEATURE_AARCH64 )) { + cpu_suspend_fn =QEMU_PSCI_0_2_FN64_CPU_SUSPEND ; + cpu_on_fn =QEMU_PSCI_0_2_FN64_CPU_ON ; + migrate_fn =QEMU_PSCI_0_2_FN64_MIGRATE ; + }else { + cpu_suspend_fn =QEMU_PSCI_0_2_FN_CPU_SUSPEND ; + cpu_on_fn =QEMU_PSCI_0_2_FN_CPU_ON ; + migrate_fn =QEMU_PSCI_0_2_FN_MIGRATE ; + } + }else { +qemu_fdt_setprop_string (fdt,"/psci" ,"compatible" ,"arm,psci" ); + + cpu_suspend_fn =QEMU_PSCI_0_1_FN_CPU_SUSPEND ; + cpu_off_fn =QEMU_PSCI_0_1_FN_CPU_OFF ; + cpu_on_fn =QEMU_PSCI_0_1_FN_CPU_ON ; + migrate_fn =QEMU_PSCI_0_1_FN_MIGRATE ; + } + +/* We adopt the PSCI spec's nomenclature, and use 'conduit' to refer +* to the instruction that should be used to invoke PSCI functions. +* However, the device tree binding uses 'method' instead, so that is +* what we should use here. +*/ +qemu_fdt_setprop_string (fdt,"/psci" ,"method" , psci_method); + +qemu_fdt_setprop_cell (fdt,"/psci" ,"cpu_suspend" , cpu_suspend_fn); +qemu_fdt_setprop_cell (fdt,"/psci" ,"cpu_off" , cpu_off_fn); +qemu_fdt_setprop_cell (fdt,"/psci" ,"cpu_on" , cpu_on_fn); +qemu_fdt_setprop_cell (fdt,"/psci" ,"migrate" , migrate_fn); +} +/** * load_dtb() - load a device tree binary image into memory * @addr: the address to load the image at
hw/arm/boot.c static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo, · line 608
Quoted 5 lines
hw/arm/boot.c +2
-0@@ -541,6 +604,8 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo, } } +fdt_add_psci_node (fdt); +
This particular change broke one of my favourite use cases, which is to feed the guest with a hand-crafted DTB, and expect QEMU to just take it as granted, and not touch it.
I now get an error:
qemu-system-aarch64: FDT: Failed to create subnode /psci: FDT_ERR_EXISTS
The obvious workaround would be to test the presence of the /psci node before generating it (such as done for the /chosen node, for example).
Thanks,
M.
Signature · 1 line
Jazz is not dead, it just smell funny.
[Qemu-devel] [PULL 23/30] target/arm: Expand vector registers for SVE
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Change vfp.regs as a uint64_t to vfp.zregs as an ARMVectorReg. The previous patches have made the change in representation relatively painless.
Message-id: [email protected]
--- target/arm/cpu.h | 59 +++++++++++++++++++++++++++++++--------------- target/arm/machine.c | 35 ++++++++++++++++++++++++++- target/arm/translate-a64.c | 8 +++---- target/arm/translate.c | 7 +++--- 4 files changed, 81 insertions(+), 28 deletions(-)
target/arm/cpu.h +40 -19
@@ -153,6 +153,42 @@ typedef struct {uint32_t base_mask; }TCR ; +/* Define a maximum sized vector register. +* For 32-bit, this is a 128-bit NEON/AdvSIMD register. +* For 64-bit, this is a 2048-bit SVE register. +* +* Note that the mapping between S, D, and Q views of the register bank +* differs between AArch64 and AArch32. +* In AArch32: +* Qn = regs[n].d[1]:regs[n].d[0] +* Dn = regs[n / 2].d[n & 1] +* Sn = regs[n / 4].d[n % 4 / 2], +* bits 31..0 for even n, and bits 63..32 for odd n +* (and regs[16] to regs[31] are inaccessible) +* In AArch64: +* Zn = regs[n].d[*] +* Qn = regs[n].d[1]:regs[n].d[0] +* Dn = regs[n].d[0] +* Sn = regs[n].d[0] bits 31..0 +* +* This corresponds to the architecturally defined mapping between +* the two execution states, and means we do not need to explicitly +* map these registers when changing states. +* +* Align the data for use with TCG host vector operations. +*/ + +#ifdef TARGET_AARCH64 +# define ARM_MAX_VQ 16 +#else +# define ARM_MAX_VQ 1 +#endif + +typedef struct ARMVectorReg { + uint64_t d[2 * ARM_MAX_VQ] QEMU_ALIGNED(16); +}ARMVectorReg ; + + typedef struct CPUARMState { /* Regs for current mode. */ uint32_t regs[16];
@@ -477,22 +513,7 @@ typedef struct CPUARMState {/* VFP coprocessor state. */ struct { -/* VFP/Neon register state. Note that the mapping between S, D and Q -* views of the register bank differs between AArch64 and AArch32: -* In AArch32: -* Qn = regs[2n+1]:regs[2n] -* Dn = regs[n] -* Sn = regs[n/2] bits 31..0 for even n, and bits 63..32 for odd n -* (and regs[32] to regs[63] are inaccessible) -* In AArch64: -* Qn = regs[2n+1]:regs[2n] -* Dn = regs[2n] -* Sn = regs[2n] bits 31..0 -* This corresponds to the architecturally defined mapping between -* the two execution states, and means we do not need to explicitly -* map these registers when changing states. -*/ - uint64_t regs[64] QEMU_ALIGNED(16); +ARMVectorReg zregs[32 ];uint32_t xregs[16 ];/* We store these fpcsr fields separately for convenience. */
@@ -2799,7 +2820,7 @@ static inline void *arm_get_el_change_hook_opaque(ARMCPU *cpu)*/ static inline uint64_t *aa32_vfp_dreg (CPUARMState *env,unsigned regno) { -return &env->vfp.regs[regno]; +return &env->vfp.zregs[regno >>1 ].d[regno &1 ]; }/**
@@ -2808,7 +2829,7 @@ static inline uint64_t *aa32_vfp_dreg(CPUARMState *env, unsigned regno)*/ static inline uint64_t *aa32_vfp_qreg (CPUARMState *env,unsigned regno) { -return &env->vfp.regs[2 * regno]; +return &env->vfp.zregs[regno].d[0 ]; }/**
@@ -2817,7 +2838,7 @@ static inline uint64_t *aa32_vfp_qreg(CPUARMState *env, unsigned regno)*/ static inline uint64_t *aa64_vfp_qreg (CPUARMState *env,unsigned regno) { -return &env->vfp.regs[2 * regno]; +return &env->vfp.zregs[regno].d[0 ]; }#endif
target/arm/machine.c +34 -1
@@ -50,7 +50,40 @@ static const VMStateDescription vmstate_vfp = { .minimum_version_id = 3, .needed = vfp_needed, .fields = (VMStateField []) { -VMSTATE_UINT64_ARRAY (env.vfp.regs,ARMCPU ,64 ), +/* For compatibility, store Qn out of Zn here. */ +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[0 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[1 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[2 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[3 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[4 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[5 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[6 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[7 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[8 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[9 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[10 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[11 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[12 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[13 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[14 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[15 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[16 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[17 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[18 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[19 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[20 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[21 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[22 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[23 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[24 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[25 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[26 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[27 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[28 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[29 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[30 ].d,ARMCPU ,0 ,2 ), +VMSTATE_UINT64_SUB_ARRAY (env.vfp.zregs[31 ].d,ARMCPU ,0 ,2 ), +/* The xregs array is a little awkward because element 1 (FPSCR) * requires a specific accessor, so we have to split it up in * the vmstate:
target/arm/translate-a64.c +4 -4
@@ -525,8 +525,8 @@ static inline int vec_reg_offset(DisasContext *s, int regno, {int offs =0 ;#ifdef HOST_WORDS_BIGENDIAN -/* This is complicated slightly because vfp.regs[2n] is -* still the low half and vfp.regs[2n+1] the high half +/* This is complicated slightly because vfp.zregs[n].d[0] is +* still the low half and vfp.zregs[n].d[1] the high half * of the 128 bit vector, even on big endian systems. * Calculate the offset assuming a fully bigendian 128 bits, * then XOR to account for the order of the two 64 bit halves.
@@ -536,7 +536,7 @@ static inline int vec_reg_offset(DisasContext *s, int regno,#else offs += element * (1 << size);#endif - offs += offsetof(CPUARMState, vfp.regs[regno * 2]); + offs += offsetof(CPUARMState, vfp.zregs[regno]);assert_fp_access_checked (s);return offs; }
@@ -545,7 +545,7 @@ static inline int vec_reg_offset(DisasContext *s, int regno,static inline int vec_full_reg_offset (DisasContext *s,int regno) {assert_fp_access_checked (s); - return offsetof(CPUARMState, vfp.regs[regno * 2]); + return offsetof(CPUARMState, vfp.zregs[regno]); }/* Return a newly allocated pointer to the vector register. */
target/arm/translate.c +3 -4
@@ -1512,13 +1512,12 @@ static inline void gen_vfp_st(DisasContext *s, int dp, TCGv_i32 addr) } } -static inline long -vfp_reg_offset (int dp,int reg) +static inline long vfp_reg_offset (bool dp,unsigned reg) {if (dp) { - return offsetof(CPUARMState, vfp.regs[reg]); + return offsetof(CPUARMState, vfp.zregs[reg >> 1].d[reg & 1]); }else { - long ofs = offsetof(CPUARMState, vfp.regs[reg >> 1]); + long ofs = offsetof(CPUARMState, vfp.zregs[reg >> 2].d[(reg >> 1) & 1]);if (reg &1 ) { ofs += offsetof(CPU_DoubleU, l.upper); }else {
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 26/30] target/arm: Add ZCR_ELx
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Define ZCR_EL[1-3].
Message-id: [email protected]
--- target/arm/cpu.h | 5 ++ target/arm/helper.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+)
target/arm/cpu.h +5 -0
@@ -549,6 +549,9 @@ typedef struct CPUARMState {*/ float_status fp_status;float_status standard_fp_status; + +/* ZCR_EL[1-3] */ +uint64_t zcr_el[4 ]; } vfp;uint64_t exclusive_addr;uint64_t exclusive_val;
@@ -923,6 +926,8 @@ void pmccntr_sync(CPUARMState *env);#define CPTR_TCPAC (1U << 31)#define CPTR_TTA (1U << 20)#define CPTR_TFP (1U << 10) +#define CPTR_TZ (1U << 8)/* CPTR_EL2 */ +#define CPTR_EZ (1U << 8)/* CPTR_EL3 */ #define MDCR_EPMAD (1U << 21)#define MDCR_EDAD (1U << 20)
target/arm/helper.c +131 -0
143 lines not on this page · raw message
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 16/30] i.MX: Add code to emulate i.MX2 watchdog IP block
In reply to Peter MaydellFrom: Andrey Smirnov <[email protected]>
Add enough code to emulate i.MX2 watchdog IP block so it would be possible to reboot the machine running Linux Guest.
--- hw/misc/Makefile.objs | 1 + include/hw/misc/imx2_wdt.h | 33 +++++++++++++++++ hw/misc/imx2_wdt.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 include/hw/misc/imx2_wdt.h create mode 100644 hw/misc/imx2_wdt.c
hw/misc/Makefile.objs +1 -0
@@ -34,6 +34,7 @@ obj-$(CONFIG_IMX) += imx25_ccm.o obj-$(CONFIG_IMX) += imx6_ccm.o obj-$(CONFIG_IMX) += imx6_src.o obj-$(CONFIG_IMX) += imx7_ccm.o +obj-$(CONFIG_IMX) += imx2_wdt.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.o
include/hw/misc/imx2_wdt.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* Copyright (c) 2017, Impinj, Inc. +* +* i.MX2 Watchdog IP block +* +* Author: Andrey Smirnov <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +*/ + +#ifndef IMX2_WDT_H +#define IMX2_WDT_H + +#include "hw/sysbus.h" + +#define TYPE_IMX2_WDT "imx2.wdt" +#define IMX2_WDT (obj) OBJECT_CHECK(IMX2WdtState, (obj), TYPE_IMX2_WDT) + +enum IMX2WdtRegisters { +IMX2_WDT_WCR =0x0000 , +IMX2_WDT_REG_NUM =0x0008 /sizeof (uint16_t ) +1 , +}; + + +typedef struct IMX2WdtState { +/* <private> */ +SysBusDevice parent_obj; + +MemoryRegion mmio; +}IMX2WdtState ; + +#endif /* IMX7_SNVS_H */
hw/misc/imx2_wdt.c new file +89 -0
89 lines not on this page · raw message
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 27/30] target/arm: Add SVE state to TB->FLAGS
In reply to Peter MaydellFrom: Richard Henderson <[email protected]>
Add both SVE exception state and vector length.
Message-id: [email protected]
--- target/arm/cpu.h | 8 ++++++++ target/arm/translate.h | 2 ++ target/arm/helper.c | 25 ++++++++++++++++++++++++- target/arm/translate-a64.c | 2 ++ 4 files changed, 36 insertions(+), 1 deletion(-)
target/arm/cpu.h +8 -0
@@ -2678,6 +2678,10 @@ static inline bool arm_cpu_data_is_big_endian(CPUARMState *env)#define ARM_TBFLAG_TBI0_MASK (0x1ull << ARM_TBFLAG_TBI0_SHIFT)#define ARM_TBFLAG_TBI1_SHIFT 1/* TBI1 for EL0/1 */ #define ARM_TBFLAG_TBI1_MASK (0x1ull << ARM_TBFLAG_TBI1_SHIFT) +#define ARM_TBFLAG_SVEEXC_EL_SHIFT 2 +#define ARM_TBFLAG_SVEEXC_EL_MASK (0x3 << ARM_TBFLAG_SVEEXC_EL_SHIFT) +#define ARM_TBFLAG_ZCR_LEN_SHIFT 4 +#define ARM_TBFLAG_ZCR_LEN_MASK (0xf << ARM_TBFLAG_ZCR_LEN_SHIFT)/* some convenience accessor macros */ #define ARM_TBFLAG_AARCH64_STATE (F ) \
@@ -2714,6 +2718,10 @@ static inline bool arm_cpu_data_is_big_endian(CPUARMState *env) (((F) & ARM_TBFLAG_TBI0_MASK) >> ARM_TBFLAG_TBI0_SHIFT)#define ARM_TBFLAG_TBI1 (F ) \ (((F) & ARM_TBFLAG_TBI1_MASK) >> ARM_TBFLAG_TBI1_SHIFT) +#define ARM_TBFLAG_SVEEXC_EL (F ) \ + (((F) & ARM_TBFLAG_SVEEXC_EL_MASK) >> ARM_TBFLAG_SVEEXC_EL_SHIFT) +#define ARM_TBFLAG_ZCR_LEN (F ) \ + (((F) & ARM_TBFLAG_ZCR_LEN_MASK) >> ARM_TBFLAG_ZCR_LEN_SHIFT)static inline bool bswap_code (bool sctlr_b) {
target/arm/translate.h +2 -0
@@ -29,6 +29,8 @@ typedef struct DisasContext {bool tbi1;/* TBI1 for EL0/1, not used for EL2/3 */ bool ns;/* Use non-secure CPREG bank on access */ int fp_excp_el;/* FP exception EL or 0 if enabled */ +int sve_excp_el;/* SVE exception EL or 0 if enabled */ +int sve_len;/* SVE vector length in bytes */ /* Flag indicating that exceptions from secure mode are routed to EL3. */ bool secure_routed_to_el3;bool vfp_enabled;/* FP enabled via FPSCR.EN */
target/arm/helper.c +24 -1
@@ -12059,14 +12059,37 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *pflags) {ARMMMUIdx mmu_idx =core_to_arm_mmu_idx (env,cpu_mmu_index (env, false)); +int fp_el =fp_exception_el (env);uint32_t flags;if (is_a64 (env)) { +int sve_el =sve_exception_el (env); +uint32_t zcr_len; + *pc = env->pc; flags =ARM_TBFLAG_AARCH64_STATE_MASK ;/* Get control bits for tagged addresses */ flags |= (arm_regime_tbi0 (env, mmu_idx) <<ARM_TBFLAG_TBI0_SHIFT ); flags |= (arm_regime_tbi1 (env, mmu_idx) <<ARM_TBFLAG_TBI1_SHIFT ); + flags |= sve_el <<ARM_TBFLAG_SVEEXC_EL_SHIFT ; + +/* If SVE is disabled, but FP is enabled, +then the effective len is 0. */ +if (sve_el !=0 && fp_el ==0 ) { + zcr_len =0 ; + }else { +int current_el =arm_current_el (env); + + zcr_len = env->vfp.zcr_el[current_el <=1 ?1 : current_el]; + zcr_len &=0xf ; +if (current_el <2 &&arm_feature (env,ARM_FEATURE_EL2 )) { + zcr_len =MIN (zcr_len,0xf & (uint32_t )env->vfp.zcr_el[2 ]); + } +if (current_el <3 &&arm_feature (env,ARM_FEATURE_EL3 )) { + zcr_len =MIN (zcr_len,0xf & (uint32_t )env->vfp.zcr_el[3 ]); + } + } + flags |= zcr_len <<ARM_TBFLAG_ZCR_LEN_SHIFT ; }else { *pc = env->regs[15 ]; flags = (env->thumb <<ARM_TBFLAG_THUMB_SHIFT )
@@ -12109,7 +12132,7 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,if (arm_cpu_data_is_big_endian (env)) { flags |=ARM_TBFLAG_BE_DATA_MASK ; } - flags |=fp_exception_el (env) <<ARM_TBFLAG_FPEXC_EL_SHIFT ; + flags |= fp_el <<ARM_TBFLAG_FPEXC_EL_SHIFT ;if (arm_v7m_is_handler_mode (env)) { flags |=ARM_TBFLAG_HANDLER_MASK ;
target/arm/translate-a64.c +2 -0
@@ -12058,6 +12058,8 @@ static int aarch64_tr_init_disas_context(DisasContextBase *dcbase, dc->user = (dc->current_el ==0 );#endif dc->fp_excp_el =ARM_TBFLAG_FPEXC_EL (dc->base.tb->flags); + dc->sve_excp_el =ARM_TBFLAG_SVEEXC_EL (dc->base.tb->flags); + dc->sve_len = (ARM_TBFLAG_ZCR_LEN (dc->base.tb->flags) +1 ) *16 ; dc->vec_len =0 ; dc->vec_stride =0 ; dc->cp_regs = arm_cpu->cp_regs;
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 28/30] target/arm/kvm: gic: Prevent creating userspace GICv3 with KVM
In reply to Peter MaydellFrom: Christoffer Dall <[email protected]>
KVM doesn't support emulating a GICv3 in userspace, only GICv2. We currently attempt this anyway, and as a result a KVM guest doesn't receive interrupts and the user is left wondering why. Report an error to the user if this particular combination is requested.
Message-id: [email protected]
--- target/arm/kvm_arm.h | 4 ++++ 1 file changed, 4 insertions(+)
target/arm/kvm_arm.h +4 -0
@@ -234,6 +234,10 @@ static inline const char *gicv3_class_name(void)exit (1 );#endif }else { +if (kvm_enabled ()) { +error_report ("Userspace GICv3 is not supported with KVM" ); +exit (1 ); + }return "arm-gicv3" ; } }
Signature · 1 line
2.16.1
[Qemu-devel] [PULL 30/30] hw/core/generic-loader: Allow PC to be set on command line
In reply to Peter MaydellThe documentation for the generic loader claims that you can set the PC for a CPU with an option of the form
-device loader,cpu-num=0,addr=0x10000004
However if you try this QEMU complains:
cpu_num must be specified when setting a program counter
This is because we were testing against 0 rather than CPU_NONE.
Message-id: [email protected]
--- hw/core/generic-loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/generic-loader.c +1 -1
@@ -105,7 +105,7 @@ static void generic_loader_realize(DeviceState *dev, Error **errp)error_setg (errp,"data can not be specified when setting a " "program counter" );return ; - }else if (!s->cpu_num) { + }else if (s->cpu_num ==CPU_NONE ) {error_setg (errp,"cpu_num must be specified when setting a " "program counter" );return ;
Signature · 1 line
2.16.1
Peter Maydell
AppliedQuoted 11 lines · Peter Maydell
Another lump of target-arm patches. I still have some patches in my to-review queue, but this is a big enough set that I wanted to send it out.
thanks
-- PMMThe following changes since commit
04bb7fe2bf55bdf66d5b7a5a719b40bbb4048178:Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20180208' into staging (2018-02-08 17:41:15 +0000)
Quoted 8 lines
are available in the Git repository at:
git://git.linaro.org/people/pmaydell/qemu-arm.gittags/pull-target-arm-20180209for you to fetch changes up to
bbba7757bacc9f890a3f028d328b4b429dbe78ec:hw/core/generic-loader: Allow PC to be set on command line (2018-02-09 10:55:40 +0000)
Applied, thanks.
-- PMM