Skip to contentSkip to conversation

more s390x patches

GIT PULL Applied Cornelia Huck 2 participants 8 messages Dec 19, 2019 – Dec 20, 2019

lore
Share & tools
lore
#1 lore raw

[PULL 4/6] pc-bios/s390x: Fix reset psw mask

In reply to Cornelia Huck

From: Janosch Frank <[email protected]>

We need to set the short psw indication bit in the reset psw, as it is a short psw.

Exposed by "s390x: Properly fetch and test the short psw on diag308 subc 0/1".

Fixes 962982329029 ("pc-bios/s390-ccw: do a subsystem reset before running the guest")

Message-Id: <[email protected]>

---
 pc-bios/s390-ccw/jump2ipl.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
pc-bios/s390-ccw/jump2ipl.c +7 -5
index 266f1502b967..da13c43cc047 100644
@@ -12,11 +12,11 @@
 #define KERN_IMAGE_START 0x010000UL
 #define PSW_MASK_64 0x0000000100000000ULL
 #define PSW_MASK_32 0x0000000080000000ULL
-#define IPL_PSW_MASK (PSW_MASK_32 | PSW_MASK_64)
+#define PSW_MASK_SHORTPSW 0x0008000000000000ULL
+#define RESET_PSW_MASK (PSW_MASK_SHORTPSW | PSW_MASK_32 | PSW_MASK_64)
 
 typedef struct ResetInfo {
-    uint32_t ipl_mask;
-    uint32_t ipl_addr;
+    uint64_t ipl_psw;
     uint32_t ipl_continue;
 } ResetInfo;
 
@@ -50,7 +50,9 @@ void jump_to_IPL_code(uint64_t address)
     ResetInfo *current = 0;
 
     save = *current;
-    current->ipl_addr = (uint32_t) (uint64_t) &jump_to_IPL_2;
+
+    current->ipl_psw = (uint64_t) &jump_to_IPL_2;
+    current->ipl_psw |= RESET_PSW_MASK;
     current->ipl_continue = address & 0x7fffffff;
 
     debug_print_int("set IPL addr to", current->ipl_continue);
@@ -82,7 +84,7 @@ void jump_to_low_kernel(void)
     }
 
     /* Trying to get PSW at zero address */
-    if (*((uint64_t *)0) & IPL_PSW_MASK) {
+    if (*((uint64_t *)0) & RESET_PSW_MASK) {
         jump_to_IPL_code((*((uint64_t *)0)) & 0x7fffffff);
     }
 
Signature · 1 line
2.21.0
#2 lore raw

[PULL 6/6] s390x: Properly fetch and test the short psw on diag308 subc 0/1

In reply to Cornelia Huck

From: Janosch Frank <[email protected]>

We need to actually fetch the cpu mask and set it. As we invert the short psw indication in the mask, SIE will report a specification exception, if it wasn't present in the reset psw.

Message-Id: <[email protected]>

---
 target/s390x/cpu.c | 12 ++++++++++--
 target/s390x/cpu.h |  1 +
 2 files changed, 11 insertions(+), 2 deletions(-)
target/s390x/cpu.c +10 -2
index 99ea09085a30..625daeedd133 100644
@@ -76,8 +76,16 @@ static bool s390_cpu_has_work(CPUState *cs)
 static void s390_cpu_load_normal(CPUState *s)
 {
     S390CPU *cpu = S390_CPU(s);
-    cpu->env.psw.addr = ldl_phys(s->as, 4) & PSW_MASK_ESA_ADDR;
-    cpu->env.psw.mask = PSW_MASK_32 | PSW_MASK_64;
+    uint64_t spsw = ldq_phys(s->as, 0);
+
+    cpu->env.psw.mask = spsw & 0xffffffff80000000ULL;
+    /*
+     * Invert short psw indication, so SIE will report a specification
+     * exception if it was not set.
+     */
+    cpu->env.psw.mask ^= PSW_MASK_SHORTPSW;
+    cpu->env.psw.addr = spsw & 0x7fffffffULL;
+
     s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu);
 }
 #endif
target/s390x/cpu.h +1 -0
index aa829e954cbf..e195e5c7c8bb 100644
@@ -269,6 +269,7 @@ extern const VMStateDescription vmstate_s390_cpu;
 #define PSW_MASK_EXT            0x0100000000000000ULL
 #define PSW_MASK_KEY            0x00F0000000000000ULL
 #define PSW_SHIFT_KEY           52
+#define PSW_MASK_SHORTPSW       0x0008000000000000ULL
 #define PSW_MASK_MCHECK         0x0004000000000000ULL
 #define PSW_MASK_WAIT           0x0002000000000000ULL
 #define PSW_MASK_PSTATE         0x0001000000000000ULL
Signature · 1 line
2.21.0
#3 lore raw

[PULL 5/6] pc-bios/s390: Update firmware images

In reply to Cornelia Huck

Contains "pc-bios/s390x: Fix reset psw mask".

---
 pc-bios/s390-ccw.img     | Bin 42608 -> 42608 bytes
 pc-bios/s390-netboot.img | Bin 67232 -> 67232 bytes
 2 files changed, 0 insertions(+), 0 deletions(-)
pc-bios/s390-ccw.img binary +0 -0
index c84ae93561ddfa3e1749f81ff62e60aad97fc061..91cdee4436ad828fe6cb664cfac270a21f2bde70 100644
GIT binary patch
pc-bios/s390-netboot.img binary +0 -0
index f9ef28ef1a3879b5ee0cdb45cb5a3a74965e82ba..6bb5c86eb086a6b06e3f1a42664cdbd27366f992 100644
GIT binary patch
Signature · 1 line
2.21.0
#4 lore raw

[PULL 2/6] target/s390x: Implement LOAD/STORE TO REAL ADDRESS inline

In reply to Cornelia Huck

From: Richard Henderson <[email protected]>

These are trivially done by performing a memory operation with the correct mmu_idx. The only tricky part is using get_address directly in order to get the address wrapped; we cannot use la2 because of the format.

Message-Id: <[email protected]>

---
 target/s390x/helper.h      |  4 ----
 target/s390x/insn-data.def |  8 ++++----
 target/s390x/mem_helper.c  | 22 ----------------------
 target/s390x/translate.c   | 21 ++++-----------------
 4 files changed, 8 insertions(+), 47 deletions(-)
target/s390x/helper.h +0 -4
index f5b4bb6a316b..b5813c2ac2b9 100644
@@ -324,10 +324,6 @@ DEF_HELPER_FLAGS_4(ipte, TCG_CALL_NO_RWG, void, env, i64, i64, i32)
 DEF_HELPER_FLAGS_1(ptlb, TCG_CALL_NO_RWG, void, env)
 DEF_HELPER_FLAGS_1(purge, TCG_CALL_NO_RWG, void, env)
 DEF_HELPER_2(lra, i64, env, i64)
-DEF_HELPER_FLAGS_2(lura, TCG_CALL_NO_WG, i64, env, i64)
-DEF_HELPER_FLAGS_2(lurag, TCG_CALL_NO_WG, i64, env, i64)
-DEF_HELPER_FLAGS_3(stura, TCG_CALL_NO_WG, void, env, i64, i64)
-DEF_HELPER_FLAGS_3(sturg, TCG_CALL_NO_WG, void, env, i64, i64)
 DEF_HELPER_1(per_check_exception, void, env)
 DEF_HELPER_FLAGS_3(per_branch, TCG_CALL_NO_RWG, void, env, i64, i64)
 DEF_HELPER_FLAGS_2(per_ifetch, TCG_CALL_NO_RWG, void, env, i64)
target/s390x/insn-data.def +4 -4
index 449eee1662d0..2bc77f087102 100644
@@ -1275,8 +1275,8 @@
     F(0xe313, LRAY,    RXY_a, LD,  0, a2, r1, 0, lra, 0, IF_PRIV)
     F(0xe303, LRAG,    RXY_a, Z,   0, a2, r1, 0, lra, 0, IF_PRIV)
 /* LOAD USING REAL ADDRESS */
-    F(0xb24b, LURA,    RRE,   Z,   0, r2, new, r1_32, lura, 0, IF_PRIV)
-    F(0xb905, LURAG,   RRE,   Z,   0, r2, r1, 0, lurag, 0, IF_PRIV)
+    E(0xb24b, LURA,    RRE,   Z,   0, 0, new, r1_32, lura, 0, MO_TEUL, IF_PRIV)
+    E(0xb905, LURAG,   RRE,   Z,   0, 0, r1, 0, lura, 0, MO_TEQ, IF_PRIV)
 /* MOVE TO PRIMARY */
     F(0xda00, MVCP,    SS_d,  Z,   la1, a2, 0, 0, mvcp, 0, IF_PRIV)
 /* MOVE TO SECONDARY */
@@ -1329,8 +1329,8 @@
 /* STORE THEN OR SYSTEM MASK */
     F(0xad00, STOSM,   SI,    Z,   la1, 0, 0, 0, stnosm, 0, IF_PRIV)
 /* STORE USING REAL ADDRESS */
-    F(0xb246, STURA,   RRE,   Z,   r1_o, r2_o, 0, 0, stura, 0, IF_PRIV)
-    F(0xb925, STURG,   RRE,   Z,   r1_o, r2_o, 0, 0, sturg, 0, IF_PRIV)
+    E(0xb246, STURA,   RRE,   Z,   r1_o, 0, 0, 0, stura, 0, MO_TEUL, IF_PRIV)
+    E(0xb925, STURG,   RRE,   Z,   r1_o, 0, 0, 0, stura, 0, MO_TEQ, IF_PRIV)
 /* TEST BLOCK */
     F(0xb22c, TB,      RRE,   Z,   0, r2_o, 0, 0, testblock, 0, IF_PRIV)
 /* TEST PROTECTION */
target/s390x/mem_helper.c +0 -22
index b1b3f406c9e0..2921419c27cd 100644
@@ -2329,28 +2329,6 @@ void HELPER(purge)(CPUS390XState *env)
     tlb_flush_all_cpus_synced(env_cpu(env));
 }
 
-/* load using real address */
-uint64_t HELPER(lura)(CPUS390XState *env, uint64_t addr)
-{
-    return cpu_ldl_real_ra(env, wrap_address(env, addr), GETPC());
-}
-
-uint64_t HELPER(lurag)(CPUS390XState *env, uint64_t addr)
-{
-    return cpu_ldq_real_ra(env, wrap_address(env, addr), GETPC());
-}
-
-/* store using real address */
-void HELPER(stura)(CPUS390XState *env, uint64_t addr, uint64_t v1)
-{
-    cpu_stl_real_ra(env, wrap_address(env, addr), (uint32_t)v1, GETPC());
-}
-
-void HELPER(sturg)(CPUS390XState *env, uint64_t addr, uint64_t v1)
-{
-    cpu_stq_real_ra(env, wrap_address(env, addr), v1, GETPC());
-}
-
 /* load real address */
 uint64_t HELPER(lra)(CPUS390XState *env, uint64_t addr)
 {
target/s390x/translate.c +4 -17
index ef751fefa4e5..4292bb0dd078 100644
@@ -3272,13 +3272,8 @@ static DisasJumpType op_lpq(DisasContext *s, DisasOps *o)
 #ifndef CONFIG_USER_ONLY
 static DisasJumpType op_lura(DisasContext *s, DisasOps *o)
 {
-    gen_helper_lura(o->out, cpu_env, o->in2);
-    return DISAS_NEXT;
-}
-
-static DisasJumpType op_lurag(DisasContext *s, DisasOps *o)
-{
-    gen_helper_lurag(o->out, cpu_env, o->in2);
+    o->addr1 = get_address(s, 0, get_field(s->fields, r2), 0);
+    tcg_gen_qemu_ld_tl(o->out, o->addr1, MMU_REAL_IDX, s->insn->data);
     return DISAS_NEXT;
 }
 #endif
@@ -4506,17 +4501,9 @@ static DisasJumpType op_stnosm(DisasContext *s, DisasOps *o)
 
 static DisasJumpType op_stura(DisasContext *s, DisasOps *o)
 {
-    gen_helper_stura(cpu_env, o->in2, o->in1);
-    if (s->base.tb->flags & FLAG_MASK_PER) {
-        update_psw_addr(s);
-        gen_helper_per_store_real(cpu_env);
-    }
-    return DISAS_NEXT;
-}
+    o->addr1 = get_address(s, 0, get_field(s->fields, r2), 0);
+    tcg_gen_qemu_st_tl(o->in1, o->addr1, MMU_REAL_IDX, s->insn->data);
 
-static DisasJumpType op_sturg(DisasContext *s, DisasOps *o)
-{
-    gen_helper_sturg(cpu_env, o->in2, o->in1);
     if (s->base.tb->flags & FLAG_MASK_PER) {
         update_psw_addr(s);
         gen_helper_per_store_real(cpu_env);
Signature · 1 line
2.21.0
#5 lore raw

[PULL 3/6] tests/boot-sector: Fix the bad s390x assembler code

In reply to Cornelia Huck

From: Thomas Huth <[email protected]>

There are currently two bugs in s390x_code[]: First, the initial jump uses the wrong offset, so it was jumping to 0x10014 instead of 0x10010. Second, LHI only loads the lower 32-bit of the register.

Everything worked fine as long as the s390-ccw bios code was jumping here with r3 containing zeroes in the uppermost 48 bit - which just happened to be the case so far by accident. But we can not rely on this fact, and indeed one of the recent suggested patches to jump2ipl.c cause the newer GCCs to put different values into r3. In that case the code from s390x_code[] crashes very ungracefully.

Thus let's make sure to jump to the right instruction, and use LGHI instead of LHI to make sure that we always zero out the upper bits of the register.

Message-Id: <[email protected]>

---
 tests/boot-sector.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/boot-sector.c +2 -2
index 7824286b9a4e..9e66c6d0130a 100644
@@ -75,11 +75,11 @@ static const uint8_t s390x_psw_and_magic[] = {
     0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40   /* in the s390-ccw bios */
 };
 static const uint8_t s390x_code[] = {
-    0xa7, 0xf4, 0x00, 0x0a,                                /* j 0x10010 */
+    0xa7, 0xf4, 0x00, 0x08,                                /* j 0x10010 */
     0x00, 0x00, 0x00, 0x00,
     'S', '3', '9', '0',
     'E', 'P', 0x00, 0x01,
-    0xa7, 0x38, HIGH(SIGNATURE_ADDR), LOW(SIGNATURE_ADDR), /* lhi r3,0x7c10 */
+    0xa7, 0x39, HIGH(SIGNATURE_ADDR), LOW(SIGNATURE_ADDR), /* lghi r3,0x7c10 */
     0xa7, 0x48, LOW(SIGNATURE), HIGH(SIGNATURE),           /* lhi r4,0xadde */
     0x40, 0x40, 0x30, 0x00,                                /* sth r4,0(r3) */
     0xa7, 0xf4, 0xff, 0xfa                                 /* j 0x10010 */
Signature · 1 line
2.21.0
#0 lore raw

The following changes since commit aceeaa69d28e6f08a24395d0aa6915b687d0a681:

Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2019-12-17' into staging (2019-12-17 15:55:20 +0000)

are available in the Git repository at:

https://github.com/cohuck/qemu tags/s390x-20191219

for you to fetch changes up to 104130cb7c106378dab944397c6a455c4a6d552f:

s390x: Properly fetch and test the short psw on diag308 subc 0/1 (2019-12-18 15:54:24 +0100)

----------------------------------------------------------------
More s390x patches:
- tcg: implement LOAD/STORE TO REAL ADDRESS inline
- fixes in tests, the bios, and diag308 handling

----------------------------------------------------------------

Cornelia Huck (1):
pc-bios/s390: Update firmware images

Janosch Frank (2):
pc-bios/s390x: Fix reset psw mask
s390x: Properly fetch and test the short psw on diag308 subc 0/1

Richard Henderson (2):
target/s390x: Split out helper_per_store_real target/s390x: Implement LOAD/STORE TO REAL ADDRESS inline

Thomas Huth (1):
tests/boot-sector: Fix the bad s390x assembler code

 pc-bios/s390-ccw.img        | Bin 42608 -> 42608 bytes
 pc-bios/s390-ccw/jump2ipl.c |  12 +++++++-----
 pc-bios/s390-netboot.img    | Bin 67232 -> 67232 bytes
 target/s390x/cpu.c          |  12 ++++++++++--
 target/s390x/cpu.h          |   1 +
 target/s390x/helper.h       |   5 +----
 target/s390x/insn-data.def  |   8 ++++----
 target/s390x/mem_helper.c   |  38 ------------------------------------
 target/s390x/misc_helper.c  |  10 ++++++++++
 target/s390x/translate.c    |  21 ++++++++------------
 tests/boot-sector.c         |   4 ++--
 11 files changed, 43 insertions(+), 68 deletions(-)
Signature · 1 line
2.21.0
#6 lore raw

[PULL 1/6] target/s390x: Split out helper_per_store_real

From: Richard Henderson <[email protected]>

Split the PER handling for store-to-real-address into its own helper function, conditionally called when PER is enabled, just as we do for per_branch and per_ifetch.

Message-Id: <[email protected]>

---
 target/s390x/helper.h      |  1 +
 target/s390x/mem_helper.c  | 16 ----------------
 target/s390x/misc_helper.c | 10 ++++++++++
 target/s390x/translate.c   |  8 ++++++++
 4 files changed, 19 insertions(+), 16 deletions(-)
target/s390x/helper.h +1 -0
index 56e8149866f4..f5b4bb6a316b 100644
@@ -331,6 +331,7 @@ DEF_HELPER_FLAGS_3(sturg, TCG_CALL_NO_WG, void, env, i64, i64)
 DEF_HELPER_1(per_check_exception, void, env)
 DEF_HELPER_FLAGS_3(per_branch, TCG_CALL_NO_RWG, void, env, i64, i64)
 DEF_HELPER_FLAGS_2(per_ifetch, TCG_CALL_NO_RWG, void, env, i64)
+DEF_HELPER_FLAGS_1(per_store_real, TCG_CALL_NO_RWG, void, env)
 DEF_HELPER_FLAGS_1(stfl, TCG_CALL_NO_RWG, void, env)
 
 DEF_HELPER_2(xsch, void, env, i64)
target/s390x/mem_helper.c +0 -16
index 2325767f1787..b1b3f406c9e0 100644
@@ -2344,27 +2344,11 @@ uint64_t HELPER(lurag)(CPUS390XState *env, uint64_t addr)
 void HELPER(stura)(CPUS390XState *env, uint64_t addr, uint64_t v1)
 {
     cpu_stl_real_ra(env, wrap_address(env, addr), (uint32_t)v1, GETPC());
-
-    if ((env->psw.mask & PSW_MASK_PER) &&
-        (env->cregs[9] & PER_CR9_EVENT_STORE) &&
-        (env->cregs[9] & PER_CR9_EVENT_STORE_REAL)) {
-        /* PSW is saved just before calling the helper.  */
-        env->per_address = env->psw.addr;
-        env->per_perc_atmid = PER_CODE_EVENT_STORE_REAL | get_per_atmid(env);
-    }
 }
 
 void HELPER(sturg)(CPUS390XState *env, uint64_t addr, uint64_t v1)
 {
     cpu_stq_real_ra(env, wrap_address(env, addr), v1, GETPC());
-
-    if ((env->psw.mask & PSW_MASK_PER) &&
-        (env->cregs[9] & PER_CR9_EVENT_STORE) &&
-        (env->cregs[9] & PER_CR9_EVENT_STORE_REAL)) {
-        /* PSW is saved just before calling the helper.  */
-        env->per_address = env->psw.addr;
-        env->per_perc_atmid = PER_CODE_EVENT_STORE_REAL | get_per_atmid(env);
-    }
 }
 
 /* load real address */
target/s390x/misc_helper.c +10 -0
index bfb457fb631a..58dbc023eb54 100644
@@ -620,6 +620,16 @@ void HELPER(per_ifetch)(CPUS390XState *env, uint64_t addr)
         }
     }
 }
+
+void HELPER(per_store_real)(CPUS390XState *env)
+{
+    if ((env->cregs[9] & PER_CR9_EVENT_STORE) &&
+        (env->cregs[9] & PER_CR9_EVENT_STORE_REAL)) {
+        /* PSW is saved just before calling the helper.  */
+        env->per_address = env->psw.addr;
+        env->per_perc_atmid = PER_CODE_EVENT_STORE_REAL | get_per_atmid(env);
+    }
+}
 #endif
 
 static uint8_t stfl_bytes[2048];
target/s390x/translate.c +8 -0
index 151dfa91fb9f..ef751fefa4e5 100644
@@ -4507,12 +4507,20 @@ static DisasJumpType op_stnosm(DisasContext *s, DisasOps *o)
 static DisasJumpType op_stura(DisasContext *s, DisasOps *o)
 {
     gen_helper_stura(cpu_env, o->in2, o->in1);
+    if (s->base.tb->flags & FLAG_MASK_PER) {
+        update_psw_addr(s);
+        gen_helper_per_store_real(cpu_env);
+    }
     return DISAS_NEXT;
 }
 
 static DisasJumpType op_sturg(DisasContext *s, DisasOps *o)
 {
     gen_helper_sturg(cpu_env, o->in2, o->in1);
+    if (s->base.tb->flags & FLAG_MASK_PER) {
+        update_psw_addr(s);
+        gen_helper_per_store_real(cpu_env);
+    }
     return DISAS_NEXT;
 }
 #endif
Signature · 1 line
2.21.0
#7 lore raw
In reply to Cornelia Huck
Quoted 9 lines · Cornelia Huck

The following changes since commit aceeaa69d28e6f08a24395d0aa6915b687d0a681:

Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2019-12-17' into staging (2019-12-17 15:55:20 +0000)

are available in the Git repository at:

https://github.com/cohuck/qemu tags/s390x-20191219

Quoted 9 lines

for you to fetch changes up to 104130cb7c106378dab944397c6a455c4a6d552f:

s390x: Properly fetch and test the short psw on diag308 subc 0/1 (2019-12-18 15:54:24 +0100)

----------------------------------------------------------------
More s390x patches:
- tcg: implement LOAD/STORE TO REAL ADDRESS inline
- fixes in tests, the bios, and diag308 handling

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/5.0
for any user-visible changes.

-- PMM