target-arm queue
Flushing a bunch of queued up ARM patches, a mix of new features and bug fixes.
thanks
-- PMM
The following changes since commit 0dfa7e30126364c434a48cb37a1a41119e536c2a:
Merge remote-tracking branch 'remotes/kraxel/tags/pull-console-20140905-2' into staging (2014-09-11 11:44:17 +0100)
are available in the git repository at:
git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20140912
for you to fetch changes up to 92df845070290236d1b28b03453deec1ae9c4263:
hw/arm/boot: enable DTB support when booting ELF images (2014-09-12 14:06:50 +0100)
----------------------------------------------------------------
target-arm:
* add "linux,stdout-path" to the virt DTB
* fix a long standing bug with IRQ disabling on Cortex-M CPUs
* implement input interrupt logic in the PL061
* fix failure to load correct SP/PC on reset of Cortex-M CPUs if the vector table is not in a ROM-blob-in-RAM
* provide flash devices for boot ROMs in the virt board
* implement architectural watchpoints
* fix misimplementation of Inner Shareable TLB operations that caused instability of guests in TCG SMP configurations
* configure PL011 and PL031 in the virt board correctly with level-triggered interrupts rather than edge-triggered
* support providing a device tree blob to ROM (firmware) images as well as to kernels
----------------------------------------------------------------
Ard Biesheuvel (5):
hw/arm/virt: add linux, stdout-path to /chosen DT node hw/arm/boot: load DTB as a ROM image
hw/arm/boot: pass an address limit to and return size from load_dtb() hw/arm/boot: load device tree to base of DRAM if no -kernel option was passed hw/arm/boot: enable DTB support when booting ELF images
Colin Leitner (1):
pl061: implement input interrupt logic
David Hoover (1):
cpu-exec.c: Allow disabling of IRQs on ARM Cortex-M CPUs
Martin Galvan (2):
target-arm: Fix resetting issues on ARMv7-M CPUs
target-arm: Fix broken indentation in arm_cpu_reest()
Peter Maydell (14):
hw/arm/virt: Provide flash devices for boot ROMs
exec.c: Relax restrictions on watchpoint length and alignment exec.c: Provide full set of dummy wp remove functions in user-mode exec.c: Record watchpoint fault address and direction
cpu-exec: Make debug_excp_handler a QOM CPU method
target-arm: Implement setting of watchpoints
target-arm: Move extended_addresses_enabled() to internals.h
target-arm: Implement handling of fired watchpoints
target-arm: Set DBGDSCR.MOE for debug exceptions taken to AArch32
target-arm: Remove comment about MDSCR_EL1 being dummy implementation
target-arm: Implement minimal DBGVCR, OSDLR_EL1, MDCCSR_EL0
target-arm: Push legacy wildcard TLB ops back into v6
target-arm: Make *IS TLB maintenance ops affect all CPUs hw/arm/virt: fix pl011 and pl031 irq flags
cpu-exec.c | 17 +-- exec.c | 61 ++++++-- hw/arm/boot.c | 71 ++++++++- hw/arm/virt.c | 76 ++++++++- hw/gpio/pl061.c | 59 +++++-- include/exec/exec-all.h | 4 - include/qom/cpu.h | 10 +- linux-user/main.c | 3 +- qom/cpu.c | 5 + target-arm/cpu.c | 37 +++-- target-arm/cpu.h | 2 + target-arm/helper.c | 397 +++++++++++++++++++++++++++++++++++++++--------- target-arm/internals.h | 30 ++++ target-arm/machine.c | 3 + target-arm/op_helper.c | 188 +++++++++++++++++++++++ target-i386/cpu.c | 6 +- target-i386/cpu.h | 2 +- target-i386/helper.c | 5 +- target-lm32/cpu.c | 2 +- target-lm32/cpu.h | 2 +- target-lm32/helper.c | 5 +- target-xtensa/cpu.c | 2 +- target-xtensa/cpu.h | 2 +- target-xtensa/helper.c | 5 +- 24 files changed, 840 insertions(+), 154 deletions(-)
[Qemu-devel] [PULL 17/23] target-arm: Push legacy wildcard TLB ops back into v6
When we implemented ARMv8 in QEMU we retained our legacy loose wildcarded decoding of the TLB maintenance operations for v7 and earlier CPUs and provided the correct stricter decode for v8. However the loose decode is in fact wrong for v7MP, because it doesn't correctly implement the operations which must apply to every CPU in the Inner Shareable domain.
Move the legacy wildcarding from the not_v8 reginfo array into the not_v7 array, and move the strictly decoded operations from the v8 reginfo to v7 or v7mp arrays as appropriate.
Cache and TLB lockdown legacy wildcarding remains in the not_v8 array for the moment.
Message-id: [email protected]
Cc: [email protected]
--- target-arm/helper.c | 102 ++++++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 47 deletions(-)
target-arm/helper.c +55 -47
@@ -403,21 +403,6 @@ static const ARMCPRegInfo not_v8_cp_reginfo[] = {*/ { .name = "TLB_LOCKDOWN", .cp = 15, .crn = 10, .crm = CP_ANY, .opc1 = CP_ANY, .opc2 = CP_ANY, .access = PL1_RW, .type = ARM_CP_NOP }, - /* MMU TLB control. Note that the wildcarding means we cover not just - * the unified TLB ops but also the dside/iside/inner-shareable variants. - */ - { .name = "TLBIALL", .cp = 15, .crn = 8, .crm = CP_ANY, - .opc1 = CP_ANY, .opc2 = 0, .access = PL1_W, .writefn = tlbiall_write, - .type = ARM_CP_NO_MIGRATE }, - { .name = "TLBIMVA", .cp = 15, .crn = 8, .crm = CP_ANY, - .opc1 = CP_ANY, .opc2 = 1, .access = PL1_W, .writefn = tlbimva_write, - .type = ARM_CP_NO_MIGRATE }, - { .name = "TLBIASID", .cp = 15, .crn = 8, .crm = CP_ANY, - .opc1 = CP_ANY, .opc2 = 2, .access = PL1_W, .writefn = tlbiasid_write, - .type = ARM_CP_NO_MIGRATE }, - { .name = "TLBIMVAA", .cp = 15, .crn = 8, .crm = CP_ANY, - .opc1 = CP_ANY, .opc2 = 3, .access = PL1_W, .writefn = tlbimvaa_write, - .type = ARM_CP_NO_MIGRATE }, /* Cache maintenance ops; some of this space may be overridden later. */ { .name = "CACHEMAINT", .cp = 15, .crn = 7, .crm = CP_ANY, .opc1 = 0, .opc2 = CP_ANY, .access = PL1_W,
@@ -461,6 +446,21 @@ static const ARMCPRegInfo not_v7_cp_reginfo[] = {*/ { .name = "DBGDIDR", .cp = 14, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 0, .access = PL0_R, .type = ARM_CP_CONST, .resetvalue = 0 }, + /* MMU TLB control. Note that the wildcarding means we cover not just + * the unified TLB ops but also the dside/iside/inner-shareable variants. + */ + { .name = "TLBIALL", .cp = 15, .crn = 8, .crm = CP_ANY, + .opc1 = CP_ANY, .opc2 = 0, .access = PL1_W, .writefn = tlbiall_write, + .type = ARM_CP_NO_MIGRATE }, + { .name = "TLBIMVA", .cp = 15, .crn = 8, .crm = CP_ANY, + .opc1 = CP_ANY, .opc2 = 1, .access = PL1_W, .writefn = tlbimva_write, + .type = ARM_CP_NO_MIGRATE }, + { .name = "TLBIASID", .cp = 15, .crn = 8, .crm = CP_ANY, + .opc1 = CP_ANY, .opc2 = 2, .access = PL1_W, .writefn = tlbiasid_write, + .type = ARM_CP_NO_MIGRATE }, + { .name = "TLBIMVAA", .cp = 15, .crn = 8, .crm = CP_ANY, + .opc1 = CP_ANY, .opc2 = 3, .access = PL1_W, .writefn = tlbimvaa_write, + .type = ARM_CP_NO_MIGRATE }, REGINFO_SENTINEL };
@@ -879,6 +879,42 @@ static const ARMCPRegInfo v7_cp_reginfo[] = { { .name = "ISR_EL1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 12, .crm = 1, .opc2 = 0, .type = ARM_CP_NO_MIGRATE, .access = PL1_R, .readfn = isr_read }, + /* 32 bit ITLB invalidates */ + { .name = "ITLBIALL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 0, + .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbiall_write }, + { .name = "ITLBIMVA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 1, + .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbimva_write }, + { .name = "ITLBIASID", .cp = 15, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 2, + .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbiasid_write }, + /* 32 bit DTLB invalidates */ + { .name = "DTLBIALL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 0, + .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbiall_write }, + { .name = "DTLBIMVA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 1, + .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbimva_write }, + { .name = "DTLBIASID", .cp = 15, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 2, + .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbiasid_write }, + /* 32 bit TLB invalidates */ + { .name = "TLBIALL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 0, + .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbiall_write }, + { .name = "TLBIMVA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 1, + .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbimva_write }, + { .name = "TLBIASID", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 2, + .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbiasid_write }, + { .name = "TLBIMVAA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 3, + .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbimvaa_write }, +REGINFO_SENTINEL +}; + +static const ARMCPRegInfo v7mp_cp_reginfo[] = { +/* 32 bit TLB invalidates, Inner Shareable */ + { .name ="TLBIALLIS" , .cp =15 , .opc1 =0 , .crn =8 , .crm =3 , .opc2 =0 , + .type =ARM_CP_NO_MIGRATE , .access =PL1_W , .writefn = tlbiall_write }, + { .name ="TLBIMVAIS" , .cp =15 , .opc1 =0 , .crn =8 , .crm =3 , .opc2 =1 , + .type =ARM_CP_NO_MIGRATE , .access =PL1_W , .writefn = tlbimva_write }, + { .name ="TLBIASIDIS" , .cp =15 , .opc1 =0 , .crn =8 , .crm =3 , .opc2 =2 , + .type =ARM_CP_NO_MIGRATE , .access =PL1_W , .writefn = tlbiasid_write }, + { .name ="TLBIMVAAIS" , .cp =15 , .opc1 =0 , .crn =8 , .crm =3 , .opc2 =3 , + .type =ARM_CP_NO_MIGRATE , .access =PL1_W , .writefn = tlbimvaa_write },REGINFO_SENTINEL };
@@ -2045,42 +2081,11 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 8, .opc2 = 3, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = ats_write },#endif -/* 32 bit TLB invalidates, Inner Shareable */ - { .name = "TLBIALLIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 0, - .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbiall_write }, - { .name = "TLBIMVAIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 1, - .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbimva_write }, - { .name = "TLBIASIDIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 2, - .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbiasid_write }, - { .name = "TLBIMVAAIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3, - .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbimvaa_write }, +/* TLB invalidate last level of translation table walk */ { .name = "TLBIMVALIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 5, .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbimva_write }, { .name = "TLBIMVAALIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 7, .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbimvaa_write }, - /* 32 bit ITLB invalidates */ - { .name = "ITLBIALL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 0, - .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbiall_write }, - { .name = "ITLBIMVA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 1, - .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbimva_write }, - { .name = "ITLBIASID", .cp = 15, .opc1 = 0, .crn = 8, .crm = 5, .opc2 = 2, - .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbiasid_write }, - /* 32 bit DTLB invalidates */ - { .name = "DTLBIALL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 0, - .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbiall_write }, - { .name = "DTLBIMVA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 1, - .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbimva_write }, - { .name = "DTLBIASID", .cp = 15, .opc1 = 0, .crn = 8, .crm = 6, .opc2 = 2, - .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbiasid_write }, - /* 32 bit TLB invalidates */ - { .name = "TLBIALL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 0, - .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbiall_write }, - { .name = "TLBIMVA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 1, - .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbimva_write }, - { .name = "TLBIASID", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 2, - .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbiasid_write }, - { .name = "TLBIMVAA", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 3, - .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbimvaa_write }, { .name = "TLBIMVAL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 5, .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbimva_write }, { .name = "TLBIMVAAL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 7,
@@ -2574,6 +2579,9 @@ void register_cp_regs_for_features(ARMCPU *cpu)if (arm_feature (env,ARM_FEATURE_V6K )) {define_arm_cp_regs (cpu, v6k_cp_reginfo); } +if (arm_feature (env,ARM_FEATURE_V7MP )) { +define_arm_cp_regs (cpu, v7mp_cp_reginfo); + }if (arm_feature (env,ARM_FEATURE_V7 )) {/* v7 performance monitor control register: same implementor * field as main ID register, and we implement only the cycle
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 09/23] exec.c: Record watchpoint fault address and direction
In reply to Peter MaydellWhen we check whether we've hit a watchpoint we know the address that we were attempting to access and whether it was a read or a write. Record this information in the CPUWatchpoint struct so that target-specific code can report it to the guest.
--- exec.c | 7 ++++++- include/qom/cpu.h | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-)
exec.c +6 -1
@@ -1673,7 +1673,12 @@ static void check_watchpoint(int offset, int len, int flags) QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) {if (cpu_watchpoint_address_matches (wp, vaddr, len) && (wp->flags & flags)) { - wp->flags |=BP_WATCHPOINT_HIT ; +if (flags ==BP_MEM_READ ) { + wp->flags |=BP_WATCHPOINT_HIT_READ ; + }else { + wp->flags |=BP_WATCHPOINT_HIT_WRITE ; + } + wp->hitaddr = vaddr;if (!cpu->watchpoint_hit) { cpu->watchpoint_hit = wp;tb_check_watchpoint (cpu);
include/qom/cpu.h +5 -1
@@ -170,6 +170,7 @@ typedef struct CPUBreakpoint {typedef struct CPUWatchpoint {vaddr vaddr;vaddr len; +vaddr hitaddr;int flags;/* BP_* */ QTAILQ_ENTRY (CPUWatchpoint) entry; }CPUWatchpoint ;
@@ -622,9 +623,12 @@ void cpu_single_step(CPUState *cpu, int enabled);#define BP_MEM_WRITE 0x02#define BP_MEM_ACCESS (BP_MEM_READ | BP_MEM_WRITE)#define BP_STOP_BEFORE_ACCESS 0x04 -#define BP_WATCHPOINT_HIT 0x08 +/* 0x08 currently unused */ #define BP_GDB 0x10#define BP_CPU 0x20 +#define BP_WATCHPOINT_HIT_READ 0x40 +#define BP_WATCHPOINT_HIT_WRITE 0x80 +#define BP_WATCHPOINT_HIT (BP_WATCHPOINT_HIT_READ | BP_WATCHPOINT_HIT_WRITE)int cpu_breakpoint_insert (CPUState *cpu,vaddr pc,int flags,CPUBreakpoint **breakpoint);
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 18/23] target-arm: Make *IS TLB maintenance ops affect all CPUs
In reply to Peter MaydellThe ARM architecture defines that the "IS" variants of TLB maintenance operations must affect all TLBs in the Inner Shareable domain, which for us means all CPUs. We were incorrectly implementing these to only affect the current CPU, which meant that SMP TCG operation was unstable.
Message-id: [email protected]
Cc: [email protected]
--- target-arm/helper.c | 101 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 89 insertions(+), 12 deletions(-)
target-arm/helper.c +89 -12
@@ -377,6 +377,47 @@ static void tlbimvaa_write(CPUARMState *env, const ARMCPRegInfo *ri,tlb_flush_page (CPU (cpu), value &TARGET_PAGE_MASK ); } +/* IS variants of TLB operations must affect all cores */ +static void tlbiall_is_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ +CPUState *other_cs; + +CPU_FOREACH (other_cs) { +tlb_flush (other_cs,1 ); + } +} + +static void tlbiasid_is_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ +CPUState *other_cs; + +CPU_FOREACH (other_cs) { +tlb_flush (other_cs, value ==0 ); + } +} + +static void tlbimva_is_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ +CPUState *other_cs; + +CPU_FOREACH (other_cs) { +tlb_flush_page (other_cs, value &TARGET_PAGE_MASK ); + } +} + +static void tlbimvaa_is_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ +CPUState *other_cs; + +CPU_FOREACH (other_cs) { +tlb_flush_page (other_cs, value &TARGET_PAGE_MASK ); + } +} +static const ARMCPRegInfo cp_reginfo[] = { { .name ="FCSEIDR" , .cp =15 , .crn =13 , .crm =0 , .opc1 =0 , .opc2 =0 , .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.c13_fcse),
@@ -908,13 +949,15 @@ static const ARMCPRegInfo v7_cp_reginfo[] = {static const ARMCPRegInfo v7mp_cp_reginfo[] = {/* 32 bit TLB invalidates, Inner Shareable */ { .name ="TLBIALLIS" , .cp =15 , .opc1 =0 , .crn =8 , .crm =3 , .opc2 =0 , - .type =ARM_CP_NO_MIGRATE , .access =PL1_W , .writefn = tlbiall_write }, + .type =ARM_CP_NO_MIGRATE , .access =PL1_W , .writefn = tlbiall_is_write }, { .name ="TLBIMVAIS" , .cp =15 , .opc1 =0 , .crn =8 , .crm =3 , .opc2 =1 , - .type =ARM_CP_NO_MIGRATE , .access =PL1_W , .writefn = tlbimva_write }, + .type =ARM_CP_NO_MIGRATE , .access =PL1_W , .writefn = tlbimva_is_write }, { .name ="TLBIASIDIS" , .cp =15 , .opc1 =0 , .crn =8 , .crm =3 , .opc2 =2 , - .type =ARM_CP_NO_MIGRATE , .access =PL1_W , .writefn = tlbiasid_write }, + .type =ARM_CP_NO_MIGRATE , .access =PL1_W , + .writefn = tlbiasid_is_write }, { .name ="TLBIMVAAIS" , .cp =15 , .opc1 =0 , .crn =8 , .crm =3 , .opc2 =3 , - .type =ARM_CP_NO_MIGRATE , .access =PL1_W , .writefn = tlbimvaa_write }, + .type =ARM_CP_NO_MIGRATE , .access =PL1_W , + .writefn = tlbimvaa_is_write },REGINFO_SENTINEL };
@@ -1904,6 +1947,39 @@ static void tlbi_aa64_asid_write(CPUARMState *env, const ARMCPRegInfo *ri,tlb_flush (CPU (cpu), asid ==0 ); } +static void tlbi_aa64_va_is_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ +CPUState *other_cs; +uint64_t pageaddr =sextract64 (value <<12 ,0 ,56 ); + +CPU_FOREACH (other_cs) { +tlb_flush_page (other_cs, pageaddr); + } +} + +static void tlbi_aa64_vaa_is_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ +CPUState *other_cs; +uint64_t pageaddr =sextract64 (value <<12 ,0 ,56 ); + +CPU_FOREACH (other_cs) { +tlb_flush_page (other_cs, pageaddr); + } +} + +static void tlbi_aa64_asid_is_write (CPUARMState *env,const ARMCPRegInfo *ri, +uint64_t value) +{ +CPUState *other_cs; +int asid =extract64 (value,48 ,16 ); + +CPU_FOREACH (other_cs) { +tlb_flush (other_cs, asid ==0 ); + } +} +static CPAccessResult aa64_zva_access (CPUARMState *env,const ARMCPRegInfo *ri) {/* We don't implement EL2, so the only control on DC ZVA is the
@@ -2021,27 +2097,27 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { { .name = "TLBI_VMALLE1IS", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 0, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, - .writefn = tlbiall_write }, + .writefn = tlbiall_is_write }, { .name = "TLBI_VAE1IS", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 1, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, - .writefn = tlbi_aa64_va_write }, + .writefn = tlbi_aa64_va_is_write }, { .name = "TLBI_ASIDE1IS", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 2, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, - .writefn = tlbi_aa64_asid_write }, + .writefn = tlbi_aa64_asid_is_write }, { .name = "TLBI_VAAE1IS", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, - .writefn = tlbi_aa64_vaa_write }, + .writefn = tlbi_aa64_vaa_is_write }, { .name = "TLBI_VALE1IS", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 5, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, - .writefn = tlbi_aa64_va_write }, + .writefn = tlbi_aa64_va_is_write }, { .name = "TLBI_VAALE1IS", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 7, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, - .writefn = tlbi_aa64_vaa_write }, + .writefn = tlbi_aa64_vaa_is_write }, { .name = "TLBI_VMALLE1", .state = ARM_CP_STATE_AA64, .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 0, .access = PL1_W, .type = ARM_CP_NO_MIGRATE,
@@ -2083,9 +2159,10 @@ static const ARMCPRegInfo v8_cp_reginfo[] = {#endif /* TLB invalidate last level of translation table walk */ { .name = "TLBIMVALIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 5, - .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbimva_write }, + .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbimva_is_write }, { .name = "TLBIMVAALIS", .cp = 15, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 7, - .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbimvaa_write }, + .type = ARM_CP_NO_MIGRATE, .access = PL1_W, + .writefn = tlbimvaa_is_write }, { .name = "TLBIMVAL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 5, .type = ARM_CP_NO_MIGRATE, .access = PL1_W, .writefn = tlbimva_write }, { .name = "TLBIMVAAL", .cp = 15, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 7,
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 23/23] hw/arm/boot: enable DTB support when booting ELF images
In reply to Peter MaydellFrom: Ard Biesheuvel <[email protected]>
Add support for loading DTB images when booting ELF images using -kernel. If there are no conflicts with the placement of the ELF segments, the DTB image is loaded at the base of RAM.
Message-id: [email protected]
--- hw/arm/boot.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-)
hw/arm/boot.c +20 -2
@@ -482,7 +482,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)int kernel_size;int initrd_size;int is_linux =0 ; -uint64_t elf_entry; +uint64_t elf_entry, elf_low_addr, elf_high_addr;int elf_machine;hwaddr entry, kernel_load_offset;int big_endian;
@@ -549,7 +549,25 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)/* Assume that raw images are linux kernels, and ELF images are not. */ kernel_size =load_elf (info->kernel_filename,NULL ,NULL , &elf_entry, -NULL ,NULL , big_endian, elf_machine,1 ); + &elf_low_addr, &elf_high_addr, big_endian, + elf_machine,1 ); +if (kernel_size >0 &&have_dtb (info)) { +/* If there is still some room left at the base of RAM, try and put +* the DTB there like we do for images loaded with -bios or -pflash. +*/ +if (elf_low_addr > info->loader_start + || elf_high_addr < info->loader_start) { +/* Pass elf_low_addr as address limit to load_dtb if it may be +* pointing into RAM, otherwise pass '0' (no limit) +*/ +if (elf_low_addr < info->loader_start) { + elf_low_addr =0 ; + } +if (load_dtb (info->loader_start, info, elf_low_addr) <0 ) { +exit (1 ); + } + } + } entry = elf_entry;if (kernel_size <0 ) { kernel_size = load_uimage(info->kernel_filename, &entry, NULL,
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 10/23] cpu-exec: Make debug_excp_handler a QOM CPU method
In reply to Peter MaydellMake the debug_excp_handler target specific hook into a QOM CPU method.
--- cpu-exec.c | 13 +++---------- include/exec/exec-all.h | 4 ---- include/qom/cpu.h | 2 ++ qom/cpu.c | 5 +++++ target-i386/cpu.c | 6 +++--- target-i386/cpu.h | 2 +- target-i386/helper.c | 5 +++-- target-lm32/cpu.c | 2 +- target-lm32/cpu.h | 2 +- target-lm32/helper.c | 5 +++-- target-xtensa/cpu.c | 2 +- target-xtensa/cpu.h | 2 +- target-xtensa/helper.c | 5 +++-- 13 files changed, 27 insertions(+), 28 deletions(-)
cpu-exec.c +3 -10
@@ -295,16 +295,10 @@ static inline TranslationBlock *tb_find_fast(CPUArchState *env)return tb; } -static CPUDebugExcpHandler *debug_excp_handler; - -void cpu_set_debug_excp_handler (CPUDebugExcpHandler *handler) -{ - debug_excp_handler = handler; -} -static void cpu_handle_debug_exception (CPUArchState *env) {CPUState *cpu =ENV_GET_CPU (env); +CPUClass *cc =CPU_GET_CLASS (cpu);CPUWatchpoint *wp;if (!cpu->watchpoint_hit) {
@@ -312,9 +306,8 @@ static void cpu_handle_debug_exception(CPUArchState *env) wp->flags &= ~BP_WATCHPOINT_HIT ; } } -if (debug_excp_handler) { -debug_excp_handler (env); - } + + cc->debug_excp_handler (cpu); }/* main execution loop */
include/exec/exec-all.h +0 -4
@@ -356,10 +356,6 @@ static inline tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulongtb_page_addr_t get_page_addr_code (CPUArchState *env1,target_ulong addr);#endif -typedef void (CPUDebugExcpHandler )(CPUArchState *env); - -void cpu_set_debug_excp_handler (CPUDebugExcpHandler *handler); -/* vl.c */ extern int singlestep;
include/qom/cpu.h +2 -0
@@ -95,6 +95,7 @@ struct TranslationBlock;* @get_phys_page_debug: Callback for obtaining a physical address. * @gdb_read_register: Callback for letting GDB read a register. * @gdb_write_register: Callback for letting GDB write a register. +* @debug_excp_handler: Callback for handling debug exceptions. * @vmsd: State description for migration. * @gdb_num_core_regs: Number of core registers accessible to GDB. * @gdb_core_xml_file: File name for core registers GDB XML description.
@@ -134,6 +135,7 @@ typedef struct CPUClass {hwaddr (*get_phys_page_debug)(CPUState *cpu,vaddr addr);int (*gdb_read_register)(CPUState *cpu,uint8_t *buf,int reg);int (*gdb_write_register)(CPUState *cpu,uint8_t *buf,int reg); +void (*debug_excp_handler)(CPUState *cpu);int (*write_elf64_note)(WriteCoreDumpFunction f,CPUState *cpu,int cpuid,void *opaque);
qom/cpu.c +5 -0
@@ -202,6 +202,10 @@ static bool cpu_common_virtio_is_big_endian(CPUState *cpu)return target_words_bigendian (); } +static void cpu_common_debug_excp_handler (CPUState *cpu) +{ +} +void cpu_dump_state (CPUState *cpu,FILE *f,fprintf_function cpu_fprintf,int flags) {
@@ -340,6 +344,7 @@ static void cpu_class_init(ObjectClass *klass, void *data) k->gdb_read_register = cpu_common_gdb_read_register; k->gdb_write_register = cpu_common_gdb_write_register; k->virtio_is_big_endian = cpu_common_virtio_is_big_endian; + k->debug_excp_handler = cpu_common_debug_excp_handler; dc->realize = cpu_common_realizefn;/* * Reason: CPUs still need special care by board code: wiring up
target-i386/cpu.c +3 -3
@@ -2843,9 +2843,6 @@ static void x86_cpu_initfn(Object *obj)if (tcg_enabled () && !inited) { inited =1 ;optimize_flags_init (); -#ifndef CONFIG_USER_ONLY -cpu_set_debug_excp_handler (breakpoint_handler); -#endif } }
@@ -2942,6 +2939,9 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) cc->vmsd = &vmstate_x86_cpu;#endif cc->gdb_num_core_regs =CPU_NB_REGS *2 +25 ; +#ifndef CONFIG_USER_ONLY + cc->debug_excp_handler = breakpoint_handler; +#endif }static const TypeInfo x86_cpu_type_info = {
target-i386/cpu.h +1 -1
@@ -1121,7 +1121,7 @@ static inline int hw_breakpoint_len(unsigned long dr7, int index)void hw_breakpoint_insert (CPUX86State *env,int index);void hw_breakpoint_remove (CPUX86State *env,int index);bool check_hw_breakpoints (CPUX86State *env,bool force_dr6_update); -void breakpoint_handler (CPUX86State *env); +void breakpoint_handler (CPUState *cs);/* will be suppressed */ void cpu_x86_update_cr0 (CPUX86State *env,uint32_t new_cr0);
target-i386/helper.c +3 -2
@@ -1011,9 +1011,10 @@ bool check_hw_breakpoints(CPUX86State *env, bool force_dr6_update)return hit_enabled; } -void breakpoint_handler (CPUX86State *env) +void breakpoint_handler (CPUState *cs) { -CPUState *cs =CPU (x86_env_get_cpu (env)); +X86CPU *cpu =X86_CPU (cs); +CPUX86State *env = &cpu->env;CPUBreakpoint *bp;if (cs->watchpoint_hit) {
target-lm32/cpu.c +1 -1
@@ -158,7 +158,6 @@ static void lm32_cpu_initfn(Object *obj)if (tcg_enabled () && !tcg_initialized) { tcg_initialized = true;lm32_translate_init (); -cpu_set_debug_excp_handler (lm32_debug_excp_handler); } }
@@ -273,6 +272,7 @@ static void lm32_cpu_class_init(ObjectClass *oc, void *data) cc->vmsd = &vmstate_lm32_cpu;#endif cc->gdb_num_core_regs =32 +7 ; + cc->debug_excp_handler = lm32_debug_excp_handler; }static void lm32_register_cpu_type (const LM32CPUInfo *info)
target-lm32/cpu.h +1 -1
@@ -211,7 +211,7 @@ void lm32_cpu_list(FILE *f, fprintf_function cpu_fprintf);void lm32_translate_init (void );void cpu_lm32_set_phys_msb_ignore (CPULM32State *env,int value); void QEMU_NORETURN raise_exception(CPULM32State *env, int index); -void lm32_debug_excp_handler (CPULM32State *env); +void lm32_debug_excp_handler (CPUState *cs);void lm32_breakpoint_insert (CPULM32State *env,int index,target_ulong address);void lm32_breakpoint_remove (CPULM32State *env,int index); void lm32_watchpoint_insert(CPULM32State *env, int index, target_ulong address,
target-lm32/helper.c +3 -2
@@ -125,9 +125,10 @@ static bool check_watchpoints(CPULM32State *env)return false; } -void lm32_debug_excp_handler (CPULM32State *env) +void lm32_debug_excp_handler (CPUState *cs) { -CPUState *cs =CPU (lm32_env_get_cpu (env)); +LM32CPU *cpu =LM32_CPU (cs); +CPULM32State *env = &cpu->env;CPUBreakpoint *bp;if (cs->watchpoint_hit) {
target-xtensa/cpu.c +1 -1
@@ -119,7 +119,6 @@ static void xtensa_cpu_initfn(Object *obj)if (tcg_enabled () && !tcg_inited) { tcg_inited = true;xtensa_translate_init (); -cpu_set_debug_excp_handler (xtensa_breakpoint_handler); } }
@@ -151,6 +150,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void *data) cc->do_unaligned_access = xtensa_cpu_do_unaligned_access; cc->get_phys_page_debug = xtensa_cpu_get_phys_page_debug;#endif + cc->debug_excp_handler = xtensa_breakpoint_handler; dc->vmsd = &vmstate_xtensa_cpu; }
target-xtensa/cpu.h +1 -1
@@ -390,7 +390,7 @@ static inline CPUXtensaState *cpu_init(const char *cpu_model) }void xtensa_translate_init (void ); -void xtensa_breakpoint_handler (CPUXtensaState *env); +void xtensa_breakpoint_handler (CPUState *cs);int cpu_xtensa_exec (CPUXtensaState *s);void xtensa_register_core (XtensaConfigList *node);void check_interrupts (CPUXtensaState *s);
target-xtensa/helper.c +3 -2
@@ -79,9 +79,10 @@ static uint32_t check_hw_breakpoints(CPUXtensaState *env)return 0 ; } -void xtensa_breakpoint_handler (CPUXtensaState *env) +void xtensa_breakpoint_handler (CPUState *cs) { -CPUState *cs =CPU (xtensa_env_get_cpu (env)); +XtensaCPU *cpu =XTENSA_CPU (cs); +CPUXtensaState *env = &cpu->env;if (cs->watchpoint_hit) {if (cs->watchpoint_hit->flags &BP_CPU ) {
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 11/23] target-arm: Implement setting of watchpoints
In reply to Peter MaydellImplement support for setting QEMU watchpoints based on the values the guest writes to the ARM architected watchpoint registers. (We do not yet report the firing of the watchpoints to the guest, so they will just be ignored.)
--- target-arm/cpu.c | 2 + target-arm/cpu.h | 2 + target-arm/helper.c | 135 +++++++++++++++++++++++++++++++++++++++++++++++-- target-arm/internals.h | 10 ++++ target-arm/machine.c | 3 ++ 5 files changed, 149 insertions(+), 3 deletions(-)
target-arm/cpu.c +2 -0
@@ -184,6 +184,8 @@ static void arm_cpu_reset(CPUState *s) kvm_arm_reset_vcpu(cpu); }#endif + +hw_watchpoint_update_all (cpu); }#ifndef CONFIG_USER_ONLY
target-arm/cpu.h +2 -0
@@ -323,6 +323,8 @@ typedef struct CPUARMState {int eabi;#endif +struct CPUWatchpoint *cpu_watchpoint[16 ]; +CPU_COMMON /* These fields after the common ones so they are preserved on reset. */
target-arm/helper.c +132 -3
150 lines not on this page · raw message
target-arm/internals.h +10 -0
@@ -296,4 +296,14 @@ static inline uint32_t syn_swstep(int same_el, int isv, int ex) | (isv << 24) | (ex << 6) | 0x22; } +/* Update a QEMU watchpoint based on the information the guest has set in the +* DBGWCR<n>_EL1 and DBGWVR<n>_EL1 registers. +*/ +void hw_watchpoint_update (ARMCPU *cpu,int n); +/* Update the QEMU watchpoints for every guest watchpoint. This does a +* complete delete-and-reinstate of the QEMU watchpoint list and so is +* suitable for use after migration or on reset. +*/ +void hw_watchpoint_update_all (ARMCPU *cpu); +#endif
target-arm/machine.c +3 -0
@@ -2,6 +2,7 @@#include "hw/boards.h" #include "sysemu/kvm.h" #include "kvm_arm.h" +#include "internals.h" static bool vfp_needed (void *opaque) {
@@ -213,6 +214,8 @@ static int cpu_post_load(void *opaque, int version_id) } } +hw_watchpoint_update_all (cpu); +return 0 ; }
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 14/23] target-arm: Set DBGDSCR.MOE for debug exceptions taken to AArch32
In reply to Peter MaydellFor debug exceptions taken to AArch32 we have to set the DBGDSCR.MOE (Method Of Entry) bits; we can identify the kind of debug exception from the information in exception.syndrome.
--- target-arm/helper.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
target-arm/helper.c +26 -0
@@ -3629,11 +3629,37 @@ void arm_cpu_do_interrupt(CPUState *cs)uint32_t mask;int new_mode;uint32_t offset; +uint32_t moe;assert (!IS_M (env));arm_log_exception (cs->exception_index); +/* If this is a debug exception we must update the DBGDSCR.MOE bits */ +switch (env->exception.syndrome >>ARM_EL_EC_SHIFT ) { +case EC_BREAKPOINT : +case EC_BREAKPOINT_SAME_EL : + moe =1 ; +break ; +case EC_WATCHPOINT : +case EC_WATCHPOINT_SAME_EL : + moe =10 ; +break ; +case EC_AA32_BKPT : + moe =3 ; +break ; +case EC_VECTORCATCH : + moe =5 ; +break ; +default : + moe =0 ; +break ; + } + +if (moe) { + env->cp15.mdscr_el1 =deposit64 (env->cp15.mdscr_el1,2 ,4 , moe); + } +/* TODO: Vectored interrupt controller. */ switch (cs->exception_index) {case EXCP_UDEF :
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 16/23] target-arm: Implement minimal DBGVCR, OSDLR_EL1, MDCCSR_EL0
In reply to Peter MaydellImplement debug registers DBGVCR, OSDLR_EL1 and MDCCSR_EL0 (as dummy or limited-functionality). 32 bit Linux kernels will access these at startup so they are required for breakpoints and watchpoints to be supported.
--- target-arm/helper.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
target-arm/helper.c +19 -0
@@ -2250,10 +2250,29 @@ static const ARMCPRegInfo debug_cp_reginfo[] = { .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.mdscr_el1), .resetvalue = 0 }, +/* MDCCSR_EL0, aka DBGDSCRint. This is a read-only mirror of MDSCR_EL1. +* We don't implement the configurable EL0 access. +*/ + { .name = "MDCCSR_EL0", .state = ARM_CP_STATE_BOTH, + .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 1, .opc2 = 0, + .type = ARM_CP_NO_MIGRATE, + .access = PL1_R, + .fieldoffset = offsetof(CPUARMState, cp15.mdscr_el1), + .resetfn = arm_cp_reset_ignore }, /* We define a dummy WI OSLAR_EL1, because Linux writes to it. */ { .name = "OSLAR_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 4, .access = PL1_W, .type = ARM_CP_NOP }, + /* Dummy OSDLR_EL1: 32-bit Linux will read this */ + { .name = "OSDLR_EL1", .state = ARM_CP_STATE_BOTH, + .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 1, .crm = 3, .opc2 = 4, + .access = PL1_RW, .type = ARM_CP_NOP }, + /* Dummy DBGVCR: Linux wants to clear this on startup, but we don't + * implement vector catch debug events yet. + */ + { .name = "DBGVCR", + .cp = 14, .opc1 = 0, .crn = 0, .crm = 7, .opc2 = 0, + .access = PL1_RW, .type = ARM_CP_NOP }, REGINFO_SENTINEL };
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 15/23] target-arm: Remove comment about MDSCR_EL1 being dummy implementation
In reply to Peter MaydellMDSCR_EL1 has actual functionality now; remove the out of date comment that claims it is a dummy implementation.
--- target-arm/helper.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
target-arm/helper.c +1 -3
@@ -2244,9 +2244,7 @@ static const ARMCPRegInfo debug_cp_reginfo[] = { .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 }, { .name = "DBGDSAR", .cp = 14, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 0, .access = PL0_R, .type = ARM_CP_CONST, .resetvalue = 0 }, - /* Dummy implementation of monitor debug system control register: - * we don't support debug. (The 32-bit alias is DBGDSCRext.) - */ + /* Monitor debug system control register; the 32-bit alias is DBGDSCRext. */ { .name = "MDSCR_EL1", .state = ARM_CP_STATE_BOTH, .cp = 14, .opc0 = 2, .opc1 = 0, .crn = 0, .crm = 2, .opc2 = 2, .access = PL1_RW,
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 19/23] hw/arm/virt: fix pl011 and pl031 irq flags
In reply to Peter MaydellThe pl011 and pl031 devices both use level triggered interrupts, but the device tree we construct was incorrectly telling the kernel to configure the GIC to treat them as edge triggered. This meant that output from the pl011 would hang after a while.
Message-id: [email protected]
--- hw/arm/virt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/arm/virt.c +2 -2
@@ -372,7 +372,7 @@ static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic) 2, base, 2, size);qemu_fdt_setprop_cells (vbi->fdt, nodename,"interrupts" ,GIC_FDT_IRQ_TYPE_SPI , irq, -GIC_FDT_IRQ_FLAGS_EDGE_LO_HI ); +GIC_FDT_IRQ_FLAGS_LEVEL_HI );qemu_fdt_setprop_cells (vbi->fdt, nodename,"clocks" , vbi->clock_phandle, vbi->clock_phandle); qemu_fdt_setprop(vbi->fdt, nodename, "clock-names",
@@ -399,7 +399,7 @@ static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic) 2, base, 2, size);qemu_fdt_setprop_cells (vbi->fdt, nodename,"interrupts" ,GIC_FDT_IRQ_TYPE_SPI , irq, -GIC_FDT_IRQ_FLAGS_EDGE_LO_HI ); +GIC_FDT_IRQ_FLAGS_LEVEL_HI );qemu_fdt_setprop_cell (vbi->fdt, nodename,"clocks" , vbi->clock_phandle);qemu_fdt_setprop_string (vbi->fdt, nodename,"clock-names" ,"apb_pclk" );g_free (nodename);
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 05/23] target-arm: Fix broken indentation in arm_cpu_reest()
In reply to Peter MaydellFrom: Martin Galvan <[email protected]>
Fix a single misindented line in arm_cpu_reset().
--- target-arm/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-arm/cpu.c +1 -1
@@ -160,7 +160,7 @@ static void arm_cpu_reset(CPUState *s) }if (env->cp15.c1_sys &SCTLR_V ) { - env->regs[15 ] =0xFFFF0000 ; + env->regs[15 ] =0xFFFF0000 ; } env->vfp.xregs[ARM_VFP_FPEXC ] =0 ;
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 07/23] exec.c: Relax restrictions on watchpoint length and alignment
In reply to Peter MaydellThe current implementation of watchpoints requires that they have a power of 2 length which is not greater than TARGET_PAGE_SIZE and that their address is a multiple of their length. Watchpoints on ARM don't fit these restrictions, so change the implementation so they can be relaxed.
--- exec.c | 44 +++++++++++++++++++++++++++++++------------- include/qom/cpu.h | 2 +- linux-user/main.c | 3 +-- 3 files changed, 33 insertions(+), 16 deletions(-)
exec.c +31 -13
@@ -582,12 +582,10 @@ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,int cpu_watchpoint_insert (CPUState *cpu,vaddr addr,vaddr len,int flags,CPUWatchpoint **watchpoint) { -vaddr len_mask = ~(len -1 );CPUWatchpoint *wp; -/* sanity checks: allow power-of-2 lengths, deny unaligned watchpoints */ -if ((len & (len -1 )) || (addr & ~len_mask) || - len ==0 || len >TARGET_PAGE_SIZE ) { +/* forbid ranges which are empty or run off the end of the address space */ +if (len ==0 || (addr + len -1 ) <= addr) {error_report ("tried to set invalid watchpoint at %" VADDR_PRIx", len=%" VADDR_PRIu, addr, len);return -EINVAL ;
@@ -595,7 +593,7 @@ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, wp =g_malloc (sizeof (*wp)); wp->vaddr = addr; - wp->len_mask = len_mask; + wp->len = len; wp->flags = flags;/* keep all GDB-injected watchpoints in front */
@@ -616,11 +614,10 @@ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,int cpu_watchpoint_remove (CPUState *cpu,vaddr addr,vaddr len,int flags) { -vaddr len_mask = ~(len -1 );CPUWatchpoint *wp; QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { -if (addr == wp->vaddr && len_mask == wp->len_mask +if (addr == wp->vaddr && len == wp->len && flags == (wp->flags & ~BP_WATCHPOINT_HIT )) {cpu_watchpoint_remove_by_ref (cpu, wp);return 0 ;
@@ -650,6 +647,27 @@ void cpu_watchpoint_remove_all(CPUState *cpu, int mask) } } } + +/* Return true if this watchpoint address matches the specified +* access (ie the address range covered by the watchpoint overlaps +* partially or completely with the address range covered by the +* access). +*/ +static inline bool cpu_watchpoint_address_matches (CPUWatchpoint *wp, +vaddr addr, +vaddr len) +{ +/* We know the lengths are non-zero, but a little caution is +* required to avoid errors in the case where the range ends +* exactly at the top of the address space and so addr + len +* wraps round to zero. +*/ +vaddr wpend = wp->vaddr + wp->len -1 ; +vaddr addrend = addr + len -1 ; + +return !(addr > wpend || wp->vaddr > addrend); +} +#endif /* Add a breakpoint. */
@@ -861,7 +879,7 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu,/* Make accesses to pages with watchpoints go via the watchpoint trap routines. */ QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { -if (vaddr == (wp->vaddr &TARGET_PAGE_MASK )) { +if (cpu_watchpoint_address_matches (wp, vaddr,TARGET_PAGE_SIZE )) {/* Avoid trapping reads of pages with a write breakpoint. */ if ((prot &PAGE_WRITE ) || (wp->flags &BP_MEM_READ )) { iotlb =PHYS_SECTION_WATCH + paddr;
@@ -1625,7 +1643,7 @@ static const MemoryRegionOps notdirty_mem_ops = { };/* Generate a debug exception if a watchpoint has been hit. */ -static void check_watchpoint (int offset,int len_mask,int flags) +static void check_watchpoint (int offset,int len,int flags) {CPUState *cpu = current_cpu;CPUArchState *env = cpu->env_ptr;
@@ -1643,8 +1661,8 @@ static void check_watchpoint(int offset, int len_mask, int flags) } vaddr = (cpu->mem_io_vaddr &TARGET_PAGE_MASK ) + offset; QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { -if ((vaddr == (wp->vaddr & len_mask) || - (vaddr & wp->len_mask) == wp->vaddr) && (wp->flags & flags)) { +if (cpu_watchpoint_address_matches (wp, vaddr, len) + && (wp->flags & flags)) { wp->flags |=BP_WATCHPOINT_HIT ;if (!cpu->watchpoint_hit) { cpu->watchpoint_hit = wp;
@@ -1670,7 +1688,7 @@ static void check_watchpoint(int offset, int len_mask, int flags)static uint64_t watch_mem_read (void *opaque,hwaddr addr,unsigned size) { -check_watchpoint (addr & ~TARGET_PAGE_MASK , ~(size -1 ),BP_MEM_READ ); +check_watchpoint (addr & ~TARGET_PAGE_MASK , size,BP_MEM_READ );switch (size) {case 1 :return ldub_phys (&address_space_memory, addr);case 2 :return lduw_phys (&address_space_memory, addr);
@@ -1682,7 +1700,7 @@ static uint64_t watch_mem_read(void *opaque, hwaddr addr,static void watch_mem_write (void *opaque,hwaddr addr,uint64_t val,unsigned size) { -check_watchpoint (addr & ~TARGET_PAGE_MASK , ~(size -1 ),BP_MEM_WRITE ); +check_watchpoint (addr & ~TARGET_PAGE_MASK , size,BP_MEM_WRITE );switch (size) {case 1 :stb_phys (&address_space_memory, addr, val);
include/qom/cpu.h +1 -1
@@ -169,7 +169,7 @@ typedef struct CPUBreakpoint {typedef struct CPUWatchpoint {vaddr vaddr; -vaddr len_mask; +vaddr len;int flags;/* BP_* */ QTAILQ_ENTRY (CPUWatchpoint) entry; }CPUWatchpoint ;
linux-user/main.c +1 -2
@@ -3458,8 +3458,7 @@ CPUArchState *cpu_copy(CPUArchState *env)cpu_breakpoint_insert (new_cpu, bp->pc, bp->flags,NULL ); } QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { -cpu_watchpoint_insert (new_cpu, wp->vaddr, (~wp->len_mask) +1 , - wp->flags, NULL); + cpu_watchpoint_insert(new_cpu, wp->vaddr, wp->len, wp->flags, NULL); }#endif
Signature · 1 line
1.9.1
Re: [Qemu-devel] [PULL 07/23] exec.c: Relax restrictions on watchpoint length and alignment
Hi Peter,
Quoted 20 lines · Peter Maydell
The current implementation of watchpoints requires that they have a power of 2 length which is not greater than
TARGET_PAGE_SIZEand that their address is a multiple of their length. Watchpoints on ARM don't fit these restrictions, so change the implementation so they can be relaxed.Signed-off-by Peter Maydell <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- exec.c | 44 +++++++++++++++++++++++++++++++------------- include/qom/cpu.h | 2 +- linux-user/main.c | 3 +-- 3 files changed, 33 insertions(+), 16 deletions(-)exec.c +0
-0@@ -582,12 +582,10 @@ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,
exec.c int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, · line 588
Quoted 10 lines
exec.c +2
-4int flags, CPUWatchpoint **watchpoint) { - vaddr len_mask = ~(len - 1); CPUWatchpoint *wp; -/* sanity checks: allow power-of-2 lengths, deny unaligned watchpoints */ -if ((len & (len -1 )) || (addr & ~len_mask) || - len ==0 || len >TARGET_PAGE_SIZE ) { +/* forbid ranges which are empty or run off the end of the address space */ +if (len ==0 || (addr + len -1 ) <= addr) {
With this change it's no longer possible to set one-byte-long watchpoint, xtensa testsuite fails because of that.
I guess you meant 'len == 0 || (addr + len - 1) < addr' ?
Signature · 2 lines
Thanks. -- Max
Re: [Qemu-devel] [PULL 07/23] exec.c: Relax restrictions on watchpoint length and alignment
Quoted 28 lines · Max Filippov
Hi Peter,
Quoted 25 lines · Peter Maydell
The current implementation of watchpoints requires that they have a power of 2 length which is not greater than
TARGET_PAGE_SIZEand that their address is a multiple of their length. Watchpoints on ARM don't fit these restrictions, so change the implementation so they can be relaxed.Signed-off-by Peter Maydell <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- exec.c | 44 +++++++++++++++++++++++++++++++------------- include/qom/cpu.h | 2 +- linux-user/main.c | 3 +-- 3 files changed, 33 insertions(+), 16 deletions(-)exec.c +0
-1@@ -582,12 +582,10 @@ int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len,int cpu_watchpoint_insert (CPUState *cpu,vaddr addr,vaddr len,int flags,CPUWatchpoint **watchpoint) { -vaddr len_mask = ~(len -1 );CPUWatchpoint *wp;
Quoted 9 lines
exec.c int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, · line 588
Quoted 5 lines
exec.c +2
-3-/* sanity checks: allow power-of-2 lengths, deny unaligned watchpoints */ -if ((len & (len -1 )) || (addr & ~len_mask) || - len ==0 || len >TARGET_PAGE_SIZE ) { +/* forbid ranges which are empty or run off the end of the address space */ +if (len ==0 || (addr + len -1 ) <= addr) {With this change it's no longer possible to set one-byte-long watchpoint, xtensa testsuite fails because of that.
I guess you meant 'len == 0 || (addr + len - 1) < addr' ?
Oops, yes.
thanks
-- PMM
[Qemu-devel] [PULL 12/23] target-arm: Move extended_addresses_enabled() to internals.h
In reply to Peter MaydellMove the utility function extended_addresses_enabled() into internals.h; we're going to need to call it from op_helper.c.
--- target-arm/helper.c | 11 ----------- target-arm/internals.h | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-)
target-arm/helper.c +0 -11
@@ -304,17 +304,6 @@ void init_cpreg_list(ARMCPU *cpu)g_list_free (keys); } -/* Return true if extended addresses are enabled. -* This is always the case if our translation regime is 64 bit, -* but depends on TTBCR.EAE for 32 bit. -*/ -static inline bool extended_addresses_enabled (CPUARMState *env) -{ -return arm_el_is_aa64 (env,1 ) - || ((arm_feature (env,ARM_FEATURE_LPAE ) - && (env->cp15.c2_control &TTBCR_EAE ))); -} -static void dacr_write (CPUARMState *env,const ARMCPRegInfo *ri,uint64_t value) {ARMCPU *cpu =arm_env_get_cpu (env);
target-arm/internals.h +11 -0
@@ -142,6 +142,17 @@ static inline void update_spsel(CPUARMState *env, uint32_t imm)aarch64_restore_sp (env, cur_el); } +/* Return true if extended addresses are enabled. +* This is always the case if our translation regime is 64 bit, +* but depends on TTBCR.EAE for 32 bit. +*/ +static inline bool extended_addresses_enabled (CPUARMState *env) +{ +return arm_el_is_aa64 (env,1 ) + || ((arm_feature (env,ARM_FEATURE_LPAE ) + && (env->cp15.c2_control &TTBCR_EAE ))); +} +/* Valid Syndrome Register EC field values */ enum arm_exception_class {EC_UNCATEGORIZED =0x00 ,
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 01/23] hw/arm/virt: add linux, stdout-path to /chosen DT node
In reply to Peter MaydellFrom: Ard Biesheuvel <[email protected]>
Add a property "linux,stdout-path" to the /chosen DT node and make it point to the emulated UART. This allows users such as the Linux kernel to produce console output without the need to pass console= or earlycon=pl011,0x... command line arguments.
Message-id: [email protected]
--- hw/arm/virt.c | 2 ++ 1 file changed, 2 insertions(+)
hw/arm/virt.c +2 -0
@@ -376,6 +376,8 @@ static void create_uart(const VirtBoardInfo *vbi, qemu_irq *pic) vbi->clock_phandle, vbi->clock_phandle);qemu_fdt_setprop (vbi->fdt, nodename,"clock-names" , clocknames,sizeof (clocknames)); + +qemu_fdt_setprop_string (vbi->fdt,"/chosen" ,"linux,stdout-path" , nodename);g_free (nodename); }
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 06/23] hw/arm/virt: Provide flash devices for boot ROMs
In reply to Peter MaydellAdd two flash devices to the virt board, so that it can be used for running guests which want a bootrom image such as UEFI. We provide two flash devices to make it more convenient to provide both a read-only UEFI image and a read-write place to store guest-set UEFI config variables. The '-bios' command line option is set up to provide an image for the first of the two flash devices.
Message-id: [email protected]
--- hw/arm/virt.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+)
hw/arm/virt.c +70 -0
@@ -37,6 +37,7 @@#include "sysemu/sysemu.h" #include "sysemu/kvm.h" #include "hw/boards.h" +#include "hw/loader.h" #include "exec/address-spaces.h" #include "qemu/bitops.h" #include "qemu/error-report.h"
@@ -439,6 +440,73 @@ static void create_virtio_devices(const VirtBoardInfo *vbi, qemu_irq *pic) } } +static void create_one_flash (const char *name,hwaddr flashbase, +hwaddr flashsize) +{ +/* Create and map a single flash device. We use the same +* parameters as the flash devices on the Versatile Express board. +*/ +DriveInfo *dinfo =drive_get_next (IF_PFLASH ); +DeviceState *dev =qdev_create (NULL ,"cfi.pflash01" ); +const uint64_t sectorlength =256 *1024 ; + +if (dinfo &&qdev_prop_set_drive (dev,"drive" , dinfo->bdrv)) { +abort (); + } + +qdev_prop_set_uint32 (dev,"num-blocks" , flashsize / sectorlength); +qdev_prop_set_uint64 (dev,"sector-length" , sectorlength); +qdev_prop_set_uint8 (dev,"width" ,4 ); +qdev_prop_set_uint8 (dev,"device-width" ,2 ); +qdev_prop_set_uint8 (dev,"big-endian" ,0 ); +qdev_prop_set_uint16 (dev,"id0" ,0x89 ); +qdev_prop_set_uint16 (dev,"id1" ,0x18 ); +qdev_prop_set_uint16 (dev,"id2" ,0x00 ); +qdev_prop_set_uint16 (dev,"id3" ,0x00 ); +qdev_prop_set_string (dev,"name" , name); +qdev_init_nofail (dev); + +sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , flashbase); +} + +static void create_flash (const VirtBoardInfo *vbi) +{ +/* Create two flash devices to fill the VIRT_FLASH space in the memmap. +* Any file passed via -bios goes in the first of these. +*/ +hwaddr flashsize = vbi->memmap[VIRT_FLASH ].size /2 ; +hwaddr flashbase = vbi->memmap[VIRT_FLASH ].base; +char *nodename; + +if (bios_name) { +const char *fn; + +if (drive_get (IF_PFLASH ,0 ,0 )) { +error_report ("The contents of the first flash device may be " +"specified with -bios or with -drive if=pflash... " +"but you cannot use both options at once" ); +exit (1 ); + } + fn =qemu_find_file (QEMU_FILE_TYPE_BIOS , bios_name); +if (!fn ||load_image_targphys (fn, flashbase, flashsize) <0 ) { +error_report ("Could not load ROM image '%s'" , bios_name); +exit (1 ); + } + } + +create_one_flash ("virt.flash0" , flashbase, flashsize); +create_one_flash ("virt.flash1" , flashbase + flashsize, flashsize); + + nodename =g_strdup_printf ("/flash@%" PRIx64, flashbase); +qemu_fdt_add_subnode (vbi->fdt, nodename); +qemu_fdt_setprop_string (vbi->fdt, nodename,"compatible" ,"cfi-flash" ); +qemu_fdt_setprop_sized_cells (vbi->fdt, nodename,"reg" , +2 , flashbase,2 , flashsize, +2 , flashbase + flashsize,2 , flashsize); +qemu_fdt_setprop_cell (vbi->fdt, nodename,"bank-width" ,4 ); +g_free (nodename); +} +static void *machvirt_dtb (const struct arm_boot_info *binfo,int *fdt_size) {const VirtBoardInfo *board = (const VirtBoardInfo *)binfo;
@@ -516,6 +584,8 @@ static void machvirt_init(MachineState *machine)vmstate_register_ram_global (ram);memory_region_add_subregion (sysmem, vbi->memmap[VIRT_MEM ].base, ram); +create_flash (vbi); +create_gic (vbi, pic);create_uart (vbi, pic);
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 20/23] hw/arm/boot: load DTB as a ROM image
In reply to Peter MaydellFrom: Ard Biesheuvel <[email protected]>
In order to make the device tree blob (DTB) available in memory not only at first boot, but also after system reset, use rom_blob_add_fixed() to install it into memory.
Message-id: [email protected]
--- hw/arm/boot.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
hw/arm/boot.c +4 -1
@@ -396,7 +396,10 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo)qemu_fdt_dumpdtb (fdt, size); -cpu_physical_memory_write (addr, fdt, size); +/* Put the DTB into the memory map as a ROM image: this will ensure +* the DTB is copied again upon reset, even if addr points into RAM. +*/ +rom_add_blob_fixed ("dtb" , fdt, size, addr);g_free (fdt);
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 21/23] hw/arm/boot: pass an address limit to and return size from load_dtb()
In reply to Peter MaydellFrom: Ard Biesheuvel <[email protected]>
Add an address limit input parameter to load_dtb() so that we can tell load_dtb() how much memory the dtb is allowed to consume. If the dtb doesn't fit, return 0, otherwise return the actual size of the loaded dtb.
Message-id: [email protected]
--- hw/arm/boot.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-)
hw/arm/boot.c +31 -3
@@ -312,7 +312,26 @@ static void set_kernel_args_old(const struct arm_boot_info *info) } } -static int load_dtb (hwaddr addr,const struct arm_boot_info *binfo) +/** +* load_dtb() - load a device tree binary image into memory +* @addr: the address to load the image at +* @binfo: struct describing the boot environment +* @addr_limit: upper limit of the available memory area at @addr +* +* Load a device tree supplied by the machine or by the user with the +* '-dtb' command line option, and put it at offset @addr in target +* memory. +* +* If @addr_limit contains a meaningful value (i.e., it is strictly greater +* than @addr), the device tree is only loaded if its size does not exceed +* the limit. +* +* Returns: the size of the device tree image on success, +* 0 if the image size exceeds the limit, +* -1 on errors. +*/ +static int load_dtb (hwaddr addr,const struct arm_boot_info *binfo, +hwaddr addr_limit) {void *fdt =NULL ;int size, rc;
@@ -341,6 +360,15 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo) } } +if (addr_limit > addr && size > (addr_limit - addr)) { +/* Installing the device tree blob at addr would exceed addr_limit. +* Whether this constitutes failure is up to the caller to decide, +* so just return 0 as size, i.e., no error. +*/ +g_free (fdt); +return 0 ; + } + acells =qemu_fdt_getprop_cell (fdt,"/" ,"#address-cells" ); scells =qemu_fdt_getprop_cell (fdt,"/" ,"#size-cells" );if (acells ==0 || scells ==0 ) {
@@ -403,7 +431,7 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo)g_free (fdt); -return 0 ; +return size; fail:g_free (fdt);
@@ -572,7 +600,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)*/ hwaddr dtb_start =QEMU_ALIGN_UP (info->initrd_start + initrd_size,4096 ); -if (load_dtb (dtb_start, info)) { +if (load_dtb (dtb_start, info,0 ) <0 ) {exit (1 ); } fixupcontext[FIXUP_ARGPTR ] = dtb_start;
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 03/23] pl061: implement input interrupt logic
In reply to Peter MaydellFrom: Colin Leitner <[email protected]>
This patch adds the missing input interrupt logic to the pl061 GPIO device. To keep the floating output pins to stay high, the old state variable had to be split into two separate ones for input and output - which brings the vmstate version to 3.
Edge level interrupts and I/O were tested under Linux 3.14. Level interrupt handling hasn't been tested.
Message-id: [email protected]
--- hw/gpio/pl061.c | 59 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 14 deletions(-)
hw/gpio/pl061.c +45 -14
@@ -37,7 +37,8 @@ typedef struct PL061State {MemoryRegion iomem;uint32_t locked;uint32_t data; -uint32_t old_data; +uint32_t old_out_data; +uint32_t old_in_data;uint32_t dir;uint32_t isense;uint32_t ibe;
@@ -63,12 +64,13 @@ typedef struct PL061State {static const VMStateDescription vmstate_pl061 = { .name ="pl061" , - .version_id =2 , - .minimum_version_id =1 , + .version_id =3 , + .minimum_version_id =3 , .fields = (VMStateField []) {VMSTATE_UINT32 (locked, PL061State),VMSTATE_UINT32 (data, PL061State), -VMSTATE_UINT32 (old_data, PL061State), +VMSTATE_UINT32 (old_out_data, PL061State), +VMSTATE_UINT32 (old_in_data, PL061State),VMSTATE_UINT32 (dir, PL061State),VMSTATE_UINT32 (isense, PL061State),VMSTATE_UINT32 (ibe, PL061State),
@@ -98,23 +100,52 @@ static void pl061_update(PL061State *s)uint8_t out;int i; +DPRINTF ("dir = %d, data = %d\n" , s->dir, s->data); +/* Outputs float high. */ /* FIXME: This is board dependent. */ out = (s->data & s->dir) | ~s->dir; - changed = s->old_data ^ out; -if (!changed) -return ; + changed = s->old_out_data ^ out; +if (changed) { + s->old_out_data = out; +for (i =0 ; i <8 ; i++) { + mask =1 << i; +if (changed & mask) { +DPRINTF ("Set output %d = %d\n" , i, (out & mask) !=0 ); +qemu_set_irq (s->out[i], (out & mask) !=0 ); + } + } + } - s->old_data = out; -for (i =0 ; i <8 ; i++) { - mask =1 << i; -if (changed & mask) { -DPRINTF ("Set output %d = %d\n" , i, (out & mask) !=0 ); -qemu_set_irq (s->out[i], (out & mask) !=0 ); +/* Inputs */ + changed = (s->old_in_data ^ s->data) & ~s->dir; +if (changed) { + s->old_in_data = s->data; +for (i =0 ; i <8 ; i++) { + mask =1 << i; +if (changed & mask) { +DPRINTF ("Changed input %d = %d\n" , i, (s->data & mask) !=0 ); + +if (!(s->isense & mask)) { +/* Edge interrupt */ +if (s->ibe & mask) { +/* Any edge triggers the interrupt */ + s->istate |= mask; + }else { +/* Edge is selected by IEV */ + s->istate |= ~(s->data ^ s->iev) & mask; + } + } + } } } -/* FIXME: Implement input interrupts. */ +/* Level interrupt */ + s->istate |= ~(s->data ^ s->iev) & s->isense; + +DPRINTF ("istate = %02X\n" , s->istate); + +qemu_set_irq (s->irq, (s->istate & s->im) !=0 ); } static uint64_t pl061_read(void *opaque, hwaddr offset,
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 04/23] target-arm: Fix resetting issues on ARMv7-M CPUs
In reply to Peter MaydellFrom: Martin Galvan <[email protected]>
When calling qemu_system_reset after startup on a Cortex-M
CPU, the initial values of PC, MSP and the Thumb bit weren't being set correctly if the vector table was in ROM. In particular, since Thumb was 0, a Usage Fault would arise immediately after trying to execute any instruction on a Cortex-M.
Message-id: CAOKbPbaLt-LJsAKkQdOE0cs9Xx4OWrUfpDhATXPSdtuNw2xu_A@mail.gmail.com
--- target-arm/cpu.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)
target-arm/cpu.c +22 -10
@@ -129,22 +129,34 @@ static void arm_cpu_reset(CPUState *s) env->uncached_cpsr =ARM_CPU_MODE_SVC ; env->daif =PSTATE_D |PSTATE_A |PSTATE_I |PSTATE_F ;/* On ARMv7-M the CPSR_I is the value of the PRIMASK register, and is -clear at reset. Initial SP and PC are loaded from ROM. */ +* clear at reset. Initial SP and PC are loaded from ROM. +*/ if (IS_M (env)) { -uint32_t pc; +uint32_t initial_msp;/* Loaded from 0x0 */ +uint32_t initial_pc;/* Loaded from 0x4 */ uint8_t *rom; + env->daif &= ~PSTATE_I ; rom =rom_ptr (0 );if (rom) { -/* We should really use ldl_phys here, in case the guest -modified flash and reset itself. However images -loaded via -kernel have not been copied yet, so load the -values directly from there. */ - env->regs[13 ] =ldl_p (rom) &0xFFFFFFFC ; - pc =ldl_p (rom +4 ); - env->thumb = pc &1 ; - env->regs[15 ] = pc & ~1 ; +/* Address zero is covered by ROM which hasn't yet been +* copied into physical memory. +*/ + initial_msp =ldl_p (rom); + initial_pc =ldl_p (rom +4 ); + }else { +/* Address zero not covered by a ROM blob, or the ROM blob +* is in non-modifiable memory and this is a second reset after +* it got copied into memory. In the latter case, rom_ptr +* will return a NULL pointer and we should use ldl_phys instead. +*/ + initial_msp =ldl_phys (s->as,0 ); + initial_pc =ldl_phys (s->as,4 ); } + + env->regs[13 ] = initial_msp &0xFFFFFFFC ; + env->regs[15 ] = initial_pc & ~1 ; + env->thumb = initial_pc &1 ; }if (env->cp15.c1_sys &SCTLR_V ) {
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 08/23] exec.c: Provide full set of dummy wp remove functions in user-mode
In reply to Peter MaydellWe already provide dummy versions of the cpu_watchpoint_insert and cpu_watchpoint_remove_all functions when CONFIG_USER_ONLY is defined. Complete the set by providing cpu_watchpoint_remove and cpu_watchpoint_remove_by_ref as well.
This allows target-* code using these functions to avoid some ifdeffery.
--- exec.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
exec.c +10 -0
@@ -572,6 +572,16 @@ void cpu_watchpoint_remove_all(CPUState *cpu, int mask) { } +int cpu_watchpoint_remove (CPUState *cpu,vaddr addr,vaddr len, +int flags) +{ +return -ENOSYS ; +} + +void cpu_watchpoint_remove_by_ref (CPUState *cpu,CPUWatchpoint *watchpoint) +{ +} +int cpu_watchpoint_insert (CPUState *cpu,vaddr addr,vaddr len,int flags,CPUWatchpoint **watchpoint) {
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 13/23] target-arm: Implement handling of fired watchpoints
In reply to Peter MaydellImplement the ARM debug exception handler for dealing with fired watchpoints.
--- target-arm/cpu.c | 1 + target-arm/helper.c | 7 +- target-arm/internals.h | 9 +++ target-arm/op_helper.c | 188 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 204 insertions(+), 1 deletion(-)
target-arm/cpu.c +1 -0
@@ -1065,6 +1065,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)#endif cc->gdb_num_core_regs =26 ; cc->gdb_core_xml_file ="arm-core.xml" ; + cc->debug_excp_handler = arm_debug_excp_handler; }static void cpu_register (const ARMCPUInfo *info)
target-arm/helper.c +6 -1
@@ -2399,14 +2399,18 @@ static void define_debug_regs(ARMCPU *cpu)* These are just dummy implementations for now. */ int i; -int wrps, brps; +int wrps, brps, ctx_cmps;ARMCPRegInfo dbgdidr = { .name ="DBGDIDR" , .cp =14 , .crn =0 , .crm =0 , .opc1 =0 , .opc2 =0 , .access =PL0_R , .type =ARM_CP_CONST , .resetvalue = cpu->dbgdidr, }; +/* Note that all these register fields hold "number of Xs minus 1". */ brps =extract32 (cpu->dbgdidr,24 ,4 ); wrps =extract32 (cpu->dbgdidr,28 ,4 ); + ctx_cmps =extract32 (cpu->dbgdidr,20 ,4 ); + +assert (ctx_cmps <= brps);/* The DBGDIDR and ID_AA64DFR0_EL1 define various properties * of the debug registers such as number of breakpoints;
@@ -2415,6 +2419,7 @@ static void define_debug_regs(ARMCPU *cpu)if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) {assert (extract32 (cpu->id_aa64dfr0,12 ,4 ) == brps);assert (extract32 (cpu->id_aa64dfr0,20 ,4 ) == wrps); +assert (extract32 (cpu->id_aa64dfr0,28 ,4 ) == ctx_cmps); }define_one_arm_cp_reg (cpu, &dbgdidr);
target-arm/internals.h +9 -0
@@ -307,6 +307,12 @@ static inline uint32_t syn_swstep(int same_el, int isv, int ex) | (isv << 24) | (ex << 6) | 0x22; } +static inline uint32_t syn_watchpoint (int same_el,int cm,int wnr) +{ +return (EC_WATCHPOINT <<ARM_EL_EC_SHIFT ) | (same_el <<ARM_EL_EC_SHIFT ) + | (cm <<8 ) | (wnr <<6 ) |0x22 ; +} +/* Update a QEMU watchpoint based on the information the guest has set in the * DBGWCR<n>_EL1 and DBGWVR<n>_EL1 registers. */
@@ -317,4 +323,7 @@ void hw_watchpoint_update(ARMCPU *cpu, int n);*/ void hw_watchpoint_update_all (ARMCPU *cpu); +/* Callback function for when a watchpoint or breakpoint triggers. */ +void arm_debug_excp_handler (CPUState *cs); +#endif
target-arm/op_helper.c +188 -0
194 lines not on this page · raw message
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 22/23] hw/arm/boot: load device tree to base of DRAM if no -kernel option was passed
In reply to Peter MaydellFrom: Ard Biesheuvel <[email protected]>
If we are running the 'virt' machine, we may have a device tree blob but no kernel to supply it to if no -kernel option was passed. In that case, copy it to the base of RAM where it can be picked up by a bootloader.
Message-id: [email protected]
--- hw/arm/boot.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
hw/arm/boot.c +10 -0
@@ -490,6 +490,16 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)/* Load the kernel. */ if (!info->kernel_filename) { + +if (have_dtb (info)) { +/* If we have a device tree blob, but no kernel to supply it to, +* copy it to the base of RAM for a bootloader to pick up. +*/ +if (load_dtb (info->loader_start, info,0 ) <0 ) { +exit (1 ); + } + } +/* If no kernel specified, do nothing; we will start from address 0 * (typically a boot ROM image) in the same way as hardware. */
Signature · 1 line
1.9.1
[Qemu-devel] [PULL 02/23] cpu-exec.c: Allow disabling of IRQs on ARM Cortex-M CPUs
In reply to Peter MaydellFrom: David Hoover <[email protected]>
Correct an error in the logic for deciding whether we can take an IRQ interrupt which meant that on M profile cores it was never possible to disable them.
The design here is still bogus in that M profile doesn't have separate "IRQ" and "FIQ", which are an A/R profile concept; we should ideally implement the proper priority based scheme.
--- cpu-exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
cpu-exec.c +2 -2
@@ -618,8 +618,8 @@ int cpu_exec(CPUArchState *env)We avoid this by disabling interrupts when pc contains a magic address. */ if (interrupt_request &CPU_INTERRUPT_HARD - && ((IS_M (env) && env->regs[15 ] <0xfffffff0 ) - || !(env->daif &PSTATE_I ))) { + && !(env->daif &PSTATE_I ) + && (!IS_M (env) || env->regs[15 ] <0xfffffff0 )) { cpu->exception_index =EXCP_IRQ ; cc->do_interrupt (cpu); next_tb =0 ;
Signature · 1 line
1.9.1
Peter Maydell
AppliedQuoted 10 lines · Peter Maydell
Flushing a bunch of queued up ARM patches, a mix of new features and bug fixes.
thanks
-- PMMThe following changes since commit
0dfa7e30126364c434a48cb37a1a41119e536c2a:Merge remote-tracking branch 'remotes/kraxel/tags/pull-console-20140905-2' into staging (2014-09-11 11:44:17 +0100)
Quoted 9 lines
are available in the git repository at:
git://git.linaro.org/people/pmaydell/qemu-arm.gittags/pull-target-arm-20140912for you to fetch changes up to
92df845070290236d1b28b03453deec1ae9c4263:hw/arm/boot: enable DTB support when booting ELF images (2014-09-12 14:06:50 +0100)
Applied, thanks.
-- PMM