target-arm queue
Subsystems (2)
The following changes since commit 4d1e324b2241017c92d816ec3af51a14685dbf62:
Merge remote-tracking branch 'remotes/lalrae/tags/mips-20160226' into staging (2016-02-26 12:54:22 +0000)
are available in the git repository at:
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20160226
for you to fetch changes up to e20d84c1407d43d5a2e2ac95dbb46db3b0af8f9f:
target-arm: Make reserved ranges in ID_AA64* spaces RAZ, not UNDEF (2016-02-26 15:09:42 +0000)
----------------------------------------------------------------
target-arm queue:
* Clean up handling of bad mode switches writing to CPSR, and implement the ARMv8 requirement that they set PSTATE.IL
* Implement MDCR_EL3.TPM and MDCR_EL2.TPM traps on perf monitor register accesses
* Don't implement stellaris-pl061-only registers on generic-pl061
* Fix SD card handling for raspi
* Add missing include files to MAINTAINERS
* Mark CNTHP_TVAL_EL2 as ARM_CP_NO_RAW
* Make reserved ranges in ID_AA64* spaces RAZ, not UNDEF
----------------------------------------------------------------
Andrew Baumann (3):
raspi: fix SD card with recent sdhci changes
sdhci: Revert "add optional quirk property to disable card insertion/removal interrupts"
sdhci: add quirk property for card insert interrupt status on Raspberry Pi
Edgar E. Iglesias (1):
target-arm: Mark CNTHP_TVAL_EL2 as ARM_CP_NO_RAW
Peter Maydell (14):
target-arm: Give CPSR setting on 32-bit exception return its own helper
target-arm: Add write_type argument to cpsr_write()
target-arm: Raw CPSR writes should skip checks and bank switching
linux-user: Use restrictive mask when calling cpsr_write()
target-arm: In cpsr_write() ignore mode switches from User mode
target-arm: Add comment about not implementing NSACR.RFR
target-arm: Add Hyp mode checks to bad_mode_switch()
target-arm: Forbid mode switch to Mon from Secure EL1
target-arm: In v8, make illegal AArch32 mode changes set PSTATE.IL
target-arm: Make mode switches from Hyp via CPS and MRS illegal
target-arm: Make Monitor->NS PL1 mode changes illegal if HCR.TGE is 1
target-arm: Fix handling of SDCR for 32-bit code
target-arm: Implement MDCR_EL3.TPM and MDCR_EL2.TPM traps
target-arm: Make reserved ranges in ID_AA64* spaces RAZ, not UNDEF
Thomas Huth (1):
MAINTAINERS: Add some missing ARM related header files
Wei Huang (1):
ARM: PL061: Checking register r/w accesses to reserved area
MAINTAINERS | 4 + hw/arm/bcm2835_peripherals.c | 7 ++ hw/arm/bcm2836.c | 7 ++ hw/arm/raspi.c | 16 +++ hw/gpio/pl061.c | 30 ++++-- hw/sd/sdhci.c | 47 ++++++-- include/hw/sd/sdhci.h | 3 +- linux-user/arm/nwfpe/fpa11.h | 2 +- linux-user/main.c | 7 +- linux-user/signal.c | 4 +- target-arm/cpu-qom.h | 1 + target-arm/cpu.h | 17 ++- target-arm/gdbstub.c | 2 +- target-arm/helper.c | 250 +++++++++++++++++++++++++++++++++++++------ target-arm/helper.h | 1 + target-arm/kvm32.c | 2 +- target-arm/kvm64.c | 3 +- target-arm/machine.c | 4 +- target-arm/op_helper.c | 15 ++- target-arm/translate.c | 6 +- 20 files changed, 359 insertions(+), 69 deletions(-)
[Qemu-devel] [PULL 05/20] target-arm: In cpsr_write() ignore mode switches from User mode
The only case where we can attempt a cpsr_write() mode switch from User is from the gdbstub; all other cases are handled in the calling code (notably translate.c). Architecturally attempts to alter the mode bits from user mode are simply ignored (and not treated as a bad mode switch, which in v8 sets CPSR.IL). Make mode switches from User ignored in cpsr_write() as well, for consistency.
Message-id: [email protected]
--- target-arm/helper.c | 1 + 1 file changed, 1 insertion(+)
target-arm/helper.c +1 -0
@@ -5316,6 +5316,7 @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, env->daif |= val &CPSR_AIF & mask;if (write_type != CPSRWriteRaw && + (env->uncached_cpsr &CPSR_M ) !=CPSR_USER && ((env->uncached_cpsr ^ val) & mask &CPSR_M )) {if (bad_mode_switch (env, val &CPSR_M )) {/* Attempt to switch to an invalid mode: this is UNPREDICTABLE.
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 06/20] target-arm: Add comment about not implementing NSACR.RFR
In reply to Peter MaydellQEMU doesn't implement the NSACR.RFR bit, which is a permitted IMPDEF in choice in ARMv7 and the only permitted choice in ARMv8. Add a comment to bad_mode_switch() to note that this is why FIQ is always a valid mode regardless of the CPU's Secure state.
Message-id: [email protected]
--- target-arm/helper.c | 3 +++ 1 file changed, 3 insertions(+)
target-arm/helper.c +3 -0
@@ -5214,6 +5214,9 @@ static int bad_mode_switch(CPUARMState *env, int mode)case ARM_CPU_MODE_UND :case ARM_CPU_MODE_IRQ :case ARM_CPU_MODE_FIQ : +/* Note that we don't implement the IMPDEF NSACR.RFR which in v7 +* allows FIQ mode to be Secure-only. (In v8 this doesn't exist.) +*/ return 0 ;case ARM_CPU_MODE_MON :return !arm_is_secure (env);
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 01/20] target-arm: Give CPSR setting on 32-bit exception return its own helper
In reply to Peter MaydellThe rules for setting the CPSR on a 32-bit exception return are subtly different from those for setting the CPSR via an instruction like MSR or CPS. (In particular, in Hyp mode changing the mode bits is not valid via MSR or CPS.) Split the exception-return case into its own helper for setting CPSR, so we can eventually handle them differently in the helper function.
Message-id: [email protected]
--- target-arm/helper.h | 1 + target-arm/op_helper.c | 6 ++++++ target-arm/translate.c | 6 +++--- 3 files changed, 10 insertions(+), 3 deletions(-)
target-arm/helper.h +1 -0
@@ -57,6 +57,7 @@ DEF_HELPER_2(pre_smc, void, env, i32) DEF_HELPER_1(check_breakpoints, void, env) DEF_HELPER_3(cpsr_write, void, env, i32, i32) +DEF_HELPER_2(cpsr_write_eret, void, env, i32) DEF_HELPER_1(cpsr_read, i32, env)DEF_HELPER_3 (v7m_msr, void, env, i32, i32)
target-arm/op_helper.c +6 -0
@@ -425,6 +425,12 @@ void HELPER(cpsr_write)(CPUARMState *env, uint32_t val, uint32_t mask)cpsr_write (env, val, mask); } +/* Write the CPSR for a 32-bit exception return */ +void HELPER (cpsr_write_eret )(CPUARMState *env,uint32_t val) +{ +cpsr_write (env, val,CPSR_ERET_MASK ); +} +/* Access to user mode registers from privileged modes. */ uint32_t HELPER (get_user_reg )(CPUARMState *env,uint32_t regno) {
target-arm/translate.c +3 -3
@@ -4094,7 +4094,7 @@ static void gen_exception_return(DisasContext *s, TCGv_i32 pc)TCGv_i32 tmp;store_reg (s,15 , pc); tmp =load_cpu_field (spsr); -gen_set_cpsr (tmp,CPSR_ERET_MASK ); +gen_helper_cpsr_write_eret (cpu_env, tmp);tcg_temp_free_i32 (tmp); s->is_jmp =DISAS_JUMP ; }
@@ -4102,7 +4102,7 @@ static void gen_exception_return(DisasContext *s, TCGv_i32 pc)/* Generate a v6 exception return. Marks both values as dead. */ static void gen_rfe (DisasContext *s,TCGv_i32 pc,TCGv_i32 cpsr) { -gen_set_cpsr (cpsr,CPSR_ERET_MASK ); +gen_helper_cpsr_write_eret (cpu_env, cpsr);tcg_temp_free_i32 (cpsr);store_reg (s,15 , pc); s->is_jmp =DISAS_JUMP ;
@@ -9094,7 +9094,7 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)if (exc_return) {/* Restore CPSR from SPSR. */ tmp =load_cpu_field (spsr); -gen_set_cpsr (tmp,CPSR_ERET_MASK ); +gen_helper_cpsr_write_eret (cpu_env, tmp);tcg_temp_free_i32 (tmp); s->is_jmp =DISAS_JUMP ; }
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 03/20] target-arm: Raw CPSR writes should skip checks and bank switching
In reply to Peter MaydellRaw CPSR writes should skip the architectural checks for whether we're allowed to set the A or F bits and should also not do the switching of register banks if the mode changes. Handle this inside cpsr_write(), which allows us to drop the "manually set the mode bits to avoid the bank switch" code from all the callsites which are using CPSRWriteRaw.
This fixes a bug in 32-bit KVM handling where we had forgotten the "manually set the mode bits" part and could thus potentially trash the register state if the mode from the last exit to userspace differed from the mode on this exit.
Message-id: [email protected]
--- target-arm/helper.c | 5 +++-- target-arm/kvm64.c | 1 - target-arm/machine.c | 2 -- target-arm/op_helper.c | 5 ++++- 4 files changed, 7 insertions(+), 6 deletions(-)
target-arm/helper.c +3 -2
@@ -5268,7 +5268,7 @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask,* In a V8 implementation, it is permitted for privileged software to * change the CPSR A/F bits regardless of the SCR.AW/FW bits. */ -if (!arm_feature (env,ARM_FEATURE_V8 ) && +if (write_type != CPSRWriteRaw && !arm_feature (env,ARM_FEATURE_V8 ) &&arm_feature (env,ARM_FEATURE_EL3 ) && !arm_feature (env,ARM_FEATURE_EL2 ) && !arm_is_secure (env)) {
@@ -5315,7 +5315,8 @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, env->daif &= ~(CPSR_AIF & mask); env->daif |= val &CPSR_AIF & mask; -if ((env->uncached_cpsr ^ val) & mask &CPSR_M ) { +if (write_type != CPSRWriteRaw && + ((env->uncached_cpsr ^ val) & mask &CPSR_M )) {if (bad_mode_switch (env, val &CPSR_M )) {/* Attempt to switch to an invalid mode: this is UNPREDICTABLE. * We choose to ignore the attempt and leave the CPSR M field
target-arm/kvm64.c +0 -1
@@ -722,7 +722,6 @@ int kvm_arch_get_registers(CPUState *cs)if (is_a64 (env)) {pstate_write (env, val); }else { - env->uncached_cpsr = val &CPSR_M ;cpsr_write (env, val,0xffffffff , CPSRWriteRaw); }
target-arm/machine.c +0 -2
@@ -173,8 +173,6 @@ static int get_cpsr(QEMUFile *f, void *opaque, size_t size)return 0 ; } -/* Avoid mode switch when restoring CPSR */ - env->uncached_cpsr = val &CPSR_M ;cpsr_write (env, val,0xffffffff , CPSRWriteRaw);return 0 ; }
target-arm/op_helper.c +4 -1
@@ -779,7 +779,10 @@ void HELPER(exception_return)(CPUARMState *env)if (!return_to_aa64) { env->aarch64 =0 ; - env->uncached_cpsr = spsr &CPSR_M ; +/* We do a raw CPSR write because aarch64_sync_64_to_32() +* will sort the register banks out for us, and we've already +* caught all the bad-mode cases in el_from_spsr(). +*/ cpsr_write (env, spsr, ~0 , CPSRWriteRaw);if (!arm_singlestep_active (env)) { env->uncached_cpsr &= ~PSTATE_SS ;
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 08/20] target-arm: Forbid mode switch to Mon from Secure EL1
In reply to Peter MaydellIn v8 trying to switch mode to Mon from Secure EL1 is an illegal mode switch. (In v7 this is impossible as all secure modes except User are at EL3.) We can handle this case by making a switch to Mon valid only if the current EL is 3, which then gives the correct answer whether EL3 is AArch32 or AArch64.
Message-id: [email protected]
--- target-arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-arm/helper.c +1 -1
@@ -5222,7 +5222,7 @@ static int bad_mode_switch(CPUARMState *env, int mode)return !arm_feature (env,ARM_FEATURE_EL2 ) ||arm_current_el (env) <2 ||arm_is_secure (env);case ARM_CPU_MODE_MON : -return !arm_is_secure (env); +return arm_current_el (env) <3 ;default :return 1 ; }
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 10/20] target-arm: Make mode switches from Hyp via CPS and MRS illegal
In reply to Peter MaydellMode switches from Hyp to any other mode via the CPS and MRS instructions are illegal mode switches (though obviously switching via exception return is valid). Add this check to bad_mode_switch().
Message-id: [email protected]
--- target-arm/helper.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
target-arm/helper.c +10 -2
@@ -5200,12 +5200,20 @@ void arm_cp_reset_ignore(CPUARMState *env, const ARMCPRegInfo *opaque)/* Helper coprocessor reset function for do-nothing-on-reset registers */ } -static int bad_mode_switch (CPUARMState *env,int mode) +static int bad_mode_switch (CPUARMState *env,int mode,CPSRWriteType write_type) {/* Return true if it is not valid for us to switch to * this CPU mode (ie all the UNPREDICTABLE cases in * the ARM ARM CPSRWriteByInstr pseudocode). */ + +/* Changes to or from Hyp via MSR and CPS are illegal. */ +if (write_type == CPSRWriteByInstr && + ((env->uncached_cpsr &CPSR_M ) ==ARM_CPU_MODE_HYP || + mode ==ARM_CPU_MODE_HYP )) { +return 1 ; + } +switch (mode) {case ARM_CPU_MODE_USR :case ARM_CPU_MODE_SYS :
@@ -5324,7 +5332,7 @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask,if (write_type != CPSRWriteRaw && (env->uncached_cpsr &CPSR_M ) !=CPSR_USER && ((env->uncached_cpsr ^ val) & mask &CPSR_M )) { -if (bad_mode_switch (env, val &CPSR_M )) { +if (bad_mode_switch (env, val &CPSR_M , write_type)) {/* Attempt to switch to an invalid mode: this is UNPREDICTABLE in * v7, and has defined behaviour in v8: * + leave CPSR.M untouched
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 11/20] target-arm: Make Monitor->NS PL1 mode changes illegal if HCR.TGE is 1
In reply to Peter MaydellIf HCR.TGE is 1 then mode changes via CPS and MSR from Monitor to NonSecure PL1 modes are illegal mode changes. Implement this check in bad_mode_switch().
(We don't currently implement HCR.TGE, but this is the only missing check from the v8 ARM ARM G1.9.3 and so it's worth adding now; the rest of the HCR.TGE checks can be added later as necessary.)
Message-id: [email protected]
--- target-arm/helper.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
target-arm/helper.c +10 -0
@@ -5216,6 +5216,7 @@ static int bad_mode_switch(CPUARMState *env, int mode, CPSRWriteType write_type)switch (mode) {case ARM_CPU_MODE_USR : +return 0 ;case ARM_CPU_MODE_SYS :case ARM_CPU_MODE_SVC :case ARM_CPU_MODE_ABT :
@@ -5225,6 +5226,15 @@ static int bad_mode_switch(CPUARMState *env, int mode, CPSRWriteType write_type)/* Note that we don't implement the IMPDEF NSACR.RFR which in v7 * allows FIQ mode to be Secure-only. (In v8 this doesn't exist.) */ +/* If HCR.TGE is set then changes from Monitor to NS PL1 via MSR +* and CPS are treated as illegal mode changes. +*/ +if (write_type == CPSRWriteByInstr && + (env->cp15.hcr_el2 &HCR_TGE ) && + (env->uncached_cpsr &CPSR_M ) ==ARM_CPU_MODE_MON && + !arm_is_secure_below_el3 (env)) { +return 1 ; + }return 0 ;case ARM_CPU_MODE_HYP :return !arm_feature (env,ARM_FEATURE_EL2 )
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 02/20] target-arm: Add write_type argument to cpsr_write()
In reply to Peter MaydellAdd an argument to cpsr_write() to indicate what kind of CPSR write is being requested, since the exact behaviour should differ for the different cases.
Message-id: [email protected]
--- linux-user/arm/nwfpe/fpa11.h | 2 +- linux-user/main.c | 6 +++--- linux-user/signal.c | 4 ++-- target-arm/cpu.h | 13 +++++++++++-- target-arm/gdbstub.c | 2 +- target-arm/helper.c | 3 ++- target-arm/kvm32.c | 2 +- target-arm/kvm64.c | 2 +- target-arm/machine.c | 2 +- target-arm/op_helper.c | 6 +++--- 10 files changed, 26 insertions(+), 16 deletions(-)
linux-user/arm/nwfpe/fpa11.h +1 -1
@@ -105,7 +105,7 @@ static inline void writeRegister(unsigned int x, unsigned int y)static inline void writeConditionCodes (unsigned int x) { -cpsr_write (user_registers,x,CPSR_NZCV ); +cpsr_write (user_registers, x,CPSR_NZCV , CPSRWriteByInstr); }#define ARM_REG_PC 15
linux-user/main.c +3 -3
@@ -513,7 +513,7 @@ static void arm_kernel_cmpxchg64_helper(CPUARMState *env) env->regs[0 ] =-1 ; cpsr &= ~CPSR_C ; } -cpsr_write (env, cpsr,CPSR_C ); +cpsr_write (env, cpsr,CPSR_C , CPSRWriteByInstr);end_exclusive ();return ;
@@ -562,7 +562,7 @@ do_kernel_trap(CPUARMState *env) env->regs[0 ] =-1 ; cpsr &= ~CPSR_C ; } -cpsr_write (env, cpsr,CPSR_C ); +cpsr_write (env, cpsr,CPSR_C , CPSRWriteByInstr);end_exclusive ();break ;case 0xffff0fe0 :/* __kernel_get_tls */
@@ -4446,7 +4446,7 @@ int main(int argc, char **argv, char **envp)#elif defined(TARGET_ARM ) {int i; -cpsr_write (env, regs->uregs[16 ],0xffffffff ); +cpsr_write (env, regs->uregs[16 ],0xffffffff , CPSRWriteByInstr);for (i =0 ; i <16 ; i++) { env->regs[i] = regs->uregs[i]; }
linux-user/signal.c +2 -2
@@ -1611,7 +1611,7 @@ setup_return(CPUARMState *env, struct target_sigaction *ka, env->regs[13 ] = frame_addr; env->regs[14 ] = retcode; env->regs[15 ] = handler & (thumb ? ~1 : ~3 ); -cpsr_write (env, cpsr,0xffffffff ); +cpsr_write (env, cpsr,0xffffffff , CPSRWriteByInstr); }static abi_ulong *setup_sigframe_v2_vfp (abi_ulong *regspace,CPUARMState *env)
@@ -1843,7 +1843,7 @@ restore_sigcontext(CPUARMState *env, struct target_sigcontext *sc)__get_user (env->regs[15 ], &sc->arm_pc);#ifdef TARGET_CONFIG_CPU_32 __get_user (cpsr, &sc->arm_cpsr); -cpsr_write (env, cpsr,CPSR_USER |CPSR_EXEC ); +cpsr_write (env, cpsr,CPSR_USER |CPSR_EXEC , CPSRWriteByInstr);#endif err |= !valid_user_regs (env);
target-arm/cpu.h +11 -2
@@ -718,8 +718,17 @@ static inline void pstate_write(CPUARMState *env, uint32_t val)/* Return the current CPSR value. */ uint32_t cpsr_read (CPUARMState *env); -/* Set the CPSR. Note that some bits of mask must be all-set or all-clear. */ -void cpsr_write (CPUARMState *env,uint32_t val,uint32_t mask); + +typedef enum CPSRWriteType { + CPSRWriteByInstr =0 ,/* from guest MSR or CPS */ + CPSRWriteExceptionReturn =1 ,/* from guest exception return insn */ + CPSRWriteRaw =2 ,/* trust values, do not switch reg banks */ + CPSRWriteByGDBStub =3 ,/* from the GDB stub */ +}CPSRWriteType ; + +/* Set the CPSR. Note that some bits of mask must be all-set or all-clear.*/ +void cpsr_write (CPUARMState *env,uint32_t val,uint32_t mask, +CPSRWriteType write_type);/* Return the current xPSR value. */ static inline uint32_t xpsr_read (CPUARMState *env)
target-arm/gdbstub.c +1 -1
@@ -94,7 +94,7 @@ int arm_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)return 4 ;case 25 :/* CPSR */ -cpsr_write (env, tmp,0xffffffff ); +cpsr_write (env, tmp,0xffffffff , CPSRWriteByGDBStub);return 4 ; }/* Unknown register. */
target-arm/helper.c +2 -1
@@ -5233,7 +5233,8 @@ uint32_t cpsr_read(CPUARMState *env) | (env->GE << 16) | (env->daif & CPSR_AIF); } -void cpsr_write (CPUARMState *env,uint32_t val,uint32_t mask) +void cpsr_write (CPUARMState *env,uint32_t val,uint32_t mask, +CPSRWriteType write_type) {uint32_t changed_daif;
target-arm/kvm32.c +1 -1
@@ -428,7 +428,7 @@ int kvm_arch_get_registers(CPUState *cs)if (ret) {return ret; } -cpsr_write (env, cpsr,0xffffffff ); +cpsr_write (env, cpsr,0xffffffff , CPSRWriteRaw);/* Make sure the current mode regs are properly set */ mode = env->uncached_cpsr &CPSR_M ;
target-arm/kvm64.c +1 -1
@@ -723,7 +723,7 @@ int kvm_arch_get_registers(CPUState *cs)pstate_write (env, val); }else { env->uncached_cpsr = val &CPSR_M ; -cpsr_write (env, val,0xffffffff ); +cpsr_write (env, val,0xffffffff , CPSRWriteRaw); }/* KVM puts SP_EL0 in regs.sp and SP_EL1 in regs.sp_el1. On the
target-arm/machine.c +1 -1
@@ -175,7 +175,7 @@ static int get_cpsr(QEMUFile *f, void *opaque, size_t size)/* Avoid mode switch when restoring CPSR */ env->uncached_cpsr = val &CPSR_M ; -cpsr_write (env, val,0xffffffff ); +cpsr_write (env, val,0xffffffff , CPSRWriteRaw);return 0 ; }
target-arm/op_helper.c +3 -3
@@ -422,13 +422,13 @@ uint32_t HELPER(cpsr_read)(CPUARMState *env)void HELPER (cpsr_write )(CPUARMState *env,uint32_t val,uint32_t mask) { -cpsr_write (env, val, mask); +cpsr_write (env, val, mask, CPSRWriteByInstr); }/* Write the CPSR for a 32-bit exception return */ void HELPER (cpsr_write_eret )(CPUARMState *env,uint32_t val) { -cpsr_write (env, val,CPSR_ERET_MASK ); +cpsr_write (env, val,CPSR_ERET_MASK , CPSRWriteExceptionReturn); }/* Access to user mode registers from privileged modes. */
@@ -780,7 +780,7 @@ void HELPER(exception_return)(CPUARMState *env)if (!return_to_aa64) { env->aarch64 =0 ; env->uncached_cpsr = spsr &CPSR_M ; -cpsr_write (env, spsr, ~0 ); +cpsr_write (env, spsr, ~0 , CPSRWriteRaw);if (!arm_singlestep_active (env)) { env->uncached_cpsr &= ~PSTATE_SS ; }
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 12/20] target-arm: Fix handling of SDCR for 32-bit code
In reply to Peter MaydellFix two issues with our implementation of the SDCR:
* it is only present from ARMv8 onwards
* it does not contain several of the trap bits present in its 64-bit counterpart the MDCR_EL3
Put the register description in the right place so that it does not get enabled for ARMv7 and earlier, and give it a write function so that we can mask out the bits which should not be allowed to have an effect if EL3 is 32-bit.
Message-id: [email protected]
--- target-arm/cpu.h | 4 ++++ target-arm/helper.c | 23 +++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-)
target-arm/cpu.h +4 -0
@@ -598,6 +598,7 @@ void pmccntr_sync(CPUARMState *env);#define MDCR_EDAD (1U << 20)#define MDCR_SPME (1U << 17)#define MDCR_SDD (1U << 16) +#define MDCR_SPD (3U << 14)#define MDCR_TDRA (1U << 11)#define MDCR_TDOSA (1U << 10)#define MDCR_TDA (1U << 9)
@@ -606,6 +607,9 @@ void pmccntr_sync(CPUARMState *env);#define MDCR_TPM (1U << 6)#define MDCR_TPMCR (1U << 5) +/* Not all of the MDCR_EL3 bits are present in the 32-bit SDCR */ +#define SDCR_VALID_MASK (MDCR_EPMAD | MDCR_EDAD | MDCR_SPME | MDCR_SPD) +#define CPSR_M (0x1fU)#define CPSR_T (1U << 5)#define CPSR_F (1U << 6)
target-arm/helper.c +15 -8
@@ -3037,6 +3037,12 @@ static CPAccessResult fpexc32_access(CPUARMState *env, const ARMCPRegInfo *ri,return CP_ACCESS_OK ; } +static void sdcr_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ + env->cp15.mdcr_el3 = value &SDCR_VALID_MASK ; +} +static const ARMCPRegInfo v8_cp_reginfo[] = {/* Minimal set of EL0-visible registers. This will need to be expanded * significantly for system emulation of AArch64 CPUs.
@@ -3331,6 +3337,15 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 3, .opc2 = 3, .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[BANK_FIQ]) }, + { .name = "MDCR_EL3", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 3, .opc2 = 1, + .resetvalue = 0, + .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.mdcr_el3) }, + { .name = "SDCR", .type = ARM_CP_ALIAS, + .cp = 15, .opc1 = 0, .crn = 1, .crm = 3, .opc2 = 1, + .access = PL1_RW, .accessfn = access_trap_aa32s_el1, + .writefn = sdcr_write, + .fieldoffset = offsetoflow32(CPUARMState, cp15.mdcr_el3) }, REGINFO_SENTINEL };
@@ -3688,14 +3703,6 @@ static const ARMCPRegInfo el3_cp_reginfo[] = { .access = PL1_RW, .accessfn = access_trap_aa32s_el1, .fieldoffset = offsetoflow32(CPUARMState, cp15.scr_el3), .writefn = scr_write }, - { .name = "MDCR_EL3", .state = ARM_CP_STATE_AA64, - .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 3, .opc2 = 1, - .resetvalue = 0, - .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.mdcr_el3) }, - { .name = "SDCR", .type = ARM_CP_ALIAS, - .cp = 15, .opc1 = 0, .crn = 1, .crm = 3, .opc2 = 1, - .access = PL1_RW, .accessfn = access_trap_aa32s_el1, - .fieldoffset = offsetoflow32(CPUARMState, cp15.mdcr_el3) }, { .name = "SDER32_EL3", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 1, .opc2 = 1, .access = PL3_RW, .resetvalue = 0,
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 13/20] target-arm: Implement MDCR_EL3.TPM and MDCR_EL2.TPM traps
In reply to Peter MaydellImplement the performance monitor register traps controlled by MDCR_EL3.TPM and MDCR_EL2.TPM. Most of the performance registers already have an access function to deal with the user-enable bit, and the TPM checks can be added there. We also need a new access function which only implements the TPM checks for use by the few not-EL0-accessible registers and by PMUSERENR_EL0 (which is always EL0-readable).
Message-id: [email protected]
--- target-arm/helper.c | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-)
target-arm/helper.c +36 -7
@@ -439,6 +439,24 @@ static CPAccessResult access_tda(CPUARMState *env, const ARMCPRegInfo *ri,return CP_ACCESS_OK ; } +/* Check for traps to performance monitor registers, which are controlled +* by MDCR_EL2.TPM for EL2 and MDCR_EL3.TPM for EL3. +*/ +static CPAccessResult access_tpm (CPUARMState *env,const ARMCPRegInfo *ri, +bool isread) +{ +int el =arm_current_el (env); + +if (el <2 && (env->cp15.mdcr_el2 &MDCR_TPM ) + && !arm_is_secure_below_el3 (env)) { +return CP_ACCESS_TRAP_EL2 ; + } +if (el <3 && (env->cp15.mdcr_el3 &MDCR_TPM )) { +return CP_ACCESS_TRAP_EL3 ; + } +return CP_ACCESS_OK ; +} +static void dacr_write (CPUARMState *env,const ARMCPRegInfo *ri,uint64_t value) {ARMCPU *cpu =arm_env_get_cpu (env);
@@ -774,11 +792,22 @@ static CPAccessResult pmreg_access(CPUARMState *env, const ARMCPRegInfo *ri, bool isread) {/* Performance monitor registers user accessibility is controlled -* by PMUSERENR. +* by PMUSERENR. MDCR_EL2.TPM and MDCR_EL3.TPM allow configurable +* trapping to EL2 or EL3 for other accesses. */ -if (arm_current_el (env) ==0 && !env->cp15.c9_pmuserenr) { +int el =arm_current_el (env); + +if (el ==0 && !env->cp15.c9_pmuserenr) {return CP_ACCESS_TRAP ; } +if (el <2 && (env->cp15.mdcr_el2 &MDCR_TPM ) + && !arm_is_secure_below_el3 (env)) { +return CP_ACCESS_TRAP_EL2 ; + } +if (el <3 && (env->cp15.mdcr_el3 &MDCR_TPM )) { +return CP_ACCESS_TRAP_EL3 ; + } +return CP_ACCESS_OK ; }
@@ -1101,28 +1130,28 @@ static const ARMCPRegInfo v7_cp_reginfo[] = { .access = PL0_RW, .type = ARM_CP_CONST, .resetvalue = 0, .accessfn = pmreg_access }, { .name = "PMUSERENR", .cp = 15, .crn = 9, .crm = 14, .opc1 = 0, .opc2 = 0, - .access = PL0_R | PL1_RW, + .access = PL0_R | PL1_RW, .accessfn = access_tpm, .fieldoffset = offsetof(CPUARMState, cp15.c9_pmuserenr), .resetvalue = 0, .writefn = pmuserenr_write, .raw_writefn = raw_write }, { .name = "PMUSERENR_EL0", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 3, .crn = 9, .crm = 14, .opc2 = 0, - .access = PL0_R | PL1_RW, .type = ARM_CP_ALIAS, + .access = PL0_R | PL1_RW, .accessfn = access_tpm, .type = ARM_CP_ALIAS, .fieldoffset = offsetof(CPUARMState, cp15.c9_pmuserenr), .resetvalue = 0, .writefn = pmuserenr_write, .raw_writefn = raw_write }, { .name = "PMINTENSET", .cp = 15, .crn = 9, .crm = 14, .opc1 = 0, .opc2 = 1, - .access = PL1_RW, + .access = PL1_RW, .accessfn = access_tpm, .fieldoffset = offsetof(CPUARMState, cp15.c9_pminten), .resetvalue = 0, .writefn = pmintenset_write, .raw_writefn = raw_write }, { .name = "PMINTENCLR", .cp = 15, .crn = 9, .crm = 14, .opc1 = 0, .opc2 = 2, - .access = PL1_RW, .type = ARM_CP_ALIAS, + .access = PL1_RW, .accessfn = access_tpm, .type = ARM_CP_ALIAS, .fieldoffset = offsetof(CPUARMState, cp15.c9_pminten), .writefn = pmintenclr_write, }, { .name = "PMINTENCLR_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 9, .crm = 14, .opc2 = 2, - .access = PL1_RW, .type = ARM_CP_ALIAS, + .access = PL1_RW, .accessfn = access_tpm, .type = ARM_CP_ALIAS, .fieldoffset = offsetof(CPUARMState, cp15.c9_pminten), .writefn = pmintenclr_write }, { .name = "VBAR", .state = ARM_CP_STATE_BOTH,
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 14/20] ARM: PL061: Checking register r/w accesses to reserved area
In reply to Peter MaydellFrom: Wei Huang <[email protected]>
pl061.c emulates two GPIO devices, ARM PL061 and TI Stellaris, which share the same read/write functions (pl061_read and pl061_write). However PL061 and Stellaris have different GPIO register definitions and pl061_read()/pl061_write() doesn't check it. This patch enforces checking on offset, preventing R/W into the reserved memory area.
Message-id: [email protected]
--- hw/gpio/pl061.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-)
hw/gpio/pl061.c +22 -8
@@ -60,6 +60,7 @@ typedef struct PL061State {qemu_irq irq;qemu_irq out[8 ];const unsigned char *id; +uint32_t rsvd_start;/* reserved area: [rsvd_start, 0xfcc] */ } PL061State;static const VMStateDescription vmstate_pl061 = {
@@ -152,12 +153,15 @@ static uint64_t pl061_read(void *opaque, hwaddr offset, {PL061State *s = (PL061State *)opaque; -if (offset >=0xfd0 && offset <0x1000 ) { -return s->id[(offset -0xfd0 ) >>2 ]; - }if (offset <0x400 ) {return s->data & (offset >>2 ); } +if (offset >= s->rsvd_start && offset <=0xfcc ) { + goto err_out; + } +if (offset >=0xfd0 && offset <0x1000 ) { +return s->id[(offset -0xfd0 ) >>2 ]; + }switch (offset) {case 0x400 :/* Direction */ return s->dir;
@@ -198,10 +202,12 @@ static uint64_t pl061_read(void *opaque, hwaddr offset,case 0x528 :/* Analog mode select */ return s->amsel;default : -qemu_log_mask (LOG_GUEST_ERROR , -"pl061_read: Bad offset %x\n" , (int )offset); -return 0 ; +break ; } +err_out: +qemu_log_mask (LOG_GUEST_ERROR , +"pl061_read: Bad offset %x\n" , (int )offset); +return 0 ; } static void pl061_write(void *opaque, hwaddr offset,
@@ -216,6 +222,9 @@ static void pl061_write(void *opaque, hwaddr offset,pl061_update (s);return ; } +if (offset >= s->rsvd_start) { + goto err_out; + }switch (offset) {case 0x400 :/* Direction */ s->dir = value &0xff ;
@@ -274,10 +283,13 @@ static void pl061_write(void *opaque, hwaddr offset, s->amsel = value &0xff ;break ;default : -qemu_log_mask (LOG_GUEST_ERROR , -"pl061_write: Bad offset %x\n" , (int )offset); + goto err_out; }pl061_update (s); +return ; +err_out: +qemu_log_mask (LOG_GUEST_ERROR , +"pl061_write: Bad offset %x\n" , (int )offset); }static void pl061_reset (DeviceState *dev)
@@ -347,6 +359,7 @@ static void pl061_luminary_init(Object *obj)PL061State *s =PL061 (obj); s->id = pl061_id_luminary; + s->rsvd_start =0x52c ; }static void pl061_init (Object *obj)
@@ -354,6 +367,7 @@ static void pl061_init(Object *obj)PL061State *s =PL061 (obj); s->id = pl061_id; + s->rsvd_start =0x424 ; }static void pl061_class_init (ObjectClass *klass,void *data)
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 15/20] raspi: fix SD card with recent sdhci changes
In reply to Peter MaydellFrom: Andrew Baumann <[email protected]>
Recent changes to sdhci broke SD on raspi. This change mirrors the logic to create the SD card device at the board level.
Message-id: [email protected]
--- hw/arm/bcm2835_peripherals.c | 7 +++++++ hw/arm/bcm2836.c | 7 +++++++ hw/arm/raspi.c | 16 ++++++++++++++++ 3 files changed, 30 insertions(+)
hw/arm/bcm2835_peripherals.c +7 -0
@@ -182,6 +182,13 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->sdhci),0 ,qdev_get_gpio_in_named (DEVICE (&s->ic),BCM2835_IC_GPU_IRQ ,INTERRUPT_ARASANSDIO )); +object_property_add_alias (OBJECT (s),"sd-bus" ,OBJECT (&s->sdhci),"sd-bus" , + &err); +if (err) { +error_propagate (errp, err); +return ; + } + }static void bcm2835_peripherals_class_init (ObjectClass *oc,void *data)
hw/arm/bcm2836.c +7 -0
@@ -73,6 +73,13 @@ static void bcm2836_realize(DeviceState *dev, Error **errp)return ; } +object_property_add_alias (OBJECT (s),"sd-bus" ,OBJECT (&s->peripherals), +"sd-bus" , &err); +if (err) { +error_propagate (errp, err); +return ; + } +sysbus_mmio_map_overlap (SYS_BUS_DEVICE (&s->peripherals),0 ,BCM2836_PERI_BASE ,1 );
hw/arm/raspi.c +16 -0
@@ -113,6 +113,10 @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)static void raspi2_init (MachineState *machine) {RasPiState *s =g_new0 (RasPiState,1 ); +DriveInfo *di; +BlockBackend *blk; +BusState *bus; +DeviceState *carddev;object_initialize (&s->soc,sizeof (s->soc),TYPE_BCM2836 ); object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc),
@@ -133,6 +137,18 @@ static void raspi2_init(MachineState *machine) &error_abort);object_property_set_bool (OBJECT (&s->soc), true,"realized" , &error_abort); +/* Create and plug in the SD cards */ + di =drive_get_next (IF_SD ); + blk = di ?blk_by_legacy_dinfo (di) :NULL ; + bus =qdev_get_child_bus (DEVICE (&s->soc),"sd-bus" ); +if (bus ==NULL ) { +error_report ("No SD bus found in SOC object" ); +exit (1 ); + } + carddev =qdev_create (bus,TYPE_SD_CARD ); +qdev_prop_set_drive (carddev,"drive" , blk, &error_fatal); +object_property_set_bool (OBJECT (carddev), true,"realized" , &error_fatal); +setup_boot (machine,2 , machine->ram_size); }
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 04/20] linux-user: Use restrictive mask when calling cpsr_write()
In reply to Peter MaydellWhen linux-user code is calling cpsr_write(), use a restrictive mask to ensure we are limiting the set of CPSR bits we update. In particular, don't allow the mode bits to be changed.
Message-id: [email protected]
--- linux-user/main.c | 3 ++- linux-user/signal.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
linux-user/main.c +2 -1
@@ -4446,7 +4446,8 @@ int main(int argc, char **argv, char **envp)#elif defined(TARGET_ARM ) {int i; -cpsr_write (env, regs->uregs[16 ],0xffffffff , CPSRWriteByInstr); +cpsr_write (env, regs->uregs[16 ],CPSR_USER |CPSR_EXEC , + CPSRWriteByInstr);for (i =0 ; i <16 ; i++) { env->regs[i] = regs->uregs[i]; }
linux-user/signal.c +1 -1
@@ -1611,7 +1611,7 @@ setup_return(CPUARMState *env, struct target_sigaction *ka, env->regs[13 ] = frame_addr; env->regs[14 ] = retcode; env->regs[15 ] = handler & (thumb ? ~1 : ~3 ); -cpsr_write (env, cpsr,0xffffffff , CPSRWriteByInstr); +cpsr_write (env, cpsr,CPSR_IT |CPSR_T , CPSRWriteByInstr); }static abi_ulong *setup_sigframe_v2_vfp (abi_ulong *regspace,CPUARMState *env)
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 07/20] target-arm: Add Hyp mode checks to bad_mode_switch()
In reply to Peter MaydellWe don't actually support Hyp mode yet, but add the correct checks for it to the bad_mode_switch() function for completeness.
Message-id: [email protected]
--- target-arm/helper.c | 3 +++ 1 file changed, 3 insertions(+)
target-arm/helper.c +3 -0
@@ -5218,6 +5218,9 @@ static int bad_mode_switch(CPUARMState *env, int mode)* allows FIQ mode to be Secure-only. (In v8 this doesn't exist.) */ return 0 ; +case ARM_CPU_MODE_HYP : +return !arm_feature (env,ARM_FEATURE_EL2 ) + ||arm_current_el (env) <2 ||arm_is_secure (env);case ARM_CPU_MODE_MON :return !arm_is_secure (env);default :
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 09/20] target-arm: In v8, make illegal AArch32 mode changes set PSTATE.IL
In reply to Peter MaydellIn v8, the illegal mode changes which are UNPREDICTABLE in v7 are given architected behaviour:
* the mode field is unchanged
* PSTATE.IL is set (so any subsequent instructions will UNDEF)
* any other CPSR fields are written to as normal
This is pretty much the same behaviour we picked for our UNPREDICTABLE handling, with the exception that for v8 we need to set the IL bit.
Message-id: [email protected]
--- target-arm/helper.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
target-arm/helper.c +12 -3
@@ -5325,11 +5325,20 @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask, (env->uncached_cpsr & CPSR_M) != CPSR_USER && ((env->uncached_cpsr ^ val) & mask & CPSR_M)) {if (bad_mode_switch (env, val &CPSR_M )) { -/* Attempt to switch to an invalid mode: this is UNPREDICTABLE. -* We choose to ignore the attempt and leave the CPSR M field -* untouched. +/* Attempt to switch to an invalid mode: this is UNPREDICTABLE in +* v7, and has defined behaviour in v8: +* + leave CPSR.M untouched +* + allow changes to the other CPSR fields +* + set PSTATE.IL +* For user changes via the GDB stub, we don't set PSTATE.IL, +* as this would be unnecessarily harsh for a user error. */ mask &= ~CPSR_M ; +if (write_type != CPSRWriteByGDBStub && +arm_feature (env,ARM_FEATURE_V8 )) { + mask |=CPSR_IL ; + val |=CPSR_IL ; + } }else {switch_mode (env, val &CPSR_M ); }
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 16/20] MAINTAINERS: Add some missing ARM related header files
In reply to Peter MaydellFrom: Thomas Huth <[email protected]>
Some header files in the include/hw/arm/ directory can be assigned to entries in the MAINTAINERS file.
Message-id: [email protected]
--- MAINTAINERS | 4 ++++ 1 file changed, 4 insertions(+)
MAINTAINERS +4 -0
@@ -363,6 +363,7 @@ M: Dmitry Solodkiy <[email protected]> L: [email protected] S: Maintained F: hw/*/exynos* +F: include/hw/arm/exynos4210.h Calxeda Highbank M: Rob Herring <[email protected]>
@@ -390,6 +391,7 @@ L: [email protected] S: Odd fixes F: hw/*/imx* F: hw/arm/kzm.c +F: include/hw/arm/fsl-imx31.h Integrator CP M: Peter Maydell <[email protected]>
@@ -432,6 +434,7 @@ F: hw/arm/spitz.c F: hw/arm/tosa.c F: hw/arm/z2.c F: hw/*/pxa2xx* +F: include/hw/arm/pxa.h Stellaris M: Peter Maydell <[email protected]>
@@ -768,6 +771,7 @@ OMAP M: Peter Maydell <[email protected]> S: Maintained F: hw/*/omap* +F: include/hw/arm/omap.h IPack M: Alberto Garcia <[email protected]>
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 17/20] sdhci: Revert "add optional quirk property to disable card insertion/removal interrupts"
In reply to Peter MaydellFrom: Andrew Baumann <[email protected]>
This reverts commit 723697551a7e926abe7d3c7f2966012b8075143d.
This change was poorly tested on my part. It squelched card insertion interrupts on reset, but that was not necessary because sdhci_reset() clears all the registers (via the call to memset), so the subsequent sdhci_insert_eject_cb() call never sees the card insert interrupt enabled. However, not calling the insert_eject_cb results in prnsts remaining 0, when it actually needs to be updated to indicate card presence and R/O status.
Message-id: [email protected]
--- hw/sd/sdhci.c | 9 +++------ include/hw/sd/sdhci.h | 1 - 2 files changed, 3 insertions(+), 7 deletions(-)
hw/sd/sdhci.c +3 -6
@@ -198,11 +198,9 @@ static void sdhci_reset(SDHCIState *s)* initialization */ memset (&s->sdmasysad,0 , (uintptr_t )&s->capareg - (uintptr_t )&s->sdmasysad); -if (!s->noeject_quirk) { -/* Reset other state based on current card insertion/readonly status */ -sdhci_set_inserted (dev,sdbus_get_inserted (&s->sdbus)); -sdhci_set_readonly (dev,sdbus_get_readonly (&s->sdbus)); - } +/* Reset other state based on current card insertion/readonly status */ +sdhci_set_inserted (dev,sdbus_get_inserted (&s->sdbus)); +sdhci_set_readonly (dev,sdbus_get_readonly (&s->sdbus)); s->data_count =0 ; s->stopped_state = sdhc_not_stopped;
@@ -1275,7 +1273,6 @@ static Property sdhci_sysbus_properties[] = {DEFINE_PROP_UINT32 ("capareg" , SDHCIState, capareg,SDHC_CAPAB_REG_DEFAULT ),DEFINE_PROP_UINT32 ("maxcurr" , SDHCIState, maxcurr,0 ), -DEFINE_PROP_BOOL ("noeject-quirk" , SDHCIState, noeject_quirk, false), DEFINE_PROP_END_OF_LIST(), };
include/hw/sd/sdhci.h +0 -1
@@ -76,7 +76,6 @@ typedef struct SDHCIState {uint32_t buf_maxsz;uint16_t data_count;/* current element in FIFO buffer */ uint8_t stopped_state;/* Current SDHC state */ -bool noeject_quirk;/* Quirk to disable card insert/remove interrupts */ /* Buffer Data Port Register - virtual access point to R and W buffers */ /* Software Reset Register - always reads as 0 */ /* Force Event Auto CMD12 Error Interrupt Reg - write only */
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 18/20] sdhci: add quirk property for card insert interrupt status on Raspberry Pi
In reply to Peter MaydellFrom: Andrew Baumann <[email protected]>
This quirk is a workaround for the following hardware behaviour, on which UEFI (specifically, the bootloader for Windows on Pi2) depends:
1. at boot with an SD card present, the interrupt status/enable registers are initially zero
2. upon enabling it in the interrupt enable register, the card insert bit in the interrupt status register is immediately set
3. after a subsequent controller reset, the card insert interrupt does not fire, even if enabled in the interrupt enable register
Message-id: [email protected]
--- hw/sd/sdhci.c | 38 +++++++++++++++++++++++++++++++++++++- include/hw/sd/sdhci.h | 2 ++ 2 files changed, 39 insertions(+), 1 deletion(-)
hw/sd/sdhci.c +37 -1
@@ -204,6 +204,7 @@ static void sdhci_reset(SDHCIState *s) s->data_count =0 ; s->stopped_state = sdhc_not_stopped; + s->pending_insert_state = false; }static void sdhci_data_transfer (void *opaque);
@@ -1095,6 +1096,13 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) }else { s->norintsts &= ~SDHC_NIS_ERR ; } +/* Quirk for Raspberry Pi: pending card insert interrupt +* appears when first enabled after power on */ +if ((s->norintstsen &SDHC_NISEN_INSERT ) && s->pending_insert_state) { +assert (s->pending_insert_quirk); + s->norintsts |=SDHC_NIS_INSERT ; + s->pending_insert_state = false; + }sdhci_update_irq (s);break ;case SDHC_NORINTSIGEN :
@@ -1181,6 +1189,24 @@ static void sdhci_uninitfn(SDHCIState *s) s->fifo_buffer =NULL ; } +static bool sdhci_pending_insert_vmstate_needed (void *opaque) +{ +SDHCIState *s = opaque; + +return s->pending_insert_state; +} + +static const VMStateDescription sdhci_pending_insert_vmstate = { + .name ="sdhci/pending-insert" , + .version_id =1 , + .minimum_version_id =1 , + .needed = sdhci_pending_insert_vmstate_needed, + .fields = (VMStateField []) { +VMSTATE_BOOL (pending_insert_state, SDHCIState), +VMSTATE_END_OF_LIST () + }, +}; +const VMStateDescription sdhci_vmstate = { .name ="sdhci" , .version_id =1 ,
@@ -1215,7 +1241,11 @@ const VMStateDescription sdhci_vmstate = { VMSTATE_TIMER_PTR(insert_timer, SDHCIState), VMSTATE_TIMER_PTR(transfer_timer, SDHCIState),VMSTATE_END_OF_LIST () - } + }, + .subsections = (const VMStateDescription *[]) { + &sdhci_pending_insert_vmstate, +NULL + }, };/* Capabilities registers provide information on supported features of this
@@ -1273,6 +1303,8 @@ static Property sdhci_sysbus_properties[] = {DEFINE_PROP_UINT32 ("capareg" , SDHCIState, capareg,SDHC_CAPAB_REG_DEFAULT ),DEFINE_PROP_UINT32 ("maxcurr" , SDHCIState, maxcurr,0 ), +DEFINE_PROP_BOOL ("pending-insert-quirk" , SDHCIState, pending_insert_quirk, + false), DEFINE_PROP_END_OF_LIST(), };
@@ -1300,6 +1332,10 @@ static void sdhci_sysbus_realize(DeviceState *dev, Error ** errp)memory_region_init_io (&s->iomem,OBJECT (s), &sdhci_mmio_ops, s,"sdhci" ,SDHC_REGISTERS_MAP_SIZE );sysbus_init_mmio (sbd, &s->iomem); + +if (s->pending_insert_quirk) { + s->pending_insert_state = true; + } }static void sdhci_sysbus_class_init (ObjectClass *klass,void *data)
include/hw/sd/sdhci.h +2 -0
@@ -76,6 +76,8 @@ typedef struct SDHCIState {uint32_t buf_maxsz;uint16_t data_count;/* current element in FIFO buffer */ uint8_t stopped_state;/* Current SDHC state */ +bool pending_insert_quirk;/* Quirk for Raspberry Pi card insert int */ +bool pending_insert_state;/* Buffer Data Port Register - virtual access point to R and W buffers */ /* Software Reset Register - always reads as 0 */ /* Force Event Auto CMD12 Error Interrupt Reg - write only */
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 19/20] target-arm: Mark CNTHP_TVAL_EL2 as ARM_CP_NO_RAW
In reply to Peter MaydellFrom: "Edgar E. Iglesias" <[email protected]>
Mark CNTHP_TVAL_EL2 as ARM_CP_NO_RAW due to the register not having any underlying state. This fixes an issue with booting KVM enabled kernels when EL2 is on.
Message-id: [email protected]
--- target-arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-arm/helper.c +1 -1
@@ -3672,7 +3672,7 @@ static const ARMCPRegInfo el2_cp_reginfo[] = { .writefn = gt_hyp_cval_write, .raw_writefn = raw_write }, { .name = "CNTHP_TVAL_EL2", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 2, .opc2 = 0, - .type = ARM_CP_IO, .access = PL2_RW, + .type = ARM_CP_NO_RAW | ARM_CP_IO, .access = PL2_RW, .resetfn = gt_hyp_timer_reset, .readfn = gt_hyp_tval_read, .writefn = gt_hyp_tval_write }, { .name = "CNTHP_CTL_EL2", .state = ARM_CP_STATE_BOTH,
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 20/20] target-arm: Make reserved ranges in ID_AA64* spaces RAZ, not UNDEF
In reply to Peter MaydellThe v8 ARM ARM defines that unused spaces in the ID_AA64* system register ranges are Reserved and must RAZ, rather than being UNDEF. Implement this.
In particular, ARM v8.2 adds a new feature register ID_AA64MMFR2, and newer versions of the Linux kernel will attempt to read this, which causes them not to boot up on versions of QEMU missing this fix.
Since the encoding .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 6 is actually defined in ARMv8 (as ID_MMFR4), we give it an entry in the ARMCPU struct so CPUs can override it, though since none do this too will just RAZ.
Message-id: [email protected]
--- target-arm/cpu-qom.h | 1 + target-arm/helper.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 122 insertions(+), 7 deletions(-)
target-arm/cpu-qom.h +1 -0
@@ -155,6 +155,7 @@ typedef struct ARMCPU {uint32_t id_mmfr1;uint32_t id_mmfr2;uint32_t id_mmfr3; +uint32_t id_mmfr4;uint32_t id_isar0;uint32_t id_isar1;uint32_t id_isar2;
target-arm/helper.c +121 -7
176 lines not on this page · raw message
Signature · 1 line
1.9.1
Peter Maydell
AppliedQuoted 13 lines · Peter Maydell
The following changes since commit
4d1e324b2241017c92d816ec3af51a14685dbf62:Merge remote-tracking branch 'remotes/lalrae/tags/mips-20160226' into staging (2016-02-26 12:54:22 +0000)
are available in the git repository at:
git://git.linaro.org/people/pmaydell/qemu-arm.gittags/pull-target-arm-20160226for you to fetch changes up to
e20d84c1407d43d5a2e2ac95dbb46db3b0af8f9f:target-arm: Make reserved ranges in ID_AA64* spaces RAZ, not UNDEF (2016-02-26 15:09:42 +0000)
Quoted 11 lines
----------------------------------------------------------------
target-arm queue:
* Clean up handling of bad mode switches writing to CPSR, and implement the ARMv8 requirement that they set PSTATE.IL
* Implement MDCR_EL3.TPM and MDCR_EL2.TPM traps on perf monitor register accesses
* Don't implement stellaris-pl061-only registers on generic-pl061
* Fix SD card handling for raspi
* Add missing include files toMAINTAINERS
* MarkCNTHP_TVAL_EL2asARM_CP_NO_RAW
* Make reserved ranges in ID_AA64* spaces RAZ, not UNDEF
Applied, thanks.
-- PMM