qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/7] Enable doorbell for e500mc
@ 2012-01-31  2:27 Alexander Graf
  2012-01-31  2:27 ` [Qemu-devel] [PATCH 1/7] PPC: E500: Add some more excp vectors Alexander Graf
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Alexander Graf @ 2012-01-31  2:27 UTC (permalink / raw)
  To: qemu-ppc; +Cc: qemu-devel Developers

On e500mc we need to implement the doorbell / processor control / msgsnd
instructions to allow for smp with Linux guests. This patch set implements
everything necessary for this to work.

Alexander Graf (7):
  PPC: E500: Add some more excp vectors
  PPC: E500: Add doorbell defines
  PPC: Add CPU feature for processor control
  PPC: Enable doorbell excp handlers
  PPC: E500: Implement msgclr
  PPC: E500: Implement msgsnd
  PPC: e500mc: Enable processor control

 target-ppc/cpu.h            |   25 ++++++++++++++++++-
 target-ppc/helper.c         |   16 +-----------
 target-ppc/helper.h         |    2 +
 target-ppc/op_helper.c      |   53 +++++++++++++++++++++++++++++++++++++++++++
 target-ppc/translate.c      |   34 +++++++++++++++++++++++++++
 target-ppc/translate_init.c |    2 +-
 6 files changed, 115 insertions(+), 17 deletions(-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 1/7] PPC: E500: Add some more excp vectors
  2012-01-31  2:27 [Qemu-devel] [PATCH 0/7] Enable doorbell for e500mc Alexander Graf
@ 2012-01-31  2:27 ` Alexander Graf
  2012-01-31  2:27 ` [Qemu-devel] [PATCH 2/7] PPC: E500: Add doorbell defines Alexander Graf
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2012-01-31  2:27 UTC (permalink / raw)
  To: qemu-ppc; +Cc: qemu-devel Developers

Our EXCP list is getting outdated. By now, 3 new exception vectors have
been introduced. Update the list so we have everything at one place.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 target-ppc/cpu.h |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index 668ddf3..c7a6427 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -187,7 +187,10 @@ enum {
     POWERPC_EXCP_EPERFM   = 35, /* Embedded performance monitor interrupt    */
     POWERPC_EXCP_DOORI    = 36, /* Embedded doorbell interrupt               */
     POWERPC_EXCP_DOORCI   = 37, /* Embedded doorbell critical interrupt      */
-    /* Vectors 38 to 63 are reserved                                         */
+    POWERPC_EXCP_GDOORI   = 38, /* Embedded guest doorbell interrupt         */
+    POWERPC_EXCP_GDOORCI  = 39, /* Embedded guest doorbell critical interrupt*/
+    POWERPC_EXCP_HYPPRIV  = 41, /* Embedded hypervisor priv instruction      */
+    /* Vectors 42 to 63 are reserved                                         */
     /* Exceptions defined in the PowerPC server specification                */
     POWERPC_EXCP_RESET    = 64, /* System reset exception                    */
     POWERPC_EXCP_DSEG     = 65, /* Data segment exception                    */
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 2/7] PPC: E500: Add doorbell defines
  2012-01-31  2:27 [Qemu-devel] [PATCH 0/7] Enable doorbell for e500mc Alexander Graf
  2012-01-31  2:27 ` [Qemu-devel] [PATCH 1/7] PPC: E500: Add some more excp vectors Alexander Graf
@ 2012-01-31  2:27 ` Alexander Graf
  2012-01-31  2:27 ` [Qemu-devel] [PATCH 3/7] PPC: Add CPU feature for processor control Alexander Graf
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2012-01-31  2:27 UTC (permalink / raw)
  To: qemu-ppc; +Cc: qemu-devel Developers

We're going to introduce doorbell instructions (called processor
control in the spec) soon. Add some defines for easier patch
readability later.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 target-ppc/cpu.h |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index c7a6427..f9cea3d 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -858,6 +858,22 @@ enum {
 #define BOOKE206_MAX_TLBN      4
 
 /*****************************************************************************/
+/* Embedded.Processor Control */
+
+#define DBELL_TYPE_SHIFT               27
+#define DBELL_TYPE_MASK                (0x1f << DBELL_TYPE_SHIFT)
+#define DBELL_TYPE_DBELL               (0x00 << DBELL_TYPE_SHIFT)
+#define DBELL_TYPE_DBELL_CRIT          (0x01 << DBELL_TYPE_SHIFT)
+#define DBELL_TYPE_G_DBELL             (0x02 << DBELL_TYPE_SHIFT)
+#define DBELL_TYPE_G_DBELL_CRIT        (0x03 << DBELL_TYPE_SHIFT)
+#define DBELL_TYPE_G_DBELL_MC          (0x04 << DBELL_TYPE_SHIFT)
+
+#define DBELL_BRDCAST                  (1 << 26)
+#define DBELL_LPIDTAG_SHIFT            14
+#define DBELL_LPIDTAG_MASK             (0xfff << DBELL_LPIDTAG_SHIFT)
+#define DBELL_PIRTAG_MASK              0x3fff
+
+/*****************************************************************************/
 /* The whole PowerPC CPU context */
 #define NB_MMU_MODES 3
 
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 3/7] PPC: Add CPU feature for processor control
  2012-01-31  2:27 [Qemu-devel] [PATCH 0/7] Enable doorbell for e500mc Alexander Graf
  2012-01-31  2:27 ` [Qemu-devel] [PATCH 1/7] PPC: E500: Add some more excp vectors Alexander Graf
  2012-01-31  2:27 ` [Qemu-devel] [PATCH 2/7] PPC: E500: Add doorbell defines Alexander Graf
@ 2012-01-31  2:27 ` Alexander Graf
  2012-01-31  2:27 ` [Qemu-devel] [PATCH 4/7] PPC: Enable doorbell excp handlers Alexander Graf
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2012-01-31  2:27 UTC (permalink / raw)
  To: qemu-ppc; +Cc: qemu-devel Developers

We're soon going to implement processor control features. Add the
feature flag, so we're well prepared.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 target-ppc/cpu.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index f9cea3d..fbcf488 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -1916,8 +1916,10 @@ enum {
     PPC2_VSX           = 0x0000000000000002ULL,
     /* Decimal Floating Point (DFP)                                          */
     PPC2_DFP           = 0x0000000000000004ULL,
+    /* Embedded.Processor Control                                            */
+    PPC2_PRCNTL        = 0x0000000000000008ULL,
 
-#define PPC_TCG_INSNS2 (PPC2_BOOKE206)
+#define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_PRCNTL)
 };
 
 /*****************************************************************************/
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 4/7] PPC: Enable doorbell excp handlers
  2012-01-31  2:27 [Qemu-devel] [PATCH 0/7] Enable doorbell for e500mc Alexander Graf
                   ` (2 preceding siblings ...)
  2012-01-31  2:27 ` [Qemu-devel] [PATCH 3/7] PPC: Add CPU feature for processor control Alexander Graf
@ 2012-01-31  2:27 ` Alexander Graf
  2012-01-31  2:27 ` [Qemu-devel] [PATCH 5/7] PPC: E500: Implement msgclr Alexander Graf
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2012-01-31  2:27 UTC (permalink / raw)
  To: qemu-ppc; +Cc: qemu-devel Developers

We already had all the code available to have doorbell exceptions
be handled properly. It was just disabled.

Enable it, so we can rely on it.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 target-ppc/helper.c |   16 ++--------------
 1 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/target-ppc/helper.c b/target-ppc/helper.c
index 31a9897..e56fac8 100644
--- a/target-ppc/helper.c
+++ b/target-ppc/helper.c
@@ -2698,22 +2698,10 @@ static inline void powerpc_excp(CPUState *env, int excp_model, int excp)
                   "Performance counter exception is not implemented yet !\n");
         goto store_next;
     case POWERPC_EXCP_DOORI:     /* Embedded doorbell interrupt              */
-        /* XXX: TODO */
-        cpu_abort(env,
-                  "Embedded doorbell interrupt is not implemented yet !\n");
         goto store_next;
     case POWERPC_EXCP_DOORCI:    /* Embedded doorbell critical interrupt     */
-        switch (excp_model) {
-        case POWERPC_EXCP_BOOKE:
-            srr0 = SPR_BOOKE_CSRR0;
-            srr1 = SPR_BOOKE_CSRR1;
-            break;
-        default:
-            break;
-        }
-        /* XXX: TODO */
-        cpu_abort(env, "Embedded doorbell critical interrupt "
-                  "is not implemented yet !\n");
+        srr0 = SPR_BOOKE_CSRR0;
+        srr1 = SPR_BOOKE_CSRR1;
         goto store_next;
     case POWERPC_EXCP_RESET:     /* System reset exception                   */
         if (msr_pow) {
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 5/7] PPC: E500: Implement msgclr
  2012-01-31  2:27 [Qemu-devel] [PATCH 0/7] Enable doorbell for e500mc Alexander Graf
                   ` (3 preceding siblings ...)
  2012-01-31  2:27 ` [Qemu-devel] [PATCH 4/7] PPC: Enable doorbell excp handlers Alexander Graf
@ 2012-01-31  2:27 ` Alexander Graf
  2012-01-31  2:27 ` [Qemu-devel] [PATCH 6/7] PPC: E500: Implement msgsnd Alexander Graf
  2012-01-31  2:27 ` [Qemu-devel] [PATCH 7/7] PPC: e500mc: Enable processor control Alexander Graf
  6 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2012-01-31  2:27 UTC (permalink / raw)
  To: qemu-ppc; +Cc: qemu-devel Developers

This patch implements the msgclr instruction. It is part of the
Embedded.Processor Control specification and clears pending doorbell
interrupts on the current CPU.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 target-ppc/helper.h    |    1 +
 target-ppc/op_helper.c |   35 +++++++++++++++++++++++++++++++++++
 target-ppc/translate.c |   18 ++++++++++++++++++
 3 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/target-ppc/helper.h b/target-ppc/helper.h
index 4798fd5..48ceb61 100644
--- a/target-ppc/helper.h
+++ b/target-ppc/helper.h
@@ -358,6 +358,7 @@ DEF_HELPER_FLAGS_1(load_sr, TCG_CALL_CONST, tl, tl);
 DEF_HELPER_FLAGS_2(store_sr, TCG_CALL_CONST, void, tl, tl)
 
 DEF_HELPER_FLAGS_1(602_mfrom, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl)
+DEF_HELPER_1(msgclr, void, tl)
 #endif
 
 DEF_HELPER_3(dlmzb, tl, tl, tl, i32)
diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c
index 0d1206a..e2f7614 100644
--- a/target-ppc/op_helper.c
+++ b/target-ppc/op_helper.c
@@ -4514,4 +4514,39 @@ void helper_booke206_tlbflush(uint32_t type)
     booke206_flush_tlb(env, flags, 1);
 }
 
+/* Embedded.Processor Control */
+static int dbell2irq(target_ulong rb)
+{
+    int msg = rb & DBELL_TYPE_MASK;
+    int irq = -1;
+
+    switch (msg) {
+    case DBELL_TYPE_DBELL:
+        irq = PPC_INTERRUPT_DOORBELL;
+        break;
+    case DBELL_TYPE_DBELL_CRIT:
+        irq = PPC_INTERRUPT_CDOORBELL;
+        break;
+    case DBELL_TYPE_G_DBELL:
+    case DBELL_TYPE_G_DBELL_CRIT:
+    case DBELL_TYPE_G_DBELL_MC:
+        /* XXX implement */
+    default:
+        break;
+    }
+
+    return irq;
+}
+
+void helper_msgclr(target_ulong rb)
+{
+    int irq = dbell2irq(rb);
+
+    if (irq < 0) {
+        return;
+    }
+
+    env->pending_interrupts &= ~(1 << irq);
+}
+
 #endif /* !CONFIG_USER_ONLY */
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index 58a4853..01bfe0a 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -6220,6 +6220,22 @@ static void gen_icbt_440(DisasContext *ctx)
      */
 }
 
+/* Embedded.Processor Control */
+
+static void gen_msgclr(DisasContext *ctx)
+{
+#if defined(CONFIG_USER_ONLY)
+    gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
+#else
+    if (unlikely(ctx->mem_idx == 0)) {
+        gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
+        return;
+    }
+
+    gen_helper_msgclr(cpu_gpr[rB(ctx->opcode)]);
+#endif
+}
+
 /***                      Altivec vector extension                         ***/
 /* Altivec registers moves */
 
@@ -8610,6 +8626,8 @@ GEN_HANDLER2_E(tlbivax_booke206, "tlbivax", 0x1F, 0x12, 0x18, 0x00000001,
                PPC_NONE, PPC2_BOOKE206),
 GEN_HANDLER2_E(tlbilx_booke206, "tlbilx", 0x1F, 0x12, 0x00, 0x03800001,
                PPC_NONE, PPC2_BOOKE206),
+GEN_HANDLER2_E(msgclr, "msgclr", 0x1F, 0x0E, 0x07, 0x03ff0001,
+               PPC_NONE, PPC2_PRCNTL),
 GEN_HANDLER(wrtee, 0x1F, 0x03, 0x04, 0x000FFC01, PPC_WRTEE),
 GEN_HANDLER(wrteei, 0x1F, 0x03, 0x05, 0x000E7C01, PPC_WRTEE),
 GEN_HANDLER(dlmzb, 0x1F, 0x0E, 0x02, 0x00000000, PPC_440_SPEC),
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 6/7] PPC: E500: Implement msgsnd
  2012-01-31  2:27 [Qemu-devel] [PATCH 0/7] Enable doorbell for e500mc Alexander Graf
                   ` (4 preceding siblings ...)
  2012-01-31  2:27 ` [Qemu-devel] [PATCH 5/7] PPC: E500: Implement msgclr Alexander Graf
@ 2012-01-31  2:27 ` Alexander Graf
  2012-01-31  2:27 ` [Qemu-devel] [PATCH 7/7] PPC: e500mc: Enable processor control Alexander Graf
  6 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2012-01-31  2:27 UTC (permalink / raw)
  To: qemu-ppc; +Cc: qemu-devel Developers

This patch implements the msgsnd instruction. It is part of the
Embedded.Processor Control specification and allows one CPU to
IPI another CPU without going through an interrupt controller.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 target-ppc/helper.h    |    1 +
 target-ppc/op_helper.c |   18 ++++++++++++++++++
 target-ppc/translate.c |   16 ++++++++++++++++
 3 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/target-ppc/helper.h b/target-ppc/helper.h
index 48ceb61..148543a 100644
--- a/target-ppc/helper.h
+++ b/target-ppc/helper.h
@@ -358,6 +358,7 @@ DEF_HELPER_FLAGS_1(load_sr, TCG_CALL_CONST, tl, tl);
 DEF_HELPER_FLAGS_2(store_sr, TCG_CALL_CONST, void, tl, tl)
 
 DEF_HELPER_FLAGS_1(602_mfrom, TCG_CALL_CONST | TCG_CALL_PURE, tl, tl)
+DEF_HELPER_1(msgsnd, void, tl)
 DEF_HELPER_1(msgclr, void, tl)
 #endif
 
diff --git a/target-ppc/op_helper.c b/target-ppc/op_helper.c
index e2f7614..3f4e067 100644
--- a/target-ppc/op_helper.c
+++ b/target-ppc/op_helper.c
@@ -4549,4 +4549,22 @@ void helper_msgclr(target_ulong rb)
     env->pending_interrupts &= ~(1 << irq);
 }
 
+void helper_msgsnd(target_ulong rb)
+{
+    int irq = dbell2irq(rb);
+    int pir = rb & DBELL_PIRTAG_MASK;
+    CPUState *cenv;
+
+    if (irq < 0) {
+        return;
+    }
+
+    for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu) {
+        if ((rb & DBELL_BRDCAST) || (cenv->spr[SPR_BOOKE_PIR] == pir)) {
+            cenv->pending_interrupts |= 1 << irq;
+            cpu_interrupt(cenv, CPU_INTERRUPT_HARD);
+        }
+    }
+}
+
 #endif /* !CONFIG_USER_ONLY */
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index 01bfe0a..b2780db 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -6236,6 +6236,20 @@ static void gen_msgclr(DisasContext *ctx)
 #endif
 }
 
+static void gen_msgsnd(DisasContext *ctx)
+{
+#if defined(CONFIG_USER_ONLY)
+    gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
+#else
+    if (unlikely(ctx->mem_idx == 0)) {
+        gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
+        return;
+    }
+
+    gen_helper_msgsnd(cpu_gpr[rB(ctx->opcode)]);
+#endif
+}
+
 /***                      Altivec vector extension                         ***/
 /* Altivec registers moves */
 
@@ -8626,6 +8640,8 @@ GEN_HANDLER2_E(tlbivax_booke206, "tlbivax", 0x1F, 0x12, 0x18, 0x00000001,
                PPC_NONE, PPC2_BOOKE206),
 GEN_HANDLER2_E(tlbilx_booke206, "tlbilx", 0x1F, 0x12, 0x00, 0x03800001,
                PPC_NONE, PPC2_BOOKE206),
+GEN_HANDLER2_E(msgsnd, "msgsnd", 0x1F, 0x0E, 0x06, 0x03ff0001,
+               PPC_NONE, PPC2_PRCNTL),
 GEN_HANDLER2_E(msgclr, "msgclr", 0x1F, 0x0E, 0x07, 0x03ff0001,
                PPC_NONE, PPC2_PRCNTL),
 GEN_HANDLER(wrtee, 0x1F, 0x03, 0x04, 0x000FFC01, PPC_WRTEE),
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Qemu-devel] [PATCH 7/7] PPC: e500mc: Enable processor control
  2012-01-31  2:27 [Qemu-devel] [PATCH 0/7] Enable doorbell for e500mc Alexander Graf
                   ` (5 preceding siblings ...)
  2012-01-31  2:27 ` [Qemu-devel] [PATCH 6/7] PPC: E500: Implement msgsnd Alexander Graf
@ 2012-01-31  2:27 ` Alexander Graf
  6 siblings, 0 replies; 8+ messages in thread
From: Alexander Graf @ 2012-01-31  2:27 UTC (permalink / raw)
  To: qemu-ppc; +Cc: qemu-devel Developers

The e500mc implements Embedded.Processor Control, so enable it and
thus enable guests to IPI each other. This makes -smp work with -cpu
e500mc.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 target-ppc/translate_init.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index b14a98c..7848cd7 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -4412,7 +4412,7 @@ static void init_proc_e300 (CPUPPCState *env)
                                 PPC_FLOAT_FRSQRTE | PPC_FLOAT_FSEL |        \
                                 PPC_FLOAT_STFIWX | PPC_WAIT |               \
                                 PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC)
-#define POWERPC_INSNS2_e500mc  (PPC2_BOOKE206)
+#define POWERPC_INSNS2_e500mc  (PPC2_BOOKE206 | PPC2_PRCNTL)
 #define POWERPC_MSRM_e500mc    (0x000000001402FB36ULL)
 #define POWERPC_MMU_e500mc     (POWERPC_MMU_BOOKE206)
 #define POWERPC_EXCP_e500mc    (POWERPC_EXCP_BOOKE)
-- 
1.6.0.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-01-31  2:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-31  2:27 [Qemu-devel] [PATCH 0/7] Enable doorbell for e500mc Alexander Graf
2012-01-31  2:27 ` [Qemu-devel] [PATCH 1/7] PPC: E500: Add some more excp vectors Alexander Graf
2012-01-31  2:27 ` [Qemu-devel] [PATCH 2/7] PPC: E500: Add doorbell defines Alexander Graf
2012-01-31  2:27 ` [Qemu-devel] [PATCH 3/7] PPC: Add CPU feature for processor control Alexander Graf
2012-01-31  2:27 ` [Qemu-devel] [PATCH 4/7] PPC: Enable doorbell excp handlers Alexander Graf
2012-01-31  2:27 ` [Qemu-devel] [PATCH 5/7] PPC: E500: Implement msgclr Alexander Graf
2012-01-31  2:27 ` [Qemu-devel] [PATCH 6/7] PPC: E500: Implement msgsnd Alexander Graf
2012-01-31  2:27 ` [Qemu-devel] [PATCH 7/7] PPC: e500mc: Enable processor control Alexander Graf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).