target-arm queue
ARM pullreq; contains some patches that arrived while I was on holiday, plus the series I sent off before going away, which got reviewed while I was away.
thanks
-- PMM
The following changes since commit c077a998eb3fcae2d048e3baeb5bc592d30fddde:
Merge remote-tracking branch 'remotes/riku/tags/pull-linux-user-20170531' into staging (2017-06-01 15:50:40 +0100)
are available in the git repository at:
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20170601
for you to fetch changes up to cdc58be430b0bdeaef282e2e70f8135ae531616d:
hw/arm/virt: fdt: generate distance-map when needed (2017-06-01 17:27:07 +0100)
----------------------------------------------------------------
target-arm queue:
* virt: numa: provide ACPI distance info when needed
* aspeed: fix i2c controller bugs
* aspeed: add temperature sensor device
* M profile: support MPU
* gicv3: fix mishandling of BPR1, VBPR1
* load_uboot_image: don't assume a full header read
* libvixl: Correct build failures on NetBSD
----------------------------------------------------------------
Andrew Jones (3):
load_uboot_image: don't assume a full header read hw/arm/virt-acpi-build: build SLIT when needed hw/arm/virt: fdt: generate distance-map when needed
Cédric Le Goater (6):
aspeed/i2c: improve command handling aspeed/i2c: handle LAST command under the RX command aspeed/i2c: introduce a state machine
aspeed: add some I2C devices to the Aspeed machines hw/misc: add a TMP42{1,2,3} device model
aspeed: add a temp sensor device on I2C bus 3
Kamil Rytarowski (1):
libvixl: Correct build failures on NetBSD
Michael Davidsaver (4):
armv7m: Improve "-d mmu" tracing for PMSAv7 MPU
armv7m: Implement M profile default memory map
armv7m: Classify faults as MemManage or BusFault
arm: add MPU support to M profile CPUs
Peter Maydell (12):
hw/intc/arm_gicv3_cpuif: Fix reset value for VMCR_EL2.VBPR1 hw/intc/arm_gicv3_cpuif: Don't let BPR be set below its minimum hw/intc/arm_gicv3_cpuif: Fix priority masking for NS BPR1
arm: Use the mmu_idx we're passed in arm_cpu_do_unaligned_access()
arm: Add support for M profile CPUs having different MMU index semantics
arm: Use different ARMMMUIdx values for M profile
arm: Clean up handling of no-MPU PMSA CPUs
arm: Don't clear ARM_FEATURE_PMSA for no-mpu configs
arm: Don't let no-MPU PMSA cores write to SCTLR.M
arm: Remove unnecessary check on cpu->pmsav7_dregion
arm: All M profile cores are PMSA
arm: Implement HFNMIENA support for M profile MPU
Wei Huang (1):
target/arm: clear PMUVER field of AA64DFR0 when vPMU=off
disas/libvixl/Makefile.objs | 3 + hw/misc/Makefile.objs | 1 + target/arm/cpu.h | 118 ++++++++++-- target/arm/translate.h | 2 +- hw/arm/aspeed.c | 36 ++++ hw/arm/virt-acpi-build.c | 4 + hw/arm/virt.c | 21 +++ hw/core/loader.c | 3 +- hw/i2c/aspeed_i2c.c | 65 ++++++- hw/intc/arm_gicv3_cpuif.c | 50 ++++- hw/intc/armv7m_nvic.c | 104 +++++++++++ hw/misc/tmp421.c | 401 ++++++++++++++++++++++++++++++++++++++++ target/arm/cpu.c | 28 ++- target/arm/helper.c | 338 ++++++++++++++++++++++----------- target/arm/machine.c | 7 +- target/arm/op_helper.c | 3 +- target/arm/translate-a64.c | 18 +- target/arm/translate.c | 14 +- default-configs/arm-softmmu.mak | 1 + 19 files changed, 1060 insertions(+), 157 deletions(-) create mode 100644 hw/misc/tmp421.c
[Qemu-devel] [PULL 11/27] arm: Don't clear ARM_FEATURE_PMSA for no-mpu configs
Fix the handling of QOM properties for PMSA CPUs with no MPU:
Allow no-MPU to be specified by either:
* has-mpu = false
* pmsav7_dregion = 0
and make setting one imply the other. Don't clear the PMSA feature bit in this situation.
Message-id: [email protected]
--- target/arm/cpu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
target/arm/cpu.c +7 -1
@@ -763,8 +763,14 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) cpu->id_pfr1 &= ~0xf000 ; } +/* MPU can be configured out of a PMSA CPU either by setting has-mpu +* to false or by setting pmsav7-dregion to 0. +*/ if (!cpu->has_mpu) { -unset_feature (env,ARM_FEATURE_PMSA ); + cpu->pmsav7_dregion =0 ; + } +if (cpu->pmsav7_dregion ==0 ) { + cpu->has_mpu = false; } if (arm_feature(env, ARM_FEATURE_PMSA) &&
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 12/27] arm: Don't let no-MPU PMSA cores write to SCTLR.M
In reply to Peter MaydellIf the CPU is a PMSA config with no MPU implemented, then the SCTLR.M bit should be RAZ/WI, so that the guest can never turn on the non-existent MPU.
Message-id: [email protected]
--- target/arm/helper.c | 5 +++++ 1 file changed, 5 insertions(+)
target/arm/helper.c +5 -0
@@ -3258,6 +3258,11 @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri,return ; } +if (arm_feature (env,ARM_FEATURE_PMSA ) && !cpu->has_mpu) { +/* M bit is RAZ/WI for PMSA with no MPU implemented */ + value &= ~SCTLR_M ; + } +raw_write (env, ri, value);/* ??? Lots of these bits are not implemented. */ /* This may enable/disable the MMU, so do a TLB flush. */
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 13/27] arm: Remove unnecessary check on cpu->pmsav7_dregion
In reply to Peter MaydellNow that we enforce both:
* pmsav7_dregion == 0 implies has_mpu == false
* PMSA with has_mpu == false means SCTLR.M cannot be set
we can remove a check on pmsav7_dregion from get_phys_addr_pmsav7(), because we can only reach this code path if the MPU is enabled (and so region_translation_disabled() returned false).
Message-id: [email protected]
--- target/arm/helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
target/arm/helper.c +1 -2
@@ -8227,8 +8227,7 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, }if (n ==-1 ) {/* no hits */ -if (cpu->pmsav7_dregion && - (is_user || !(regime_sctlr (env, mmu_idx) &SCTLR_BR ))) { +if (is_user || !(regime_sctlr (env, mmu_idx) &SCTLR_BR )) {/* background fault */ *fsr =0 ;return true;
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 09/27] arm: Use different ARMMMUIdx values for M profile
In reply to Peter MaydellMake M profile use completely separate ARMMMUIdx values from those that A profile CPUs use. This is a prelude to adding support for the MPU and for v8M, which together will require 6 MMU indexes which don't map cleanly onto the A profile uses:
non secure User
non secure Privileged
non secure Privileged, execution priority < 0 secure User
secure Privileged
secure Privileged, execution priority < 0
Message-id: [email protected]
--- target/arm/cpu.h | 21 +++++++++++++++++++-- target/arm/helper.c | 5 +++++ target/arm/translate.c | 3 +++ 3 files changed, 27 insertions(+), 2 deletions(-)
target/arm/cpu.h +19 -2
@@ -2057,8 +2057,9 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,* of the AT/ATS operations. * The values used are carefully arranged to make mmu_idx => EL lookup easy. */ -#define ARM_MMU_IDX_A 0x10/* A profile (and M profile, for the moment) */ +#define ARM_MMU_IDX_A 0x10/* A profile */ #define ARM_MMU_IDX_NOTLB 0x20/* does not have a TLB */ +#define ARM_MMU_IDX_M 0x40/* M profile */ #define ARM_MMU_IDX_TYPE_MASK (~0x7)#define ARM_MMU_IDX_COREIDX_MASK 0x7
@@ -2071,6 +2072,8 @@ typedef enum ARMMMUIdx { ARMMMUIdx_S1SE0 =4 |ARM_MMU_IDX_A , ARMMMUIdx_S1SE1 =5 |ARM_MMU_IDX_A , ARMMMUIdx_S2NS =6 |ARM_MMU_IDX_A , + ARMMMUIdx_MUser =0 |ARM_MMU_IDX_M , + ARMMMUIdx_MPriv =1 |ARM_MMU_IDX_M ,/* Indexes below here don't have TLBs and are used only for AT system * instructions or for the first stage of an S12 page table walk. */
@@ -2089,6 +2092,8 @@ typedef enum ARMMMUIdxBit { ARMMMUIdxBit_S1SE0 =1 <<4 , ARMMMUIdxBit_S1SE1 =1 <<5 , ARMMMUIdxBit_S2NS =1 <<6 , + ARMMMUIdxBit_MUser =1 <<0 , + ARMMMUIdxBit_MPriv =1 <<1 , } ARMMMUIdxBit;#define MMU_USER_IDX 0
@@ -2100,7 +2105,11 @@ static inline int arm_to_core_mmu_idx(ARMMMUIdx mmu_idx)static inline ARMMMUIdx core_to_arm_mmu_idx (CPUARMState *env,int mmu_idx) { -return mmu_idx |ARM_MMU_IDX_A ; +if (arm_feature (env,ARM_FEATURE_M )) { +return mmu_idx |ARM_MMU_IDX_M ; + }else { +return mmu_idx |ARM_MMU_IDX_A ; + } }/* Return the exception level we're running at if this is our mmu_idx */
@@ -2109,6 +2118,8 @@ static inline int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx)switch (mmu_idx &ARM_MMU_IDX_TYPE_MASK ) {case ARM_MMU_IDX_A :return mmu_idx &3 ; +case ARM_MMU_IDX_M : +return mmu_idx &1 ;default :g_assert_not_reached (); }
@@ -2119,6 +2130,12 @@ static inline int cpu_mmu_index(CPUARMState *env, bool ifetch) {int el =arm_current_el (env); +if (arm_feature (env,ARM_FEATURE_M )) { +ARMMMUIdx mmu_idx = el ==0 ? ARMMMUIdx_MUser : ARMMMUIdx_MPriv; + +return arm_to_core_mmu_idx (mmu_idx); + } +if (el <2 &&arm_is_secure_below_el3 (env)) {return arm_to_core_mmu_idx (ARMMMUIdx_S1SE0 + el); }
target/arm/helper.c +5 -0
@@ -6992,6 +6992,8 @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx)case ARMMMUIdx_S1SE1:case ARMMMUIdx_S1NSE0:case ARMMMUIdx_S1NSE1: +case ARMMMUIdx_MPriv: +case ARMMMUIdx_MUser:return 1 ;default :g_assert_not_reached ();
@@ -7008,6 +7010,8 @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx)case ARMMMUIdx_S1NSE1:case ARMMMUIdx_S1E2:case ARMMMUIdx_S2NS: +case ARMMMUIdx_MPriv: +case ARMMMUIdx_MUser:return false;case ARMMMUIdx_S1E3:case ARMMMUIdx_S1SE0:
@@ -7146,6 +7150,7 @@ static inline bool regime_is_user(CPUARMState *env, ARMMMUIdx mmu_idx)switch (mmu_idx) {case ARMMMUIdx_S1SE0:case ARMMMUIdx_S1NSE0: +case ARMMMUIdx_MUser:return true;default :return false;
target/arm/translate.c +3 -0
@@ -161,6 +161,9 @@ static inline int get_a32_user_mem_index(DisasContext *s)case ARMMMUIdx_S1SE0:case ARMMMUIdx_S1SE1:return arm_to_core_mmu_idx (ARMMMUIdx_S1SE0); +case ARMMMUIdx_MUser: +case ARMMMUIdx_MPriv: +return arm_to_core_mmu_idx (ARMMMUIdx_MUser);case ARMMMUIdx_S2NS:default :g_assert_not_reached ();
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 10/27] arm: Clean up handling of no-MPU PMSA CPUs
In reply to Peter MaydellARM CPUs come in two flavours:
* proper MMU ("VMSA")
* only an MPU ("PMSA")
For PMSA, the MPU may be implemented, or not (in which case there is default "always acts the same" behaviour, but it isn't guest programmable).
QEMU is a bit confused about how we indicate this: we have an ARM_FEATURE_MPU, but it's not clear whether this indicates "PMSA, not VMSA" or "PMSA and MPU present" , and sometimes we use it for one purpose and sometimes the other.
Currently trying to implement a PMSA-without-MPU core won't work correctly because we turn off the ARM_FEATURE_MPU bit and then a lot of things which should still exist get turned off too.
As the first step in cleaning this up, rename the feature bit to ARM_FEATURE_PMSA, which indicates a PMSA CPU (with or without MPU).
Message-id: [email protected]
--- target/arm/cpu.h | 2 +- target/arm/cpu.c | 12 ++++++------ target/arm/helper.c | 12 ++++++------ target/arm/machine.c | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-)
target/arm/cpu.h +1 -1
@@ -1181,7 +1181,7 @@ enum arm_features {ARM_FEATURE_V6K ,ARM_FEATURE_V7 ,ARM_FEATURE_THUMB2 , -ARM_FEATURE_MPU ,/* Only has Memory Protection Unit, not full MMU. */ +ARM_FEATURE_PMSA ,/* no MMU; may have Memory Protection Unit */ ARM_FEATURE_VFP3 ,ARM_FEATURE_VFP_FP16 , ARM_FEATURE_NEON,
target/arm/cpu.c +6 -6
@@ -593,7 +593,7 @@ static void arm_cpu_post_init(Object *obj) &error_abort); } -if (arm_feature (&cpu->env,ARM_FEATURE_MPU )) { +if (arm_feature (&cpu->env,ARM_FEATURE_PMSA )) {qdev_property_add_static (DEVICE (obj), &arm_cpu_has_mpu_property, &error_abort);if (arm_feature (&cpu->env,ARM_FEATURE_V7 )) {
@@ -689,7 +689,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)if (arm_feature (env,ARM_FEATURE_V7 ) && !arm_feature (env,ARM_FEATURE_M ) && - !arm_feature (env,ARM_FEATURE_MPU )) { + !arm_feature (env,ARM_FEATURE_PMSA )) {/* v7VMSA drops support for the old ARMv5 tiny pages, so we * can use 4K pages. */
@@ -764,10 +764,10 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) }if (!cpu->has_mpu) { -unset_feature (env,ARM_FEATURE_MPU ); +unset_feature (env,ARM_FEATURE_PMSA ); } -if (arm_feature (env,ARM_FEATURE_MPU ) && +if (arm_feature (env,ARM_FEATURE_PMSA ) &&arm_feature (env,ARM_FEATURE_V7 )) {uint32_t nr = cpu->pmsav7_dregion;
@@ -867,7 +867,7 @@ static void arm946_initfn(Object *obj) cpu->dtb_compatible ="arm,arm946" ;set_feature (&cpu->env,ARM_FEATURE_V5 ); -set_feature (&cpu->env,ARM_FEATURE_MPU ); +set_feature (&cpu->env,ARM_FEATURE_PMSA );set_feature (&cpu->env,ARM_FEATURE_DUMMY_C15_REGS ); cpu->midr =0x41059461 ; cpu->ctr =0x0f004006 ;
@@ -1079,7 +1079,7 @@ static void cortex_r5_initfn(Object *obj)set_feature (&cpu->env,ARM_FEATURE_THUMB_DIV );set_feature (&cpu->env,ARM_FEATURE_ARM_DIV );set_feature (&cpu->env,ARM_FEATURE_V7MP ); -set_feature (&cpu->env,ARM_FEATURE_MPU ); +set_feature (&cpu->env,ARM_FEATURE_PMSA ); cpu->midr =0x411fc153 ;/* r1p3 */ cpu->id_pfr0 =0x0131 ; cpu->id_pfr1 =0x001 ;
target/arm/helper.c +6 -6
@@ -485,7 +485,7 @@ static void contextidr_write(CPUARMState *env, const ARMCPRegInfo *ri, {ARMCPU *cpu =arm_env_get_cpu (env); -if (raw_read (env, ri) != value && !arm_feature (env,ARM_FEATURE_MPU ) +if (raw_read (env, ri) != value && !arm_feature (env,ARM_FEATURE_PMSA ) && !extended_addresses_enabled (env)) {/* For VMSA (when not using the LPAE long descriptor page table * format) this register includes the ASID, so do a TLB flush.
@@ -4615,7 +4615,7 @@ void register_cp_regs_for_features(ARMCPU *cpu)define_arm_cp_regs (cpu, v6k_cp_reginfo); }if (arm_feature (env,ARM_FEATURE_V7MP ) && - !arm_feature (env,ARM_FEATURE_MPU )) { + !arm_feature (env,ARM_FEATURE_PMSA )) {define_arm_cp_regs (cpu, v7mp_cp_reginfo); }if (arm_feature (env,ARM_FEATURE_V7 )) {
@@ -4969,7 +4969,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) } } -if (arm_feature (env,ARM_FEATURE_MPU )) { +if (arm_feature (env,ARM_FEATURE_PMSA )) {if (arm_feature (env,ARM_FEATURE_V6 )) {/* PMSAv6 not implemented */ assert (arm_feature (env,ARM_FEATURE_V7 ));
@@ -5131,7 +5131,7 @@ void register_cp_regs_for_features(ARMCPU *cpu)define_arm_cp_regs (cpu, id_pre_v8_midr_cp_reginfo); }define_arm_cp_regs (cpu, id_cp_reginfo); -if (!arm_feature (env,ARM_FEATURE_MPU )) { +if (!arm_feature (env,ARM_FEATURE_PMSA )) {define_one_arm_cp_reg (cpu, &id_tlbtr_reginfo); }else if (arm_feature (env,ARM_FEATURE_V7 )) {define_one_arm_cp_reg (cpu, &id_mpuir_reginfo);
@@ -8442,7 +8442,7 @@ static bool get_phys_addr(CPUARMState *env, target_ulong address,/* pmsav7 has special handling for when MPU is disabled so call it before * the common MMU/MPU disabled check below. */ -if (arm_feature (env,ARM_FEATURE_MPU ) && +if (arm_feature (env,ARM_FEATURE_PMSA ) &&arm_feature (env,ARM_FEATURE_V7 )) { *page_size =TARGET_PAGE_SIZE ; return get_phys_addr_pmsav7(env, address, access_type, mmu_idx,
@@ -8457,7 +8457,7 @@ static bool get_phys_addr(CPUARMState *env, target_ulong address,return 0 ; } -if (arm_feature (env,ARM_FEATURE_MPU )) { +if (arm_feature (env,ARM_FEATURE_PMSA )) {/* Pre-v7 MPU */ *page_size =TARGET_PAGE_SIZE ; return get_phys_addr_pmsav5(env, address, access_type, mmu_idx,
target/arm/machine.c +1 -1
@@ -142,7 +142,7 @@ static bool pmsav7_needed(void *opaque)ARMCPU *cpu = opaque;CPUARMState *env = &cpu->env; -return arm_feature (env,ARM_FEATURE_MPU ) && +return arm_feature (env,ARM_FEATURE_PMSA ) &&arm_feature (env,ARM_FEATURE_V7 ); }
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 14/27] armv7m: Improve "-d mmu" tracing for PMSAv7 MPU
In reply to Peter MaydellFrom: Michael Davidsaver <[email protected]>
Improve the "-d mmu" tracing for the PMSAv7 MPU translation process as an aid in debugging guest MPU configurations:
* fix a missing newline for a guest-error log
* report the region number with guest-error or unimp logs of bad region register values
* add a log message for the overall result of the lookup
* print "0x" prefix for hex values
Message-id: [email protected] [PMM: a little tidyup, report region number in all messages
rather than just one]
--- target/arm/helper.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-)
target/arm/helper.c +27 -12
@@ -8169,16 +8169,18 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, }if (!rsize) { -qemu_log_mask (LOG_GUEST_ERROR ,"DRSR.Rsize field can not be 0" ); +qemu_log_mask (LOG_GUEST_ERROR , +"DRSR[%d]: Rsize field cannot be 0\n" , n);continue ; } rsize++; rmask = (1ull << rsize) -1 ;if (base & rmask) { -qemu_log_mask (LOG_GUEST_ERROR ,"DRBAR %" PRIx32" misaligned " -"to DRSR region size, mask = %" PRIx32, - base, rmask); +qemu_log_mask (LOG_GUEST_ERROR , +"DRBAR[%d]: 0x%" PRIx32" misaligned " +"to DRSR region size, mask = 0x%" PRIx32"\n" , + n, base, rmask);continue ; }
@@ -8215,9 +8217,10 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, } }if (rsize <TARGET_PAGE_BITS ) { -qemu_log_mask (LOG_UNIMP ,"No support for MPU (sub)region" +qemu_log_mask (LOG_UNIMP , +"DRSR[%d]: No support for MPU (sub)region " "alignment of %" PRIu32" bits. Minimum is %d\n" , - rsize,TARGET_PAGE_BITS ); + n, rsize,TARGET_PAGE_BITS );continue ; }if (srdis) {
@@ -8251,8 +8254,8 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,break ;default :qemu_log_mask (LOG_GUEST_ERROR , -"Bad value for AP bits in DRACR %" - PRIx32"\n" , ap); +"DRACR[%d]: Bad value for AP bits: 0x%" + PRIx32"\n" , n, ap); } }else {/* Priv. mode AP bits decoding */ switch (ap) {
@@ -8269,8 +8272,8 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,break ;default :qemu_log_mask (LOG_GUEST_ERROR , -"Bad value for AP bits in DRACR %" - PRIx32"\n" , ap); +"DRACR[%d]: Bad value for AP bits: 0x%" + PRIx32"\n" , n, ap); } }
@@ -8448,9 +8451,21 @@ static bool get_phys_addr(CPUARMState *env, target_ulong address,*/ if (arm_feature (env,ARM_FEATURE_PMSA ) &&arm_feature (env,ARM_FEATURE_V7 )) { +bool ret; *page_size =TARGET_PAGE_SIZE ; -return get_phys_addr_pmsav7 (env, address, access_type, mmu_idx, - phys_ptr, prot, fsr); + ret =get_phys_addr_pmsav7 (env, address, access_type, mmu_idx, + phys_ptr, prot, fsr); +qemu_log_mask (CPU_LOG_MMU ,"PMSAv7 MPU lookup for %s at 0x%08" PRIx32 +" mmu_idx %u -> %s (prot %c%c%c)\n" , + access_type ==1 ?"reading" : + (access_type ==2 ?"writing" :"execute" ), + (uint32_t )address, mmu_idx, + ret ?"Miss" :"Hit" , + *prot &PAGE_READ ?'r' :'-' , + *prot &PAGE_WRITE ?'w' :'-' , + *prot &PAGE_EXEC ?'x' :'-' ); + +return ret; }if (regime_translation_disabled (env, mmu_idx)) {
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 15/27] armv7m: Implement M profile default memory map
In reply to Peter MaydellFrom: Michael Davidsaver <[email protected]>
Add support for the M profile default memory map which is used if the MPU is not present or disabled.
The main differences in behaviour from implementing this correctly are that we set the PAGE_EXEC attribute on the right regions of memory, such that device regions are not executable.
Message-id: [email protected] [PMM: rephrased comment and commit message; don't mark
the flash memory region as not-writable; list all
the cases in the default map explicitly rather than
using a 'default' case for the non-executable regions]
--- target/arm/helper.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-)
target/arm/helper.c +32 -9
@@ -8129,18 +8129,41 @@ static inline void get_phys_addr_pmsav7_default(CPUARMState *env,ARMMMUIdx mmu_idx, int32_t address, int *prot) { - *prot =PAGE_READ |PAGE_WRITE ; -switch (address) { - case 0xF0000000 ... 0xFFFFFFFF: -if (regime_sctlr (env, mmu_idx) &SCTLR_V ) {/* hivecs execing is ok */ + if (!arm_feature(env, ARM_FEATURE_M)) { + *prot =PAGE_READ |PAGE_WRITE ; +switch (address) { + case 0xF0000000 ... 0xFFFFFFFF: +if (regime_sctlr (env, mmu_idx) &SCTLR_V ) { +/* hivecs execing is ok */ + *prot |=PAGE_EXEC ; + } +break ; + case 0x00000000 ... 0x7FFFFFFF: *prot |=PAGE_EXEC ; +break ; + } + } else { +/* Default system address map for M profile cores. +* The architecture specifies which regions are execute-never; +* at the MPU level no other checks are defined. +*/ +switch (address) { + case 0x00000000 ... 0x1fffffff: /* ROM */ + case 0x20000000 ... 0x3fffffff: /* SRAM */ + case 0x60000000 ... 0x7fffffff: /* RAM */ + case 0x80000000 ... 0x9fffffff: /* RAM */ + *prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; +break ; + case 0x40000000 ... 0x5fffffff: /* Peripheral */ + case 0xa0000000 ... 0xbfffffff: /* Device */ + case 0xc0000000 ... 0xdfffffff: /* Device */ + case 0xe0000000 ... 0xffffffff: /* System */ + *prot =PAGE_READ |PAGE_WRITE ; +break ; +default : +g_assert_not_reached (); } -break ; - case 0x00000000 ... 0x7FFFFFFF: - *prot |=PAGE_EXEC ; -break ; } - } static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 16/27] arm: All M profile cores are PMSA
In reply to Peter MaydellAll M profile CPUs are PMSA, so set the feature bit. (We haven't actually implemented the M profile MPU register interface yet, but setting this feature bit gives us closer to correct behaviour for the MPU-disabled case.)
Message-id: [email protected]
--- target/arm/cpu.c | 8 ++++++++ 1 file changed, 8 insertions(+)
target/arm/cpu.c +8 -0
@@ -550,6 +550,14 @@ static void arm_cpu_post_init(Object *obj) {ARMCPU *cpu =ARM_CPU (obj); +/* M profile implies PMSA. We have to do this here rather than +* in realize with the other feature-implication checks because +* we look at the PMSA bit to see if we should add some properties. +*/ +if (arm_feature (&cpu->env,ARM_FEATURE_M )) { +set_feature (&cpu->env,ARM_FEATURE_PMSA ); + } +if (arm_feature (&cpu->env,ARM_FEATURE_CBAR ) ||arm_feature (&cpu->env,ARM_FEATURE_CBAR_RO )) { qdev_property_add_static(DEVICE(obj), &arm_cpu_reset_cbar_property,
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 17/27] armv7m: Classify faults as MemManage or BusFault
In reply to Peter MaydellFrom: Michael Davidsaver <[email protected]>
General logic is that operations stopped by the MPU are MemManage, and those which go through the MPU and are caught by the unassigned handle are BusFault. Distinguish these by looking at the exception.fsr values, and set the CFSR bits and (if appropriate) fill in the BFAR or MMFAR with the exception address.
Message-id: [email protected] [PMM: i-side faults do not set BFAR/MMFAR, only d-side;
added some CPU_LOG_INT logging]
--- target/arm/helper.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-)
target/arm/helper.c +42 -3
@@ -6342,10 +6342,49 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)break ;case EXCP_PREFETCH_ABORT :case EXCP_DATA_ABORT : -/* TODO: if we implemented the MPU registers, this is where we -* should set the MMFAR, etc from exception.fsr and exception.vaddress. +/* Note that for M profile we don't have a guest facing FSR, but +* the env->exception.fsr will be populated by the code that +* raises the fault, in the A profile short-descriptor format. */ -armv7m_nvic_set_pending (env->nvic,ARMV7M_EXCP_MEM ); +switch (env->exception.fsr &0xf ) { +case 0x8 :/* External Abort */ +switch (cs->exception_index) { +case EXCP_PREFETCH_ABORT : + env->v7m.cfsr |=R_V7M_CFSR_PRECISERR_MASK ; +qemu_log_mask (CPU_LOG_INT ,"...with CFSR.PRECISERR\n" ); +break ; +case EXCP_DATA_ABORT : + env->v7m.cfsr |= + (R_V7M_CFSR_IBUSERR_MASK |R_V7M_CFSR_BFARVALID_MASK ); + env->v7m.bfar = env->exception.vaddress; +qemu_log_mask (CPU_LOG_INT , +"...with CFSR.IBUSERR and BFAR 0x%x\n" , + env->v7m.bfar); +break ; + } +armv7m_nvic_set_pending (env->nvic,ARMV7M_EXCP_BUS ); +break ; +default : +/* All other FSR values are either MPU faults or "can't happen +* for M profile" cases. +*/ +switch (cs->exception_index) { +case EXCP_PREFETCH_ABORT : + env->v7m.cfsr |=R_V7M_CFSR_IACCVIOL_MASK ; +qemu_log_mask (CPU_LOG_INT ,"...with CFSR.IACCVIOL\n" ); +break ; +case EXCP_DATA_ABORT : + env->v7m.cfsr |= + (R_V7M_CFSR_DACCVIOL_MASK |R_V7M_CFSR_MMARVALID_MASK ); + env->v7m.mmfar = env->exception.vaddress; +qemu_log_mask (CPU_LOG_INT , +"...with CFSR.DACCVIOL and MMFAR 0x%x\n" , + env->v7m.mmfar); +break ; + } +armv7m_nvic_set_pending (env->nvic,ARMV7M_EXCP_MEM ); +break ; + }break ;case EXCP_BKPT :if (semihosting_enabled ()) {
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 04/27] hw/intc/arm_gicv3_cpuif: Don't let BPR be set below its minimum
In reply to Peter Maydellicc_bpr_write() was not enforcing that writing a value below the minimum for the BPR should behave as if the BPR was set to the minimum value. This doesn't make a difference for the secure BPRs (since we define the minimum for the QEMU implementation as zero) but did mean we were allowing the NS BPR1 to be set to 0 when 1 should be the lowest value.
Message-id: [email protected]
--- hw/intc/arm_gicv3_cpuif.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/intc/arm_gicv3_cpuif.c +6 -0
@@ -1388,6 +1388,7 @@ static void icc_bpr_write(CPUARMState *env, const ARMCPRegInfo *ri, {GICv3CPUState *cs =icc_cs_from_env (env);int grp = (ri->crm ==8 ) ?GICV3_G0 :GICV3_G1 ; +uint64_t minval;if (icv_access (env, grp ==GICV3_G0 ?HCR_FMO :HCR_IMO )) {icv_bpr_write (env, ri, value);
@@ -1415,6 +1416,11 @@ static void icc_bpr_write(CPUARMState *env, const ARMCPRegInfo *ri,return ; } + minval = (grp ==GICV3_G1NS ) ?GIC_MIN_BPR_NS :GIC_MIN_BPR ; +if (value < minval) { + value = minval; + } + cs->icc_bpr[grp] = value &7 ;gicv3_cpuif_update (cs); }
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 06/27] target/arm: clear PMUVER field of AA64DFR0 when vPMU=off
In reply to Peter MaydellFrom: Wei Huang <[email protected]>
The PMUv3 driver of linux kernel (in arch/arm64/kernel/perf_event.c) relies on the PMUVER field of id_aa64dfr0_el1 to decide if PMU support is present or not. This patch clears the PMUVER field under TCG mode when vPMU=off. Without it, PMUv3 will init insider guest VMs even with vPMU=off. This patch also removes a redundant line inside the if-statement.
Message-id: [email protected]
--- target/arm/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/cpu.c +1 -1
@@ -750,8 +750,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) }if (!cpu->has_pmu) { - cpu->has_pmu = false;unset_feature (env,ARM_FEATURE_PMU ); + cpu->id_aa64dfr0 &= ~0xf00 ; }if (!arm_feature (env,ARM_FEATURE_EL2 )) {
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 07/27] arm: Use the mmu_idx we're passed in arm_cpu_do_unaligned_access()
In reply to Peter MaydellWhen identifying the DFSR format for an alignment fault, use the mmu index that we are passed, rather than calling cpu_mmu_index() to get the mmu index for the current CPU state. This doesn't actually make any difference since the only cases where the current MMU index differs from the index used for the load are the "unprivileged load/store" instructions, and in that case the mmu index may differ but the translation regime is the same (apart from the "use from Hyp mode" case which is UNPREDICTABLE).
However it's the more logical thing to do.
Message-id: [email protected]
--- target/arm/op_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/arm/op_helper.c +1 -1
@@ -208,7 +208,7 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,/* the DFSR for an alignment fault depends on whether we're using * the LPAE long descriptor format, or the short descriptor format */ -if (arm_s1_regime_using_lpae_format (env,cpu_mmu_index (env, false))) { +if (arm_s1_regime_using_lpae_format (env, mmu_idx)) { env->exception.fsr = (1 <<9 ) |0x21 ; }else { env->exception.fsr =0x1 ;
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 01/27] libvixl: Correct build failures on NetBSD
In reply to Peter MaydellFrom: Kamil Rytarowski <[email protected]>
Ensure that C99 macros are defined regardless of the inclusion order of headers in vixl. This is required at least on NetBSD.
The vixl/globals.h headers defines __STDC_CONSTANT_MACROS and must be included before other system headers.
This file defines unconditionally the following macros, without altering the original sources:
- __STDC_CONSTANT_MACROS
- __STDC_LIMIT_MACROS
- __STDC_FORMAT_MACROS
Message-id: [email protected]
--- disas/libvixl/Makefile.objs | 3 +++ 1 file changed, 3 insertions(+)
disas/libvixl/Makefile.objs +3 -0
@@ -7,5 +7,8 @@ libvixl_OBJS = vixl/utils.o \ # The -Wno-sign-compare is needed only for gcc 4.6, which complains about # some signed-unsigned equality comparisons which later gcc versions do not. $(addprefix $(obj)/,$(libvixl_OBJS)): QEMU_CFLAGS := -I$(SRC_PATH)/disas/libvixl $(QEMU_CFLAGS) -Wno-sign-compare +# Ensure that C99 macros are defined regardless of the inclusion order of +# headers in vixl. This is required at least on NetBSD. +$(addprefix $(obj)/,$(libvixl_OBJS)): QEMU_CFLAGS += -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS common-obj-$(CONFIG_ARM_A64_DIS) += $(libvixl_OBJS)
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 02/27] load_uboot_image: don't assume a full header read
In reply to Peter MaydellFrom: Andrew Jones <[email protected]>
Don't allow load_uboot_image() to proceed when less bytes than header-size was read.
Message-id: [email protected]
--- hw/core/loader.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/core/loader.c +2 -1
@@ -611,8 +611,9 @@ static int load_uboot_image(const char *filename, hwaddr *ep, hwaddr *loadaddr,return -1 ; size =read (fd, hdr,sizeof (uboot_image_header_t)); -if (size <0 ) +if (size <sizeof (uboot_image_header_t)) { goto out; + }bswap_uboot_header (hdr);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 05/27] hw/intc/arm_gicv3_cpuif: Fix priority masking for NS BPR1
In reply to Peter MaydellWhen we calculate the mask to use to get the group priority from an interrupt priority, the way that NS BPR1 is handled differs from how BPR0 and S BPR1 work -- a BPR1 value of 1 means the group priority is in bits [7:1], whereas for BPR0 and S BPR1 this is indicated by a 0 BPR value.
Subtract 1 from the BPR value before creating the mask if we're using the NS BPR value, for both hardware and virtual interrupts, as the GICv3 pseudocode does, and fix the comments accordingly.
Message-id: [email protected]
--- hw/intc/arm_gicv3_cpuif.c | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-)
hw/intc/arm_gicv3_cpuif.c +38 -4
@@ -216,18 +216,35 @@ static uint32_t icv_gprio_mask(GICv3CPUState *cs, int group) {/* Return a mask word which clears the subpriority bits from * a priority value for a virtual interrupt in the specified group. -* This depends on the VBPR value: +* This depends on the VBPR value. +* If using VBPR0 then: * a BPR of 0 means the group priority bits are [7:1]; * a BPR of 1 means they are [7:2], and so on down to * a BPR of 7 meaning no group priority bits at all. +* If using VBPR1 then: +* a BPR of 0 is impossible (the minimum value is 1) +* a BPR of 1 means the group priority bits are [7:1]; +* a BPR of 2 means they are [7:2], and so on down to +* a BPR of 7 meaning the group priority is [7]. +* * Which BPR to use depends on the group of the interrupt and * the current ICH_VMCR_EL2.VCBPR settings. +* +* This corresponds to the VGroupBits() pseudocode. */ +int bpr; +if (group ==GICV3_G1NS && cs->ich_vmcr_el2 &ICH_VMCR_EL2_VCBPR ) { group =GICV3_G0 ; } -return ~0U << (read_vbpr (cs, group) +1 ); + bpr =read_vbpr (cs, group); +if (group ==GICV3_G1NS ) { +assert (bpr >0 ); + bpr--; + } + +return ~0U << (bpr +1 ); }static bool icv_hppi_can_preempt (GICv3CPUState *cs,uint64_t lr)
@@ -674,20 +691,37 @@ static uint32_t icc_gprio_mask(GICv3CPUState *cs, int group) {/* Return a mask word which clears the subpriority bits from * a priority value for an interrupt in the specified group. -* This depends on the BPR value: +* This depends on the BPR value. For CBPR0 (S or NS): * a BPR of 0 means the group priority bits are [7:1]; * a BPR of 1 means they are [7:2], and so on down to * a BPR of 7 meaning no group priority bits at all. +* For CBPR1 NS: +* a BPR of 0 is impossible (the minimum value is 1) +* a BPR of 1 means the group priority bits are [7:1]; +* a BPR of 2 means they are [7:2], and so on down to +* a BPR of 7 meaning the group priority is [7]. +* * Which BPR to use depends on the group of the interrupt and * the current ICC_CTLR.CBPR settings. +* +* This corresponds to the GroupBits() pseudocode. */ +int bpr; +if ((group ==GICV3_G1 && cs->icc_ctlr_el1[GICV3_S ] &ICC_CTLR_EL1_CBPR ) || (group ==GICV3_G1NS && cs->icc_ctlr_el1[GICV3_NS ] &ICC_CTLR_EL1_CBPR )) { group =GICV3_G0 ; } -return ~0U << ((cs->icc_bpr[group] &7 ) +1 ); + bpr = cs->icc_bpr[group] &7 ; + +if (group ==GICV3_G1NS ) { +assert (bpr >0 ); + bpr--; + } + +return ~0U << (bpr +1 ); }static bool icc_no_enabled_hppi (GICv3CPUState *cs)
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 18/27] arm: add MPU support to M profile CPUs
In reply to Peter MaydellFrom: Michael Davidsaver <[email protected]>
The M series MPU is almost the same as the already implemented R profile MPU (v7 PMSA). So all we need to implement here is the MPU register interface in the system register space.
This implementation has the same restriction as the R profile MPU that it doesn't permit regions to be sized down smaller than 1K.
We also do not yet implement support for MPU_CTRL.HFNMIENA; this bit should if zero disable use of the MPU when running HardFault, NMI or with FAULTMASK set to 1 (ie at an execution priority of less than zero) -- if the MPU is enabled we don't treat these cases any differently.
Message-id: [email protected] [PMM: Keep all the bits in mpu_ctrl field, rather than
using SCTLR bits for them; drop broken HFNMIENA support; various cleanup]
--- target/arm/cpu.h | 6 +++ hw/intc/armv7m_nvic.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++ target/arm/helper.c | 25 +++++++++++- target/arm/machine.c | 5 ++- 4 files changed, 137 insertions(+), 3 deletions(-)
target/arm/cpu.h +6 -0
@@ -418,6 +418,7 @@ typedef struct CPUARMState {uint32_t dfsr;/* Debug Fault Status Register */ uint32_t mmfar;/* MemManage Fault Address */ uint32_t bfar;/* BusFault Address */ +unsigned mpu_ctrl;/* MPU_CTRL (some bits kept in sctlr_el[1]) */ int exception; } v7m;
@@ -1168,6 +1169,11 @@ FIELD(V7M_DFSR, DWTTRAP, 2, 1) FIELD(V7M_DFSR, VCATCH, 3, 1)FIELD (V7M_DFSR ,EXTERNAL ,4 ,1 ) +/* v7M MPU_CTRL bits */ +FIELD(V7M_MPU_CTRL, ENABLE, 0, 1) +FIELD(V7M_MPU_CTRL, HFNMIENA, 1, 1) +FIELD (V7M_MPU_CTRL ,PRIVDEFENA ,2 ,1 ) +/* If adding a feature bit which corresponds to a Linux ELF * HWCAP bit, remember to update the feature-bit-to-hwcap * mapping in linux-user/elfload.c:get_elf_hwcap().
hw/intc/armv7m_nvic.c +104 -0
122 lines not on this page · raw message
target/arm/helper.c +24 -1
@@ -7076,6 +7076,10 @@ static inline uint32_t regime_sctlr(CPUARMState *env, ARMMMUIdx mmu_idx)static inline bool regime_translation_disabled (CPUARMState *env,ARMMMUIdx mmu_idx) { +if (arm_feature (env,ARM_FEATURE_M )) { +return !(env->v7m.mpu_ctrl &R_V7M_MPU_CTRL_ENABLE_MASK ); + } +if (mmu_idx == ARMMMUIdx_S2NS) {return (env->cp15.hcr_el2 &HCR_VM ) ==0 ; }
@@ -8205,6 +8209,25 @@ static inline void get_phys_addr_pmsav7_default(CPUARMState *env, } } +static bool pmsav7_use_background_region (ARMCPU *cpu, +ARMMMUIdx mmu_idx,bool is_user) +{ +/* Return true if we should use the default memory map as a +* "background" region if there are no hits against any MPU regions. +*/ +CPUARMState *env = &cpu->env; + +if (is_user) { +return false; + } + +if (arm_feature (env,ARM_FEATURE_M )) { +return env->v7m.mpu_ctrl &R_V7M_MPU_CTRL_PRIVDEFENA_MASK ; + }else { +return regime_sctlr (env, mmu_idx) &SCTLR_BR ; + } +} +static bool get_phys_addr_pmsav7 (CPUARMState *env,uint32_t address,int access_type,ARMMMUIdx mmu_idx,hwaddr *phys_ptr,int *prot,uint32_t *fsr)
@@ -8292,7 +8315,7 @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address, }if (n ==-1 ) {/* no hits */ -if (is_user || !(regime_sctlr (env, mmu_idx) &SCTLR_BR )) { +if (!pmsav7_use_background_region (cpu, mmu_idx, is_user)) {/* background fault */ *fsr =0 ;return true;
target/arm/machine.c +3 -2
@@ -99,8 +99,8 @@ static bool m_needed(void *opaque)static const VMStateDescription vmstate_m = { .name ="cpu/m" , - .version_id =3 , - .minimum_version_id =3 , + .version_id =4 , + .minimum_version_id =4 , .needed = m_needed, .fields = (VMStateField []) {VMSTATE_UINT32 (env.v7m.vecbase,ARMCPU ),
@@ -112,6 +112,7 @@ static const VMStateDescription vmstate_m = {VMSTATE_UINT32 (env.v7m.dfsr,ARMCPU ),VMSTATE_UINT32 (env.v7m.mmfar,ARMCPU ),VMSTATE_UINT32 (env.v7m.bfar,ARMCPU ), +VMSTATE_UINT32 (env.v7m.mpu_ctrl,ARMCPU ),VMSTATE_INT32 (env.v7m.exception,ARMCPU ), VMSTATE_END_OF_LIST() }
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 19/27] arm: Implement HFNMIENA support for M profile MPU
In reply to Peter MaydellImplement HFNMIENA support for the M profile MPU. This bit controls whether the MPU is treated as enabled when executing at execution priorities of less than zero (in NMI, HardFault or with the FAULTMASK bit set).
Doing this requires us to use a different MMU index for "running at execution priority < 0", because we will have different access permissions for that case versus the normal case.
Message-id: [email protected]
--- target/arm/cpu.h | 24 +++++++++++++++++++++++- target/arm/helper.c | 18 +++++++++++++++++- target/arm/translate.c | 1 + 3 files changed, 41 insertions(+), 2 deletions(-)
target/arm/cpu.h +23 -1
@@ -2045,6 +2045,18 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,* for the accesses done as part of a stage 1 page table walk, rather than * having to walk the stage 2 page table over and over.) * +* R profile CPUs have an MPU, but can use the same set of MMU indexes +* as A profile. They only need to distinguish NS EL0 and NS EL1 (and +* NS EL2 if we ever model a Cortex-R52). +* +* M profile CPUs are rather different as they do not have a true MMU. +* They have the following different MMU indexes: +* User +* Privileged +* Execution priority negative (this is like privileged, but the +* MPU HFNMIENA bit means that it may have different access permission +* check results to normal privileged code, so can't share a TLB). +* * The ARMMMUIdx and the mmu index value used by the core QEMU TLB code * are not quite the same -- different CPU types (most notably M profile * vs A/R profile) would like to use MMU indexes with different semantics,
@@ -2080,6 +2092,7 @@ typedef enum ARMMMUIdx { ARMMMUIdx_S2NS =6 |ARM_MMU_IDX_A , ARMMMUIdx_MUser =0 |ARM_MMU_IDX_M , ARMMMUIdx_MPriv =1 |ARM_MMU_IDX_M , + ARMMMUIdx_MNegPri =2 |ARM_MMU_IDX_M ,/* Indexes below here don't have TLBs and are used only for AT system * instructions or for the first stage of an S12 page table walk. */
@@ -2100,6 +2113,7 @@ typedef enum ARMMMUIdxBit { ARMMMUIdxBit_S2NS =1 <<6 , ARMMMUIdxBit_MUser =1 <<0 , ARMMMUIdxBit_MPriv =1 <<1 , + ARMMMUIdxBit_MNegPri =1 <<2 , } ARMMMUIdxBit;#define MMU_USER_IDX 0
@@ -2125,7 +2139,7 @@ static inline int arm_mmu_idx_to_el(ARMMMUIdx mmu_idx)case ARM_MMU_IDX_A :return mmu_idx &3 ;case ARM_MMU_IDX_M : -return mmu_idx &1 ; +return mmu_idx == ARMMMUIdx_MUser ?0 :1 ;default :g_assert_not_reached (); }
@@ -2139,6 +2153,14 @@ static inline int cpu_mmu_index(CPUARMState *env, bool ifetch)if (arm_feature (env,ARM_FEATURE_M )) {ARMMMUIdx mmu_idx = el ==0 ? ARMMMUIdx_MUser : ARMMMUIdx_MPriv; +/* Execution priority is negative if FAULTMASK is set or +* we're in a HardFault or NMI handler. +*/ +if ((env->v7m.exception >0 && env->v7m.exception <=3 ) + || env->daif &PSTATE_F ) { +return arm_to_core_mmu_idx (ARMMMUIdx_MNegPri); + } +return arm_to_core_mmu_idx (mmu_idx); }
target/arm/helper.c +17 -1
@@ -7037,6 +7037,7 @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx)case ARMMMUIdx_S1NSE0:case ARMMMUIdx_S1NSE1:case ARMMMUIdx_MPriv: +case ARMMMUIdx_MNegPri:case ARMMMUIdx_MUser:return 1 ;default :
@@ -7055,6 +7056,7 @@ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx)case ARMMMUIdx_S1E2:case ARMMMUIdx_S2NS:case ARMMMUIdx_MPriv: +case ARMMMUIdx_MNegPri:case ARMMMUIdx_MUser:return false;case ARMMMUIdx_S1E3:
@@ -7077,7 +7079,21 @@ static inline bool regime_translation_disabled(CPUARMState *env, ARMMMUIdx mmu_idx) {if (arm_feature (env,ARM_FEATURE_M )) { -return !(env->v7m.mpu_ctrl &R_V7M_MPU_CTRL_ENABLE_MASK ); +switch (env->v7m.mpu_ctrl & + (R_V7M_MPU_CTRL_ENABLE_MASK |R_V7M_MPU_CTRL_HFNMIENA_MASK )) { +case R_V7M_MPU_CTRL_ENABLE_MASK : +/* Enabled, but not for HardFault and NMI */ +return mmu_idx == ARMMMUIdx_MNegPri; +case R_V7M_MPU_CTRL_ENABLE_MASK |R_V7M_MPU_CTRL_HFNMIENA_MASK : +/* Enabled for all cases */ +return false; +case 0 : +default : +/* HFNMIENA set and ENABLE clear is UNPREDICTABLE, but +* we warned about that in armv7m_nvic.c when the guest set it. +*/ +return true; + } }if (mmu_idx == ARMMMUIdx_S2NS) {
target/arm/translate.c +1 -0
@@ -163,6 +163,7 @@ static inline int get_a32_user_mem_index(DisasContext *s)return arm_to_core_mmu_idx (ARMMMUIdx_S1SE0);case ARMMMUIdx_MUser:case ARMMMUIdx_MPriv: +case ARMMMUIdx_MNegPri:return arm_to_core_mmu_idx (ARMMMUIdx_MUser);case ARMMMUIdx_S2NS:default :
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 20/27] aspeed/i2c: improve command handling
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
Multiple I2C commands can be fired simultaneously and the controller execute the commands following these priorities:
(1) Master Start Command
(2) Master Transmit Command
(3) Slave Transmit Command or Master Receive Command
(4) Master Stop Command
The current code is incorrect with respect to the above sequence and needs to be reworked to handle each individual command.
Message-id: [email protected]
--- hw/i2c/aspeed_i2c.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
hw/i2c/aspeed_i2c.c +18 -6
@@ -171,6 +171,7 @@ static uint64_t aspeed_i2c_bus_read(void *opaque, hwaddr offset,static void aspeed_i2c_bus_handle_cmd (AspeedI2CBus *bus,uint64_t value) { + bus->cmd &= ~0xFFFF ; bus->cmd |= value &0xFFFF ; bus->intr_status =0 ;
@@ -182,15 +183,27 @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) bus->intr_status |=I2CD_INTR_TX_ACK ; } - }else if (bus->cmd &I2CD_M_TX_CMD ) { +/* START command is also a TX command, as the slave address is +* sent on the bus */ + bus->cmd &= ~(I2CD_M_START_CMD |I2CD_M_TX_CMD ); + +/* No slave found */ +if (!i2c_bus_busy (bus->bus)) { +return ; + } + } + +if (bus->cmd &I2CD_M_TX_CMD ) {if (i2c_send (bus->bus, bus->buf)) { bus->intr_status |= (I2CD_INTR_TX_NAK |I2CD_INTR_ABNORMAL );i2c_end_transfer (bus->bus); }else { bus->intr_status |=I2CD_INTR_TX_ACK ; } + bus->cmd &= ~I2CD_M_TX_CMD ; + } - }else if (bus->cmd &I2CD_M_RX_CMD ) { +if (bus->cmd &I2CD_M_RX_CMD ) {int ret =i2c_recv (bus->bus);if (ret <0 ) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: read failed\n" , __func__);
@@ -199,6 +212,7 @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) bus->intr_status |=I2CD_INTR_RX_DONE ; } bus->buf = (ret &I2CD_BYTE_BUF_RX_MASK ) <<I2CD_BYTE_BUF_RX_SHIFT ; + bus->cmd &= ~I2CD_M_RX_CMD ; }if (bus->cmd & (I2CD_M_STOP_CMD |I2CD_M_S_RX_CMD_LAST )) {
@@ -208,11 +222,8 @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value)i2c_end_transfer (bus->bus); bus->intr_status |=I2CD_INTR_NORMAL_STOP ; } + bus->cmd &= ~I2CD_M_STOP_CMD ; } - -/* command is handled, reset it and check for interrupts */ - bus->cmd &= ~0xFFFF ; -aspeed_i2c_bus_raise_interrupt (bus); } static void aspeed_i2c_bus_write(void *opaque, hwaddr offset,
@@ -262,6 +273,7 @@ static void aspeed_i2c_bus_write(void *opaque, hwaddr offset, }aspeed_i2c_bus_handle_cmd (bus, value); +aspeed_i2c_bus_raise_interrupt (bus);break ;default :
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 21/27] aspeed/i2c: handle LAST command under the RX command
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
Today, the LAST command is handled with the STOP command but this is incorrect. Also nack the I2C bus when a LAST is issued.
Message-id: [email protected]
--- hw/i2c/aspeed_i2c.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
hw/i2c/aspeed_i2c.c +6 -3
@@ -203,7 +203,7 @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) bus->cmd &= ~I2CD_M_TX_CMD ; } -if (bus->cmd &I2CD_M_RX_CMD ) { +if (bus->cmd & (I2CD_M_RX_CMD |I2CD_M_S_RX_CMD_LAST )) {int ret =i2c_recv (bus->bus);if (ret <0 ) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: read failed\n" , __func__);
@@ -212,10 +212,13 @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) bus->intr_status |=I2CD_INTR_RX_DONE ; } bus->buf = (ret &I2CD_BYTE_BUF_RX_MASK ) <<I2CD_BYTE_BUF_RX_SHIFT ; - bus->cmd &= ~I2CD_M_RX_CMD ; +if (bus->cmd &I2CD_M_S_RX_CMD_LAST ) { +i2c_nack (bus->bus); + } + bus->cmd &= ~(I2CD_M_RX_CMD |I2CD_M_S_RX_CMD_LAST ); } -if (bus->cmd & (I2CD_M_STOP_CMD |I2CD_M_S_RX_CMD_LAST )) { +if (bus->cmd &I2CD_M_STOP_CMD ) {if (!i2c_bus_busy (bus->bus)) { bus->intr_status |=I2CD_INTR_ABNORMAL ; }else {
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 03/27] hw/intc/arm_gicv3_cpuif: Fix reset value for VMCR_EL2.VBPR1
In reply to Peter MaydellWe were setting the VBPR1 field of VMCR_EL2 to icv_min_vbpr() on reset, but this is not correct. The field should reset to the minimum value of ICV_BPR0_EL1 plus one.
Message-id: [email protected]
--- hw/intc/arm_gicv3_cpuif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/intc/arm_gicv3_cpuif.c +1 -1
@@ -2014,7 +2014,7 @@ static void icc_reset(CPUARMState *env, const ARMCPRegInfo *ri) cs->ich_hcr_el2 =0 ;memset (cs->ich_lr_el2,0 ,sizeof (cs->ich_lr_el2)); cs->ich_vmcr_el2 =ICH_VMCR_EL2_VFIQEN | - (icv_min_vbpr (cs) <<ICH_VMCR_EL2_VBPR1_SHIFT ) | + ((icv_min_vbpr (cs) +1 ) <<ICH_VMCR_EL2_VBPR1_SHIFT ) | (icv_min_vbpr (cs) <<ICH_VMCR_EL2_VBPR0_SHIFT ); }
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 08/27] arm: Add support for M profile CPUs having different MMU index semantics
In reply to Peter MaydellThe M profile CPU's MPU has an awkward corner case which we would like to implement with a different MMU index.
We can avoid having to bump the number of MMU modes ARM uses, because some of our existing MMU indexes are only used by non-M-profile CPUs, so we can borrow one. To avoid that getting too confusing, clean up the code to try to keep the two meanings of the index separate.
Instead of ARMMMUIdx enum values being identical to core QEMU MMU index values, they are now the core index values with some high bits set. Any particular CPU always uses the same high bits (so eventually A profile cores and M profile cores will use different bits). New functions arm_to_core_mmu_idx() and core_to_arm_mmu_idx() convert between the two.
In general core index values are stored in 'int' types, and ARM values are stored in ARMMMUIdx types.
Message-id: [email protected]
--- target/arm/cpu.h | 71 ++++++++++++++++----- target/arm/translate.h | 2 +- target/arm/helper.c | 151 ++++++++++++++++++++++++--------------------- target/arm/op_helper.c | 3 +- target/arm/translate-a64.c | 18 ++++-- target/arm/translate.c | 10 +-- 6 files changed, 156 insertions(+), 99 deletions(-)
target/arm/cpu.h +57 -14
@@ -2039,6 +2039,16 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,* for the accesses done as part of a stage 1 page table walk, rather than * having to walk the stage 2 page table over and over.) * +* The ARMMMUIdx and the mmu index value used by the core QEMU TLB code +* are not quite the same -- different CPU types (most notably M profile +* vs A/R profile) would like to use MMU indexes with different semantics, +* but since we don't ever need to use all of those in a single CPU we +* can avoid setting NB_MMU_MODES to more than 8. The lower bits of +* ARMMMUIdx are the core TLB mmu index, and the higher bits are always +* the same for any particular CPU. +* Variables of type ARMMUIdx are always full values, and the core +* index values are in variables of type 'int'. +* * Our enumeration includes at the end some entries which are not "true" * mmu_idx values in that they don't have corresponding TLBs and are only * valid for doing slow path page table walks.
@@ -2047,28 +2057,61 @@ static inline bool arm_excp_unmasked(CPUState *cs, unsigned int excp_idx,* of the AT/ATS operations. * The values used are carefully arranged to make mmu_idx => EL lookup easy. */ +#define ARM_MMU_IDX_A 0x10/* A profile (and M profile, for the moment) */ +#define ARM_MMU_IDX_NOTLB 0x20/* does not have a TLB */ + +#define ARM_MMU_IDX_TYPE_MASK (~0x7) +#define ARM_MMU_IDX_COREIDX_MASK 0x7 +typedef enum ARMMMUIdx { - ARMMMUIdx_S12NSE0 =0 , - ARMMMUIdx_S12NSE1 =1 , - ARMMMUIdx_S1E2 =2 , - ARMMMUIdx_S1E3 =3 , - ARMMMUIdx_S1SE0 =4 , - ARMMMUIdx_S1SE1 =5 , - ARMMMUIdx_S2NS =6 , + ARMMMUIdx_S12NSE0 =0 |ARM_MMU_IDX_A , + ARMMMUIdx_S12NSE1 =1 |ARM_MMU_IDX_A , + ARMMMUIdx_S1E2 =2 |ARM_MMU_IDX_A , + ARMMMUIdx_S1E3 =3 |ARM_MMU_IDX_A , + ARMMMUIdx_S1SE0 =4 |ARM_MMU_IDX_A , + ARMMMUIdx_S1SE1 =5 |ARM_MMU_IDX_A , + ARMMMUIdx_S2NS =6 |ARM_MMU_IDX_A ,/* Indexes below here don't have TLBs and are used only for AT system * instructions or for the first stage of an S12 page table walk. */ - ARMMMUIdx_S1NSE0 =7 , - ARMMMUIdx_S1NSE1 =8 , + ARMMMUIdx_S1NSE0 =0 |ARM_MMU_IDX_NOTLB , + ARMMMUIdx_S1NSE1 =1 |ARM_MMU_IDX_NOTLB , }ARMMMUIdx ; +/* Bit macros for the core-mmu-index values for each index, +* for use when calling tlb_flush_by_mmuidx() and friends. +*/ +typedef enum ARMMMUIdxBit { + ARMMMUIdxBit_S12NSE0 =1 <<0 , + ARMMMUIdxBit_S12NSE1 =1 <<1 , + ARMMMUIdxBit_S1E2 =1 <<2 , + ARMMMUIdxBit_S1E3 =1 <<3 , + ARMMMUIdxBit_S1SE0 =1 <<4 , + ARMMMUIdxBit_S1SE1 =1 <<5 , + ARMMMUIdxBit_S2NS =1 <<6 , +}ARMMMUIdxBit ; +#define MMU_USER_IDX 0 +static inline int arm_to_core_mmu_idx (ARMMMUIdx mmu_idx) +{ +return mmu_idx &ARM_MMU_IDX_COREIDX_MASK ; +} + +static inline ARMMMUIdx core_to_arm_mmu_idx (CPUARMState *env,int mmu_idx) +{ +return mmu_idx |ARM_MMU_IDX_A ; +} +/* Return the exception level we're running at if this is our mmu_idx */ static inline int arm_mmu_idx_to_el (ARMMMUIdx mmu_idx) { -assert (mmu_idx < ARMMMUIdx_S2NS); -return mmu_idx &3 ; +switch (mmu_idx &ARM_MMU_IDX_TYPE_MASK ) { +case ARM_MMU_IDX_A : +return mmu_idx &3 ; +default : +g_assert_not_reached (); + } }/* Determine the current mmu_idx to use for normal loads/stores */
@@ -2077,7 +2120,7 @@ static inline int cpu_mmu_index(CPUARMState *env, bool ifetch)int el =arm_current_el (env);if (el <2 &&arm_is_secure_below_el3 (env)) { -return ARMMMUIdx_S1SE0 + el; +return arm_to_core_mmu_idx (ARMMMUIdx_S1SE0 + el); }return el; }
@@ -2473,7 +2516,7 @@ static inline uint32_t arm_regime_tbi1(CPUARMState *env, ARMMMUIdx mmu_idx)static inline void cpu_get_tb_cpu_state (CPUARMState *env,target_ulong *pc,target_ulong *cs_base,uint32_t *flags) { -ARMMMUIdx mmu_idx =cpu_mmu_index (env, false); +ARMMMUIdx mmu_idx =core_to_arm_mmu_idx (env,cpu_mmu_index (env, false));if (is_a64 (env)) { *pc = env->pc; *flags =ARM_TBFLAG_AARCH64_STATE_MASK ;
@@ -2498,7 +2541,7 @@ static inline void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, << ARM_TBFLAG_XSCALE_CPAR_SHIFT); } - *flags |= (mmu_idx <<ARM_TBFLAG_MMUIDX_SHIFT ); + *flags |= (arm_to_core_mmu_idx (mmu_idx) <<ARM_TBFLAG_MMUIDX_SHIFT );/* The SS_ACTIVE and PSTATE_SS bits correspond to the state machine * states defined in the ARM ARM for software singlestep:
target/arm/translate.h +1 -1
@@ -88,7 +88,7 @@ static inline int arm_dc_feature(DisasContext *dc, int feature)static inline int get_mem_index (DisasContext *s) { -return s->mmu_idx; +return arm_to_core_mmu_idx (s->mmu_idx); }/* Function used to determine the target exception EL when otherwise not known
target/arm/helper.c +79 -72
369 lines not on this page · raw message
target/arm/op_helper.c +2 -1
@@ -194,6 +194,7 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,int target_el;bool same_el;uint32_t syn; +ARMMMUIdx arm_mmu_idx =core_to_arm_mmu_idx (env, mmu_idx);if (retaddr) {/* now we have a real cpu fault */
@@ -208,7 +209,7 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,/* the DFSR for an alignment fault depends on whether we're using * the LPAE long descriptor format, or the short descriptor format */ -if (arm_s1_regime_using_lpae_format (env, mmu_idx)) { +if (arm_s1_regime_using_lpae_format (env, arm_mmu_idx)) { env->exception.fsr = (1 <<9 ) |0x21 ; }else { env->exception.fsr =0x1 ;
target/arm/translate-a64.c +12 -6
@@ -101,21 +101,27 @@ void a64_translate_init(void) offsetof(CPUARMState, exclusive_high), "exclusive_high"); } -static inline ARMMMUIdx get_a64_user_mem_index (DisasContext *s) +static inline int get_a64_user_mem_index (DisasContext *s) { -/* Return the mmu_idx to use for A64 "unprivileged load/store" insns: +/* Return the core mmu_idx to use for A64 "unprivileged load/store" insns: * if EL1, access as if EL0; otherwise access at current EL */ +ARMMMUIdx useridx; +switch (s->mmu_idx) {case ARMMMUIdx_S12NSE1: -return ARMMMUIdx_S12NSE0; + useridx = ARMMMUIdx_S12NSE0; +break ;case ARMMMUIdx_S1SE1: -return ARMMMUIdx_S1SE0; + useridx = ARMMMUIdx_S1SE0; +break ;case ARMMMUIdx_S2NS:g_assert_not_reached ();default : -return s->mmu_idx; + useridx = s->mmu_idx; +break ; } +return arm_to_core_mmu_idx (useridx); } void aarch64_cpu_dump_state(CPUState *cs, FILE *f,
@@ -11212,7 +11218,7 @@ void gen_intermediate_code_a64(ARMCPU *cpu, TranslationBlock *tb) dc->be_data =ARM_TBFLAG_BE_DATA (tb->flags) ?MO_BE :MO_LE ; dc->condexec_mask =0 ; dc->condexec_cond =0 ; - dc->mmu_idx =ARM_TBFLAG_MMUIDX (tb->flags); + dc->mmu_idx =core_to_arm_mmu_idx (env,ARM_TBFLAG_MMUIDX (tb->flags)); dc->tbi0 =ARM_TBFLAG_TBI0 (tb->flags); dc->tbi1 =ARM_TBFLAG_TBI1 (tb->flags); dc->current_el =arm_mmu_idx_to_el (dc->mmu_idx);
target/arm/translate.c +5 -5
@@ -145,9 +145,9 @@ static void disas_set_da_iss(DisasContext *s, TCGMemOp memop, ISSInfo issinfo)disas_set_insn_syndrome (s, syn); } -static inline ARMMMUIdx get_a32_user_mem_index (DisasContext *s) +static inline int get_a32_user_mem_index (DisasContext *s) { -/* Return the mmu_idx to use for A32/T32 "unprivileged load/store" +/* Return the core mmu_idx to use for A32/T32 "unprivileged load/store" * insns: * if PL2, UNPREDICTABLE (we choose to implement as if PL0) * otherwise, access as if at PL0.
@@ -156,11 +156,11 @@ static inline ARMMMUIdx get_a32_user_mem_index(DisasContext *s)case ARMMMUIdx_S1E2:/* this one is UNPREDICTABLE */ case ARMMMUIdx_S12NSE0:case ARMMMUIdx_S12NSE1: -return ARMMMUIdx_S12NSE0; +return arm_to_core_mmu_idx (ARMMMUIdx_S12NSE0);case ARMMMUIdx_S1E3:case ARMMMUIdx_S1SE0:case ARMMMUIdx_S1SE1: -return ARMMMUIdx_S1SE0; +return arm_to_core_mmu_idx (ARMMMUIdx_S1SE0);case ARMMMUIdx_S2NS:default :g_assert_not_reached ();
@@ -11816,7 +11816,7 @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) dc->be_data =ARM_TBFLAG_BE_DATA (tb->flags) ?MO_BE :MO_LE ; dc->condexec_mask = (ARM_TBFLAG_CONDEXEC (tb->flags) &0xf ) <<1 ; dc->condexec_cond =ARM_TBFLAG_CONDEXEC (tb->flags) >>4 ; - dc->mmu_idx =ARM_TBFLAG_MMUIDX (tb->flags); + dc->mmu_idx =core_to_arm_mmu_idx (env,ARM_TBFLAG_MMUIDX (tb->flags)); dc->current_el =arm_mmu_idx_to_el (dc->mmu_idx);#if !defined(CONFIG_USER_ONLY ) dc->user = (dc->current_el ==0 );
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 23/27] aspeed: add some I2C devices to the Aspeed machines
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
Let's add an RTC to the palmetto BMC and a LM75 temperature sensor to the AST2500 EVB to start with.
Message-id: [email protected]
--- hw/arm/aspeed.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
hw/arm/aspeed.c +27 -0
@@ -39,6 +39,7 @@ typedef struct AspeedBoardConfig {const char *fmc_model;const char *spi_model;uint32_t num_cs; +void (*i2c_init)(AspeedBoardState *bmc); } AspeedBoardConfig;enum {
@@ -82,6 +83,9 @@ enum { SCU_AST2500_HW_STRAP_ACPI_ENABLE | \ SCU_HW_STRAP_SPI_MODE(SCU_HW_STRAP_SPI_MASTER)) +static void palmetto_bmc_i2c_init (AspeedBoardState *bmc); +static void ast2500_evb_i2c_init (AspeedBoardState *bmc); +static const AspeedBoardConfig aspeed_boards[] = { [PALMETTO_BMC ] = { .soc_name ="ast2400-a1" ,
@@ -89,6 +93,7 @@ static const AspeedBoardConfig aspeed_boards[] = { .fmc_model = "n25q256a", .spi_model = "mx25l25635e", .num_cs = 1, + .i2c_init = palmetto_bmc_i2c_init, }, [AST2500_EVB] = { .soc_name = "ast2500-a1",
@@ -96,6 +101,7 @@ static const AspeedBoardConfig aspeed_boards[] = { .fmc_model = "n25q256a", .spi_model = "mx25l25635e", .num_cs = 1, + .i2c_init = ast2500_evb_i2c_init, }, [ROMULUS_BMC] = { .soc_name = "ast2500-a1",
@@ -223,9 +229,22 @@ static void aspeed_board_init(MachineState *machine, aspeed_board_binfo.ram_size = ram_size; aspeed_board_binfo.loader_start = sc->info->sdram_base; +if (cfg->i2c_init) { + cfg->i2c_init (bmc); + } +arm_load_kernel (ARM_CPU (first_cpu), &aspeed_board_binfo); } +static void palmetto_bmc_i2c_init (AspeedBoardState *bmc) +{ +AspeedSoCState *soc = &bmc->soc; + +/* The palmetto platform expects a ds3231 RTC but a ds1338 is +* enough to provide basic RTC features. Alarms will be missing */ +i2c_create_slave (aspeed_i2c_get_bus (DEVICE (&soc->i2c),0 ),"ds1338" ,0x68 ); +} +static void palmetto_bmc_init (MachineState *machine) {aspeed_board_init (machine, &aspeed_boards[PALMETTO_BMC ]);
@@ -250,6 +269,14 @@ static const TypeInfo palmetto_bmc_type = { .class_init = palmetto_bmc_class_init, }; +static void ast2500_evb_i2c_init (AspeedBoardState *bmc) +{ +AspeedSoCState *soc = &bmc->soc; + +/* The AST2500 EVB expects a LM75 but a TMP105 is compatible */ +i2c_create_slave (aspeed_i2c_get_bus (DEVICE (&soc->i2c),7 ),"tmp105" ,0x4d ); +} +static void ast2500_evb_init (MachineState *machine) {aspeed_board_init (machine, &aspeed_boards[AST2500_EVB ]);
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 25/27] aspeed: add a temp sensor device on I2C bus 3
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
Temperatures can be changed from the monitor with :
(qemu) qom-set /machine/unattached/device[2] temperature0 12000
Message-id: [email protected]
--- hw/arm/aspeed.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/arm/aspeed.c +9 -0
@@ -239,10 +239,19 @@ static void aspeed_board_init(MachineState *machine,static void palmetto_bmc_i2c_init (AspeedBoardState *bmc) {AspeedSoCState *soc = &bmc->soc; +DeviceState *dev;/* The palmetto platform expects a ds3231 RTC but a ds1338 is * enough to provide basic RTC features. Alarms will be missing */ i2c_create_slave (aspeed_i2c_get_bus (DEVICE (&soc->i2c),0 ),"ds1338" ,0x68 ); + +/* add a TMP423 temperature sensor */ + dev =i2c_create_slave (aspeed_i2c_get_bus (DEVICE (&soc->i2c),2 ), +"tmp423" ,0x4c ); +object_property_set_int (OBJECT (dev),31000 ,"temperature0" , &error_abort); +object_property_set_int (OBJECT (dev),28000 ,"temperature1" , &error_abort); +object_property_set_int (OBJECT (dev),20000 ,"temperature2" , &error_abort); +object_property_set_int (OBJECT (dev),110000 ,"temperature3" , &error_abort); }static void palmetto_bmc_init (MachineState *machine)
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 24/27] hw/misc: add a TMP42{1, 2, 3} device model
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
Largely inspired by the TMP105 temperature sensor, here is a model for the TMP42{1,2,3} temperature sensors.
Specs can be found here :
http://www.ti.com/lit/gpn/tmp421
Message-id: [email protected]
--- hw/misc/Makefile.objs | 1 + hw/misc/tmp421.c | 401 ++++++++++++++++++++++++++++++++++++++++ default-configs/arm-softmmu.mak | 1 + 3 files changed, 403 insertions(+) create mode 100644 hw/misc/tmp421.c
hw/misc/Makefile.objs +1 -0
@@ -1,6 +1,7 @@ common-obj-$(CONFIG_APPLESMC) += applesmc.o common-obj-$(CONFIG_MAX111X) += max111x.o common-obj-$(CONFIG_TMP105) += tmp105.o +common-obj-$(CONFIG_TMP421) += tmp421.o common-obj-$(CONFIG_ISA_DEBUG) += debugexit.o common-obj-$(CONFIG_SGA) += sga.o common-obj-$(CONFIG_ISA_TESTDEV) += pc-testdev.o
hw/misc/tmp421.c new file +401 -0
401 lines not on this page · raw message
default-configs/arm-softmmu.mak +1 -0
@@ -15,6 +15,7 @@ CONFIG_TWL92230=y CONFIG_TSC2005=y CONFIG_LM832X=y CONFIG_TMP105=y +CONFIG_TMP421=y CONFIG_STELLARIS=y CONFIG_STELLARIS_INPUT=y CONFIG_STELLARIS_ENET=y
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 26/27] hw/arm/virt-acpi-build: build SLIT when needed
In reply to Peter MaydellFrom: Andrew Jones <[email protected]>
Message-id: [email protected]
--- hw/arm/virt-acpi-build.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/arm/virt-acpi-build.c +4 -0
@@ -776,6 +776,10 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)if (nb_numa_nodes >0 ) {acpi_add_table (table_offsets, tables_blob);build_srat (tables_blob, tables->linker, vms); +if (have_numa_distance) { +acpi_add_table (table_offsets, tables_blob); +build_slit (tables_blob, tables->linker); + } }if (its_class_name () && !vmc->no_its) {
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 27/27] hw/arm/virt: fdt: generate distance-map when needed
In reply to Peter MaydellFrom: Andrew Jones <[email protected]>
This is based on patch Shannon Zhao originally posted.
Message-id: [email protected]
--- hw/arm/virt.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
hw/arm/virt.c +21 -0
@@ -219,6 +219,27 @@ static void create_fdt(VirtMachineState *vms) "clk24mhz");qemu_fdt_setprop_cell (fdt,"/apb-pclk" ,"phandle" , vms->clock_phandle); +if (have_numa_distance) { +int size = nb_numa_nodes * nb_numa_nodes *3 *sizeof (uint32_t ); +uint32_t *matrix =g_malloc0 (size); +int idx, i, j; + +for (i =0 ; i < nb_numa_nodes; i++) { +for (j =0 ; j < nb_numa_nodes; j++) { + idx = (i * nb_numa_nodes + j) *3 ; + matrix[idx +0 ] =cpu_to_be32 (i); + matrix[idx +1 ] =cpu_to_be32 (j); + matrix[idx +2 ] =cpu_to_be32 (numa_info[i].distance[j]); + } + } + +qemu_fdt_add_subnode (fdt,"/distance-map" ); +qemu_fdt_setprop_string (fdt,"/distance-map" ,"compatible" , +"numa-distance-map-v1" ); +qemu_fdt_setprop (fdt,"/distance-map" ,"distance-matrix" , + matrix, size); +g_free (matrix); + } }static void fdt_add_psci_node (const VirtMachineState *vms)
Signature · 1 line
2.7.4
[Qemu-devel] [PULL 22/27] aspeed/i2c: introduce a state machine
In reply to Peter MaydellFrom: Cédric Le Goater <[email protected]>
The Aspeed I2C controller maintains a state machine in the command register, which is mostly used for debug.
Let's start adding a few states to handle abnormal STOP commands. Today, the model uses the busy status of the bus as a condition to do so but it is not precise enough.
Also remove the ABNORMAL bit for failing TX commands. This is incorrect with respect to the specs.
Message-id: [email protected]
--- hw/i2c/aspeed_i2c.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-)
hw/i2c/aspeed_i2c.c +33 -3
@@ -169,6 +169,21 @@ static uint64_t aspeed_i2c_bus_read(void *opaque, hwaddr offset, } } +static void aspeed_i2c_set_state (AspeedI2CBus *bus,uint8_t state) +{ + bus->cmd &= ~(I2CD_TX_STATE_MASK <<I2CD_TX_STATE_SHIFT ); + bus->cmd |= (state &I2CD_TX_STATE_MASK ) <<I2CD_TX_STATE_SHIFT ; +} + +static uint8_t aspeed_i2c_get_state (AspeedI2CBus *bus) +{ +return (bus->cmd >>I2CD_TX_STATE_SHIFT ) &I2CD_TX_STATE_MASK ; +} + +/* +* The state machine needs some refinement. It is only used to track +* invalid STOP commands for the moment. +*/ static void aspeed_i2c_bus_handle_cmd (AspeedI2CBus *bus,uint64_t value) { bus->cmd &= ~0xFFFF ;
@@ -176,6 +191,11 @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value) bus->intr_status =0 ;if (bus->cmd &I2CD_M_START_CMD ) { +uint8_t state =aspeed_i2c_get_state (bus) &I2CD_MACTIVE ? +I2CD_MSTARTR :I2CD_MSTART ; + +aspeed_i2c_set_state (bus, state); +if (i2c_start_transfer (bus->bus,extract32 (bus->buf,1 ,7 ),extract32 (bus->buf,0 ,1 ))) { bus->intr_status |=I2CD_INTR_TX_NAK ;
@@ -191,20 +211,26 @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value)if (!i2c_bus_busy (bus->bus)) {return ; } +aspeed_i2c_set_state (bus,I2CD_MACTIVE ); }if (bus->cmd &I2CD_M_TX_CMD ) { +aspeed_i2c_set_state (bus,I2CD_MTXD );if (i2c_send (bus->bus, bus->buf)) { - bus->intr_status |= (I2CD_INTR_TX_NAK |I2CD_INTR_ABNORMAL ); + bus->intr_status |= (I2CD_INTR_TX_NAK );i2c_end_transfer (bus->bus); }else { bus->intr_status |=I2CD_INTR_TX_ACK ; } bus->cmd &= ~I2CD_M_TX_CMD ; +aspeed_i2c_set_state (bus,I2CD_MACTIVE ); }if (bus->cmd & (I2CD_M_RX_CMD |I2CD_M_S_RX_CMD_LAST )) { -int ret =i2c_recv (bus->bus); +int ret; + +aspeed_i2c_set_state (bus,I2CD_MRXD ); + ret =i2c_recv (bus->bus);if (ret <0 ) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: read failed\n" , __func__); ret =0xff ;
@@ -216,16 +242,20 @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value)i2c_nack (bus->bus); } bus->cmd &= ~(I2CD_M_RX_CMD |I2CD_M_S_RX_CMD_LAST ); +aspeed_i2c_set_state (bus,I2CD_MACTIVE ); }if (bus->cmd &I2CD_M_STOP_CMD ) { -if (!i2c_bus_busy (bus->bus)) { +if (!(aspeed_i2c_get_state (bus) &I2CD_MACTIVE )) { +qemu_log_mask (LOG_GUEST_ERROR ,"%s: abnormal stop\n" , __func__); bus->intr_status |=I2CD_INTR_ABNORMAL ; }else { +aspeed_i2c_set_state (bus,I2CD_MSTOP );i2c_end_transfer (bus->bus); bus->intr_status |=I2CD_INTR_NORMAL_STOP ; } bus->cmd &= ~I2CD_M_STOP_CMD ; +aspeed_i2c_set_state (bus,I2CD_IDLE ); } }
Signature · 1 line
2.7.4