Skip to contentSkip to conversation

target/s390x: misc patches

PATCH In review Aurelien Jarno 5 participants 10 messages May 9, 2017 – May 10, 2017

lore
Share & tools
lore
#0 lore raw

cover target/s390x: misc patches

Those are just random patches I have written while trying to get a MTTCG version of qemu/s390x. I just send them to avoid duplicated work.

Aurelien Jarno (3):
target/s390x: mask the SIGP order_code using SIGP_ORDER_MASK target/s390x: fix SIGNAL PROCESSOR return value target/s390x: implement serialization in BRANCH CONDITION

 target/s390x/cpu.h         |  3 +++
 target/s390x/kvm.c         |  2 --
 target/s390x/misc_helper.c |  3 +--
 target/s390x/translate.c   | 16 ++++++++++++++++
 4 files changed, 20 insertions(+), 4 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/3 target/s390x: mask the SIGP order_code using SIGP_ORDER_MASK

For that move the definition from kvm.c to cpu.h

---
 target/s390x/cpu.h         | 3 +++
 target/s390x/kvm.c         | 2 --
 target/s390x/misc_helper.c | 3 +--
 3 files changed, 4 insertions(+), 4 deletions(-)
target/s390x/cpu.h +3 -0
index df823280a5..2471db920d 100644
@@ -1081,6 +1081,9 @@ struct sysib_322 {
 #define SIGP_MODE_Z_ARCH_TRANS_ALL_PSW 1
 #define SIGP_MODE_Z_ARCH_TRANS_CUR_PSW 2
 
+/* SIGP order code mask corresponding to bit positions 56-63 */
+#define SIGP_ORDER_MASK 0x000000ff
+
 void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
 int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,
                   target_ulong *raddr, int *flags, bool exc);
target/s390x/kvm.c +0 -2
index 1a249d8359..fb105429be 100644
@@ -1764,8 +1764,6 @@ static int sigp_set_architecture(S390CPU *cpu, uint32_t param,
     return SIGP_CC_ORDER_CODE_ACCEPTED;
 }
 
-#define SIGP_ORDER_MASK 0x000000ff
-
 static int handle_sigp(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1)
 {
     CPUS390XState *env = &cpu->env;
target/s390x/misc_helper.c +1 -2
index 53cb3b8ac6..395f38dea5 100644
@@ -521,8 +521,7 @@ uint32_t HELPER(sigp)(CPUS390XState *env, uint64_t order_code, uint32_t r1,
 
     qemu_mutex_lock_iothread();
 
-    /* sigp contains the order code in bit positions 56-63, mask it here. */
-    switch (order_code & 0xff) {
+    switch (order_code & SIGP_ORDER_MASK) {
     case SIGP_SET_ARCH:
         cc = SIGP_CC_ORDER_CODE_ACCEPTED;
         /* switch arch */
Signature · 1 line
2.11.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [Qemu-devel] [PATCH 1/3] target/s390x: mask the SIGP order_code using SIGP_ORDER_MASK

Quoted 41 lines · Aurelien Jarno

For that move the definition from kvm.c to cpu.h

---
 target/s390x/cpu.h         | 3 +++
 target/s390x/kvm.c         | 2 --
 target/s390x/misc_helper.c | 3 +--
 3 files changed, 4 insertions(+), 4 deletions(-)
target/s390x/cpu.h +3 -0
index df823280a5..2471db920d 100644
@@ -1081,6 +1081,9 @@ struct sysib_322 {
 #define SIGP_MODE_Z_ARCH_TRANS_ALL_PSW 1
 #define SIGP_MODE_Z_ARCH_TRANS_CUR_PSW 2
 
+/* SIGP order code mask corresponding to bit positions 56-63 */
+#define SIGP_ORDER_MASK 0x000000ff
+
 void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
 int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,
                   target_ulong *raddr, int *flags, bool exc);
target/s390x/kvm.c +0 -2
index 1a249d8359..fb105429be 100644
@@ -1764,8 +1764,6 @@ static int sigp_set_architecture(S390CPU *cpu, uint32_t param,
     return SIGP_CC_ORDER_CODE_ACCEPTED;
 }
 
-#define SIGP_ORDER_MASK 0x000000ff
-
 static int handle_sigp(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1)
 {
     CPUS390XState *env = &cpu->env;
target/s390x/misc_helper.c +0 -0
index 53cb3b8ac6..395f38dea5 100644

target/s390x/misc_helper.c uint32_t HELPER(sigp)(CPUS390XState *env, uint64_t order_code, uint32_t r1, · line 527

Quoted 9 lines
target/s390x/misc_helper.c +1 -2
@@ -521,8 +521,7 @@ uint32_t HELPER(sigp)(CPUS390XState *env, uint64_t order_code, uint32_t r1,
 
     qemu_mutex_lock_iothread();
 
-    /* sigp contains the order code in bit positions 56-63, mask it here. */
-    switch (order_code & 0xff) {
+    switch (order_code & SIGP_ORDER_MASK) {
     case SIGP_SET_ARCH:
         cc = SIGP_CC_ORDER_CODE_ACCEPTED;
         /* switch arch */
Reviewed-by on v1 1/3
#3 lore raw

Re: [Qemu-devel] [PATCH 1/3] target/s390x: mask the SIGP order_code using SIGP_ORDER_MASK

In reply to Aurelien Jarno
Quoted 8 lines · Aurelien Jarno

For that move the definition from kvm.c to cpu.h

---
  target/s390x/cpu.h         | 3 +++
  target/s390x/kvm.c         | 2 --
  target/s390x/misc_helper.c | 3 +--
  3 files changed, 4 insertions(+), 4 deletions(-)

r~

Reviewed-by on v1 1/3
#4 lore raw

Re: [Qemu-devel] [PATCH 1/3] target/s390x: mask the SIGP order_code using SIGP_ORDER_MASK

In reply to Aurelien Jarno
Quoted 8 lines · On Tue, 9 May 2017 10:27:58 +0200 Aurelien Jarno <[email protected]> wrote:

For that move the definition from kvm.c to cpu.h

---
 target/s390x/cpu.h         | 3 +++
 target/s390x/kvm.c         | 2 --
 target/s390x/misc_helper.c | 3 +--
 3 files changed, 4 insertions(+), 4 deletions(-)

I guess this will go with the other patches in this series?

Reviewed-by on v1 1/3
#5 lore raw

Re: [Qemu-devel] [PATCH 1/3] target/s390x: mask the SIGP order_code using SIGP_ORDER_MASK

In reply to Aurelien Jarno
Quoted 3 lines · Aurelien Jarno

For that move the definition from kvm.c to cpu.h

Quoted 48 lines
---
 target/s390x/cpu.h         | 3 +++
 target/s390x/kvm.c         | 2 --
 target/s390x/misc_helper.c | 3 +--
 3 files changed, 4 insertions(+), 4 deletions(-)
target/s390x/cpu.h +3 -0
index df823280a5..2471db920d 100644
@@ -1081,6 +1081,9 @@ struct sysib_322 {
 #define SIGP_MODE_Z_ARCH_TRANS_ALL_PSW 1
 #define SIGP_MODE_Z_ARCH_TRANS_CUR_PSW 2
 
+/* SIGP order code mask corresponding to bit positions 56-63 */
+#define SIGP_ORDER_MASK 0x000000ff
+
 void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
 int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,
                   target_ulong *raddr, int *flags, bool exc);
target/s390x/kvm.c +0 -2
index 1a249d8359..fb105429be 100644
@@ -1764,8 +1764,6 @@ static int sigp_set_architecture(S390CPU *cpu, uint32_t param,
     return SIGP_CC_ORDER_CODE_ACCEPTED;
 }
 
-#define SIGP_ORDER_MASK 0x000000ff
-
 static int handle_sigp(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1)
 {
     CPUS390XState *env = &cpu->env;
target/s390x/misc_helper.c +1 -2
index 53cb3b8ac6..395f38dea5 100644
@@ -521,8 +521,7 @@ uint32_t HELPER(sigp)(CPUS390XState *env, uint64_t order_code, uint32_t r1,
 
     qemu_mutex_lock_iothread();
 
-    /* sigp contains the order code in bit positions 56-63, mask it here. */
-    switch (order_code & 0xff) {
+    switch (order_code & SIGP_ORDER_MASK) {
     case SIGP_SET_ARCH:
         cc = SIGP_CC_ORDER_CODE_ACCEPTED;
         /* switch arch */
#6 lore raw

PATCH 2/3 target/s390x: fix SIGNAL PROCESSOR return value

In reply to Aurelien Jarno

The SIGNAL PROCESSOR helper returns its value through the CC register. set_cc_static should be called just after the helper.

---
 target/s390x/translate.c | 1 +
 1 file changed, 1 insertion(+)
target/s390x/translate.c +1 -0
index 558ff78084..c58c27f8e9 100644
@@ -3363,6 +3363,7 @@ static ExitStatus op_sigp(DisasContext *s, DisasOps *o)
     check_privileged(s);
     potential_page_fault(s);
     gen_helper_sigp(cc_op, cpu_env, o->in2, r1, o->in1);
+    set_cc_static(s);
     tcg_temp_free_i32(r1);
     return NO_EXIT;
 }
Signature · 1 line
2.11.0
#8 lore raw

PATCH 3/3 target/s390x: implement serialization in BRANCH CONDITION

In reply to Aurelien Jarno
---
 target/s390x/translate.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
target/s390x/translate.c +15 -0
index c58c27f8e9..2f07ce2be9 100644
@@ -1517,6 +1517,21 @@ static ExitStatus op_bc(DisasContext *s, DisasOps *o)
     int imm = is_imm ? get_field(s->fields, i2) : 0;
     DisasCompare c;
 
+    /* BCR with R2 = 0 causes no branching */
+    if (have_field(s->fields, r2) && get_field(s->fields, r2) == 0) {
+        if (m1 == 14) {
+            /* Perform serialization */
+            /* FIXME: check for fast-BCR-serialization facility */
+            tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
+        }
+        if (m1 == 15) {
+            /* Perform serialization */
+            /* FIXME: perform checkpoint-synchronisation */
+            tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
+        }
+        return NO_EXIT;
+    }
+
     disas_jcc(s, &c, m1);
     return help_branch(s, &c, is_imm, imm, o->in2);
 }
Signature · 1 line
2.11.0
Reviewed-by on v1 3/3
#9 lore raw

Re: [Qemu-devel] [PATCH 3/3] target/s390x: implement serialization in BRANCH CONDITION

Quoted 13 lines · Aurelien Jarno
---
  target/s390x/translate.c | 15 +++++++++++++++
  1 file changed, 15 insertions(+)
target/s390x/translate.c +0 -0
index c58c27f8e9..2f07ce2be9 100644
@@ -1517,6 +1517,21 @@ static ExitStatus op_bc(DisasContext *s, DisasOps *o)
      int imm = is_imm ? get_field(s->fields, i2) : 0;
      DisasCompare c;
 

target/s390x/translate.c static ExitStatus op_bc(DisasContext *s, DisasOps *o) · line 1529

Quoted 10 lines
target/s390x/translate.c +10 -0
+    /* BCR with R2 = 0 causes no branching */
+    if (have_field(s->fields, r2) && get_field(s->fields, r2) == 0) {
+        if (m1 == 14) {
+            /* Perform serialization */
+            /* FIXME: check for fast-BCR-serialization facility */
+            tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
+        }
+        if (m1 == 15) {
+            /* Perform serialization */
+            /* FIXME: perform checkpoint-synchronisation */

I don't know if we'll ever need to do anything with this side effect, but I guess it's good to document.

r~