Skip to contentSkip to conversation

spapr: fix H_SET_MODE

PATCH Superseded Alexey Kardashevskiy 3 participants 11 messages Jan 22, 2014 – Mar 7, 2014

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover spapr: fix H_SET_MODE

This fixes H_SET_MODE.

Alexey Kardashevskiy (3):
target-ppc: introduce powerisa-207-server flag
spapr-hcall: fix little-endian resource handling in H_SET_MODE
spapr-hcall: add address-translation-mode-on-interrupt resource in
H_SET_MODE

 hw/ppc/spapr_hcall.c        | 64 +++++++++++++++++++++++++++++++++++++++------
 include/hw/ppc/spapr.h      |  9 +++++--
 target-ppc/cpu.h            |  4 +++
 target-ppc/translate_init.c |  3 ++-
 4 files changed, 69 insertions(+), 11 deletions(-)
Signature · 1 line
1.8.4.rc4
#1 lore raw

PATCH v3 1/3 target-ppc: introduce powerisa-207-server flag

This flag will be used to decide whether to emulate some bits of H_SET_MODE hypercall because some are POWER8-only.

While we are here, add 2.05 flag to POWER8 family too. POWER7/7+ already has it.

---
 target-ppc/cpu.h            | 2 ++
 target-ppc/translate_init.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)
target-ppc/cpu.h +2 -0
index 51bcd4a..8e46bda 100644
@@ -1875,6 +1875,8 @@ enum {
     PPC2_DBRX          = 0x0000000000000010ULL,
     /* Book I 2.05 PowerPC specification                                     */
     PPC2_ISA205        = 0x0000000000000020ULL,
+    /* PowerISA 2.07 Book3s specification                                    */
+    PPC2_ISA207S       = 0x0000000000000040ULL,
 
 #define PPC_TCG_INSNS2 (PPC2_BOOKE206 | PPC2_VSX | PPC2_PRCNTL | PPC2_DBRX | \
   PPC2_ISA205)
target-ppc/translate_init.c +2 -1
index 35470d4..7e25c35 100644
@@ -7144,7 +7144,8 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)
                        PPC_64B | PPC_ALTIVEC |
                        PPC_SEGMENT_64B | PPC_SLBI |
                        PPC_POPCNTB | PPC_POPCNTWD;
-    pcc->insns_flags2 = PPC2_VSX | PPC2_DFP | PPC2_DBRX;
+    pcc->insns_flags2 = PPC2_VSX | PPC2_DFP | PPC2_DBRX | PPC2_ISA205 |
+                        PPC2_ISA207S;
     pcc->msr_mask = 0x800000000284FF36ULL;
     pcc->mmu_model = POWERPC_MMU_2_06;
 #if defined(CONFIG_SOFTMMU)
Signature · 1 line
1.8.4.rc4
#2 lore raw

PATCH v3 2/3 spapr-hcall: fix little-endian resource handling in H_SET_MODE

In reply to Alexey Kardashevskiy

This changes resource code definitions to ones used in the host kernel.

This fixes H_SET_MODE_RESOURCE_LE (switch between big endian and little endian) to sync registers from KVM before changing LPCR value.

This adds a set_spr() helper to update an SPR in a CPU's context to avoid possible races and makes use of it to change LPCR.

---
 hw/ppc/spapr_hcall.c   | 38 ++++++++++++++++++++++++++++++--------
 include/hw/ppc/spapr.h |  9 +++++++--
 2 files changed, 37 insertions(+), 10 deletions(-)
hw/ppc/spapr_hcall.c +30 -8
index f755a53..b21d74b 100644
@@ -4,6 +4,33 @@
 #include "hw/ppc/spapr.h"
 #include "mmu-hash64.h"
 
+struct spr_sync_struct {
+    CPUState *cs;
+    int spr;
+    target_ulong value;
+    target_ulong mask;
+};
+
+static void do_spr_sync(void *arg)
+{
+    struct spr_sync_struct *s = arg;
+    PowerPCCPU *cp = POWERPC_CPU(s->cs);
+    CPUPPCState *env = &cp->env;
+
+    cpu_synchronize_state(s->cs);
+    env->spr[s->spr] &= ~s->mask;
+    env->spr[s->spr] |= s->value;
+}
+
+static void set_spr(CPUState *cs, int spr, target_ulong value,
+                    target_ulong mask)
+{
+    struct spr_sync_struct s = {
+        .cs = cs, .spr = spr, .value = value, .mask = mask
+    };
+    run_on_cpu(cs, do_spr_sync, &s);
+}
+
 static target_ulong compute_tlbie_rb(target_ulong v, target_ulong r,
                                      target_ulong pte_index)
 {
@@ -667,7 +694,7 @@ static target_ulong h_set_mode(PowerPCCPU *cpu, sPAPREnvironment *spapr,
     target_ulong value2 = args[3];
     target_ulong ret = H_P2;
 
-    if (resource == H_SET_MODE_ENDIAN) {
+    if (resource == H_SET_MODE_RESOURCE_LE) {
         if (value1) {
             ret = H_P3;
             goto out;
@@ -676,22 +703,17 @@ static target_ulong h_set_mode(PowerPCCPU *cpu, sPAPREnvironment *spapr,
             ret = H_P4;
             goto out;
         }
-
         switch (mflags) {
         case H_SET_MODE_ENDIAN_BIG:
             CPU_FOREACH(cs) {
-                PowerPCCPU *cp = POWERPC_CPU(cs);
-                CPUPPCState *env = &cp->env;
-                env->spr[SPR_LPCR] &= ~LPCR_ILE;
+                set_spr(cs, SPR_LPCR, 0, LPCR_ILE);
             }
             ret = H_SUCCESS;
             break;
 
         case H_SET_MODE_ENDIAN_LITTLE:
             CPU_FOREACH(cs) {
-                PowerPCCPU *cp = POWERPC_CPU(cs);
-                CPUPPCState *env = &cp->env;
-                env->spr[SPR_LPCR] |= LPCR_ILE;
+                set_spr(cs, SPR_LPCR, LPCR_ILE, LPCR_ILE);
             }
             ret = H_SUCCESS;
             break;
include/hw/ppc/spapr.h +7 -2
index b2f11e9..526faab 100644
@@ -153,8 +153,13 @@ typedef struct sPAPREnvironment {
 #define H_PP1             (1ULL<<(63-62))
 #define H_PP2             (1ULL<<(63-63))
 
-/* H_SET_MODE flags */
-#define H_SET_MODE_ENDIAN        4
+/* Values for 2nd argument to H_SET_MODE */
+#define H_SET_MODE_RESOURCE_SET_CIABR           1
+#define H_SET_MODE_RESOURCE_SET_DAWR            2
+#define H_SET_MODE_RESOURCE_ADDR_TRANS_MODE     3
+#define H_SET_MODE_RESOURCE_LE                  4
+
+/* Flags for H_SET_MODE_RESOURCE_LE */
 #define H_SET_MODE_ENDIAN_BIG    0
 #define H_SET_MODE_ENDIAN_LITTLE 1
 
Signature · 1 line
1.8.4.rc4
#3 lore raw

PATCH v3 3/3 spapr-hcall: add address-translation-mode-on-interrupt resource in H_SET_MODE

In reply to Alexey Kardashevskiy

This adds handling of the RESOURCE_ADDR_TRANS_MODE resource from the H_SET_MODE, for POWER8 (PowerISA 2.07) only.

---
 hw/ppc/spapr_hcall.c | 26 ++++++++++++++++++++++++++
 target-ppc/cpu.h     |  2 ++
 2 files changed, 28 insertions(+)
hw/ppc/spapr_hcall.c +26 -0
index b21d74b..7e4fc5f 100644
@@ -721,6 +721,32 @@ static target_ulong h_set_mode(PowerPCCPU *cpu, sPAPREnvironment *spapr,
         default:
             ret = H_UNSUPPORTED_FLAG;
         }
+    } else if (resource == H_SET_MODE_RESOURCE_ADDR_TRANS_MODE) {
+        PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
+
+        if (!(pcc->insns_flags2 & PPC2_ISA207S)) {
+            return H_P2;
+        }
+        if (value1) {
+            ret = H_P3;
+            goto out;
+        }
+        if (value2) {
+            ret = H_P4;
+            goto out;
+        }
+        switch (mflags) {
+        case 0:
+        case 2:
+        case 3:
+            CPU_FOREACH(cs) {
+                set_spr(cs, SPR_LPCR, mflags << LPCR_AIL_SH, LPCR_AIL);
+            }
+            return H_SUCCESS;
+
+        default:
+            return H_UNSUPPORTED_FLAG;
+        }
     }
 
 out:
target-ppc/cpu.h +2 -0
index 8e46bda..e1692b1 100644
@@ -458,6 +458,8 @@ struct ppc_slb_t {
 #define MSR_LE   0  /* Little-endian mode                           1 hflags */
 
 #define LPCR_ILE (1 << (63-38))
+#define LPCR_AIL      0x01800000      /* Alternate interrupt location */
+#define LPCR_AIL_SH   (63-40)
 
 #define msr_sf   ((env->msr >> MSR_SF)   & 1)
 #define msr_isf  ((env->msr >> MSR_ISF)  & 1)
Signature · 1 line
1.8.4.rc4
#4 lore raw

Re: [Qemu-devel] [PATCH v3 3/3] spapr-hcall: add address-translation-mode-on-interrupt resource in H_SET_MODE

Quoted 23 lines · Alexey Kardashevskiy

This adds handling of the RESOURCE_ADDR_TRANS_MODE resource from the H_SET_MODE, for POWER8 (PowerISA 2.07) only.

---
 hw/ppc/spapr_hcall.c | 26 ++++++++++++++++++++++++++
 target-ppc/cpu.h     |  2 ++
 2 files changed, 28 insertions(+)
hw/ppc/spapr_hcall.c +6 -0
index b21d74b..7e4fc5f 100644
@@ -721,6 +721,32 @@ static target_ulong h_set_mode(PowerPCCPU *cpu, sPAPREnvironment *spapr,
         default:
             ret = H_UNSUPPORTED_FLAG;
         }
+    } else if (resource == H_SET_MODE_RESOURCE_ADDR_TRANS_MODE) {
+        PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
+
+        if (!(pcc->insns_flags2 & PPC2_ISA207S)) {
+            return H_P2;
+        }

hw/ppc/spapr_hcall.c static target_ulong h_set_mode(PowerPCCPU *cpu, sPAPREnvironment *spapr, · line 739

Quoted 10 lines
hw/ppc/spapr_hcall.c +10 -0
+        if (value1) {
+            ret = H_P3;
+            goto out;
+        }
+        if (value2) {
+            ret = H_P4;
+            goto out;
+        }
+        switch (mflags) {
+        case 0:

Shouldn't case 0 clear the LPCR_AIL bit ?

hw/ppc/spapr_hcall.c static target_ulong h_set_mode(PowerPCCPU *cpu, sPAPREnvironment *spapr, · line 751

Quoted 12 lines
hw/ppc/spapr_hcall.c +10 -0
+        case 2:
+        case 3:
+            CPU_FOREACH(cs) {
+                set_spr(cs, SPR_LPCR, mflags << LPCR_AIL_SH, LPCR_AIL);
+            }
+            return H_SUCCESS;
+
+        default:
+            return H_UNSUPPORTED_FLAG;
+        }
     }
 

-aneesh

#5 lore raw

Re: [Qemu-devel] [PATCH v3 3/3] spapr-hcall: add address-translation-mode-on-interrupt resource in H_SET_MODE

Quoted 29 lines · Aneesh Kumar K.V
Quoted 27 lines · Alexey Kardashevskiy

This adds handling of the RESOURCE_ADDR_TRANS_MODE resource from the H_SET_MODE, for POWER8 (PowerISA 2.07) only.

---
 hw/ppc/spapr_hcall.c | 26 ++++++++++++++++++++++++++
 target-ppc/cpu.h     |  2 ++
 2 files changed, 28 insertions(+)
hw/ppc/spapr_hcall.c +10 -0
index b21d74b..7e4fc5f 100644
@@ -721,6 +721,32 @@ static target_ulong h_set_mode(PowerPCCPU *cpu, sPAPREnvironment *spapr,
         default:
             ret = H_UNSUPPORTED_FLAG;
         }
+    } else if (resource == H_SET_MODE_RESOURCE_ADDR_TRANS_MODE) {
+        PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
+
+        if (!(pcc->insns_flags2 & PPC2_ISA207S)) {
+            return H_P2;
+        }
+        if (value1) {
+            ret = H_P3;
+            goto out;
+        }
Quoted 8 lines

hw/ppc/spapr_hcall.c static target_ulong h_set_mode(PowerPCCPU *cpu, sPAPREnvironment *spapr, · line 739

Quoted 6 lines
hw/ppc/spapr_hcall.c +6 -0
+        if (value2) {
+            ret = H_P4;
+            goto out;
+        }
+        switch (mflags) {
+        case 0:

Shouldn't case 0 clear the LPCR_AIL bit ?

Does not it?

Quoted 15 lines

hw/ppc/spapr_hcall.c static target_ulong h_set_mode(PowerPCCPU *cpu, sPAPREnvironment *spapr, · line 751

Quoted 12 lines
hw/ppc/spapr_hcall.c +10 -0
+        case 2:
+        case 3:
+            CPU_FOREACH(cs) {
+                set_spr(cs, SPR_LPCR, mflags << LPCR_AIL_SH, LPCR_AIL);
+            }
+            return H_SUCCESS;
+
+        default:
+            return H_UNSUPPORTED_FLAG;
+        }
     }
 

-aneesh

Signature · 1 line
Alexey
#6 lore raw
In reply to Alexey Kardashevskiy
Quoted 8 lines · Alexey Kardashevskiy

This fixes H_SET_MODE.

Alexey Kardashevskiy (3):
target-ppc: introduce powerisa-207-server flag
spapr-hcall: fix little-endian resource handling in H_SET_MODE
spapr-hcall: add address-translation-mode-on-interrupt resource in
H_SET_MODE

Quoted 5 lines
 hw/ppc/spapr_hcall.c        | 64 +++++++++++++++++++++++++++++++++++++++------
 include/hw/ppc/spapr.h      |  9 +++++--
 target-ppc/cpu.h            |  4 +++
 target-ppc/translate_init.c |  3 ++-
 4 files changed, 69 insertions(+), 11 deletions(-)

Ping?

Signature · 1 line
Alexey
#7 lore raw
Quoted 9 lines · Alexey Kardashevskiy
Quoted 8 lines · Alexey Kardashevskiy

This fixes H_SET_MODE.

Alexey Kardashevskiy (3):
target-ppc: introduce powerisa-207-server flag
spapr-hcall: fix little-endian resource handling in H_SET_MODE
spapr-hcall: add address-translation-mode-on-interrupt resource in
H_SET_MODE

Quoted 6 lines
Quoted 5 lines
  hw/ppc/spapr_hcall.c        | 64 +++++++++++++++++++++++++++++++++++++++------
  include/hw/ppc/spapr.h      |  9 +++++--
  target-ppc/cpu.h            |  4 +++
  target-ppc/translate_init.c |  3 ++-
  4 files changed, 69 insertions(+), 11 deletions(-)

Ping?

Why are you pinging? There were review comments on this patch set, no?

Alex

#8 lore raw
Quoted 16 lines · Alexander Graf
Quoted 15 lines · Alexey Kardashevskiy
Quoted 14 lines · Alexey Kardashevskiy

This fixes H_SET_MODE.

Alexey Kardashevskiy (3):
target-ppc: introduce powerisa-207-server flag
spapr-hcall: fix little-endian resource handling in H_SET_MODE
spapr-hcall: add address-translation-mode-on-interrupt resource in
H_SET_MODE

  hw/ppc/spapr_hcall.c        | 64
+++++++++++++++++++++++++++++++++++++++------
  include/hw/ppc/spapr.h      |  9 +++++--
  target-ppc/cpu.h            |  4 +++
  target-ppc/translate_init.c |  3 ++-
  4 files changed, 69 insertions(+), 11 deletions(-)
Quoted 3 lines
Quoted 1 line

Ping?

Why are you pinging? There were review comments on this patch set, no?

I saw question from Aneesh (which does not require a change, I believe) and that is it. What did I miss?

Signature · 1 line
Alexey
#9 lore raw
Quoted 17 lines · Alexey Kardashevskiy
Quoted 16 lines · Alexander Graf
Quoted 15 lines · Alexey Kardashevskiy
Quoted 14 lines · Alexey Kardashevskiy

This fixes H_SET_MODE.

Alexey Kardashevskiy (3):
target-ppc: introduce powerisa-207-server flag
spapr-hcall: fix little-endian resource handling in H_SET_MODE
spapr-hcall: add address-translation-mode-on-interrupt resource in
H_SET_MODE

  hw/ppc/spapr_hcall.c        | 64
+++++++++++++++++++++++++++++++++++++++------
  include/hw/ppc/spapr.h      |  9 +++++--
  target-ppc/cpu.h            |  4 +++
  target-ppc/translate_init.c |  3 ++-
  4 files changed, 69 insertions(+), 11 deletions(-)
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Ping?

Why are you pinging? There were review comments on this patch set, no?

Have I answered these questions? Or am I still missing some review comments? Or what? Thanks.

Quoted 4 lines

I saw question from Aneesh (which does not require a change, I believe) and that is it. What did I miss?

Signature · 1 line
Alexey
#10 lore raw
Quoted 18 lines · Alexey Kardashevskiy
Quoted 17 lines · Alexey Kardashevskiy
Quoted 16 lines · Alexander Graf
Quoted 15 lines · Alexey Kardashevskiy
Quoted 14 lines · Alexey Kardashevskiy

This fixes H_SET_MODE.

Alexey Kardashevskiy (3):
target-ppc: introduce powerisa-207-server flag
spapr-hcall: fix little-endian resource handling in H_SET_MODE
spapr-hcall: add address-translation-mode-on-interrupt resource in
H_SET_MODE

  hw/ppc/spapr_hcall.c        | 64
+++++++++++++++++++++++++++++++++++++++------
  include/hw/ppc/spapr.h      |  9 +++++--
  target-ppc/cpu.h            |  4 +++
  target-ppc/translate_init.c |  3 ++-
  4 files changed, 69 insertions(+), 11 deletions(-)
Quoted 13 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Ping?

Why are you pinging? There were review comments on this patch set, no?

Have I answered these questions? Or am I still missing some review comments? Or what? Thanks.

Quoted 4 lines

I saw question from Aneesh (which does not require a change, I believe) and that is it. What did I miss?

Ping?

I really (really) do not understand what comments were meant. Thanks.

Signature · 1 line
Alexey