Skip to contentSkip to conversation

target-arm queue

GIT PULL Applied Peter Maydell 1 participant 11 messages Mar 10, 2014 – Mar 11, 2014 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

target-arm queue. I'm expecting to do another queue run before hard freeze, since there are still some bits and pieces on list which need a little more review before they can be committed.

thanks
-- PMM

The following changes since commit e9d818b8b1a7fadc6c92256b716f1bc21b8daabc:

Merge remote-tracking branch 'remotes/rth/tcg-aarch-6-1' into staging (2014-03-10 12:34:41 +0000)

are available in the git repository at:

git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20140310

for you to fetch changes up to 72c1d3af6e9c2745edfeaa71918a68bcee4b79db:

target-arm: Implement WFE as a yield operation (2014-03-10 14:56:30 +0000)

----------------------------------------------------------------
target-arm queue:
* implement WFE as yield (improves performance with emulated SMP)
* fixes to avoid undefined behaviour shifting left into sign bit
* libvixl format string fixes for 32 bit hosts
* fix build error when intptr_t and tcg_target_long are different sizes (eg x32)
* implement PMCCNTR register
* fix incorrect setting of E bit in CPSR (broke booting under KVM on ARM)

----------------------------------------------------------------
Alistair Francis (1):
target-arm: Implements the ARM PMCCNTR register

Peter Maydell (6):
target-arm: Fix incorrect setting of E bit in CPSR
pxa2xx: Don't shift into sign bit hw/arm/omap1.c: Avoid shifting left into sign bit hw/ssi/xilinx_spips.c: Avoid shifting left into sign bit hw/arm/musicpal: Avoid shifting left into sign bit
target-arm: Implement WFE as a yield operation

Richard Henderson (1):
target-arm: Fix intptr_t vs tcg_target_long

Stefan Weil (1):
libvixl: Fix format strings for several int64_t values

 disas/libvixl/a64/disasm-a64.cc | 20 ++++-----
 hw/arm/musicpal.c               |  4 +-
 hw/arm/omap1.c                  | 24 ++++++-----
 hw/arm/pxa2xx.c                 |  6 +--
 hw/arm/pxa2xx_gpio.c            |  2 +-
 hw/arm/pxa2xx_pic.c             |  4 +-
 hw/ssi/xilinx_spips.c           |  4 +-
 include/exec/cpu-defs.h         |  1 +
 target-arm/cpu.h                |  4 ++
 target-arm/helper.c             | 91 ++++++++++++++++++++++++++++++++++++++---
 target-arm/helper.h             |  1 +
 target-arm/op_helper.c          |  9 ++++
 target-arm/translate-a64.c      |  2 +-
 target-arm/translate.c          |  6 +++
 target-arm/translate.h          |  2 +
 15 files changed, 144 insertions(+), 36 deletions(-)
#1 lore raw

[Qemu-devel] [PULL 9/9] target-arm: Implement WFE as a yield operation

Implement WFE to yield our timeslice to the next CPU. This avoids slowdowns in multicore configurations caused by one core busy-waiting on a spinlock which can't possibly be unlocked until the other core has an opportunity to run. This speeds up my test case A15 dual-core boot by a factor of three (though it is still four or five times slower than a single-core boot).

Message-id: [email protected]

---
 include/exec/cpu-defs.h | 1 +
 target-arm/helper.h     | 1 +
 target-arm/op_helper.c  | 9 +++++++++
 target-arm/translate.c  | 6 ++++++
 target-arm/translate.h  | 2 ++
 5 files changed, 19 insertions(+)
include/exec/cpu-defs.h +1 -0
index 01cd8c7..66a3d46 100644
@@ -59,6 +59,7 @@ typedef uint64_t target_ulong;
 #define EXCP_HLT        0x10001 /* hlt instruction reached */
 #define EXCP_DEBUG      0x10002 /* cpu stopped after a breakpoint or singlestep */
 #define EXCP_HALTED     0x10003 /* cpu is halted (waiting for external event) */
+#define EXCP_YIELD      0x10004 /* cpu wants to yield timeslice to another */
 
 #define TB_JMP_CACHE_BITS 12
 #define TB_JMP_CACHE_SIZE (1 << TB_JMP_CACHE_BITS)
target-arm/helper.h +1 -0
index 276f3a9..8923f8a 100644
@@ -50,6 +50,7 @@ DEF_HELPER_FLAGS_3(sel_flags, TCG_CALL_NO_RWG_SE,
                    i32, i32, i32, i32)
 DEF_HELPER_2(exception, void, env, i32)
 DEF_HELPER_1(wfi, void, env)
+DEF_HELPER_1(wfe, void, env)
 
 DEF_HELPER_3(cpsr_write, void, env, i32, i32)
 DEF_HELPER_1(cpsr_read, i32, env)
target-arm/op_helper.c +9 -0
index 7d06d2f..5851e04 100644
@@ -225,6 +225,15 @@ void HELPER(wfi)(CPUARMState *env)
     cpu_loop_exit(env);
 }
 
+void HELPER(wfe)(CPUARMState *env)
+{
+    /* Don't actually halt the CPU, just yield back to top
+     * level loop
+     */
+    env->exception_index = EXCP_YIELD;
+    cpu_loop_exit(env);
+}
+
 void HELPER(exception)(CPUARMState *env, uint32_t excp)
 {
     env->exception_index = excp;
target-arm/translate.c +6 -0
index 253d2a1..df259de 100644
@@ -3939,6 +3939,9 @@ static void gen_nop_hint(DisasContext *s, int val)
         s->is_jmp = DISAS_WFI;
         break;
     case 2: /* wfe */
+        gen_set_pc_im(s, s->pc);
+        s->is_jmp = DISAS_WFE;
+        break;
     case 4: /* sev */
     case 5: /* sevl */
         /* TODO: Implement SEV, SEVL and WFE.  May help SMP performance.  */
@@ -10857,6 +10860,9 @@ static inline void gen_intermediate_code_internal(ARMCPU *cpu,
         case DISAS_WFI:
             gen_helper_wfi(cpu_env);
             break;
+        case DISAS_WFE:
+            gen_helper_wfe(cpu_env);
+            break;
         case DISAS_SWI:
             gen_exception(EXCP_SWI);
             break;
target-arm/translate.h +2 -0
index 67da699..2f491f9 100644
@@ -44,6 +44,8 @@ extern TCGv_ptr cpu_env;
  * emitting unreachable code at the end of the TB in the A64 decoder
  */
 #define DISAS_EXC 6
+/* WFE */
+#define DISAS_WFE 7
 
 #ifdef TARGET_AARCH64
 void a64_translate_init(void);
Signature · 1 line
1.9.0
#2 lore raw

[Qemu-devel] [PULL 3/9] target-arm: Fix intptr_t vs tcg_target_long

In reply to Peter Maydell

From: Richard Henderson <[email protected]>

Fixes a build error when these are different, e.g. x32.

Message-id: [email protected]

---
 target-arm/translate-a64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-arm/translate-a64.c +1 -1
index 08ac659..37e05e8 100644
@@ -210,7 +210,7 @@ static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest)
     if (use_goto_tb(s, n, dest)) {
         tcg_gen_goto_tb(n);
         gen_a64_set_pc_im(dest);
-        tcg_gen_exit_tb((tcg_target_long)tb + n);
+        tcg_gen_exit_tb((intptr_t)tb + n);
         s->is_jmp = DISAS_TB_JUMP;
     } else {
         gen_a64_set_pc_im(dest);
Signature · 1 line
1.9.0
#3 lore raw

[Qemu-devel] [PULL 4/9] libvixl: Fix format strings for several int64_t values

In reply to Peter Maydell

From: Stefan Weil <[email protected]>

"%d" or "%x" won't work on hosts where int values are smaller than 64 bit.

Message-id: [email protected]

---
 disas/libvixl/a64/disasm-a64.cc | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
disas/libvixl/a64/disasm-a64.cc +10 -10
index 5c6b898..5f172da 100644
@@ -1342,7 +1342,7 @@ int Disassembler::SubstituteImmediateField(Instruction* instr,
         ASSERT(format[5] == 'L');
         AppendToOutput("#0x%" PRIx64, instr->ImmMoveWide());
         if (instr->ShiftMoveWide() > 0) {
-          AppendToOutput(", lsl #%d", 16 * instr->ShiftMoveWide());
+          AppendToOutput(", lsl #%" PRId64, 16 * instr->ShiftMoveWide());
         }
       }
       return 8;
@@ -1391,7 +1391,7 @@ int Disassembler::SubstituteImmediateField(Instruction* instr,
     }
     case 'F': {  // IFPSingle, IFPDouble or IFPFBits.
       if (format[3] == 'F') {  // IFPFbits.
-        AppendToOutput("#%d", 64 - instr->FPScale());
+        AppendToOutput("#%" PRId64, 64 - instr->FPScale());
         return 8;
       } else {
         AppendToOutput("#0x%" PRIx64 " (%.4f)", instr->ImmFP(),
@@ -1412,23 +1412,23 @@ int Disassembler::SubstituteImmediateField(Instruction* instr,
       return 5;
     }
     case 'P': {  // IP - Conditional compare.
-      AppendToOutput("#%d", instr->ImmCondCmp());
+      AppendToOutput("#%" PRId64, instr->ImmCondCmp());
       return 2;
     }
     case 'B': {  // Bitfields.
       return SubstituteBitfieldImmediateField(instr, format);
     }
     case 'E': {  // IExtract.
-      AppendToOutput("#%d", instr->ImmS());
+      AppendToOutput("#%" PRId64, instr->ImmS());
       return 8;
     }
     case 'S': {  // IS - Test and branch bit.
-      AppendToOutput("#%d", (instr->ImmTestBranchBit5() << 5) |
-                            instr->ImmTestBranchBit40());
+      AppendToOutput("#%" PRId64, (instr->ImmTestBranchBit5() << 5) |
+                                  instr->ImmTestBranchBit40());
       return 2;
     }
     case 'D': {  // IDebug - HLT and BRK instructions.
-      AppendToOutput("#0x%x", instr->ImmException());
+      AppendToOutput("#0x%" PRIx64, instr->ImmException());
       return 6;
     }
     default: {
@@ -1598,12 +1598,12 @@ int Disassembler::SubstituteExtendField(Instruction* instr,
       (((instr->ExtendMode() == UXTW) && (instr->SixtyFourBits() == 0)) ||
        (instr->ExtendMode() == UXTX))) {
     if (instr->ImmExtendShift() > 0) {
-      AppendToOutput(", lsl #%d", instr->ImmExtendShift());
+      AppendToOutput(", lsl #%" PRId64, instr->ImmExtendShift());
     }
   } else {
     AppendToOutput(", %s", extend_mode[instr->ExtendMode()]);
     if (instr->ImmExtendShift() > 0) {
-      AppendToOutput(" #%d", instr->ImmExtendShift());
+      AppendToOutput(" #%" PRId64, instr->ImmExtendShift());
     }
   }
   return 3;
@@ -1632,7 +1632,7 @@ int Disassembler::SubstituteLSRegOffsetField(Instruction* instr,
   if (!((ext == UXTX) && (shift == 0))) {
     AppendToOutput(", %s", extend_mode[ext]);
     if (shift != 0) {
-      AppendToOutput(" #%d", instr->SizeLS());
+      AppendToOutput(" #%" PRId64, instr->SizeLS());
     }
   }
   return 9;
Signature · 1 line
1.9.0
#4 lore raw

[Qemu-devel] [PULL 6/9] hw/arm/omap1.c: Avoid shifting left into sign bit

In reply to Peter Maydell

Add missing 'U' suffix to avoid shifting left into sign bit.

Message-id: [email protected]

---
 hw/arm/omap1.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
hw/arm/omap1.c +14 -10
index 47511d2..b433748 100644
@@ -809,22 +809,26 @@ static inline void omap_pin_funcmux1_update(struct omap_mpu_state_s *s,
                 uint32_t diff, uint32_t value)
 {
     if (s->compat1509) {
-        if (diff & (1 << 31))			/* MCBSP3_CLK_HIZ_DI */
-            omap_clk_onoff(omap_findclk(s, "mcbsp3.clkx"),
-                            (value >> 31) & 1);
-        if (diff & (1 << 1))			/* CLK32K */
-            omap_clk_onoff(omap_findclk(s, "clk32k_out"),
-                            (~value >> 1) & 1);
+        if (diff & (1U << 31)) {
+            /* MCBSP3_CLK_HIZ_DI */
+            omap_clk_onoff(omap_findclk(s, "mcbsp3.clkx"), (value >> 31) & 1);
+        }
+        if (diff & (1 << 1)) {
+            /* CLK32K */
+            omap_clk_onoff(omap_findclk(s, "clk32k_out"), (~value >> 1) & 1);
+        }
     }
 }
 
 static inline void omap_pin_modconf1_update(struct omap_mpu_state_s *s,
                 uint32_t diff, uint32_t value)
 {
-    if (diff & (1 << 31))			/* CONF_MOD_UART3_CLK_MODE_R */
-         omap_clk_reparent(omap_findclk(s, "uart3_ck"),
-                         omap_findclk(s, ((value >> 31) & 1) ?
-                                 "ck_48m" : "armper_ck"));
+    if (diff & (1U << 31)) {
+        /* CONF_MOD_UART3_CLK_MODE_R */
+        omap_clk_reparent(omap_findclk(s, "uart3_ck"),
+                          omap_findclk(s, ((value >> 31) & 1) ?
+                                       "ck_48m" : "armper_ck"));
+    }
     if (diff & (1 << 30))			/* CONF_MOD_UART2_CLK_MODE_R */
          omap_clk_reparent(omap_findclk(s, "uart2_ck"),
                          omap_findclk(s, ((value >> 30) & 1) ?
Signature · 1 line
1.9.0
#5 lore raw

[Qemu-devel] [PULL 7/9] hw/ssi/xilinx_spips.c: Avoid shifting left into sign bit

In reply to Peter Maydell

Add missing 'U' suffix to avoid shifting left into sign bit of a signed integer.

Message-id: [email protected]

---
 hw/ssi/xilinx_spips.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/ssi/xilinx_spips.c +2 -2
index 6a28746..8977243 100644
@@ -43,7 +43,7 @@
 
 /* config register */
 #define R_CONFIG            (0x00 / 4)
-#define IFMODE              (1 << 31)
+#define IFMODE              (1U << 31)
 #define ENDIAN              (1 << 26)
 #define MODEFAIL_GEN_EN     (1 << 17)
 #define MAN_START_COM       (1 << 16)
@@ -87,7 +87,7 @@
 
 #define R_LQSPI_CFG         (0xa0 / 4)
 #define R_LQSPI_CFG_RESET       0x03A002EB
-#define LQSPI_CFG_LQ_MODE       (1 << 31)
+#define LQSPI_CFG_LQ_MODE       (1U << 31)
 #define LQSPI_CFG_TWO_MEM       (1 << 30)
 #define LQSPI_CFG_SEP_BUS       (1 << 30)
 #define LQSPI_CFG_U_PAGE        (1 << 28)
Signature · 1 line
1.9.0
#6 lore raw

[Qemu-devel] [PULL 5/9] pxa2xx: Don't shift into sign bit

In reply to Peter Maydell

Add missing 'U' suffixes to avoid potentially shifting into the sign bit of a signed integer.

Message-id: [email protected]

---
 hw/arm/pxa2xx.c      | 6 +++---
 hw/arm/pxa2xx_gpio.c | 2 +-
 hw/arm/pxa2xx_pic.c  | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
hw/arm/pxa2xx.c +3 -3
index 904277a..0429148 100644
@@ -259,7 +259,7 @@ static void pxa2xx_pwrmode_write(CPUARMState *env, const ARMCPRegInfo *ri,
 
     case 1:
         /* Idle */
-        if (!(s->cm_regs[CCCR >> 2] & (1 << 31))) { /* CPDIS */
+        if (!(s->cm_regs[CCCR >> 2] & (1U << 31))) { /* CPDIS */
             cpu_interrupt(CPU(s->cpu), CPU_INTERRUPT_HALT);
             break;
         }
@@ -496,7 +496,7 @@ typedef struct {
 #define SSCR0_SSE	(1 << 7)
 #define SSCR0_RIM	(1 << 22)
 #define SSCR0_TIM	(1 << 23)
-#define SSCR0_MOD	(1 << 31)
+#define SSCR0_MOD       (1U << 31)
 #define SSCR0_DSS(x)	(((((x) >> 16) & 0x10) | ((x) & 0xf)) + 1)
 #define SSCR1_RIE	(1 << 0)
 #define SSCR1_TIE	(1 << 1)
@@ -1006,7 +1006,7 @@ static void pxa2xx_rtc_write(void *opaque, hwaddr addr,
 
     switch (addr) {
     case RTTR:
-        if (!(s->rttr & (1 << 31))) {
+        if (!(s->rttr & (1U << 31))) {
             pxa2xx_rtc_hzupdate(s);
             s->rttr = value;
             pxa2xx_rtc_alarm_update(s, s->rtsr);
hw/arm/pxa2xx_gpio.c +1 -1
index ca77f56..0727428 100644
@@ -110,7 +110,7 @@ static void pxa2xx_gpio_set(void *opaque, int line, int level)
     }
 
     bank = line >> 5;
-    mask = 1 << (line & 31);
+    mask = 1U << (line & 31);
 
     if (level) {
         s->status[bank] |= s->rising[bank] & mask &
hw/arm/pxa2xx_pic.c +2 -2
index 345fa4a..d37fb54 100644
@@ -105,7 +105,7 @@ static inline uint32_t pxa2xx_pic_highest(PXA2xxPICState *s) {
 
     for (i = PXA2XX_PIC_SRCS - 1; i >= 0; i --) {
         irq = s->priority[i] & 0x3f;
-        if ((s->priority[i] & (1 << 31)) && irq < PXA2XX_PIC_SRCS) {
+        if ((s->priority[i] & (1U << 31)) && irq < PXA2XX_PIC_SRCS) {
             /* Source peripheral ID is valid.  */
             bit = 1 << (irq & 31);
             int_set = (irq >= 32);
@@ -119,7 +119,7 @@ static inline uint32_t pxa2xx_pic_highest(PXA2xxPICState *s) {
             if (mask[int_set] & bit & ~s->is_fiq[int_set]) {
                 /* IRQ asserted */
                 ichp &= 0x0000ffff;
-                ichp |= (1 << 31) | (irq << 16);
+                ichp |= (1U << 31) | (irq << 16);
             }
         }
     }
Signature · 1 line
1.9.0
#7 lore raw

[Qemu-devel] [PULL 2/9] target-arm: Implements the ARM PMCCNTR register

In reply to Peter Maydell

From: Alistair Francis <[email protected]>

This patch implements the ARM PMCCNTR register including the disable and reset components of the PMCR register.

Message-id: bbf405e1feaf352cf39d5db402c9efcbd0f57c78.1393459802.git.alistair.francis@xilinx.com

---
 target-arm/cpu.h    |  4 +++
 target-arm/helper.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 89 insertions(+), 4 deletions(-)
target-arm/cpu.h +4 -0
index 49fef3f..0a7edfe 100644
@@ -222,6 +222,10 @@ typedef struct CPUARMState {
         uint64_t dbgbcr[16]; /* breakpoint control registers */
         uint64_t dbgwvr[16]; /* watchpoint value registers */
         uint64_t dbgwcr[16]; /* watchpoint control registers */
+        /* If the counter is enabled, this stores the last time the counter
+         * was reset. Otherwise it stores the counter value
+         */
+        uint32_t c15_ccnt;
     } cp15;
 
     struct {
target-arm/helper.c +85 -4

134 lines not on this page · raw message

Signature · 1 line
1.9.0
#8 lore raw

[Qemu-devel] [PULL 8/9] hw/arm/musicpal: Avoid shifting left into sign bit

In reply to Peter Maydell

Add missing 'U' suffixes to avoid shifting left into sign bit of a signed integer.

Message-id: [email protected]

---
 hw/arm/musicpal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/arm/musicpal.c +2 -2
index d10b5db..de54201 100644
@@ -110,10 +110,10 @@
 #define MP_PHY_88E3015          0x01410E20
 
 /* TX descriptor status */
-#define MP_ETH_TX_OWN           (1 << 31)
+#define MP_ETH_TX_OWN           (1U << 31)
 
 /* RX descriptor status */
-#define MP_ETH_RX_OWN           (1 << 31)
+#define MP_ETH_RX_OWN           (1U << 31)
 
 /* Interrupt cause/mask bits */
 #define MP_ETH_IRQ_RX_BIT       0
Signature · 1 line
1.9.0
#9 lore raw

[Qemu-devel] [PULL 1/9] target-arm: Fix incorrect setting of E bit in CPSR

In reply to Peter Maydell

Commit 4cc35614a moved the exception mask bits out of env->uncached_cpsr and into env->daif. However the env->daif contents are AArch64 style mask bits, which include not just the AArch32 AIF bits but also the new D bit (masks debug exceptions). This means that when reconstructing the AArch32 CPSR value we must not allow the D bit in env->daif to get into the CPSR, because the corresponding bit in the CPSR is E, the endianness bit.

This bug didn't affect execution under TCG because we don't implement endianness-swapping and so simply ignored the E bit; however it meant that kernel booting under KVM failed, because KVM does honour the E bit.

---
 target-arm/helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-arm/helper.c +1 -1
index 90f85f1..d44e603 100644
@@ -2478,7 +2478,7 @@ uint32_t cpsr_read(CPUARMState *env)
         (env->CF << 29) | ((env->VF & 0x80000000) >> 3) | (env->QF << 27)
         | (env->thumb << 5) | ((env->condexec_bits & 3) << 25)
         | ((env->condexec_bits & 0xfc) << 8)
-        | (env->GE << 16) | env->daif;
+        | (env->GE << 16) | (env->daif & CPSR_AIF);
 }
 
 void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask)
Signature · 1 line
1.9.0
author Applied
#10 lore raw
In reply to Peter Maydell
Quoted 12 lines · Peter Maydell

target-arm queue. I'm expecting to do another queue run before hard freeze, since there are still some bits and pieces on list which need a little more review before they can be committed.

thanks
-- PMM

The following changes since commit e9d818b8b1a7fadc6c92256b716f1bc21b8daabc:

Merge remote-tracking branch 'remotes/rth/tcg-aarch-6-1' into staging (2014-03-10 12:34:41 +0000)

Quoted 9 lines

are available in the git repository at:

git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20140310

for you to fetch changes up to 72c1d3af6e9c2745edfeaa71918a68bcee4b79db:

target-arm: Implement WFE as a yield operation (2014-03-10 14:56:30 +0000)

Applied to master, thanks.

-- PMM