Skip to contentSkip to conversation

spapr_hcall: add address-translation-mode-on-interrupt resource in H_SET_MODE

PATCH In review Alexey Kardashevskiy 2 participants 3 messages Mar 22, 2014 – Apr 8, 2014

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 spapr_hcall: add address-translation-mode-on-interrupt resource in H_SET_MODE

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

---
Changes:
v6:
* replaced "return" with "goto out"/"break" for better consistency

---
 hw/ppc/spapr_hcall.c | 29 +++++++++++++++++++++++++++++
 target-ppc/cpu.h     |  2 ++
 2 files changed, 31 insertions(+)
hw/ppc/spapr_hcall.c +29 -0
index 0bae053..7e4d7ff 100644
@@ -746,6 +746,35 @@ 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)) {
+            ret = H_P2;
+            goto out;
+        }
+        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);
+            }
+            ret = H_SUCCESS;
+            break;
+
+        default:
+            ret = H_UNSUPPORTED_FLAG;
+            break;
+        }
     }
 
 out:
target-ppc/cpu.h +2 -0
index 2719c08..39527e2 100644
@@ -463,6 +463,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
#1 lore raw
Quoted 5 lines · Alexey Kardashevskiy

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

Unfortunately I'm lacking a specification to verify this patch against, so I can not apply it upstream.

Alex

Quoted 62 lines

---
Changes:
v6:
* replaced "return" with "goto out"/"break" for better consistency

---
  hw/ppc/spapr_hcall.c | 29 +++++++++++++++++++++++++++++
  target-ppc/cpu.h     |  2 ++
  2 files changed, 31 insertions(+)
hw/ppc/spapr_hcall.c +29 -0
index 0bae053..7e4d7ff 100644
@@ -746,6 +746,35 @@ 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)) {
+            ret = H_P2;
+            goto out;
+        }
+        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);
+            }
+            ret = H_SUCCESS;
+            break;
+
+        default:
+            ret = H_UNSUPPORTED_FLAG;
+            break;
+        }
      }
 
  out:
target-ppc/cpu.h +2 -0
index 2719c08..39527e2 100644
@@ -463,6 +463,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)
#2 lore raw
In reply to Alexey Kardashevskiy
Quoted 5 lines · Alexey Kardashevskiy

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

... but I can comment on style issues regardless for now ;)

Quoted 14 lines

---
Changes:
v6:
* replaced "return" with "goto out"/"break" for better consistency

---
  hw/ppc/spapr_hcall.c | 29 +++++++++++++++++++++++++++++
  target-ppc/cpu.h     |  2 ++
  2 files changed, 31 insertions(+)
hw/ppc/spapr_hcall.c +0 -0
index 0bae053..7e4d7ff 100644

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

Quoted 4 lines
hw/ppc/spapr_hcall.c +1 -0
@@ -746,6 +746,35 @@ 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) {

We're slowly getting to a point where a switch() would be appropriate, no? Maybe also extract the individual H_SET_MODE subfunctions into their own C functions?

Quoted 8 lines
hw/ppc/spapr_hcall.c +8 -0
+        PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu);
+
+        if (!(pcc->insns_flags2 & PPC2_ISA207S)) {
+            ret = H_P2;
+            goto out;
+        }
+        if (value1) {
+            ret = H_P3;

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

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

Magic numbers. Please give them names.

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

Quoted 2 lines
hw/ppc/spapr_hcall.c +2 -0
+            CPU_FOREACH(cs) {
+                set_spr(cs, SPR_LPCR, mflags << LPCR_AIL_SH, LPCR_AIL);

Please implement this bit for TCG if you accept the hcall.

Alex

Quoted 24 lines
hw/ppc/spapr_hcall.c +8 -0
+            }
+            ret = H_SUCCESS;
+            break;
+
+        default:
+            ret = H_UNSUPPORTED_FLAG;
+            break;
+        }
      }
 
  out:
target-ppc/cpu.h +2 -0
index 2719c08..39527e2 100644
@@ -463,6 +463,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)