All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL v2 0/9] Next set of s390x patches
@ 2015-10-21 10:30 Cornelia Huck
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 1/9] util/qemu-config: fix missing machine command line options Cornelia Huck
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Cornelia Huck @ 2015-10-21 10:30 UTC (permalink / raw)
  To: peter.maydell; +Cc: Cornelia Huck, borntraeger, jfrei, qemu-devel, agraf

Changes v1->v2:
- Fix declaration of reset_dev_types[]

The following changes since commit ee9dfed242610ecb91418270fd46b875ed56e201:

  Merge remote-tracking branch 'remotes/kraxel/tags/pull-input-20151020-1' into staging (2015-10-20 12:56:45 +0100)

are available in the git repository at:

  git://github.com/cohuck/qemu tags/s390x-20151021-v2

for you to fetch changes up to 1cd4e0f6f0a6b1978a5868b41d4faae2071dc4ee:

  s390x/cmma: clean up cmma reset (2015-10-21 12:21:30 +0200)

----------------------------------------------------------------
More s390x patches. The first ones are fixes: A regression, missed
compat and a missed part of the SIMD support. The others contain
optimizations and cleanup.

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

Christian Borntraeger (1):
  s390x/kvm: Fix vector validity bit in device machine checks

Cornelia Huck (2):
  s390x/virtio-ccw: fix 2.4 virtio compat
  s390x: flagify mcic values

David Hildenbrand (5):
  s390x: unify device reset during subsystem_reset()
  s390x/ipl: we always have an ipl device
  s390x: machine reset function with new ipl cpu handling
  s390x: reset crypto only on clear reset and QEMU reset
  s390x/cmma: clean up cmma reset

Tony Krowiak (1):
  util/qemu-config: fix missing machine command line options

 hw/s390x/ipl.c             | 53 +++++++++++++++++++------------------
 hw/s390x/ipl.h             |  5 +++-
 hw/s390x/s390-virtio-ccw.c | 44 +++++++++++++++++++------------
 hw/s390x/s390-virtio.c     | 15 +++++++++++
 hw/s390x/s390-virtio.h     |  1 +
 target-s390x/cpu.h         | 65 ++++++++++++++++++++++++++++++++++++++++++----
 target-s390x/kvm.c         | 32 ++++++++++++++++-------
 target-s390x/misc_helper.c | 12 ++++-----
 util/qemu-config.c         |  8 ++++++
 9 files changed, 168 insertions(+), 67 deletions(-)

-- 
2.6.2

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

* [Qemu-devel] [PULL v2 1/9] util/qemu-config: fix missing machine command line options
  2015-10-21 10:30 [Qemu-devel] [PULL v2 0/9] Next set of s390x patches Cornelia Huck
@ 2015-10-21 10:30 ` Cornelia Huck
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 2/9] s390x/virtio-ccw: fix 2.4 virtio compat Cornelia Huck
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2015-10-21 10:30 UTC (permalink / raw)
  To: peter.maydell
  Cc: Tony Krowiak, Cornelia Huck, qemu-stable, qemu-devel, agraf,
	borntraeger, jfrei, Marcel Apfelbaum

From: Tony Krowiak <akrowiak@linux.vnet.ibm.com>

Commit 0a7cf217 ("util/qemu-config: fix regression of
qmp_query_command_line_options") aimed to restore parsing of global
machine options, but missed two: "aes-key-wrap" and
"dea-key-wrap" (which were present in the initial version of that
patch). Let's add them to the machine_opts again.

Fixes: 0a7cf217 ("util/qemu-config: fix regression of
                  qmp_query_command_line_options")
CC: Marcel Apfelbaum <marcel@redhat.com>
CC: qemu-stable@nongnu.org
Signed-off-by: Tony Krowiak <akrowiak@linux.vnet.ibm.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Message-Id: <1444664181-28023-1-git-send-email-akrowiak@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 util/qemu-config.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/util/qemu-config.c b/util/qemu-config.c
index 5fcfd0e..687fd34 100644
--- a/util/qemu-config.c
+++ b/util/qemu-config.c
@@ -219,6 +219,14 @@ static QemuOptsList machine_opts = {
             .name = "suppress-vmdesc",
             .type = QEMU_OPT_BOOL,
             .help = "Set on to disable self-describing migration",
+        },{
+            .name = "aes-key-wrap",
+            .type = QEMU_OPT_BOOL,
+            .help = "enable/disable AES key wrapping using the CPACF wrapping key",
+        },{
+            .name = "dea-key-wrap",
+            .type = QEMU_OPT_BOOL,
+            .help = "enable/disable DEA key wrapping using the CPACF wrapping key",
         },
         { /* End of list */ }
     }
-- 
2.6.2

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

* [Qemu-devel] [PULL v2 2/9] s390x/virtio-ccw: fix 2.4 virtio compat
  2015-10-21 10:30 [Qemu-devel] [PULL v2 0/9] Next set of s390x patches Cornelia Huck
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 1/9] util/qemu-config: fix missing machine command line options Cornelia Huck
@ 2015-10-21 10:30 ` Cornelia Huck
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 3/9] s390x/kvm: Fix vector validity bit in device machine checks Cornelia Huck
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2015-10-21 10:30 UTC (permalink / raw)
  To: peter.maydell; +Cc: Cornelia Huck, borntraeger, jfrei, qemu-devel, agraf

Commit 542571d5 ("virtio-ccw: enable virtio-1") missed some virtio
devices for the 2.4 compat handling. Add them.

Fixes: 542571d5 ("virtio-ccw: enable virtio-1")
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 hw/s390x/s390-virtio-ccw.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 6195f13..b9033d4 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -262,6 +262,18 @@ static const TypeInfo ccw_machine_info = {
             .driver   = "virtio-rng-ccw",\
             .property = "max_revision",\
             .value    = "0",\
+        },{\
+            .driver   = "virtio-net-ccw",\
+            .property = "max_revision",\
+            .value    = "0",\
+        },{\
+            .driver   = "virtio-scsi-ccw",\
+            .property = "max_revision",\
+            .value    = "0",\
+        },{\
+            .driver   = "vhost-scsi-ccw",\
+            .property = "max_revision",\
+            .value    = "0",\
         },
 
 static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data)
-- 
2.6.2

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

* [Qemu-devel] [PULL v2 3/9] s390x/kvm: Fix vector validity bit in device machine checks
  2015-10-21 10:30 [Qemu-devel] [PULL v2 0/9] Next set of s390x patches Cornelia Huck
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 1/9] util/qemu-config: fix missing machine command line options Cornelia Huck
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 2/9] s390x/virtio-ccw: fix 2.4 virtio compat Cornelia Huck
@ 2015-10-21 10:30 ` Cornelia Huck
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 4/9] s390x: flagify mcic values Cornelia Huck
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2015-10-21 10:30 UTC (permalink / raw)
  To: peter.maydell
  Cc: agraf, qemu-stable, qemu-devel, borntraeger, jfrei, Cornelia Huck

From: Christian Borntraeger <borntraeger@de.ibm.com>

Device hotplugs trigger a crw machine check. All machine checks
have validity bits for certain register types. With vector support
we also have to claim that vector registers are valid.
This is a band-aid suitable for stable. Long term we should
create the full  mcic value dynamically depending on the active
features in the kernel interrupt handler.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 target-s390x/kvm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 0305ffa..e1acdac 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -2072,6 +2072,9 @@ void kvm_s390_crw_mchk(void)
         .u.mchk.cr14 = 1 << 28,
         .u.mchk.mcic = 0x00400f1d40330000ULL,
     };
+    if (kvm_check_extension(kvm_state, KVM_CAP_S390_VECTOR_REGISTERS)) {
+        irq.u.mchk.mcic |= 0x0000004000000000ULL;
+    }
     kvm_s390_floating_interrupt(&irq);
 }
 
-- 
2.6.2

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

* [Qemu-devel] [PULL v2 4/9] s390x: flagify mcic values
  2015-10-21 10:30 [Qemu-devel] [PULL v2 0/9] Next set of s390x patches Cornelia Huck
                   ` (2 preceding siblings ...)
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 3/9] s390x/kvm: Fix vector validity bit in device machine checks Cornelia Huck
@ 2015-10-21 10:30 ` Cornelia Huck
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 5/9] s390x: unify device reset during subsystem_reset() Cornelia Huck
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2015-10-21 10:30 UTC (permalink / raw)
  To: peter.maydell; +Cc: Cornelia Huck, borntraeger, jfrei, qemu-devel, agraf

Instead of using magic values when building the machine check
interruption code, add some defines as by chapter 11-14 in the PoP.

This should make it easier to catch problems like the missing vector
register validity bit ("s390x/kvm: Fix vector validity bit in device
machine checks"), and less hassle should we want to generate machine
checks beyond the channel reports we currently support.

Acked-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 target-s390x/cpu.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
 target-s390x/kvm.c | 23 +++++++++++++++++++----
 2 files changed, 64 insertions(+), 4 deletions(-)

diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index e4de863..07ae16c 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -1275,4 +1275,49 @@ static inline bool vregs_needed(void *opaque)
     return 0;
 }
 #endif
+
+/* machine check interruption code */
+
+/* subclasses */
+#define MCIC_SC_SD 0x8000000000000000ULL
+#define MCIC_SC_PD 0x4000000000000000ULL
+#define MCIC_SC_SR 0x2000000000000000ULL
+#define MCIC_SC_CD 0x0800000000000000ULL
+#define MCIC_SC_ED 0x0400000000000000ULL
+#define MCIC_SC_DG 0x0100000000000000ULL
+#define MCIC_SC_W  0x0080000000000000ULL
+#define MCIC_SC_CP 0x0040000000000000ULL
+#define MCIC_SC_SP 0x0020000000000000ULL
+#define MCIC_SC_CK 0x0010000000000000ULL
+
+/* subclass modifiers */
+#define MCIC_SCM_B  0x0002000000000000ULL
+#define MCIC_SCM_DA 0x0000000020000000ULL
+#define MCIC_SCM_AP 0x0000000000080000ULL
+
+/* storage errors */
+#define MCIC_SE_SE 0x0000800000000000ULL
+#define MCIC_SE_SC 0x0000400000000000ULL
+#define MCIC_SE_KE 0x0000200000000000ULL
+#define MCIC_SE_DS 0x0000100000000000ULL
+#define MCIC_SE_IE 0x0000000080000000ULL
+
+/* validity bits */
+#define MCIC_VB_WP 0x0000080000000000ULL
+#define MCIC_VB_MS 0x0000040000000000ULL
+#define MCIC_VB_PM 0x0000020000000000ULL
+#define MCIC_VB_IA 0x0000010000000000ULL
+#define MCIC_VB_FA 0x0000008000000000ULL
+#define MCIC_VB_VR 0x0000004000000000ULL
+#define MCIC_VB_EC 0x0000002000000000ULL
+#define MCIC_VB_FP 0x0000001000000000ULL
+#define MCIC_VB_GR 0x0000000800000000ULL
+#define MCIC_VB_CR 0x0000000400000000ULL
+#define MCIC_VB_ST 0x0000000100000000ULL
+#define MCIC_VB_AR 0x0000000040000000ULL
+#define MCIC_VB_PR 0x0000000000200000ULL
+#define MCIC_VB_FC 0x0000000000100000ULL
+#define MCIC_VB_CT 0x0000000000020000ULL
+#define MCIC_VB_CC 0x0000000000010000ULL
+
 #endif
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index e1acdac..6e488d4 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -2065,16 +2065,31 @@ void kvm_s390_io_interrupt(uint16_t subchannel_id,
     kvm_s390_floating_interrupt(&irq);
 }
 
+static uint64_t build_channel_report_mcic(void)
+{
+    uint64_t mcic;
+
+    /* subclass: indicate channel report pending */
+    mcic = MCIC_SC_CP |
+    /* subclass modifiers: none */
+    /* storage errors: none */
+    /* validity bits: no damage */
+        MCIC_VB_WP | MCIC_VB_MS | MCIC_VB_PM | MCIC_VB_IA | MCIC_VB_FP |
+        MCIC_VB_GR | MCIC_VB_CR | MCIC_VB_ST | MCIC_VB_AR | MCIC_VB_PR |
+        MCIC_VB_FC | MCIC_VB_CT | MCIC_VB_CC;
+    if (kvm_check_extension(kvm_state, KVM_CAP_S390_VECTOR_REGISTERS)) {
+        mcic |= MCIC_VB_VR;
+    }
+    return mcic;
+}
+
 void kvm_s390_crw_mchk(void)
 {
     struct kvm_s390_irq irq = {
         .type = KVM_S390_MCHK,
         .u.mchk.cr14 = 1 << 28,
-        .u.mchk.mcic = 0x00400f1d40330000ULL,
+        .u.mchk.mcic = build_channel_report_mcic(),
     };
-    if (kvm_check_extension(kvm_state, KVM_CAP_S390_VECTOR_REGISTERS)) {
-        irq.u.mchk.mcic |= 0x0000004000000000ULL;
-    }
     kvm_s390_floating_interrupt(&irq);
 }
 
-- 
2.6.2

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

* [Qemu-devel] [PULL v2 5/9] s390x: unify device reset during subsystem_reset()
  2015-10-21 10:30 [Qemu-devel] [PULL v2 0/9] Next set of s390x patches Cornelia Huck
                   ` (3 preceding siblings ...)
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 4/9] s390x: flagify mcic values Cornelia Huck
@ 2015-10-21 10:30 ` Cornelia Huck
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 6/9] s390x/ipl: we always have an ipl device Cornelia Huck
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2015-10-21 10:30 UTC (permalink / raw)
  To: peter.maydell
  Cc: borntraeger, qemu-devel, agraf, David Hildenbrand, jfrei, Cornelia Huck

From: David Hildenbrand <dahi@linux.vnet.ibm.com>

We have to manually reset several devices that are not on a bus: Let's
collect them in an array.

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/s390-virtio-ccw.c | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index b9033d4..5e56fbf 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -35,26 +35,23 @@ typedef struct S390CcwMachineState {
     bool dea_key_wrap;
 } S390CcwMachineState;
 
+static const char *const reset_dev_types[] = {
+    "virtual-css-bridge",
+    "s390-sclp-event-facility",
+    "s390-flic",
+    "diag288",
+};
+
 void subsystem_reset(void)
 {
-    DeviceState *css, *sclp, *flic, *diag288;
+    DeviceState *dev;
+    int i;
 
-    css = DEVICE(object_resolve_path_type("", "virtual-css-bridge", NULL));
-    if (css) {
-        qdev_reset_all(css);
-    }
-    sclp = DEVICE(object_resolve_path_type("",
-                  "s390-sclp-event-facility", NULL));
-    if (sclp) {
-        qdev_reset_all(sclp);
-    }
-    flic = DEVICE(object_resolve_path_type("", "s390-flic", NULL));
-    if (flic) {
-        qdev_reset_all(flic);
-    }
-    diag288 = DEVICE(object_resolve_path_type("", "diag288", NULL));
-    if (diag288) {
-        qdev_reset_all(diag288);
+    for (i = 0; i < ARRAY_SIZE(reset_dev_types); i++) {
+        dev = DEVICE(object_resolve_path_type("", reset_dev_types[i], NULL));
+        if (dev) {
+            qdev_reset_all(dev);
+        }
     }
 }
 
-- 
2.6.2

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

* [Qemu-devel] [PULL v2 6/9] s390x/ipl: we always have an ipl device
  2015-10-21 10:30 [Qemu-devel] [PULL v2 0/9] Next set of s390x patches Cornelia Huck
                   ` (4 preceding siblings ...)
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 5/9] s390x: unify device reset during subsystem_reset() Cornelia Huck
@ 2015-10-21 10:30 ` Cornelia Huck
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 7/9] s390x: machine reset function with new ipl cpu handling Cornelia Huck
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2015-10-21 10:30 UTC (permalink / raw)
  To: peter.maydell
  Cc: borntraeger, qemu-devel, agraf, David Hildenbrand, jfrei, Cornelia Huck

From: David Hildenbrand <dahi@linux.vnet.ibm.com>

Both s390 machines unconditionally create an ipl device, so no need to
handle the missing case.

Now we can also change s390_ipl_update_diag308() to return void.

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/ipl.c             | 26 ++++++++++++--------------
 hw/s390x/ipl.h             |  2 +-
 target-s390x/misc_helper.c |  7 ++-----
 3 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index 31473e7..b8c6378 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -95,6 +95,11 @@ static const VMStateDescription vmstate_ipl = {
      }
 };
 
+static S390IPLState *get_ipl_device(void)
+{
+    return S390_IPL(object_resolve_path_type("", TYPE_S390_IPL, NULL));
+}
+
 static uint64_t bios_translate_addr(void *opaque, uint64_t srcaddr)
 {
     uint64_t dstaddr = *(uint64_t *) opaque;
@@ -251,25 +256,19 @@ out:
     return (uint32_t) (ipl->cssid << 24 | ipl->ssid << 16 | ipl->devno);
 }
 
-int s390_ipl_update_diag308(IplParameterBlock *iplb)
+void s390_ipl_update_diag308(IplParameterBlock *iplb)
 {
-    S390IPLState *ipl;
+    S390IPLState *ipl = get_ipl_device();
 
-    ipl = S390_IPL(object_resolve_path(TYPE_S390_IPL, NULL));
-    if (ipl) {
-        ipl->iplb = *iplb;
-        ipl->iplb_valid = true;
-        return 0;
-    }
-    return -1;
+    ipl->iplb = *iplb;
+    ipl->iplb_valid = true;
 }
 
 IplParameterBlock *s390_ipl_get_iplb(void)
 {
-    S390IPLState *ipl;
+    S390IPLState *ipl = get_ipl_device();
 
-    ipl = S390_IPL(object_resolve_path(TYPE_S390_IPL, NULL));
-    if (!ipl || !ipl->iplb_valid) {
+    if (!ipl->iplb_valid) {
         return NULL;
     }
     return &ipl->iplb;
@@ -277,9 +276,8 @@ IplParameterBlock *s390_ipl_get_iplb(void)
 
 void s390_reipl_request(void)
 {
-    S390IPLState *ipl;
+    S390IPLState *ipl = get_ipl_device();
 
-    ipl = S390_IPL(object_resolve_path(TYPE_S390_IPL, NULL));
     ipl->reipl_requested = true;
     qemu_system_reset_request();
 }
diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h
index 70497bc..6424e08 100644
--- a/hw/s390x/ipl.h
+++ b/hw/s390x/ipl.h
@@ -18,7 +18,7 @@ typedef struct IplParameterBlock {
       uint8_t  reserved2[88];
 } IplParameterBlock;
 
-int s390_ipl_update_diag308(IplParameterBlock *iplb);
+void s390_ipl_update_diag308(IplParameterBlock *iplb);
 IplParameterBlock *s390_ipl_get_iplb(void);
 void s390_reipl_request(void);
 
diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c
index 3a19e32..ddf2498 100644
--- a/target-s390x/misc_helper.c
+++ b/target-s390x/misc_helper.c
@@ -233,11 +233,8 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3)
         }
         iplb = g_malloc0(sizeof(struct IplParameterBlock));
         cpu_physical_memory_read(addr, iplb, sizeof(struct IplParameterBlock));
-        if (!s390_ipl_update_diag308(iplb)) {
-            env->regs[r1 + 1] = DIAG_308_RC_OK;
-        } else {
-            env->regs[r1 + 1] = DIAG_308_RC_INVALID;
-        }
+        s390_ipl_update_diag308(iplb);
+        env->regs[r1 + 1] = DIAG_308_RC_OK;
         g_free(iplb);
         return;
     case 6:
-- 
2.6.2

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

* [Qemu-devel] [PULL v2 7/9] s390x: machine reset function with new ipl cpu handling
  2015-10-21 10:30 [Qemu-devel] [PULL v2 0/9] Next set of s390x patches Cornelia Huck
                   ` (5 preceding siblings ...)
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 6/9] s390x/ipl: we always have an ipl device Cornelia Huck
@ 2015-10-21 10:30 ` Cornelia Huck
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 8/9] s390x: reset crypto only on clear reset and QEMU reset Cornelia Huck
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2015-10-21 10:30 UTC (permalink / raw)
  To: peter.maydell
  Cc: borntraeger, qemu-devel, agraf, David Hildenbrand, jfrei, Cornelia Huck

From: David Hildenbrand <dahi@linux.vnet.ibm.com>

Current implementation depends on the order of resets getting triggered.

If a cpu reset is triggered after the ipl device reset, the CPU is stopped and
the VM will not run. In fact, that hinders us from converting the ipl device
into a TYPE_DEVICE. Let's change that by manually configuring the ipl cpu
during a system reset, so we have full control and can demangle that code.

Also remove the superflous cpu parameter from s390_update_iplstate on the way.

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/ipl.c             | 27 ++++++++++++++-------------
 hw/s390x/ipl.h             |  3 +++
 hw/s390x/s390-virtio-ccw.c |  1 +
 hw/s390x/s390-virtio.c     | 13 +++++++++++++
 hw/s390x/s390-virtio.h     |  1 +
 5 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index b8c6378..5f7f349 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -223,7 +223,7 @@ static Property s390_ipl_properties[] = {
  * - -1 if no valid boot device was found
  * - ccw id of the boot device otherwise
  */
-static uint64_t s390_update_iplstate(CPUS390XState *env, S390IPLState *ipl)
+static uint64_t s390_update_iplstate(S390IPLState *ipl)
 {
     DeviceState *dev_st;
 
@@ -282,26 +282,27 @@ void s390_reipl_request(void)
     qemu_system_reset_request();
 }
 
+void s390_ipl_prepare_cpu(S390CPU *cpu)
+{
+    S390IPLState *ipl = get_ipl_device();
+
+    cpu->env.psw.addr = ipl->start_addr;
+    cpu->env.psw.mask = IPL_PSW_MASK;
+
+    if (!ipl->kernel || ipl->iplb_valid) {
+        cpu->env.psw.addr = ipl->bios_start_addr;
+        cpu->env.regs[7] = s390_update_iplstate(ipl);
+    }
+}
+
 static void s390_ipl_reset(DeviceState *dev)
 {
     S390IPLState *ipl = S390_IPL(dev);
-    S390CPU *cpu = S390_CPU(qemu_get_cpu(0));
-    CPUS390XState *env = &cpu->env;
-
-    env->psw.addr = ipl->start_addr;
-    env->psw.mask = IPL_PSW_MASK;
 
     if (!ipl->reipl_requested) {
         ipl->iplb_valid = false;
     }
     ipl->reipl_requested = false;
-
-    if (!ipl->kernel || ipl->iplb_valid) {
-        env->psw.addr = ipl->bios_start_addr;
-        env->regs[7] = s390_update_iplstate(env, ipl);
-    }
-
-    s390_cpu_set_state(CPU_STATE_OPERATING, cpu);
 }
 
 static void s390_ipl_class_init(ObjectClass *klass, void *data)
diff --git a/hw/s390x/ipl.h b/hw/s390x/ipl.h
index 6424e08..7f2b403 100644
--- a/hw/s390x/ipl.h
+++ b/hw/s390x/ipl.h
@@ -12,6 +12,8 @@
 #ifndef HW_S390_IPL_H
 #define HW_S390_IPL_H
 
+#include "cpu.h"
+
 typedef struct IplParameterBlock {
       uint8_t  reserved1[110];
       uint16_t devno;
@@ -19,6 +21,7 @@ typedef struct IplParameterBlock {
 } IplParameterBlock;
 
 void s390_ipl_update_diag308(IplParameterBlock *iplb);
+void s390_ipl_prepare_cpu(S390CPU *cpu);
 IplParameterBlock *s390_ipl_get_iplb(void);
 void s390_reipl_request(void);
 
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 5e56fbf..faba773 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -161,6 +161,7 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data)
     NMIClass *nc = NMI_CLASS(oc);
 
     mc->init = ccw_init;
+    mc->reset = s390_machine_reset;
     mc->block_default_type = IF_VIRTIO;
     mc->no_cdrom = 1;
     mc->no_floppy = 1;
diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index bc013eb..7b8f15b 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -40,6 +40,7 @@
 #include "hw/s390x/s390_flic.h"
 #include "hw/s390x/s390-virtio.h"
 #include "hw/s390x/storage-keys.h"
+#include "hw/s390x/ipl.h"
 #include "cpu.h"
 
 //#define DEBUG_S390
@@ -314,6 +315,17 @@ void s390_nmi(NMIState *n, int cpu_index, Error **errp)
     }
 }
 
+void s390_machine_reset(void)
+{
+    S390CPU *ipl_cpu = S390_CPU(qemu_get_cpu(0));
+
+    qemu_devices_reset();
+
+    /* all cpus are stopped - configure and start the ipl cpu only */
+    s390_ipl_prepare_cpu(ipl_cpu);
+    s390_cpu_set_state(CPU_STATE_OPERATING, ipl_cpu);
+}
+
 static void s390_machine_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -322,6 +334,7 @@ static void s390_machine_class_init(ObjectClass *oc, void *data)
     mc->alias = "s390";
     mc->desc = "VirtIO based S390 machine";
     mc->init = s390_init;
+    mc->reset = s390_machine_reset;
     mc->block_default_type = IF_VIRTIO;
     mc->max_cpus = 255;
     mc->no_serial = 1;
diff --git a/hw/s390x/s390-virtio.h b/hw/s390x/s390-virtio.h
index f389aa1..eebce8e 100644
--- a/hw/s390x/s390-virtio.h
+++ b/hw/s390x/s390-virtio.h
@@ -27,5 +27,6 @@ void s390_init_ipl_dev(const char *kernel_filename,
                        bool enforce_bios);
 void s390_create_virtio_net(BusState *bus, const char *name);
 void s390_nmi(NMIState *n, int cpu_index, Error **errp);
+void s390_machine_reset(void);
 void s390_memory_init(ram_addr_t mem_size);
 #endif
-- 
2.6.2

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

* [Qemu-devel] [PULL v2 8/9] s390x: reset crypto only on clear reset and QEMU reset
  2015-10-21 10:30 [Qemu-devel] [PULL v2 0/9] Next set of s390x patches Cornelia Huck
                   ` (6 preceding siblings ...)
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 7/9] s390x: machine reset function with new ipl cpu handling Cornelia Huck
@ 2015-10-21 10:30 ` Cornelia Huck
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 9/9] s390x/cmma: clean up cmma reset Cornelia Huck
  2015-10-21 15:59 ` [Qemu-devel] [PULL v2 0/9] Next set of s390x patches Peter Maydell
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2015-10-21 10:30 UTC (permalink / raw)
  To: peter.maydell
  Cc: borntraeger, qemu-devel, agraf, David Hildenbrand, jfrei, Cornelia Huck

From: David Hildenbrand <dahi@linux.vnet.ibm.com>

Initializing VM crypto in initial cpu reset has multiple problems

1. We call the exact same function #VCPU times, although one time is enough
2. On SIGP initial cpu reset, we exchange the wrapping key while
   other VCPUs are running. Bad!
3. It is simply wrong. According to the Pop, a reset happens only during a
   clear reset.

So, we have to reset the keys
- on modified clear reset
- on load clear (QEMU reset - via machine reset)
- on qemu start (via machine reset)

Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/s390-virtio.c     |  1 +
 target-s390x/cpu.h         | 11 +++++++++++
 target-s390x/kvm.c         |  4 +---
 target-s390x/misc_helper.c |  1 +
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index 7b8f15b..9a7b7c2 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -320,6 +320,7 @@ void s390_machine_reset(void)
     S390CPU *ipl_cpu = S390_CPU(qemu_get_cpu(0));
 
     qemu_devices_reset();
+    s390_crypto_reset();
 
     /* all cpus are stopped - configure and start the ipl cpu only */
     s390_ipl_prepare_cpu(ipl_cpu);
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 07ae16c..ca98e5a 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -1166,6 +1166,7 @@ void kvm_s390_reset_vcpu(S390CPU *cpu);
 int kvm_s390_set_mem_limit(KVMState *s, uint64_t new_limit, uint64_t *hw_limit);
 void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu);
 int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu);
+void kvm_s390_crypto_reset(void);
 #else
 static inline void kvm_s390_io_interrupt(uint16_t subchannel_id,
                                         uint16_t subchannel_nr,
@@ -1215,6 +1216,9 @@ static inline int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu)
 {
     return 0;
 }
+static inline void kvm_s390_crypto_reset(void)
+{
+}
 #endif
 
 static inline int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit)
@@ -1261,6 +1265,13 @@ static inline int s390_assign_subch_ioeventfd(EventNotifier *notifier,
     return kvm_s390_assign_subch_ioeventfd(notifier, sch_id, vq, assign);
 }
 
+static inline void s390_crypto_reset(void)
+{
+    if (kvm_enabled()) {
+        kvm_s390_crypto_reset();
+    }
+}
+
 #ifdef CONFIG_KVM
 static inline bool vregs_needed(void *opaque)
 {
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 6e488d4..84dffe9 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -249,7 +249,7 @@ static void kvm_s390_init_dea_kw(void)
     }
 }
 
-static void kvm_s390_init_crypto(void)
+void kvm_s390_crypto_reset(void)
 {
     kvm_s390_init_aes_kw();
     kvm_s390_init_dea_kw();
@@ -301,8 +301,6 @@ void kvm_s390_reset_vcpu(S390CPU *cpu)
     if (kvm_vcpu_ioctl(cs, KVM_S390_INITIAL_RESET, NULL)) {
         error_report("Initial CPU reset failed on CPU %i", cs->cpu_index);
     }
-
-    kvm_s390_init_crypto();
 }
 
 static int can_sync_regs(CPUState *cs, int regs)
diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c
index ddf2498..a692c44 100644
--- a/target-s390x/misc_helper.c
+++ b/target-s390x/misc_helper.c
@@ -129,6 +129,7 @@ static int modified_clear_reset(S390CPU *cpu)
     }
     cmma_reset(cpu);
     subsystem_reset();
+    s390_crypto_reset();
     scc->load_normal(CPU(cpu));
     cpu_synchronize_all_post_reset();
     resume_all_vcpus();
-- 
2.6.2

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

* [Qemu-devel] [PULL v2 9/9] s390x/cmma: clean up cmma reset
  2015-10-21 10:30 [Qemu-devel] [PULL v2 0/9] Next set of s390x patches Cornelia Huck
                   ` (7 preceding siblings ...)
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 8/9] s390x: reset crypto only on clear reset and QEMU reset Cornelia Huck
@ 2015-10-21 10:30 ` Cornelia Huck
  2015-10-21 15:59 ` [Qemu-devel] [PULL v2 0/9] Next set of s390x patches Peter Maydell
  9 siblings, 0 replies; 11+ messages in thread
From: Cornelia Huck @ 2015-10-21 10:30 UTC (permalink / raw)
  To: peter.maydell
  Cc: borntraeger, qemu-devel, agraf, David Hildenbrand, jfrei, Cornelia Huck

From: David Hildenbrand <dahi@linux.vnet.ibm.com>

The cmma reset is per VM, so we don't need a cpu object. We can
directly make use of kvm_state, as it is already available when
the reset is called. By moving the cmma reset in our machine reset
function, we can avoid a manual reset handler.

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/s390-virtio.c     | 1 +
 target-s390x/cpu.h         | 9 ++++-----
 target-s390x/kvm.c         | 8 ++------
 target-s390x/misc_helper.c | 4 ++--
 4 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c
index 9a7b7c2..cbde977 100644
--- a/hw/s390x/s390-virtio.c
+++ b/hw/s390x/s390-virtio.c
@@ -320,6 +320,7 @@ void s390_machine_reset(void)
     S390CPU *ipl_cpu = S390_CPU(qemu_get_cpu(0));
 
     qemu_devices_reset();
+    s390_cmma_reset();
     s390_crypto_reset();
 
     /* all cpus are stopped - configure and start the ipl cpu only */
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index ca98e5a..658cd9d 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -1160,7 +1160,7 @@ int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch,
                                     int vq, bool assign);
 int kvm_s390_cpu_restart(S390CPU *cpu);
 int kvm_s390_get_memslot_count(KVMState *s);
-void kvm_s390_clear_cmma_callback(void *opaque);
+void kvm_s390_cmma_reset(void);
 int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state);
 void kvm_s390_reset_vcpu(S390CPU *cpu);
 int kvm_s390_set_mem_limit(KVMState *s, uint64_t new_limit, uint64_t *hw_limit);
@@ -1190,7 +1190,7 @@ static inline int kvm_s390_cpu_restart(S390CPU *cpu)
 {
     return -ENOSYS;
 }
-static inline void kvm_s390_clear_cmma_callback(void *opaque)
+static inline void kvm_s390_cmma_reset(void)
 {
 }
 static inline int kvm_s390_get_memslot_count(KVMState *s)
@@ -1229,11 +1229,10 @@ static inline int s390_set_memory_limit(uint64_t new_limit, uint64_t *hw_limit)
     return 0;
 }
 
-static inline void cmma_reset(S390CPU *cpu)
+static inline void s390_cmma_reset(void)
 {
     if (kvm_enabled()) {
-        CPUState *cs = CPU(cpu);
-        kvm_s390_clear_cmma_callback(cs->kvm_state);
+        kvm_s390_cmma_reset();
     }
 }
 
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 84dffe9..c3be180 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -173,16 +173,15 @@ int kvm_s390_set_mem_limit(KVMState *s, uint64_t new_limit, uint64_t *hw_limit)
     return kvm_vm_ioctl(s, KVM_SET_DEVICE_ATTR, &attr);
 }
 
-void kvm_s390_clear_cmma_callback(void *opaque)
+void kvm_s390_cmma_reset(void)
 {
     int rc;
-    KVMState *s = opaque;
     struct kvm_device_attr attr = {
         .group = KVM_S390_VM_MEM_CTRL,
         .attr = KVM_S390_VM_MEM_CLR_CMMA,
     };
 
-    rc = kvm_vm_ioctl(s, KVM_SET_DEVICE_ATTR, &attr);
+    rc = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
     trace_kvm_clear_cmma(rc);
 }
 
@@ -200,9 +199,6 @@ static void kvm_s390_enable_cmma(KVMState *s)
     }
 
     rc = kvm_vm_ioctl(s, KVM_SET_DEVICE_ATTR, &attr);
-    if (!rc) {
-        qemu_register_reset(kvm_s390_clear_cmma_callback, s);
-    }
     trace_kvm_enable_cmma(rc);
 }
 
diff --git a/target-s390x/misc_helper.c b/target-s390x/misc_helper.c
index a692c44..b601a33 100644
--- a/target-s390x/misc_helper.c
+++ b/target-s390x/misc_helper.c
@@ -127,7 +127,7 @@ static int modified_clear_reset(S390CPU *cpu)
     CPU_FOREACH(t) {
         run_on_cpu(t, s390_do_cpu_full_reset, t);
     }
-    cmma_reset(cpu);
+    s390_cmma_reset();
     subsystem_reset();
     s390_crypto_reset();
     scc->load_normal(CPU(cpu));
@@ -146,7 +146,7 @@ static int load_normal_reset(S390CPU *cpu)
     CPU_FOREACH(t) {
         run_on_cpu(t, s390_do_cpu_reset, t);
     }
-    cmma_reset(cpu);
+    s390_cmma_reset();
     subsystem_reset();
     scc->initial_cpu_reset(CPU(cpu));
     scc->load_normal(CPU(cpu));
-- 
2.6.2

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

* Re: [Qemu-devel] [PULL v2 0/9] Next set of s390x patches
  2015-10-21 10:30 [Qemu-devel] [PULL v2 0/9] Next set of s390x patches Cornelia Huck
                   ` (8 preceding siblings ...)
  2015-10-21 10:30 ` [Qemu-devel] [PULL v2 9/9] s390x/cmma: clean up cmma reset Cornelia Huck
@ 2015-10-21 15:59 ` Peter Maydell
  9 siblings, 0 replies; 11+ messages in thread
From: Peter Maydell @ 2015-10-21 15:59 UTC (permalink / raw)
  To: Cornelia Huck
  Cc: Christian Borntraeger, Jens Freimann, QEMU Developers, Alexander Graf

On 21 October 2015 at 11:30, Cornelia Huck <cornelia.huck@de.ibm.com> wrote:
> Changes v1->v2:
> - Fix declaration of reset_dev_types[]
>
> The following changes since commit ee9dfed242610ecb91418270fd46b875ed56e201:
>
>   Merge remote-tracking branch 'remotes/kraxel/tags/pull-input-20151020-1' into staging (2015-10-20 12:56:45 +0100)
>
> are available in the git repository at:
>
>   git://github.com/cohuck/qemu tags/s390x-20151021-v2
>
> for you to fetch changes up to 1cd4e0f6f0a6b1978a5868b41d4faae2071dc4ee:
>
>   s390x/cmma: clean up cmma reset (2015-10-21 12:21:30 +0200)
>
> ----------------------------------------------------------------
> More s390x patches. The first ones are fixes: A regression, missed
> compat and a missed part of the SIMD support. The others contain
> optimizations and cleanup.

Applied, thanks.

-- PMM

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

end of thread, other threads:[~2015-10-21 15:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-21 10:30 [Qemu-devel] [PULL v2 0/9] Next set of s390x patches Cornelia Huck
2015-10-21 10:30 ` [Qemu-devel] [PULL v2 1/9] util/qemu-config: fix missing machine command line options Cornelia Huck
2015-10-21 10:30 ` [Qemu-devel] [PULL v2 2/9] s390x/virtio-ccw: fix 2.4 virtio compat Cornelia Huck
2015-10-21 10:30 ` [Qemu-devel] [PULL v2 3/9] s390x/kvm: Fix vector validity bit in device machine checks Cornelia Huck
2015-10-21 10:30 ` [Qemu-devel] [PULL v2 4/9] s390x: flagify mcic values Cornelia Huck
2015-10-21 10:30 ` [Qemu-devel] [PULL v2 5/9] s390x: unify device reset during subsystem_reset() Cornelia Huck
2015-10-21 10:30 ` [Qemu-devel] [PULL v2 6/9] s390x/ipl: we always have an ipl device Cornelia Huck
2015-10-21 10:30 ` [Qemu-devel] [PULL v2 7/9] s390x: machine reset function with new ipl cpu handling Cornelia Huck
2015-10-21 10:30 ` [Qemu-devel] [PULL v2 8/9] s390x: reset crypto only on clear reset and QEMU reset Cornelia Huck
2015-10-21 10:30 ` [Qemu-devel] [PULL v2 9/9] s390x/cmma: clean up cmma reset Cornelia Huck
2015-10-21 15:59 ` [Qemu-devel] [PULL v2 0/9] Next set of s390x patches Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.