All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/10] first pile of s390x patches for 2.4
@ 2015-04-09  8:51 Cornelia Huck
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 01/10] s390x/kvm: Remove message about "switch_amode" kernel parameter Cornelia Huck
                   ` (9 more replies)
  0 siblings, 10 replies; 25+ messages in thread
From: Cornelia Huck @ 2015-04-09  8:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cornelia Huck, borntraeger, jfrei, agraf

Hi,

here's the first pile of pending s390x patches I plan to send
when 2.4 opens up. Contents include:

- some cleanup patches
- sort most of the s390x devices into categories
- support for the new STSI post handler, used to insert vm name and
  friends
- support for the new MEM_OP ioctl (including access register mode)
  for accessing guest memory

Alexander Yarygin (1):
  s390x/kvm: Support access register mode for KVM_S390_MEM_OP ioctl

Cornelia Huck (5):
  virtio-ccw: sort into categories
  s390-virtio: sort into categories
  sclp: sort into categories
  s390x/ipl: sort into categories
  linux-headers: update

Ekaterina Tumanova (1):
  s390x/kvm: Put vm name, extended name and UUID into STSI322 SYSIB

Thomas Huth (3):
  s390x/kvm: Remove message about "switch_amode" kernel parameter
  s390x/mmu: Use access type definitions instead of magic values
  s390x/mmu: Use ioctl for reading and writing from/to guest memory

 hw/char/sclpconsole-lm.c      |   1 +
 hw/char/sclpconsole.c         |   1 +
 hw/s390x/event-facility.c     |   1 +
 hw/s390x/ipl.c                |   1 +
 hw/s390x/s390-pci-inst.c      |  21 +++---
 hw/s390x/s390-pci-inst.h      |   7 +-
 hw/s390x/s390-virtio-bus.c    |   9 +++
 hw/s390x/sclp.c               |   9 +++
 hw/s390x/sclpcpu.c            |   2 +
 hw/s390x/sclpquiesce.c        |   1 +
 hw/s390x/virtio-ccw.c         |   9 +++
 kvm-all.c                     |   5 --
 linux-headers/asm-arm/kvm.h   |   3 +
 linux-headers/asm-arm64/kvm.h |   3 +
 linux-headers/asm-mips/kvm.h  | 164 ++++++++++++++++++++++++++----------------
 linux-headers/asm-s390/kvm.h  |   4 ++
 linux-headers/linux/kvm.h     |  65 ++++++++++++++++-
 target-s390x/cpu.h            |  37 +++++++---
 target-s390x/helper.c         |   2 +-
 target-s390x/ioinst.c         |  42 ++++++-----
 target-s390x/kvm.c            | 140 +++++++++++++++++++++++++++++++++---
 target-s390x/mmu_helper.c     |  22 ++++--
 22 files changed, 422 insertions(+), 127 deletions(-)

-- 
2.3.5

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

* [Qemu-devel] [PATCH 01/10] s390x/kvm: Remove message about "switch_amode" kernel parameter
  2015-04-09  8:51 [Qemu-devel] [PATCH 00/10] first pile of s390x patches for 2.4 Cornelia Huck
@ 2015-04-09  8:51 ` Cornelia Huck
  2015-04-23 12:26   ` Christian Borntraeger
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 02/10] virtio-ccw: sort into categories Cornelia Huck
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 25+ messages in thread
From: Cornelia Huck @ 2015-04-09  8:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cornelia Huck, borntraeger, jfrei, agraf, Thomas Huth

From: Thomas Huth <thuth@linux.vnet.ibm.com>

The "switch_amode" parameter has been removed from the Linux kernel
sources since version 3.7 - so QEMU should not advise this parameter
nowadays anymore.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 kvm-all.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index dd44f8c..7c8537b 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1542,11 +1542,6 @@ static int kvm_init(MachineState *ms)
     if (ret < 0) {
         fprintf(stderr, "ioctl(KVM_CREATE_VM) failed: %d %s\n", -ret,
                 strerror(-ret));
-
-#ifdef TARGET_S390X
-        fprintf(stderr, "Please add the 'switch_amode' kernel parameter to "
-                        "your host kernel command line\n");
-#endif
         goto err;
     }
 
-- 
2.3.5

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

* [Qemu-devel] [PATCH 02/10] virtio-ccw: sort into categories
  2015-04-09  8:51 [Qemu-devel] [PATCH 00/10] first pile of s390x patches for 2.4 Cornelia Huck
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 01/10] s390x/kvm: Remove message about "switch_amode" kernel parameter Cornelia Huck
@ 2015-04-09  8:51 ` Cornelia Huck
  2015-04-20 14:47   ` Christian Borntraeger
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 03/10] s390-virtio: " Cornelia Huck
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 25+ messages in thread
From: Cornelia Huck @ 2015-04-09  8:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cornelia Huck, borntraeger, jfrei, agraf

Sort the various virtio-ccw devices into the same categories as their
virtio-pci counterparts.

Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/virtio-ccw.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index d32ecaf..9ef1059 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -1418,6 +1418,7 @@ static void virtio_ccw_net_class_init(ObjectClass *klass, void *data)
     k->exit = virtio_ccw_exit;
     dc->reset = virtio_ccw_reset;
     dc->props = virtio_ccw_net_properties;
+    set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 }
 
 static const TypeInfo virtio_ccw_net = {
@@ -1444,6 +1445,7 @@ static void virtio_ccw_blk_class_init(ObjectClass *klass, void *data)
     k->exit = virtio_ccw_exit;
     dc->reset = virtio_ccw_reset;
     dc->props = virtio_ccw_blk_properties;
+    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
 }
 
 static const TypeInfo virtio_ccw_blk = {
@@ -1470,6 +1472,7 @@ static void virtio_ccw_serial_class_init(ObjectClass *klass, void *data)
     k->exit = virtio_ccw_exit;
     dc->reset = virtio_ccw_reset;
     dc->props = virtio_ccw_serial_properties;
+    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
 }
 
 static const TypeInfo virtio_ccw_serial = {
@@ -1496,6 +1499,7 @@ static void virtio_ccw_balloon_class_init(ObjectClass *klass, void *data)
     k->exit = virtio_ccw_exit;
     dc->reset = virtio_ccw_reset;
     dc->props = virtio_ccw_balloon_properties;
+    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
 }
 
 static const TypeInfo virtio_ccw_balloon = {
@@ -1523,6 +1527,7 @@ static void virtio_ccw_scsi_class_init(ObjectClass *klass, void *data)
     k->exit = virtio_ccw_exit;
     dc->reset = virtio_ccw_reset;
     dc->props = virtio_ccw_scsi_properties;
+    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
 }
 
 static const TypeInfo virtio_ccw_scsi = {
@@ -1548,6 +1553,7 @@ static void vhost_ccw_scsi_class_init(ObjectClass *klass, void *data)
     k->exit = virtio_ccw_exit;
     dc->reset = virtio_ccw_reset;
     dc->props = vhost_ccw_scsi_properties;
+    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
 }
 
 static const TypeInfo vhost_ccw_scsi = {
@@ -1585,6 +1591,7 @@ static void virtio_ccw_rng_class_init(ObjectClass *klass, void *data)
     k->exit = virtio_ccw_exit;
     dc->reset = virtio_ccw_reset;
     dc->props = virtio_ccw_rng_properties;
+    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
 }
 
 static const TypeInfo virtio_ccw_rng = {
@@ -1671,9 +1678,11 @@ static void virtual_css_bridge_class_init(ObjectClass *klass, void *data)
 {
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
     k->init = virtual_css_bridge_init;
     hc->unplug = virtio_ccw_busdev_unplug;
+    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo virtual_css_bridge_info = {
-- 
2.3.5

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

* [Qemu-devel] [PATCH 03/10] s390-virtio: sort into categories
  2015-04-09  8:51 [Qemu-devel] [PATCH 00/10] first pile of s390x patches for 2.4 Cornelia Huck
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 01/10] s390x/kvm: Remove message about "switch_amode" kernel parameter Cornelia Huck
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 02/10] virtio-ccw: sort into categories Cornelia Huck
@ 2015-04-09  8:51 ` Cornelia Huck
  2015-04-20 14:47   ` Christian Borntraeger
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 04/10] sclp: " Cornelia Huck
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 25+ messages in thread
From: Cornelia Huck @ 2015-04-09  8:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cornelia Huck, borntraeger, jfrei, agraf

Sort the various s390-virtio devices into the same categories as their
virtio-pci counterparts.

Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/s390-virtio-bus.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index 047c963..c211da4 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -519,6 +519,7 @@ static void s390_virtio_net_class_init(ObjectClass *klass, void *data)
 
     k->realize = s390_virtio_net_realize;
     dc->props = s390_virtio_net_properties;
+    set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
 }
 
 static const TypeInfo s390_virtio_net = {
@@ -532,8 +533,10 @@ static const TypeInfo s390_virtio_net = {
 static void s390_virtio_blk_class_init(ObjectClass *klass, void *data)
 {
     VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
     k->realize = s390_virtio_blk_realize;
+    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
 }
 
 static const TypeInfo s390_virtio_blk = {
@@ -555,6 +558,7 @@ static void s390_virtio_serial_class_init(ObjectClass *klass, void *data)
 
     k->realize = s390_virtio_serial_realize;
     dc->props = s390_virtio_serial_properties;
+    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
 }
 
 static const TypeInfo s390_virtio_serial = {
@@ -577,6 +581,7 @@ static void s390_virtio_rng_class_init(ObjectClass *klass, void *data)
 
     k->realize = s390_virtio_rng_realize;
     dc->props = s390_virtio_rng_properties;
+    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
 }
 
 static const TypeInfo s390_virtio_rng = {
@@ -635,6 +640,7 @@ static void s390_virtio_scsi_class_init(ObjectClass *klass, void *data)
 
     k->realize = s390_virtio_scsi_realize;
     dc->props = s390_virtio_scsi_properties;
+    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
 }
 
 static const TypeInfo s390_virtio_scsi = {
@@ -658,6 +664,7 @@ static void s390_vhost_scsi_class_init(ObjectClass *klass, void *data)
 
     k->realize = s390_vhost_scsi_realize;
     dc->props = s390_vhost_scsi_properties;
+    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
 }
 
 static const TypeInfo s390_vhost_scsi = {
@@ -681,8 +688,10 @@ static int s390_virtio_bridge_init(SysBusDevice *dev)
 static void s390_virtio_bridge_class_init(ObjectClass *klass, void *data)
 {
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
     k->init = s390_virtio_bridge_init;
+    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo s390_virtio_bridge_info = {
-- 
2.3.5

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

* [Qemu-devel] [PATCH 04/10] sclp: sort into categories
  2015-04-09  8:51 [Qemu-devel] [PATCH 00/10] first pile of s390x patches for 2.4 Cornelia Huck
                   ` (2 preceding siblings ...)
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 03/10] s390-virtio: " Cornelia Huck
@ 2015-04-09  8:51 ` Cornelia Huck
  2015-04-20 14:48   ` Christian Borntraeger
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 05/10] s390x/ipl: " Cornelia Huck
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 25+ messages in thread
From: Cornelia Huck @ 2015-04-09  8:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cornelia Huck, borntraeger, jfrei, agraf

Sort the sclp consoles into the input category, just as virtio-serial.
Various other sclp devices don't have an obvious category, sort them
into misc.

Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/char/sclpconsole-lm.c  | 1 +
 hw/char/sclpconsole.c     | 1 +
 hw/s390x/event-facility.c | 1 +
 hw/s390x/sclp.c           | 9 +++++++++
 hw/s390x/sclpcpu.c        | 2 ++
 hw/s390x/sclpquiesce.c    | 1 +
 6 files changed, 15 insertions(+)

diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c
index a9f5e62..02ac80b 100644
--- a/hw/char/sclpconsole-lm.c
+++ b/hw/char/sclpconsole-lm.c
@@ -364,6 +364,7 @@ static void console_class_init(ObjectClass *klass, void *data)
     ec->can_handle_event = can_handle_event;
     ec->read_event_data = read_event_data;
     ec->write_event_data = write_event_data;
+    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
 }
 
 static const TypeInfo sclp_console_info = {
diff --git a/hw/char/sclpconsole.c b/hw/char/sclpconsole.c
index 79891df..b014c7f 100644
--- a/hw/char/sclpconsole.c
+++ b/hw/char/sclpconsole.c
@@ -266,6 +266,7 @@ static void console_class_init(ObjectClass *klass, void *data)
     ec->can_handle_event = can_handle_event;
     ec->read_event_data = read_event_data;
     ec->write_event_data = write_event_data;
+    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
 }
 
 static const TypeInfo sclp_console_info = {
diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index 78da718..1cb116a 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -362,6 +362,7 @@ static void init_event_facility_class(ObjectClass *klass, void *data)
 
     dc->reset = reset_event_facility;
     dc->vmsd = &vmstate_event_facility;
+    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
     k->init = init_event_facility;
     k->command_handler = command_handler;
     k->event_pending = event_pending;
diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
index a969975..b3a6c5e 100644
--- a/hw/s390x/sclp.c
+++ b/hw/s390x/sclp.c
@@ -457,10 +457,19 @@ sclpMemoryHotplugDev *get_sclp_memory_hotplug_dev(void)
                                    TYPE_SCLP_MEMORY_HOTPLUG_DEV, NULL));
 }
 
+static void sclp_memory_hotplug_dev_class_init(ObjectClass *klass,
+                                               void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+
+    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+}
+
 static TypeInfo sclp_memory_hotplug_dev_info = {
     .name = TYPE_SCLP_MEMORY_HOTPLUG_DEV,
     .parent = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(sclpMemoryHotplugDev),
+    .class_init = sclp_memory_hotplug_dev_class_init,
 };
 
 static void register_types(void)
diff --git a/hw/s390x/sclpcpu.c b/hw/s390x/sclpcpu.c
index 3600fe2..2fe8b5a 100644
--- a/hw/s390x/sclpcpu.c
+++ b/hw/s390x/sclpcpu.c
@@ -88,12 +88,14 @@ static int irq_cpu_hotplug_init(SCLPEvent *event)
 static void cpu_class_init(ObjectClass *oc, void *data)
 {
     SCLPEventClass *k = SCLP_EVENT_CLASS(oc);
+    DeviceClass *dc = DEVICE_CLASS(oc);
 
     k->init = irq_cpu_hotplug_init;
     k->get_send_mask = send_mask;
     k->get_receive_mask = receive_mask;
     k->read_event_data = read_event_data;
     k->write_event_data = NULL;
+    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
 }
 
 static const TypeInfo sclp_cpu_info = {
diff --git a/hw/s390x/sclpquiesce.c b/hw/s390x/sclpquiesce.c
index 1a399bd..ffa5553 100644
--- a/hw/s390x/sclpquiesce.c
+++ b/hw/s390x/sclpquiesce.c
@@ -116,6 +116,7 @@ static void quiesce_class_init(ObjectClass *klass, void *data)
 
     dc->reset = quiesce_reset;
     dc->vmsd = &vmstate_sclpquiesce;
+    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
     k->init = quiesce_init;
 
     k->get_send_mask = send_mask;
-- 
2.3.5

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

* [Qemu-devel] [PATCH 05/10] s390x/ipl: sort into categories
  2015-04-09  8:51 [Qemu-devel] [PATCH 00/10] first pile of s390x patches for 2.4 Cornelia Huck
                   ` (3 preceding siblings ...)
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 04/10] sclp: " Cornelia Huck
@ 2015-04-09  8:51 ` Cornelia Huck
  2015-04-20 14:48   ` Christian Borntraeger
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 06/10] s390x/mmu: Use access type definitions instead of magic values Cornelia Huck
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 25+ messages in thread
From: Cornelia Huck @ 2015-04-09  8:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cornelia Huck, borntraeger, jfrei, agraf

The s390 ipl device has no real home (it's not really a storage device),
so let's sort it into the misc category.

Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/ipl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
index 2e26d2a..132004a 100644
--- a/hw/s390x/ipl.c
+++ b/hw/s390x/ipl.c
@@ -315,6 +315,7 @@ static void s390_ipl_class_init(ObjectClass *klass, void *data)
     dc->props = s390_ipl_properties;
     dc->reset = s390_ipl_reset;
     dc->vmsd = &vmstate_ipl;
+    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
 }
 
 static const TypeInfo s390_ipl_info = {
-- 
2.3.5

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

* [Qemu-devel] [PATCH 06/10] s390x/mmu: Use access type definitions instead of magic values
  2015-04-09  8:51 [Qemu-devel] [PATCH 00/10] first pile of s390x patches for 2.4 Cornelia Huck
                   ` (4 preceding siblings ...)
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 05/10] s390x/ipl: " Cornelia Huck
@ 2015-04-09  8:51 ` Cornelia Huck
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 07/10] linux-headers: update Cornelia Huck
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 25+ messages in thread
From: Cornelia Huck @ 2015-04-09  8:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cornelia Huck, borntraeger, jfrei, agraf, Thomas Huth

From: Thomas Huth <thuth@linux.vnet.ibm.com>

Since there are now proper definitions for the MMU access type,
let's use them in the s390x MMU code, too, instead of the
hard-to-understand magic values.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Reviewed-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 target-s390x/helper.c     |  2 +-
 target-s390x/mmu_helper.c | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/target-s390x/helper.c b/target-s390x/helper.c
index f1060c2..041c9c7 100644
--- a/target-s390x/helper.c
+++ b/target-s390x/helper.c
@@ -162,7 +162,7 @@ hwaddr s390_cpu_get_phys_page_debug(CPUState *cs, vaddr vaddr)
         vaddr &= 0x7fffffff;
     }
 
-    mmu_translate(env, vaddr, 2, asc, &raddr, &prot, false);
+    mmu_translate(env, vaddr, MMU_INST_FETCH, asc, &raddr, &prot, false);
 
     return raddr;
 }
diff --git a/target-s390x/mmu_helper.c b/target-s390x/mmu_helper.c
index b061c85..9b88498 100644
--- a/target-s390x/mmu_helper.c
+++ b/target-s390x/mmu_helper.c
@@ -68,7 +68,7 @@ static void trigger_prot_fault(CPUS390XState *env, target_ulong vaddr,
 {
     uint64_t tec;
 
-    tec = vaddr | (rw == 1 ? FS_WRITE : FS_READ) | 4 | asc >> 46;
+    tec = vaddr | (rw == MMU_DATA_STORE ? FS_WRITE : FS_READ) | 4 | asc >> 46;
 
     DPRINTF("%s: trans_exc_code=%016" PRIx64 "\n", __func__, tec);
 
@@ -85,7 +85,7 @@ static void trigger_page_fault(CPUS390XState *env, target_ulong vaddr,
     int ilen = ILEN_LATER;
     uint64_t tec;
 
-    tec = vaddr | (rw == 1 ? FS_WRITE : FS_READ) | asc >> 46;
+    tec = vaddr | (rw == MMU_DATA_STORE ? FS_WRITE : FS_READ) | asc >> 46;
 
     DPRINTF("%s: vaddr=%016" PRIx64 " bits=%d\n", __func__, vaddr, bits);
 
@@ -94,7 +94,7 @@ static void trigger_page_fault(CPUS390XState *env, target_ulong vaddr,
     }
 
     /* Code accesses have an undefined ilc.  */
-    if (rw == 2) {
+    if (rw == MMU_INST_FETCH) {
         ilen = 2;
     }
 
@@ -288,7 +288,7 @@ static int mmu_translate_asce(CPUS390XState *env, target_ulong vaddr,
 
     r = mmu_translate_region(env, vaddr, asc, asce, level, raddr, flags, rw,
                              exc);
-    if ((rw == 1) && !(*flags & PAGE_WRITE)) {
+    if (rw == MMU_DATA_STORE && !(*flags & PAGE_WRITE)) {
         trigger_prot_fault(env, vaddr, asc, rw, exc);
         return -1;
     }
@@ -338,7 +338,7 @@ int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,
          * Instruction: Primary
          * Data: Secondary
          */
-        if (rw == 2) {
+        if (rw == MMU_INST_FETCH) {
             r = mmu_translate_asce(env, vaddr, PSW_ASC_PRIMARY, env->cregs[1],
                                    raddr, flags, rw, exc);
             *flags &= ~(PAGE_READ | PAGE_WRITE);
-- 
2.3.5

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

* [Qemu-devel] [PATCH 07/10] linux-headers: update
  2015-04-09  8:51 [Qemu-devel] [PATCH 00/10] first pile of s390x patches for 2.4 Cornelia Huck
                   ` (5 preceding siblings ...)
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 06/10] s390x/mmu: Use access type definitions instead of magic values Cornelia Huck
@ 2015-04-09  8:51 ` Cornelia Huck
  2015-04-24  9:30   ` Paolo Bonzini
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 08/10] s390x/kvm: Put vm name, extended name and UUID into STSI322 SYSIB Cornelia Huck
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 25+ messages in thread
From: Cornelia Huck @ 2015-04-09  8:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cornelia Huck, borntraeger, jfrei, agraf

This updates linux-headers against kvm/queue (commit
c7f0cf16df59ac98b58af974c3947cac21402e29), with the exception of
avoiding undoing 2106ba30105969262a7810417a57524d9a225b91
("uapi/virtio_scsi: allow overriding CDB/SENSE size").

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 linux-headers/asm-arm/kvm.h   |   3 +
 linux-headers/asm-arm64/kvm.h |   3 +
 linux-headers/asm-mips/kvm.h  | 164 ++++++++++++++++++++++++++----------------
 linux-headers/asm-s390/kvm.h  |   4 ++
 linux-headers/linux/kvm.h     |  65 ++++++++++++++++-
 5 files changed, 175 insertions(+), 64 deletions(-)

diff --git a/linux-headers/asm-arm/kvm.h b/linux-headers/asm-arm/kvm.h
index 0db25bc..2499867 100644
--- a/linux-headers/asm-arm/kvm.h
+++ b/linux-headers/asm-arm/kvm.h
@@ -198,6 +198,9 @@ struct kvm_arch_memory_slot {
 /* Highest supported SPI, from VGIC_NR_IRQS */
 #define KVM_ARM_IRQ_GIC_MAX		127
 
+/* One single KVM irqchip, ie. the VGIC */
+#define KVM_NR_IRQCHIPS          1
+
 /* PSCI interface */
 #define KVM_PSCI_FN_BASE		0x95c1ba5e
 #define KVM_PSCI_FN(n)			(KVM_PSCI_FN_BASE + (n))
diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h
index 3ef77a4..c154c0b 100644
--- a/linux-headers/asm-arm64/kvm.h
+++ b/linux-headers/asm-arm64/kvm.h
@@ -191,6 +191,9 @@ struct kvm_arch_memory_slot {
 /* Highest supported SPI, from VGIC_NR_IRQS */
 #define KVM_ARM_IRQ_GIC_MAX		127
 
+/* One single KVM irqchip, ie. the VGIC */
+#define KVM_NR_IRQCHIPS          1
+
 /* PSCI interface */
 #define KVM_PSCI_FN_BASE		0x95c1ba5e
 #define KVM_PSCI_FN(n)			(KVM_PSCI_FN_BASE + (n))
diff --git a/linux-headers/asm-mips/kvm.h b/linux-headers/asm-mips/kvm.h
index 2c04b6d..6985eb5 100644
--- a/linux-headers/asm-mips/kvm.h
+++ b/linux-headers/asm-mips/kvm.h
@@ -36,77 +36,85 @@ struct kvm_regs {
 
 /*
  * for KVM_GET_FPU and KVM_SET_FPU
- *
- * If Status[FR] is zero (32-bit FPU), the upper 32-bits of the FPRs
- * are zero filled.
  */
 struct kvm_fpu {
-	__u64 fpr[32];
-	__u32 fir;
-	__u32 fccr;
-	__u32 fexr;
-	__u32 fenr;
-	__u32 fcsr;
-	__u32 pad;
 };
 
 
 /*
- * For MIPS, we use KVM_SET_ONE_REG and KVM_GET_ONE_REG to access CP0
+ * For MIPS, we use KVM_SET_ONE_REG and KVM_GET_ONE_REG to access various
  * registers.  The id field is broken down as follows:
  *
- *  bits[2..0]   - Register 'sel' index.
- *  bits[7..3]   - Register 'rd'  index.
- *  bits[15..8]  - Must be zero.
- *  bits[31..16] - 1 -> CP0 registers.
- *  bits[51..32] - Must be zero.
  *  bits[63..52] - As per linux/kvm.h
+ *  bits[51..32] - Must be zero.
+ *  bits[31..16] - Register set.
+ *
+ * Register set = 0: GP registers from kvm_regs (see definitions below).
+ *
+ * Register set = 1: CP0 registers.
+ *  bits[15..8]  - Must be zero.
+ *  bits[7..3]   - Register 'rd'  index.
+ *  bits[2..0]   - Register 'sel' index.
+ *
+ * Register set = 2: KVM specific registers (see definitions below).
+ *
+ * Register set = 3: FPU / MSA registers (see definitions below).
  *
  * Other sets registers may be added in the future.  Each set would
  * have its own identifier in bits[31..16].
- *
- * The registers defined in struct kvm_regs are also accessible, the
- * id values for these are below.
  */
 
-#define KVM_REG_MIPS_R0 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 0)
-#define KVM_REG_MIPS_R1 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 1)
-#define KVM_REG_MIPS_R2 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 2)
-#define KVM_REG_MIPS_R3 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 3)
-#define KVM_REG_MIPS_R4 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 4)
-#define KVM_REG_MIPS_R5 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 5)
-#define KVM_REG_MIPS_R6 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 6)
-#define KVM_REG_MIPS_R7 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 7)
-#define KVM_REG_MIPS_R8 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 8)
-#define KVM_REG_MIPS_R9 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 9)
-#define KVM_REG_MIPS_R10 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 10)
-#define KVM_REG_MIPS_R11 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 11)
-#define KVM_REG_MIPS_R12 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 12)
-#define KVM_REG_MIPS_R13 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 13)
-#define KVM_REG_MIPS_R14 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 14)
-#define KVM_REG_MIPS_R15 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 15)
-#define KVM_REG_MIPS_R16 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 16)
-#define KVM_REG_MIPS_R17 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 17)
-#define KVM_REG_MIPS_R18 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 18)
-#define KVM_REG_MIPS_R19 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 19)
-#define KVM_REG_MIPS_R20 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 20)
-#define KVM_REG_MIPS_R21 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 21)
-#define KVM_REG_MIPS_R22 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 22)
-#define KVM_REG_MIPS_R23 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 23)
-#define KVM_REG_MIPS_R24 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 24)
-#define KVM_REG_MIPS_R25 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 25)
-#define KVM_REG_MIPS_R26 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 26)
-#define KVM_REG_MIPS_R27 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 27)
-#define KVM_REG_MIPS_R28 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 28)
-#define KVM_REG_MIPS_R29 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 29)
-#define KVM_REG_MIPS_R30 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 30)
-#define KVM_REG_MIPS_R31 (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 31)
-
-#define KVM_REG_MIPS_HI (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 32)
-#define KVM_REG_MIPS_LO (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 33)
-#define KVM_REG_MIPS_PC (KVM_REG_MIPS | KVM_REG_SIZE_U64 | 34)
-
-/* KVM specific control registers */
+#define KVM_REG_MIPS_GP		(KVM_REG_MIPS | 0x0000000000000000ULL)
+#define KVM_REG_MIPS_CP0	(KVM_REG_MIPS | 0x0000000000010000ULL)
+#define KVM_REG_MIPS_KVM	(KVM_REG_MIPS | 0x0000000000020000ULL)
+#define KVM_REG_MIPS_FPU	(KVM_REG_MIPS | 0x0000000000030000ULL)
+
+
+/*
+ * KVM_REG_MIPS_GP - General purpose registers from kvm_regs.
+ */
+
+#define KVM_REG_MIPS_R0		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  0)
+#define KVM_REG_MIPS_R1		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  1)
+#define KVM_REG_MIPS_R2		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  2)
+#define KVM_REG_MIPS_R3		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  3)
+#define KVM_REG_MIPS_R4		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  4)
+#define KVM_REG_MIPS_R5		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  5)
+#define KVM_REG_MIPS_R6		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  6)
+#define KVM_REG_MIPS_R7		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  7)
+#define KVM_REG_MIPS_R8		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  8)
+#define KVM_REG_MIPS_R9		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 |  9)
+#define KVM_REG_MIPS_R10	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 10)
+#define KVM_REG_MIPS_R11	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 11)
+#define KVM_REG_MIPS_R12	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 12)
+#define KVM_REG_MIPS_R13	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 13)
+#define KVM_REG_MIPS_R14	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 14)
+#define KVM_REG_MIPS_R15	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 15)
+#define KVM_REG_MIPS_R16	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 16)
+#define KVM_REG_MIPS_R17	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 17)
+#define KVM_REG_MIPS_R18	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 18)
+#define KVM_REG_MIPS_R19	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 19)
+#define KVM_REG_MIPS_R20	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 20)
+#define KVM_REG_MIPS_R21	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 21)
+#define KVM_REG_MIPS_R22	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 22)
+#define KVM_REG_MIPS_R23	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 23)
+#define KVM_REG_MIPS_R24	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 24)
+#define KVM_REG_MIPS_R25	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 25)
+#define KVM_REG_MIPS_R26	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 26)
+#define KVM_REG_MIPS_R27	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 27)
+#define KVM_REG_MIPS_R28	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 28)
+#define KVM_REG_MIPS_R29	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 29)
+#define KVM_REG_MIPS_R30	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 30)
+#define KVM_REG_MIPS_R31	(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 31)
+
+#define KVM_REG_MIPS_HI		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 32)
+#define KVM_REG_MIPS_LO		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 33)
+#define KVM_REG_MIPS_PC		(KVM_REG_MIPS_GP | KVM_REG_SIZE_U64 | 34)
+
+
+/*
+ * KVM_REG_MIPS_KVM - KVM specific control registers.
+ */
 
 /*
  * CP0_Count control
@@ -118,8 +126,7 @@ struct kvm_fpu {
  *        safely without losing time or guest timer interrupts.
  * Other: Reserved, do not change.
  */
-#define KVM_REG_MIPS_COUNT_CTL		(KVM_REG_MIPS | KVM_REG_SIZE_U64 | \
-					 0x20000 | 0)
+#define KVM_REG_MIPS_COUNT_CTL	    (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 0)
 #define KVM_REG_MIPS_COUNT_CTL_DC	0x00000001
 
 /*
@@ -131,15 +138,46 @@ struct kvm_fpu {
  * emulated.
  * Modifications to times in the future are rejected.
  */
-#define KVM_REG_MIPS_COUNT_RESUME	(KVM_REG_MIPS | KVM_REG_SIZE_U64 | \
-					 0x20000 | 1)
+#define KVM_REG_MIPS_COUNT_RESUME   (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 1)
 /*
  * CP0_Count rate in Hz
  * Specifies the rate of the CP0_Count timer in Hz. Modifications occur without
  * discontinuities in CP0_Count.
  */
-#define KVM_REG_MIPS_COUNT_HZ		(KVM_REG_MIPS | KVM_REG_SIZE_U64 | \
-					 0x20000 | 2)
+#define KVM_REG_MIPS_COUNT_HZ	    (KVM_REG_MIPS_KVM | KVM_REG_SIZE_U64 | 2)
+
+
+/*
+ * KVM_REG_MIPS_FPU - Floating Point and MIPS SIMD Architecture (MSA) registers.
+ *
+ *  bits[15..8]  - Register subset (see definitions below).
+ *  bits[7..5]   - Must be zero.
+ *  bits[4..0]   - Register number within register subset.
+ */
+
+#define KVM_REG_MIPS_FPR	(KVM_REG_MIPS_FPU | 0x0000000000000000ULL)
+#define KVM_REG_MIPS_FCR	(KVM_REG_MIPS_FPU | 0x0000000000000100ULL)
+#define KVM_REG_MIPS_MSACR	(KVM_REG_MIPS_FPU | 0x0000000000000200ULL)
+
+/*
+ * KVM_REG_MIPS_FPR - Floating point / Vector registers.
+ */
+#define KVM_REG_MIPS_FPR_32(n)	(KVM_REG_MIPS_FPR | KVM_REG_SIZE_U32  | (n))
+#define KVM_REG_MIPS_FPR_64(n)	(KVM_REG_MIPS_FPR | KVM_REG_SIZE_U64  | (n))
+#define KVM_REG_MIPS_VEC_128(n)	(KVM_REG_MIPS_FPR | KVM_REG_SIZE_U128 | (n))
+
+/*
+ * KVM_REG_MIPS_FCR - Floating point control registers.
+ */
+#define KVM_REG_MIPS_FCR_IR	(KVM_REG_MIPS_FCR | KVM_REG_SIZE_U32 |  0)
+#define KVM_REG_MIPS_FCR_CSR	(KVM_REG_MIPS_FCR | KVM_REG_SIZE_U32 | 31)
+
+/*
+ * KVM_REG_MIPS_MSACR - MIPS SIMD Architecture (MSA) control registers.
+ */
+#define KVM_REG_MIPS_MSA_IR	 (KVM_REG_MIPS_MSACR | KVM_REG_SIZE_U32 |  0)
+#define KVM_REG_MIPS_MSA_CSR	 (KVM_REG_MIPS_MSACR | KVM_REG_SIZE_U32 |  1)
+
 
 /*
  * KVM MIPS specific structures and definitions
diff --git a/linux-headers/asm-s390/kvm.h b/linux-headers/asm-s390/kvm.h
index c5a93eb..512d8f1 100644
--- a/linux-headers/asm-s390/kvm.h
+++ b/linux-headers/asm-s390/kvm.h
@@ -150,6 +150,7 @@ struct kvm_guest_debug_arch {
 #define KVM_SYNC_CRS    (1UL << 3)
 #define KVM_SYNC_ARCH0  (1UL << 4)
 #define KVM_SYNC_PFAULT (1UL << 5)
+#define KVM_SYNC_VRS    (1UL << 6)
 /* definition of registers in kvm_run */
 struct kvm_sync_regs {
 	__u64 prefix;	/* prefix register */
@@ -164,6 +165,9 @@ struct kvm_sync_regs {
 	__u64 pft;	/* pfault token [PFAULT] */
 	__u64 pfs;	/* pfault select [PFAULT] */
 	__u64 pfc;	/* pfault compare [PFAULT] */
+	__u64 vrs[32][2];	/* vector registers */
+	__u8  reserved[512];	/* for future vector expansion */
+	__u32 fpc;	/* only valid with vector registers */
 };
 
 #define KVM_REG_S390_TODPR	(KVM_REG_S390 | KVM_REG_SIZE_U32 | 0x1)
diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index 60a54c8..7039166 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -147,6 +147,16 @@ struct kvm_pit_config {
 
 #define KVM_PIT_SPEAKER_DUMMY     1
 
+struct kvm_s390_skeys {
+	__u64 start_gfn;
+	__u64 count;
+	__u64 skeydata_addr;
+	__u32 flags;
+	__u32 reserved[9];
+};
+#define KVM_S390_GET_SKEYS_NONE   1
+#define KVM_S390_SKEYS_MAX        1048576
+
 #define KVM_EXIT_UNKNOWN          0
 #define KVM_EXIT_EXCEPTION        1
 #define KVM_EXIT_IO               2
@@ -172,6 +182,7 @@ struct kvm_pit_config {
 #define KVM_EXIT_S390_TSCH        22
 #define KVM_EXIT_EPR              23
 #define KVM_EXIT_SYSTEM_EVENT     24
+#define KVM_EXIT_S390_STSI        25
 
 /* For KVM_EXIT_INTERNAL_ERROR */
 /* Emulate instruction failed. */
@@ -309,6 +320,15 @@ struct kvm_run {
 			__u32 type;
 			__u64 flags;
 		} system_event;
+		/* KVM_EXIT_S390_STSI */
+		struct {
+			__u64 addr;
+			__u8 ar;
+			__u8 reserved;
+			__u8 fc;
+			__u8 sel1;
+			__u16 sel2;
+		} s390_stsi;
 		/* Fix the size of the union. */
 		char padding[256];
 	};
@@ -324,7 +344,7 @@ struct kvm_run {
 	__u64 kvm_dirty_regs;
 	union {
 		struct kvm_sync_regs regs;
-		char padding[1024];
+		char padding[2048];
 	} s;
 };
 
@@ -365,6 +385,24 @@ struct kvm_translation {
 	__u8  pad[5];
 };
 
+/* for KVM_S390_MEM_OP */
+struct kvm_s390_mem_op {
+	/* in */
+	__u64 gaddr;		/* the guest address */
+	__u64 flags;		/* flags */
+	__u32 size;		/* amount of bytes */
+	__u32 op;		/* type of operation */
+	__u64 buf;		/* buffer in userspace */
+	__u8 ar;		/* the access register number */
+	__u8 reserved[31];	/* should be set to 0 */
+};
+/* types for kvm_s390_mem_op->op */
+#define KVM_S390_MEMOP_LOGICAL_READ	0
+#define KVM_S390_MEMOP_LOGICAL_WRITE	1
+/* flags for kvm_s390_mem_op->flags */
+#define KVM_S390_MEMOP_F_CHECK_ONLY		(1ULL << 0)
+#define KVM_S390_MEMOP_F_INJECT_EXCEPTION	(1ULL << 1)
+
 /* for KVM_INTERRUPT */
 struct kvm_interrupt {
 	/* in */
@@ -520,6 +558,13 @@ struct kvm_s390_irq {
 	} u;
 };
 
+struct kvm_s390_irq_state {
+	__u64 buf;
+	__u32 flags;
+	__u32 len;
+	__u32 reserved[4];
+};
+
 /* for KVM_SET_GUEST_DEBUG */
 
 #define KVM_GUESTDBG_ENABLE		0x00000001
@@ -760,6 +805,14 @@ struct kvm_ppc_smmu_info {
 #define KVM_CAP_PPC_ENABLE_HCALL 104
 #define KVM_CAP_CHECK_EXTENSION_VM 105
 #define KVM_CAP_S390_USER_SIGP 106
+#define KVM_CAP_S390_VECTOR_REGISTERS 107
+#define KVM_CAP_S390_MEM_OP 108
+#define KVM_CAP_S390_USER_STSI 109
+#define KVM_CAP_S390_SKEYS 110
+#define KVM_CAP_MIPS_FPU 111
+#define KVM_CAP_MIPS_MSA 112
+#define KVM_CAP_S390_INJECT_IRQ 113
+#define KVM_CAP_S390_IRQ_STATE 114
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
@@ -1135,6 +1188,16 @@ struct kvm_s390_ucas_mapping {
 #define KVM_ARM_VCPU_INIT	  _IOW(KVMIO,  0xae, struct kvm_vcpu_init)
 #define KVM_ARM_PREFERRED_TARGET  _IOR(KVMIO,  0xaf, struct kvm_vcpu_init)
 #define KVM_GET_REG_LIST	  _IOWR(KVMIO, 0xb0, struct kvm_reg_list)
+/* Available with KVM_CAP_S390_MEM_OP */
+#define KVM_S390_MEM_OP		  _IOW(KVMIO,  0xb1, struct kvm_s390_mem_op)
+/* Available with KVM_CAP_S390_SKEYS */
+#define KVM_S390_GET_SKEYS      _IOW(KVMIO, 0xb2, struct kvm_s390_skeys)
+#define KVM_S390_SET_SKEYS      _IOW(KVMIO, 0xb3, struct kvm_s390_skeys)
+/* Available with KVM_CAP_S390_INJECT_IRQ */
+#define KVM_S390_IRQ              _IOW(KVMIO,  0xb4, struct kvm_s390_irq)
+/* Available with KVM_CAP_S390_IRQ_STATE */
+#define KVM_S390_SET_IRQ_STATE	  _IOW(KVMIO, 0xb5, struct kvm_s390_irq_state)
+#define KVM_S390_GET_IRQ_STATE	  _IOW(KVMIO, 0xb6, struct kvm_s390_irq_state)
 
 #define KVM_DEV_ASSIGN_ENABLE_IOMMU	(1 << 0)
 #define KVM_DEV_ASSIGN_PCI_2_3		(1 << 1)
-- 
2.3.5

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

* [Qemu-devel] [PATCH 08/10] s390x/kvm: Put vm name, extended name and UUID into STSI322 SYSIB
  2015-04-09  8:51 [Qemu-devel] [PATCH 00/10] first pile of s390x patches for 2.4 Cornelia Huck
                   ` (6 preceding siblings ...)
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 07/10] linux-headers: update Cornelia Huck
@ 2015-04-09  8:51 ` Cornelia Huck
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 09/10] s390x/mmu: Use ioctl for reading and writing from/to guest memory Cornelia Huck
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 10/10] s390x/kvm: Support access register mode for KVM_S390_MEM_OP ioctl Cornelia Huck
  9 siblings, 0 replies; 25+ messages in thread
From: Cornelia Huck @ 2015-04-09  8:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cornelia Huck, borntraeger, jfrei, agraf, Ekaterina Tumanova

From: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>

KVM prefills the SYSIB, returned by STSI 3.2.2. This patch allows
userspace to intercept execution, and fill in the values, that are
known to qemu: machine name (8 chars), extended machine name (256
chars), extended machine name encoding (equals 2 for UTF-8) and UUID.

STSI322 qemu handler also finds a highest virtualization level in
level-3 virtualization stack that doesn't support Extended Names
(Ext Name delimiter) and propagates zero Ext Name to all levels below,
because this level is not capable of managing Extended Names of lower
levels.

Signed-off-by: Ekaterina Tumanova <tumanova@linux.vnet.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 target-s390x/cpu.h |  8 ++++--
 target-s390x/kvm.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+), 2 deletions(-)

diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 8135dda..79bc80b 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -865,9 +865,13 @@ struct sysib_322 {
         uint8_t  name[8];
         uint32_t caf;
         uint8_t  cpi[16];
-        uint8_t  res3[24];
+        uint8_t res5[3];
+        uint8_t ext_name_encoding;
+        uint32_t res3;
+        uint8_t uuid[16];
     } vm[8];
-    uint8_t res4[3552];
+    uint8_t res4[1504];
+    uint8_t ext_names[8][256];
 };
 
 /* MMU defines */
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index b48c643..619684b 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -44,6 +44,7 @@
 #include "hw/s390x/s390-pci-inst.h"
 #include "hw/s390x/s390-pci-bus.h"
 #include "hw/s390x/ipl.h"
+#include "hw/s390x/ebcdic.h"
 
 /* #define DEBUG_KVM */
 
@@ -255,6 +256,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
     }
 
     kvm_vm_enable_cap(s, KVM_CAP_S390_USER_SIGP, 0);
+    kvm_vm_enable_cap(s, KVM_CAP_S390_USER_STSI, 0);
 
     return 0;
 }
@@ -1723,6 +1725,72 @@ static int handle_tsch(S390CPU *cpu)
     return ret;
 }
 
+static void insert_stsi_3_2_2(S390CPU *cpu, __u64 addr)
+{
+    struct sysib_322 sysib;
+    int del;
+
+    if (s390_cpu_virt_mem_read(cpu, addr, &sysib, sizeof(sysib))) {
+        return;
+    }
+    /* Shift the stack of Extended Names to prepare for our own data */
+    memmove(&sysib.ext_names[1], &sysib.ext_names[0],
+            sizeof(sysib.ext_names[0]) * (sysib.count - 1));
+    /* First virt level, that doesn't provide Ext Names delimits stack. It is
+     * assumed it's not capable of managing Extended Names for lower levels.
+     */
+    for (del = 1; del < sysib.count; del++) {
+        if (!sysib.vm[del].ext_name_encoding || !sysib.ext_names[del][0]) {
+            break;
+        }
+    }
+    if (del < sysib.count) {
+        memset(sysib.ext_names[del], 0,
+               sizeof(sysib.ext_names[0]) * (sysib.count - del));
+    }
+    /* Insert short machine name in EBCDIC, padded with blanks */
+    if (qemu_name) {
+        memset(sysib.vm[0].name, 0x40, sizeof(sysib.vm[0].name));
+        ebcdic_put(sysib.vm[0].name, qemu_name, MIN(sizeof(sysib.vm[0].name),
+                                                    strlen(qemu_name)));
+    }
+    sysib.vm[0].ext_name_encoding = 2; /* 2 = UTF-8 */
+    memset(sysib.ext_names[0], 0, sizeof(sysib.ext_names[0]));
+    /* If hypervisor specifies zero Extended Name in STSI322 SYSIB, it's
+     * considered by s390 as not capable of providing any Extended Name.
+     * Therefore if no name was specified on qemu invocation, we go with the
+     * same "KVMguest" default, which KVM has filled into short name field.
+     */
+    if (qemu_name) {
+        strncpy((char *)sysib.ext_names[0], qemu_name,
+                sizeof(sysib.ext_names[0]));
+    } else {
+        strcpy((char *)sysib.ext_names[0], "KVMguest");
+    }
+    /* Insert UUID */
+    memcpy(sysib.vm[0].uuid, qemu_uuid, sizeof(sysib.vm[0].uuid));
+
+    s390_cpu_virt_mem_write(cpu, addr, &sysib, sizeof(sysib));
+}
+
+static int handle_stsi(S390CPU *cpu)
+{
+    CPUState *cs = CPU(cpu);
+    struct kvm_run *run = cs->kvm_run;
+
+    switch (run->s390_stsi.fc) {
+    case 3:
+        if (run->s390_stsi.sel1 != 2 || run->s390_stsi.sel2 != 2) {
+            return 0;
+        }
+        /* Only sysib 3.2.2 needs post-handling for now. */
+        insert_stsi_3_2_2(cpu, run->s390_stsi.addr);
+        return 0;
+    default:
+        return 0;
+    }
+}
+
 static int kvm_arch_handle_debug_exit(S390CPU *cpu)
 {
     CPUState *cs = CPU(cpu);
@@ -1772,6 +1840,9 @@ int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run)
         case KVM_EXIT_S390_TSCH:
             ret = handle_tsch(cpu);
             break;
+        case KVM_EXIT_S390_STSI:
+            ret = handle_stsi(cpu);
+            break;
         case KVM_EXIT_DEBUG:
             ret = kvm_arch_handle_debug_exit(cpu);
             break;
-- 
2.3.5

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

* [Qemu-devel] [PATCH 09/10] s390x/mmu: Use ioctl for reading and writing from/to guest memory
  2015-04-09  8:51 [Qemu-devel] [PATCH 00/10] first pile of s390x patches for 2.4 Cornelia Huck
                   ` (7 preceding siblings ...)
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 08/10] s390x/kvm: Put vm name, extended name and UUID into STSI322 SYSIB Cornelia Huck
@ 2015-04-09  8:51 ` Cornelia Huck
  2015-04-20 14:55   ` Christian Borntraeger
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 10/10] s390x/kvm: Support access register mode for KVM_S390_MEM_OP ioctl Cornelia Huck
  9 siblings, 1 reply; 25+ messages in thread
From: Cornelia Huck @ 2015-04-09  8:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cornelia Huck, borntraeger, jfrei, agraf, Thomas Huth

From: Thomas Huth <thuth@linux.vnet.ibm.com>

Add code to make use of the new ioctl for reading from / writing to
virtual guest memory. By using the ioctl, the memory accesses are now
protected with the so-called ipte-lock in the kernel.

Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 target-s390x/cpu.h        |  7 +++++++
 target-s390x/kvm.c        | 35 +++++++++++++++++++++++++++++++++++
 target-s390x/mmu_helper.c |  9 +++++++++
 3 files changed, 51 insertions(+)

diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 79bc80b..9c42743 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -401,6 +401,8 @@ void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq);
 void kvm_s390_floating_interrupt(struct kvm_s390_irq *irq);
 int kvm_s390_inject_flic(struct kvm_s390_irq *irq);
 void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code);
+int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
+                    bool is_write);
 int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_clock);
 int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_clock);
 #else
@@ -418,6 +420,11 @@ static inline int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
 {
     return -ENOSYS;
 }
+static inline int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf,
+                                  int len, bool is_write)
+{
+    return -ENOSYS;
+}
 static inline void kvm_s390_access_exception(S390CPU *cpu, uint16_t code,
                                              uint64_t te_code)
 {
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 619684b..e2ae2b3 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -123,6 +123,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
 
 static int cap_sync_regs;
 static int cap_async_pf;
+static int cap_mem_op;
 
 static void *legacy_s390_alloc(size_t size, uint64_t *align);
 
@@ -247,6 +248,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
 {
     cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
     cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);
+    cap_mem_op = kvm_check_extension(s, KVM_CAP_S390_MEM_OP);
 
     kvm_s390_enable_cmma(s);
 
@@ -550,6 +552,39 @@ int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
     return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
 }
 
+/**
+ * kvm_s390_mem_op:
+ * @addr:      the logical start address in guest memory
+ * @hostbuf:   buffer in host memory. NULL = do only checks w/o copying
+ * @len:       length that should be transfered
+ * @is_write:  true = write, false = read
+ * Returns:    0 on success, non-zero if an exception or error occured
+ *
+ * Use KVM ioctl to read/write from/to guest memory. An access exception
+ * is injected into the vCPU in case of translation errors.
+ */
+int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
+                    bool is_write)
+{
+    struct kvm_s390_mem_op mem_op = {
+        .gaddr = addr,
+        .flags = KVM_S390_MEMOP_F_INJECT_EXCEPTION,
+        .size = len,
+        .op = is_write ? KVM_S390_MEMOP_LOGICAL_WRITE
+                       : KVM_S390_MEMOP_LOGICAL_READ,
+        .buf = (uint64_t)hostbuf,
+    };
+
+    if (!cap_mem_op) {
+        return -ENOSYS;
+    }
+    if (!hostbuf) {
+        mem_op.flags |= KVM_S390_MEMOP_F_CHECK_ONLY;
+    }
+
+    return kvm_vcpu_ioctl(CPU(cpu), KVM_S390_MEM_OP, &mem_op);
+}
+
 /*
  * Legacy layout for s390:
  * Older S390 KVM requires the topmost vma of the RAM to be
diff --git a/target-s390x/mmu_helper.c b/target-s390x/mmu_helper.c
index 9b88498..1e7412c 100644
--- a/target-s390x/mmu_helper.c
+++ b/target-s390x/mmu_helper.c
@@ -450,6 +450,15 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, void *hostbuf,
     target_ulong *pages;
     int ret;
 
+    if (kvm_enabled()) {
+        ret = kvm_s390_mem_op(cpu, laddr, hostbuf, len, is_write);
+        if (ret >= 0) {
+            return ret;
+        } else if (ret != -ENOSYS) {
+            error_printf("kvm_s390_mem_op() failed: %s\n", strerror(-ret));
+        }
+    }
+
     nr_pages = (((laddr & ~TARGET_PAGE_MASK) + len - 1) >> TARGET_PAGE_BITS)
                + 1;
     pages = g_malloc(nr_pages * sizeof(*pages));
-- 
2.3.5

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

* [Qemu-devel] [PATCH 10/10] s390x/kvm: Support access register mode for KVM_S390_MEM_OP ioctl
  2015-04-09  8:51 [Qemu-devel] [PATCH 00/10] first pile of s390x patches for 2.4 Cornelia Huck
                   ` (8 preceding siblings ...)
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 09/10] s390x/mmu: Use ioctl for reading and writing from/to guest memory Cornelia Huck
@ 2015-04-09  8:51 ` Cornelia Huck
  9 siblings, 0 replies; 25+ messages in thread
From: Cornelia Huck @ 2015-04-09  8:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Cornelia Huck, borntraeger, jfrei, agraf, Alexander Yarygin

From: Alexander Yarygin <yarygin@linux.vnet.ibm.com>

Access register mode is one of the modes that control dynamic address
translation. In this mode the address space is specified by values of
the access registers. The effective address-space-control element is
obtained from the result of the access register translation. See
the "Access-Register Introduction" section of the chapter 5 "Program
Execution" in "Principles of Operations" for more details.

When the CPU is in AR mode, the s390_cpu_virt_mem_rw() function must
know which access register number to use for address translation.
This patch does several things:
- add new parameter 'uint8_t ar' to that function
- decode ar number from intercepted instructions
- pass the ar number to s390_cpu_virt_mem_rw(), which in turn passes it
to the KVM_S390_MEM_OP ioctl.

Signed-off-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/s390-pci-inst.c  | 21 +++++++++++----------
 hw/s390x/s390-pci-inst.h  |  7 ++++---
 target-s390x/cpu.h        | 30 +++++++++++++++++-------------
 target-s390x/ioinst.c     | 42 +++++++++++++++++++++++++-----------------
 target-s390x/kvm.c        | 46 ++++++++++++++++++++++++++++++----------------
 target-s390x/mmu_helper.c |  5 +++--
 6 files changed, 90 insertions(+), 61 deletions(-)

diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
index 08d8aa6..cac3d83 100644
--- a/hw/s390x/s390-pci-inst.c
+++ b/hw/s390x/s390-pci-inst.c
@@ -155,7 +155,7 @@ int clp_service_call(S390CPU *cpu, uint8_t r2)
         return 0;
     }
 
-    if (s390_cpu_virt_mem_read(cpu, env->regs[r2], buffer, sizeof(*reqh))) {
+    if (s390_cpu_virt_mem_read(cpu, env->regs[r2], r2, buffer, sizeof(*reqh))) {
         return 0;
     }
     reqh = (ClpReqHdr *)buffer;
@@ -165,7 +165,7 @@ int clp_service_call(S390CPU *cpu, uint8_t r2)
         return 0;
     }
 
-    if (s390_cpu_virt_mem_read(cpu, env->regs[r2], buffer,
+    if (s390_cpu_virt_mem_read(cpu, env->regs[r2], r2, buffer,
                                req_len + sizeof(*resh))) {
         return 0;
     }
@@ -180,7 +180,7 @@ int clp_service_call(S390CPU *cpu, uint8_t r2)
         return 0;
     }
 
-    if (s390_cpu_virt_mem_read(cpu, env->regs[r2], buffer,
+    if (s390_cpu_virt_mem_read(cpu, env->regs[r2], r2, buffer,
                                req_len + res_len)) {
         return 0;
     }
@@ -277,7 +277,7 @@ int clp_service_call(S390CPU *cpu, uint8_t r2)
     }
 
 out:
-    if (s390_cpu_virt_mem_write(cpu, env->regs[r2], buffer,
+    if (s390_cpu_virt_mem_write(cpu, env->regs[r2], r2, buffer,
                                 req_len + res_len)) {
         return 0;
     }
@@ -544,7 +544,8 @@ out:
     return 0;
 }
 
-int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr)
+int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr,
+                        uint8_t ar)
 {
     CPUS390XState *env = &cpu->env;
     S390PCIBusDevice *pbdev;
@@ -601,7 +602,7 @@ int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr)
         return 0;
     }
 
-    if (s390_cpu_virt_mem_read(cpu, gaddr, buffer, len)) {
+    if (s390_cpu_virt_mem_read(cpu, gaddr, ar, buffer, len)) {
         return 0;
     }
 
@@ -694,7 +695,7 @@ static void dereg_ioat(S390PCIBusDevice *pbdev)
     pbdev->g_iota = 0;
 }
 
-int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba)
+int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar)
 {
     CPUS390XState *env = &cpu->env;
     uint8_t oc;
@@ -723,7 +724,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba)
         return 0;
     }
 
-    if (s390_cpu_virt_mem_read(cpu, fiba, (uint8_t *)&fib, sizeof(fib))) {
+    if (s390_cpu_virt_mem_read(cpu, fiba, ar, (uint8_t *)&fib, sizeof(fib))) {
         return 0;
     }
 
@@ -769,7 +770,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba)
     return 0;
 }
 
-int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba)
+int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar)
 {
     CPUS390XState *env = &cpu->env;
     uint32_t fh;
@@ -825,7 +826,7 @@ int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba)
         fib.fc |= 0x10;
     }
 
-    if (s390_cpu_virt_mem_write(cpu, fiba, (uint8_t *)&fib, sizeof(fib))) {
+    if (s390_cpu_virt_mem_write(cpu, fiba, ar, (uint8_t *)&fib, sizeof(fib))) {
         return 0;
     }
 
diff --git a/hw/s390x/s390-pci-inst.h b/hw/s390x/s390-pci-inst.h
index 7e6c804..70fa713 100644
--- a/hw/s390x/s390-pci-inst.h
+++ b/hw/s390x/s390-pci-inst.h
@@ -281,8 +281,9 @@ int clp_service_call(S390CPU *cpu, uint8_t r2);
 int pcilg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2);
 int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2);
 int rpcit_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2);
-int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr);
-int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba);
-int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba);
+int pcistb_service_call(S390CPU *cpu, uint8_t r1, uint8_t r3, uint64_t gaddr,
+                        uint8_t ar);
+int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar);
+int stpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar);
 
 #endif
diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
index 9c42743..ba7d250 100644
--- a/target-s390x/cpu.h
+++ b/target-s390x/cpu.h
@@ -356,7 +356,8 @@ int s390_cpu_handle_mmu_fault(CPUState *cpu, vaddr address, int rw,
 #ifndef CONFIG_USER_ONLY
 void do_restart_interrupt(CPUS390XState *env);
 
-static inline hwaddr decode_basedisp_s(CPUS390XState *env, uint32_t ipb)
+static inline hwaddr decode_basedisp_s(CPUS390XState *env, uint32_t ipb,
+                                       uint8_t *ar)
 {
     hwaddr addr = 0;
     uint8_t reg;
@@ -366,6 +367,9 @@ static inline hwaddr decode_basedisp_s(CPUS390XState *env, uint32_t ipb)
         addr = env->regs[reg];
     }
     addr += (ipb >> 16) & 0xfff;
+    if (ar) {
+        *ar = reg;
+    }
 
     return addr;
 }
@@ -401,8 +405,8 @@ void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq);
 void kvm_s390_floating_interrupt(struct kvm_s390_irq *irq);
 int kvm_s390_inject_flic(struct kvm_s390_irq *irq);
 void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code);
-int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
-                    bool is_write);
+int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf,
+                    int len, bool is_write);
 int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_clock);
 int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_clock);
 #else
@@ -420,8 +424,8 @@ static inline int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
 {
     return -ENOSYS;
 }
-static inline int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf,
-                                  int len, bool is_write)
+static inline int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar,
+                                  void *hostbuf, int len, bool is_write)
 {
     return -ENOSYS;
 }
@@ -963,15 +967,15 @@ int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code);
 uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, uint64_t src, uint64_t dst,
                  uint64_t vr);
 
-int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, void *hostbuf, int len,
-                         bool is_write);
+int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, uint8_t ar, void *hostbuf,
+                         int len, bool is_write);
 
-#define s390_cpu_virt_mem_read(cpu, laddr, dest, len) \
-        s390_cpu_virt_mem_rw(cpu, laddr, dest, len, false)
-#define s390_cpu_virt_mem_write(cpu, laddr, dest, len) \
-        s390_cpu_virt_mem_rw(cpu, laddr, dest, len, true)
-#define s390_cpu_virt_mem_check_write(cpu, laddr, len) \
-        s390_cpu_virt_mem_rw(cpu, laddr, NULL, len, true)
+#define s390_cpu_virt_mem_read(cpu, laddr, ar, dest, len)    \
+        s390_cpu_virt_mem_rw(cpu, laddr, ar, dest, len, false)
+#define s390_cpu_virt_mem_write(cpu, laddr, ar, dest, len)       \
+        s390_cpu_virt_mem_rw(cpu, laddr, ar, dest, len, true)
+#define s390_cpu_virt_mem_check_write(cpu, laddr, ar, len)   \
+        s390_cpu_virt_mem_rw(cpu, laddr, ar, NULL, len, true)
 
 /* The value of the TOD clock for 1.1.1970. */
 #define TOD_UNIX_EPOCH 0x7d91048bca000000ULL
diff --git a/target-s390x/ioinst.c b/target-s390x/ioinst.c
index b00a00c..e220cea 100644
--- a/target-s390x/ioinst.c
+++ b/target-s390x/ioinst.c
@@ -149,13 +149,14 @@ void ioinst_handle_msch(S390CPU *cpu, uint64_t reg1, uint32_t ipb)
     int ret = -ENODEV;
     int cc;
     CPUS390XState *env = &cpu->env;
+    uint8_t ar;
 
-    addr = decode_basedisp_s(env, ipb);
+    addr = decode_basedisp_s(env, ipb, &ar);
     if (addr & 3) {
         program_interrupt(env, PGM_SPECIFICATION, 2);
         return;
     }
-    if (s390_cpu_virt_mem_read(cpu, addr, &schib, sizeof(schib))) {
+    if (s390_cpu_virt_mem_read(cpu, addr, ar, &schib, sizeof(schib))) {
         return;
     }
     if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid) ||
@@ -215,13 +216,14 @@ void ioinst_handle_ssch(S390CPU *cpu, uint64_t reg1, uint32_t ipb)
     int ret = -ENODEV;
     int cc;
     CPUS390XState *env = &cpu->env;
+    uint8_t ar;
 
-    addr = decode_basedisp_s(env, ipb);
+    addr = decode_basedisp_s(env, ipb, &ar);
     if (addr & 3) {
         program_interrupt(env, PGM_SPECIFICATION, 2);
         return;
     }
-    if (s390_cpu_virt_mem_read(cpu, addr, &orig_orb, sizeof(orb))) {
+    if (s390_cpu_virt_mem_read(cpu, addr, ar, &orig_orb, sizeof(orb))) {
         return;
     }
     copy_orb_from_guest(&orb, &orig_orb);
@@ -258,8 +260,9 @@ void ioinst_handle_stcrw(S390CPU *cpu, uint32_t ipb)
     uint64_t addr;
     int cc;
     CPUS390XState *env = &cpu->env;
+    uint8_t ar;
 
-    addr = decode_basedisp_s(env, ipb);
+    addr = decode_basedisp_s(env, ipb, &ar);
     if (addr & 3) {
         program_interrupt(env, PGM_SPECIFICATION, 2);
         return;
@@ -268,7 +271,7 @@ void ioinst_handle_stcrw(S390CPU *cpu, uint32_t ipb)
     cc = css_do_stcrw(&crw);
     /* 0 - crw stored, 1 - zeroes stored */
 
-    if (s390_cpu_virt_mem_write(cpu, addr, &crw, sizeof(crw)) == 0) {
+    if (s390_cpu_virt_mem_write(cpu, addr, ar, &crw, sizeof(crw)) == 0) {
         setcc(cpu, cc);
     } else if (cc == 0) {
         /* Write failed: requeue CRW since STCRW is a suppressing instruction */
@@ -284,8 +287,9 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb)
     int cc;
     SCHIB schib;
     CPUS390XState *env = &cpu->env;
+    uint8_t ar;
 
-    addr = decode_basedisp_s(env, ipb);
+    addr = decode_basedisp_s(env, ipb, &ar);
     if (addr & 3) {
         program_interrupt(env, PGM_SPECIFICATION, 2);
         return;
@@ -297,7 +301,7 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb)
          * we check whether the memory area is writeable (injecting the
          * access execption if it is not) first.
          */
-        if (!s390_cpu_virt_mem_check_write(cpu, addr, sizeof(schib))) {
+        if (!s390_cpu_virt_mem_check_write(cpu, addr, ar, sizeof(schib))) {
             program_interrupt(env, PGM_OPERAND, 2);
         }
         return;
@@ -322,12 +326,13 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb)
         }
     }
     if (cc != 3) {
-        if (s390_cpu_virt_mem_write(cpu, addr, &schib, sizeof(schib)) != 0) {
+        if (s390_cpu_virt_mem_write(cpu, addr, ar, &schib,
+                                    sizeof(schib)) != 0) {
             return;
         }
     } else {
         /* Access exceptions have a higher priority than cc3 */
-        if (s390_cpu_virt_mem_check_write(cpu, addr, sizeof(schib)) != 0) {
+        if (s390_cpu_virt_mem_check_write(cpu, addr, ar, sizeof(schib)) != 0) {
             return;
         }
     }
@@ -342,13 +347,14 @@ int ioinst_handle_tsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb)
     IRB irb;
     uint64_t addr;
     int cc, irb_len;
+    uint8_t ar;
 
     if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) {
         program_interrupt(env, PGM_OPERAND, 2);
         return -EIO;
     }
     trace_ioinst_sch_id("tsch", cssid, ssid, schid);
-    addr = decode_basedisp_s(env, ipb);
+    addr = decode_basedisp_s(env, ipb, &ar);
     if (addr & 3) {
         program_interrupt(env, PGM_SPECIFICATION, 2);
         return -EIO;
@@ -362,14 +368,14 @@ int ioinst_handle_tsch(S390CPU *cpu, uint64_t reg1, uint32_t ipb)
     }
     /* 0 - status pending, 1 - not status pending, 3 - not operational */
     if (cc != 3) {
-        if (s390_cpu_virt_mem_write(cpu, addr, &irb, irb_len) != 0) {
+        if (s390_cpu_virt_mem_write(cpu, addr, ar, &irb, irb_len) != 0) {
             return -EFAULT;
         }
         css_do_tsch_update_subch(sch);
     } else {
         irb_len = sizeof(irb) - sizeof(irb.emw);
         /* Access exceptions have a higher priority than cc3 */
-        if (s390_cpu_virt_mem_check_write(cpu, addr, irb_len) != 0) {
+        if (s390_cpu_virt_mem_check_write(cpu, addr, ar, irb_len) != 0) {
             return -EFAULT;
         }
     }
@@ -645,7 +651,7 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb)
      * present CHSC sub-handlers ... if we ever need more, we should take
      * care of req->len here first.
      */
-    if (s390_cpu_virt_mem_read(cpu, addr, buf, sizeof(ChscReq))) {
+    if (s390_cpu_virt_mem_read(cpu, addr, reg, buf, sizeof(ChscReq))) {
         return;
     }
     req = (ChscReq *)buf;
@@ -677,7 +683,8 @@ void ioinst_handle_chsc(S390CPU *cpu, uint32_t ipb)
         break;
     }
 
-    if (!s390_cpu_virt_mem_write(cpu, addr + len, res, be16_to_cpu(res->len))) {
+    if (!s390_cpu_virt_mem_write(cpu, addr + len, reg, res,
+                                 be16_to_cpu(res->len))) {
         setcc(cpu, 0);    /* Command execution complete */
     }
 }
@@ -690,9 +697,10 @@ int ioinst_handle_tpi(S390CPU *cpu, uint32_t ipb)
     IOIntCode int_code;
     hwaddr len;
     int ret;
+    uint8_t ar;
 
     trace_ioinst("tpi");
-    addr = decode_basedisp_s(env, ipb);
+    addr = decode_basedisp_s(env, ipb, &ar);
     if (addr & 3) {
         program_interrupt(env, PGM_SPECIFICATION, 2);
         return -EIO;
@@ -702,7 +710,7 @@ int ioinst_handle_tpi(S390CPU *cpu, uint32_t ipb)
     len = lowcore ? 8 /* two words */ : 12 /* three words */;
     ret = css_do_tpi(&int_code, lowcore);
     if (ret == 1) {
-        s390_cpu_virt_mem_write(cpu, lowcore ? 184 : addr, &int_code, len);
+        s390_cpu_virt_mem_write(cpu, lowcore ? 184 : addr, ar, &int_code, len);
     }
     return ret;
 }
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index e2ae2b3..b8703b8 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -555,6 +555,7 @@ int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
 /**
  * kvm_s390_mem_op:
  * @addr:      the logical start address in guest memory
+ * @ar:        the access register number
  * @hostbuf:   buffer in host memory. NULL = do only checks w/o copying
  * @len:       length that should be transfered
  * @is_write:  true = write, false = read
@@ -563,8 +564,8 @@ int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
  * Use KVM ioctl to read/write from/to guest memory. An access exception
  * is injected into the vCPU in case of translation errors.
  */
-int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
-                    bool is_write)
+int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf,
+                    int len, bool is_write)
 {
     struct kvm_s390_mem_op mem_op = {
         .gaddr = addr,
@@ -573,6 +574,7 @@ int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
         .op = is_write ? KVM_S390_MEMOP_LOGICAL_WRITE
                        : KVM_S390_MEMOP_LOGICAL_READ,
         .buf = (uint64_t)hostbuf,
+        .ar = ar,
     };
 
     if (!cap_mem_op) {
@@ -1012,7 +1014,8 @@ static int handle_b2(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1)
     return rc;
 }
 
-static uint64_t get_base_disp_rxy(S390CPU *cpu, struct kvm_run *run)
+static uint64_t get_base_disp_rxy(S390CPU *cpu, struct kvm_run *run,
+                                  uint8_t *ar)
 {
     CPUS390XState *env = &cpu->env;
     uint32_t x2 = (run->s390_sieic.ipa & 0x000f);
@@ -1023,12 +1026,16 @@ static uint64_t get_base_disp_rxy(S390CPU *cpu, struct kvm_run *run)
     if (disp2 & 0x80000) {
         disp2 += 0xfff00000;
     }
+    if (ar) {
+        *ar = base2;
+    }
 
     return (base2 ? env->regs[base2] : 0) +
            (x2 ? env->regs[x2] : 0) + (long)(int)disp2;
 }
 
-static uint64_t get_base_disp_rsy(S390CPU *cpu, struct kvm_run *run)
+static uint64_t get_base_disp_rsy(S390CPU *cpu, struct kvm_run *run,
+                                  uint8_t *ar)
 {
     CPUS390XState *env = &cpu->env;
     uint32_t base2 = run->s390_sieic.ipb >> 28;
@@ -1038,6 +1045,9 @@ static uint64_t get_base_disp_rsy(S390CPU *cpu, struct kvm_run *run)
     if (disp2 & 0x80000) {
         disp2 += 0xfff00000;
     }
+    if (ar) {
+        *ar = base2;
+    }
 
     return (base2 ? env->regs[base2] : 0) + (long)(int)disp2;
 }
@@ -1069,11 +1079,12 @@ static int kvm_stpcifc_service_call(S390CPU *cpu, struct kvm_run *run)
 {
     uint8_t r1 = (run->s390_sieic.ipa & 0x00f0) >> 4;
     uint64_t fiba;
+    uint8_t ar;
 
     cpu_synchronize_state(CPU(cpu));
-    fiba = get_base_disp_rxy(cpu, run);
+    fiba = get_base_disp_rxy(cpu, run, &ar);
 
-    return stpcifc_service_call(cpu, r1, fiba);
+    return stpcifc_service_call(cpu, r1, fiba, ar);
 }
 
 static int kvm_sic_service_call(S390CPU *cpu, struct kvm_run *run)
@@ -1095,22 +1106,24 @@ static int kvm_pcistb_service_call(S390CPU *cpu, struct kvm_run *run)
     uint8_t r1 = (run->s390_sieic.ipa & 0x00f0) >> 4;
     uint8_t r3 = run->s390_sieic.ipa & 0x000f;
     uint64_t gaddr;
+    uint8_t ar;
 
     cpu_synchronize_state(CPU(cpu));
-    gaddr = get_base_disp_rsy(cpu, run);
+    gaddr = get_base_disp_rsy(cpu, run, &ar);
 
-    return pcistb_service_call(cpu, r1, r3, gaddr);
+    return pcistb_service_call(cpu, r1, r3, gaddr, ar);
 }
 
 static int kvm_mpcifc_service_call(S390CPU *cpu, struct kvm_run *run)
 {
     uint8_t r1 = (run->s390_sieic.ipa & 0x00f0) >> 4;
     uint64_t fiba;
+    uint8_t ar;
 
     cpu_synchronize_state(CPU(cpu));
-    fiba = get_base_disp_rxy(cpu, run);
+    fiba = get_base_disp_rxy(cpu, run, &ar);
 
-    return mpcifc_service_call(cpu, r1, fiba);
+    return mpcifc_service_call(cpu, r1, fiba, ar);
 }
 
 static int handle_b9(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1)
@@ -1239,7 +1252,7 @@ static int handle_diag(S390CPU *cpu, struct kvm_run *run, uint32_t ipb)
      * For any diagnose call we support, bits 48-63 of the resulting
      * address specify the function code; the remainder is ignored.
      */
-    func_code = decode_basedisp_rs(&cpu->env, ipb) & DIAG_KVM_CODE_MASK;
+    func_code = decode_basedisp_rs(&cpu->env, ipb, NULL) & DIAG_KVM_CODE_MASK;
     switch (func_code) {
     case DIAG_IPL:
         kvm_handle_diag_308(cpu, run);
@@ -1586,7 +1599,8 @@ static int handle_sigp(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1)
     cpu_synchronize_state(CPU(cpu));
 
     /* get order code */
-    order = decode_basedisp_rs(env, run->s390_sieic.ipb) & SIGP_ORDER_MASK;
+    order = decode_basedisp_rs(env, run->s390_sieic.ipb, NULL)
+        & SIGP_ORDER_MASK;
     status_reg = &env->regs[r1];
     param = (r1 % 2) ? env->regs[r1] : env->regs[r1 + 1];
 
@@ -1760,12 +1774,12 @@ static int handle_tsch(S390CPU *cpu)
     return ret;
 }
 
-static void insert_stsi_3_2_2(S390CPU *cpu, __u64 addr)
+static void insert_stsi_3_2_2(S390CPU *cpu, __u64 addr, uint8_t ar)
 {
     struct sysib_322 sysib;
     int del;
 
-    if (s390_cpu_virt_mem_read(cpu, addr, &sysib, sizeof(sysib))) {
+    if (s390_cpu_virt_mem_read(cpu, addr, ar, &sysib, sizeof(sysib))) {
         return;
     }
     /* Shift the stack of Extended Names to prepare for our own data */
@@ -1805,7 +1819,7 @@ static void insert_stsi_3_2_2(S390CPU *cpu, __u64 addr)
     /* Insert UUID */
     memcpy(sysib.vm[0].uuid, qemu_uuid, sizeof(sysib.vm[0].uuid));
 
-    s390_cpu_virt_mem_write(cpu, addr, &sysib, sizeof(sysib));
+    s390_cpu_virt_mem_write(cpu, addr, ar, &sysib, sizeof(sysib));
 }
 
 static int handle_stsi(S390CPU *cpu)
@@ -1819,7 +1833,7 @@ static int handle_stsi(S390CPU *cpu)
             return 0;
         }
         /* Only sysib 3.2.2 needs post-handling for now. */
-        insert_stsi_3_2_2(cpu, run->s390_stsi.addr);
+        insert_stsi_3_2_2(cpu, run->s390_stsi.addr, run->s390_stsi.ar);
         return 0;
     default:
         return 0;
diff --git a/target-s390x/mmu_helper.c b/target-s390x/mmu_helper.c
index 1e7412c..18217fd 100644
--- a/target-s390x/mmu_helper.c
+++ b/target-s390x/mmu_helper.c
@@ -435,6 +435,7 @@ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages,
 /**
  * s390_cpu_virt_mem_rw:
  * @laddr:     the logical start address
+ * @ar:        the access register number
  * @hostbuf:   buffer in host memory. NULL = do only checks w/o copying
  * @len:       length that should be transfered
  * @is_write:  true = write, false = read
@@ -443,7 +444,7 @@ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages,
  * Copy from/to guest memory using logical addresses. Note that we inject a
  * program interrupt in case there is an error while accessing the memory.
  */
-int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, void *hostbuf,
+int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, uint8_t ar, void *hostbuf,
                          int len, bool is_write)
 {
     int currlen, nr_pages, i;
@@ -451,7 +452,7 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, void *hostbuf,
     int ret;
 
     if (kvm_enabled()) {
-        ret = kvm_s390_mem_op(cpu, laddr, hostbuf, len, is_write);
+        ret = kvm_s390_mem_op(cpu, laddr, ar, hostbuf, len, is_write);
         if (ret >= 0) {
             return ret;
         } else if (ret != -ENOSYS) {
-- 
2.3.5

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

* Re: [Qemu-devel] [PATCH 02/10] virtio-ccw: sort into categories
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 02/10] virtio-ccw: sort into categories Cornelia Huck
@ 2015-04-20 14:47   ` Christian Borntraeger
  0 siblings, 0 replies; 25+ messages in thread
From: Christian Borntraeger @ 2015-04-20 14:47 UTC (permalink / raw)
  To: Cornelia Huck, qemu-devel; +Cc: jfrei, agraf

Am 09.04.2015 um 10:51 schrieb Cornelia Huck:
> Sort the various virtio-ccw devices into the same categories as their
> virtio-pci counterparts.
> 
> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>

> ---
>  hw/s390x/virtio-ccw.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
> index d32ecaf..9ef1059 100644
> --- a/hw/s390x/virtio-ccw.c
> +++ b/hw/s390x/virtio-ccw.c
> @@ -1418,6 +1418,7 @@ static void virtio_ccw_net_class_init(ObjectClass *klass, void *data)
>      k->exit = virtio_ccw_exit;
>      dc->reset = virtio_ccw_reset;
>      dc->props = virtio_ccw_net_properties;
> +    set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
>  }
> 
>  static const TypeInfo virtio_ccw_net = {
> @@ -1444,6 +1445,7 @@ static void virtio_ccw_blk_class_init(ObjectClass *klass, void *data)
>      k->exit = virtio_ccw_exit;
>      dc->reset = virtio_ccw_reset;
>      dc->props = virtio_ccw_blk_properties;
> +    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
>  }
> 
>  static const TypeInfo virtio_ccw_blk = {
> @@ -1470,6 +1472,7 @@ static void virtio_ccw_serial_class_init(ObjectClass *klass, void *data)
>      k->exit = virtio_ccw_exit;
>      dc->reset = virtio_ccw_reset;
>      dc->props = virtio_ccw_serial_properties;
> +    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
>  }
> 
>  static const TypeInfo virtio_ccw_serial = {
> @@ -1496,6 +1499,7 @@ static void virtio_ccw_balloon_class_init(ObjectClass *klass, void *data)
>      k->exit = virtio_ccw_exit;
>      dc->reset = virtio_ccw_reset;
>      dc->props = virtio_ccw_balloon_properties;
> +    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
>  }
> 
>  static const TypeInfo virtio_ccw_balloon = {
> @@ -1523,6 +1527,7 @@ static void virtio_ccw_scsi_class_init(ObjectClass *klass, void *data)
>      k->exit = virtio_ccw_exit;
>      dc->reset = virtio_ccw_reset;
>      dc->props = virtio_ccw_scsi_properties;
> +    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
>  }
> 
>  static const TypeInfo virtio_ccw_scsi = {
> @@ -1548,6 +1553,7 @@ static void vhost_ccw_scsi_class_init(ObjectClass *klass, void *data)
>      k->exit = virtio_ccw_exit;
>      dc->reset = virtio_ccw_reset;
>      dc->props = vhost_ccw_scsi_properties;
> +    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
>  }
> 
>  static const TypeInfo vhost_ccw_scsi = {
> @@ -1585,6 +1591,7 @@ static void virtio_ccw_rng_class_init(ObjectClass *klass, void *data)
>      k->exit = virtio_ccw_exit;
>      dc->reset = virtio_ccw_reset;
>      dc->props = virtio_ccw_rng_properties;
> +    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
>  }
> 
>  static const TypeInfo virtio_ccw_rng = {
> @@ -1671,9 +1678,11 @@ static void virtual_css_bridge_class_init(ObjectClass *klass, void *data)
>  {
>      SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
>      HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(klass);
> +    DeviceClass *dc = DEVICE_CLASS(klass);
> 
>      k->init = virtual_css_bridge_init;
>      hc->unplug = virtio_ccw_busdev_unplug;
> +    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
>  }
> 
>  static const TypeInfo virtual_css_bridge_info = {
> 

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

* Re: [Qemu-devel] [PATCH 03/10] s390-virtio: sort into categories
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 03/10] s390-virtio: " Cornelia Huck
@ 2015-04-20 14:47   ` Christian Borntraeger
  0 siblings, 0 replies; 25+ messages in thread
From: Christian Borntraeger @ 2015-04-20 14:47 UTC (permalink / raw)
  To: Cornelia Huck, qemu-devel; +Cc: jfrei, agraf

Am 09.04.2015 um 10:51 schrieb Cornelia Huck:
> Sort the various s390-virtio devices into the same categories as their
> virtio-pci counterparts.
> 
> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>


Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
> ---
>  hw/s390x/s390-virtio-bus.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
> index 047c963..c211da4 100644
> --- a/hw/s390x/s390-virtio-bus.c
> +++ b/hw/s390x/s390-virtio-bus.c
> @@ -519,6 +519,7 @@ static void s390_virtio_net_class_init(ObjectClass *klass, void *data)
> 
>      k->realize = s390_virtio_net_realize;
>      dc->props = s390_virtio_net_properties;
> +    set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
>  }
> 
>  static const TypeInfo s390_virtio_net = {
> @@ -532,8 +533,10 @@ static const TypeInfo s390_virtio_net = {
>  static void s390_virtio_blk_class_init(ObjectClass *klass, void *data)
>  {
>      VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
> +    DeviceClass *dc = DEVICE_CLASS(klass);
> 
>      k->realize = s390_virtio_blk_realize;
> +    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
>  }
> 
>  static const TypeInfo s390_virtio_blk = {
> @@ -555,6 +558,7 @@ static void s390_virtio_serial_class_init(ObjectClass *klass, void *data)
> 
>      k->realize = s390_virtio_serial_realize;
>      dc->props = s390_virtio_serial_properties;
> +    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
>  }
> 
>  static const TypeInfo s390_virtio_serial = {
> @@ -577,6 +581,7 @@ static void s390_virtio_rng_class_init(ObjectClass *klass, void *data)
> 
>      k->realize = s390_virtio_rng_realize;
>      dc->props = s390_virtio_rng_properties;
> +    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
>  }
> 
>  static const TypeInfo s390_virtio_rng = {
> @@ -635,6 +640,7 @@ static void s390_virtio_scsi_class_init(ObjectClass *klass, void *data)
> 
>      k->realize = s390_virtio_scsi_realize;
>      dc->props = s390_virtio_scsi_properties;
> +    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
>  }
> 
>  static const TypeInfo s390_virtio_scsi = {
> @@ -658,6 +664,7 @@ static void s390_vhost_scsi_class_init(ObjectClass *klass, void *data)
> 
>      k->realize = s390_vhost_scsi_realize;
>      dc->props = s390_vhost_scsi_properties;
> +    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
>  }
> 
>  static const TypeInfo s390_vhost_scsi = {
> @@ -681,8 +688,10 @@ static int s390_virtio_bridge_init(SysBusDevice *dev)
>  static void s390_virtio_bridge_class_init(ObjectClass *klass, void *data)
>  {
>      SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
> +    DeviceClass *dc = DEVICE_CLASS(klass);
> 
>      k->init = s390_virtio_bridge_init;
> +    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
>  }
> 
>  static const TypeInfo s390_virtio_bridge_info = {
> 

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

* Re: [Qemu-devel] [PATCH 04/10] sclp: sort into categories
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 04/10] sclp: " Cornelia Huck
@ 2015-04-20 14:48   ` Christian Borntraeger
  0 siblings, 0 replies; 25+ messages in thread
From: Christian Borntraeger @ 2015-04-20 14:48 UTC (permalink / raw)
  To: Cornelia Huck, qemu-devel; +Cc: jfrei, agraf

Am 09.04.2015 um 10:51 schrieb Cornelia Huck:
> Sort the sclp consoles into the input category, just as virtio-serial.
> Various other sclp devices don't have an obvious category, sort them
> into misc.
> 
> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>

> ---
>  hw/char/sclpconsole-lm.c  | 1 +
>  hw/char/sclpconsole.c     | 1 +
>  hw/s390x/event-facility.c | 1 +
>  hw/s390x/sclp.c           | 9 +++++++++
>  hw/s390x/sclpcpu.c        | 2 ++
>  hw/s390x/sclpquiesce.c    | 1 +
>  6 files changed, 15 insertions(+)
> 
> diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c
> index a9f5e62..02ac80b 100644
> --- a/hw/char/sclpconsole-lm.c
> +++ b/hw/char/sclpconsole-lm.c
> @@ -364,6 +364,7 @@ static void console_class_init(ObjectClass *klass, void *data)
>      ec->can_handle_event = can_handle_event;
>      ec->read_event_data = read_event_data;
>      ec->write_event_data = write_event_data;
> +    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
>  }
> 
>  static const TypeInfo sclp_console_info = {
> diff --git a/hw/char/sclpconsole.c b/hw/char/sclpconsole.c
> index 79891df..b014c7f 100644
> --- a/hw/char/sclpconsole.c
> +++ b/hw/char/sclpconsole.c
> @@ -266,6 +266,7 @@ static void console_class_init(ObjectClass *klass, void *data)
>      ec->can_handle_event = can_handle_event;
>      ec->read_event_data = read_event_data;
>      ec->write_event_data = write_event_data;
> +    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
>  }
> 
>  static const TypeInfo sclp_console_info = {
> diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
> index 78da718..1cb116a 100644
> --- a/hw/s390x/event-facility.c
> +++ b/hw/s390x/event-facility.c
> @@ -362,6 +362,7 @@ static void init_event_facility_class(ObjectClass *klass, void *data)
> 
>      dc->reset = reset_event_facility;
>      dc->vmsd = &vmstate_event_facility;
> +    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
>      k->init = init_event_facility;
>      k->command_handler = command_handler;
>      k->event_pending = event_pending;
> diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c
> index a969975..b3a6c5e 100644
> --- a/hw/s390x/sclp.c
> +++ b/hw/s390x/sclp.c
> @@ -457,10 +457,19 @@ sclpMemoryHotplugDev *get_sclp_memory_hotplug_dev(void)
>                                     TYPE_SCLP_MEMORY_HOTPLUG_DEV, NULL));
>  }
> 
> +static void sclp_memory_hotplug_dev_class_init(ObjectClass *klass,
> +                                               void *data)
> +{
> +    DeviceClass *dc = DEVICE_CLASS(klass);
> +
> +    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
> +}
> +
>  static TypeInfo sclp_memory_hotplug_dev_info = {
>      .name = TYPE_SCLP_MEMORY_HOTPLUG_DEV,
>      .parent = TYPE_SYS_BUS_DEVICE,
>      .instance_size = sizeof(sclpMemoryHotplugDev),
> +    .class_init = sclp_memory_hotplug_dev_class_init,
>  };
> 
>  static void register_types(void)
> diff --git a/hw/s390x/sclpcpu.c b/hw/s390x/sclpcpu.c
> index 3600fe2..2fe8b5a 100644
> --- a/hw/s390x/sclpcpu.c
> +++ b/hw/s390x/sclpcpu.c
> @@ -88,12 +88,14 @@ static int irq_cpu_hotplug_init(SCLPEvent *event)
>  static void cpu_class_init(ObjectClass *oc, void *data)
>  {
>      SCLPEventClass *k = SCLP_EVENT_CLASS(oc);
> +    DeviceClass *dc = DEVICE_CLASS(oc);
> 
>      k->init = irq_cpu_hotplug_init;
>      k->get_send_mask = send_mask;
>      k->get_receive_mask = receive_mask;
>      k->read_event_data = read_event_data;
>      k->write_event_data = NULL;
> +    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
>  }
> 
>  static const TypeInfo sclp_cpu_info = {
> diff --git a/hw/s390x/sclpquiesce.c b/hw/s390x/sclpquiesce.c
> index 1a399bd..ffa5553 100644
> --- a/hw/s390x/sclpquiesce.c
> +++ b/hw/s390x/sclpquiesce.c
> @@ -116,6 +116,7 @@ static void quiesce_class_init(ObjectClass *klass, void *data)
> 
>      dc->reset = quiesce_reset;
>      dc->vmsd = &vmstate_sclpquiesce;
> +    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
>      k->init = quiesce_init;
> 
>      k->get_send_mask = send_mask;
> 

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

* Re: [Qemu-devel] [PATCH 05/10] s390x/ipl: sort into categories
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 05/10] s390x/ipl: " Cornelia Huck
@ 2015-04-20 14:48   ` Christian Borntraeger
  0 siblings, 0 replies; 25+ messages in thread
From: Christian Borntraeger @ 2015-04-20 14:48 UTC (permalink / raw)
  To: Cornelia Huck, qemu-devel; +Cc: jfrei, agraf

Am 09.04.2015 um 10:51 schrieb Cornelia Huck:
> The s390 ipl device has no real home (it's not really a storage device),
> so let's sort it into the misc category.
> 
> Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>

> ---
>  hw/s390x/ipl.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c
> index 2e26d2a..132004a 100644
> --- a/hw/s390x/ipl.c
> +++ b/hw/s390x/ipl.c
> @@ -315,6 +315,7 @@ static void s390_ipl_class_init(ObjectClass *klass, void *data)
>      dc->props = s390_ipl_properties;
>      dc->reset = s390_ipl_reset;
>      dc->vmsd = &vmstate_ipl;
> +    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
>  }
> 
>  static const TypeInfo s390_ipl_info = {
> 

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

* Re: [Qemu-devel] [PATCH 09/10] s390x/mmu: Use ioctl for reading and writing from/to guest memory
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 09/10] s390x/mmu: Use ioctl for reading and writing from/to guest memory Cornelia Huck
@ 2015-04-20 14:55   ` Christian Borntraeger
  2015-04-21 19:12     ` Alexander Graf
  0 siblings, 1 reply; 25+ messages in thread
From: Christian Borntraeger @ 2015-04-20 14:55 UTC (permalink / raw)
  To: Cornelia Huck, qemu-devel; +Cc: jfrei, agraf, Thomas Huth

Am 09.04.2015 um 10:51 schrieb Cornelia Huck:
> From: Thomas Huth <thuth@linux.vnet.ibm.com>
> 
> Add code to make use of the new ioctl for reading from / writing to
> virtual guest memory. By using the ioctl, the memory accesses are now
> protected with the so-called ipte-lock in the kernel.
> 
> Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>

> ---
>  target-s390x/cpu.h        |  7 +++++++
>  target-s390x/kvm.c        | 35 +++++++++++++++++++++++++++++++++++
>  target-s390x/mmu_helper.c |  9 +++++++++
>  3 files changed, 51 insertions(+)
> 
> diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
> index 79bc80b..9c42743 100644
> --- a/target-s390x/cpu.h
> +++ b/target-s390x/cpu.h
> @@ -401,6 +401,8 @@ void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq);
>  void kvm_s390_floating_interrupt(struct kvm_s390_irq *irq);
>  int kvm_s390_inject_flic(struct kvm_s390_irq *irq);
>  void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code);
> +int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
> +                    bool is_write);
>  int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_clock);
>  int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_clock);
>  #else
> @@ -418,6 +420,11 @@ static inline int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
>  {
>      return -ENOSYS;
>  }
> +static inline int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf,
> +                                  int len, bool is_write)
> +{
> +    return -ENOSYS;
> +}
>  static inline void kvm_s390_access_exception(S390CPU *cpu, uint16_t code,
>                                               uint64_t te_code)
>  {
> diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
> index 619684b..e2ae2b3 100644
> --- a/target-s390x/kvm.c
> +++ b/target-s390x/kvm.c
> @@ -123,6 +123,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
> 
>  static int cap_sync_regs;
>  static int cap_async_pf;
> +static int cap_mem_op;
> 
>  static void *legacy_s390_alloc(size_t size, uint64_t *align);
> 
> @@ -247,6 +248,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
>  {
>      cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
>      cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);
> +    cap_mem_op = kvm_check_extension(s, KVM_CAP_S390_MEM_OP);
> 
>      kvm_s390_enable_cmma(s);
> 
> @@ -550,6 +552,39 @@ int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
>      return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
>  }
> 
> +/**
> + * kvm_s390_mem_op:
> + * @addr:      the logical start address in guest memory
> + * @hostbuf:   buffer in host memory. NULL = do only checks w/o copying
> + * @len:       length that should be transfered
> + * @is_write:  true = write, false = read
> + * Returns:    0 on success, non-zero if an exception or error occured
> + *
> + * Use KVM ioctl to read/write from/to guest memory. An access exception
> + * is injected into the vCPU in case of translation errors.
> + */
> +int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
> +                    bool is_write)
> +{
> +    struct kvm_s390_mem_op mem_op = {
> +        .gaddr = addr,
> +        .flags = KVM_S390_MEMOP_F_INJECT_EXCEPTION,
> +        .size = len,
> +        .op = is_write ? KVM_S390_MEMOP_LOGICAL_WRITE
> +                       : KVM_S390_MEMOP_LOGICAL_READ,
> +        .buf = (uint64_t)hostbuf,
> +    };
> +
> +    if (!cap_mem_op) {
> +        return -ENOSYS;
> +    }
> +    if (!hostbuf) {
> +        mem_op.flags |= KVM_S390_MEMOP_F_CHECK_ONLY;
> +    }
> +
> +    return kvm_vcpu_ioctl(CPU(cpu), KVM_S390_MEM_OP, &mem_op);
> +}
> +
>  /*
>   * Legacy layout for s390:
>   * Older S390 KVM requires the topmost vma of the RAM to be
> diff --git a/target-s390x/mmu_helper.c b/target-s390x/mmu_helper.c
> index 9b88498..1e7412c 100644
> --- a/target-s390x/mmu_helper.c
> +++ b/target-s390x/mmu_helper.c
> @@ -450,6 +450,15 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, void *hostbuf,
>      target_ulong *pages;
>      int ret;
> 
> +    if (kvm_enabled()) {
> +        ret = kvm_s390_mem_op(cpu, laddr, hostbuf, len, is_write);
> +        if (ret >= 0) {
> +            return ret;
> +        } else if (ret != -ENOSYS) {
> +            error_printf("kvm_s390_mem_op() failed: %s\n", strerror(-ret));
> +        }
> +    }
> +
>      nr_pages = (((laddr & ~TARGET_PAGE_MASK) + len - 1) >> TARGET_PAGE_BITS)
>                 + 1;
>      pages = g_malloc(nr_pages * sizeof(*pages));
> 

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

* Re: [Qemu-devel] [PATCH 09/10] s390x/mmu: Use ioctl for reading and writing from/to guest memory
  2015-04-20 14:55   ` Christian Borntraeger
@ 2015-04-21 19:12     ` Alexander Graf
  2015-04-21 19:34       ` Christian Borntraeger
  0 siblings, 1 reply; 25+ messages in thread
From: Alexander Graf @ 2015-04-21 19:12 UTC (permalink / raw)
  To: Christian Borntraeger, Cornelia Huck, qemu-devel; +Cc: jfrei, Thomas Huth

On 04/20/2015 04:55 PM, Christian Borntraeger wrote:
> Am 09.04.2015 um 10:51 schrieb Cornelia Huck:
>> From: Thomas Huth <thuth@linux.vnet.ibm.com>
>>
>> Add code to make use of the new ioctl for reading from / writing to
>> virtual guest memory. By using the ioctl, the memory accesses are now
>> protected with the so-called ipte-lock in the kernel.
>>
>> Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
>> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
>
>> ---
>>   target-s390x/cpu.h        |  7 +++++++
>>   target-s390x/kvm.c        | 35 +++++++++++++++++++++++++++++++++++
>>   target-s390x/mmu_helper.c |  9 +++++++++
>>   3 files changed, 51 insertions(+)
>>
>> diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
>> index 79bc80b..9c42743 100644
>> --- a/target-s390x/cpu.h
>> +++ b/target-s390x/cpu.h
>> @@ -401,6 +401,8 @@ void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq);
>>   void kvm_s390_floating_interrupt(struct kvm_s390_irq *irq);
>>   int kvm_s390_inject_flic(struct kvm_s390_irq *irq);
>>   void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code);
>> +int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
>> +                    bool is_write);
>>   int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_clock);
>>   int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_clock);
>>   #else
>> @@ -418,6 +420,11 @@ static inline int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
>>   {
>>       return -ENOSYS;
>>   }
>> +static inline int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf,
>> +                                  int len, bool is_write)
>> +{
>> +    return -ENOSYS;
>> +}
>>   static inline void kvm_s390_access_exception(S390CPU *cpu, uint16_t code,
>>                                                uint64_t te_code)
>>   {
>> diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
>> index 619684b..e2ae2b3 100644
>> --- a/target-s390x/kvm.c
>> +++ b/target-s390x/kvm.c
>> @@ -123,6 +123,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
>>
>>   static int cap_sync_regs;
>>   static int cap_async_pf;
>> +static int cap_mem_op;
>>
>>   static void *legacy_s390_alloc(size_t size, uint64_t *align);
>>
>> @@ -247,6 +248,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
>>   {
>>       cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
>>       cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);
>> +    cap_mem_op = kvm_check_extension(s, KVM_CAP_S390_MEM_OP);
>>
>>       kvm_s390_enable_cmma(s);
>>
>> @@ -550,6 +552,39 @@ int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
>>       return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
>>   }
>>
>> +/**
>> + * kvm_s390_mem_op:
>> + * @addr:      the logical start address in guest memory
>> + * @hostbuf:   buffer in host memory. NULL = do only checks w/o copying
>> + * @len:       length that should be transfered
>> + * @is_write:  true = write, false = read
>> + * Returns:    0 on success, non-zero if an exception or error occured
>> + *
>> + * Use KVM ioctl to read/write from/to guest memory. An access exception
>> + * is injected into the vCPU in case of translation errors.
>> + */
>> +int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
>> +                    bool is_write)
>> +{
>> +    struct kvm_s390_mem_op mem_op = {
>> +        .gaddr = addr,
>> +        .flags = KVM_S390_MEMOP_F_INJECT_EXCEPTION,
>> +        .size = len,
>> +        .op = is_write ? KVM_S390_MEMOP_LOGICAL_WRITE
>> +                       : KVM_S390_MEMOP_LOGICAL_READ,
>> +        .buf = (uint64_t)hostbuf,
>> +    };
>> +
>> +    if (!cap_mem_op) {
>> +        return -ENOSYS;
>> +    }
>> +    if (!hostbuf) {
>> +        mem_op.flags |= KVM_S390_MEMOP_F_CHECK_ONLY;
>> +    }
>> +
>> +    return kvm_vcpu_ioctl(CPU(cpu), KVM_S390_MEM_OP, &mem_op);
>> +}
>> +
>>   /*
>>    * Legacy layout for s390:
>>    * Older S390 KVM requires the topmost vma of the RAM to be
>> diff --git a/target-s390x/mmu_helper.c b/target-s390x/mmu_helper.c
>> index 9b88498..1e7412c 100644
>> --- a/target-s390x/mmu_helper.c
>> +++ b/target-s390x/mmu_helper.c
>> @@ -450,6 +450,15 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, void *hostbuf,
>>       target_ulong *pages;
>>       int ret;
>>
>> +    if (kvm_enabled()) {
>> +        ret = kvm_s390_mem_op(cpu, laddr, hostbuf, len, is_write);
>> +        if (ret >= 0) {
>> +            return ret;
>> +        } else if (ret != -ENOSYS) {
>> +            error_printf("kvm_s390_mem_op() failed: %s\n", strerror(-ret));

Won't this spill the logs like crazy when running new qemu on old kernels?


Alex

>> +        }
>> +    }
>> +
>>       nr_pages = (((laddr & ~TARGET_PAGE_MASK) + len - 1) >> TARGET_PAGE_BITS)
>>                  + 1;
>>       pages = g_malloc(nr_pages * sizeof(*pages));
>>

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

* Re: [Qemu-devel] [PATCH 09/10] s390x/mmu: Use ioctl for reading and writing from/to guest memory
  2015-04-21 19:12     ` Alexander Graf
@ 2015-04-21 19:34       ` Christian Borntraeger
  2015-04-21 19:36         ` Alexander Graf
  0 siblings, 1 reply; 25+ messages in thread
From: Christian Borntraeger @ 2015-04-21 19:34 UTC (permalink / raw)
  To: Alexander Graf, Cornelia Huck, qemu-devel; +Cc: jfrei, Thomas Huth

Am 21.04.2015 um 21:12 schrieb Alexander Graf:
> On 04/20/2015 04:55 PM, Christian Borntraeger wrote:
>> Am 09.04.2015 um 10:51 schrieb Cornelia Huck:
>>> From: Thomas Huth <thuth@linux.vnet.ibm.com>
>>>
>>> Add code to make use of the new ioctl for reading from / writing to
>>> virtual guest memory. By using the ioctl, the memory accesses are now
>>> protected with the so-called ipte-lock in the kernel.
>>>
>>> Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
>>> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
>> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
>>
>>> ---
>>>   target-s390x/cpu.h        |  7 +++++++
>>>   target-s390x/kvm.c        | 35 +++++++++++++++++++++++++++++++++++
>>>   target-s390x/mmu_helper.c |  9 +++++++++
>>>   3 files changed, 51 insertions(+)
>>>
>>> diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
>>> index 79bc80b..9c42743 100644
>>> --- a/target-s390x/cpu.h
>>> +++ b/target-s390x/cpu.h
>>> @@ -401,6 +401,8 @@ void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq);
>>>   void kvm_s390_floating_interrupt(struct kvm_s390_irq *irq);
>>>   int kvm_s390_inject_flic(struct kvm_s390_irq *irq);
>>>   void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code);
>>> +int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
>>> +                    bool is_write);
>>>   int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_clock);
>>>   int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_clock);
>>>   #else
>>> @@ -418,6 +420,11 @@ static inline int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
>>>   {
>>>       return -ENOSYS;
>>>   }
>>> +static inline int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf,
>>> +                                  int len, bool is_write)
>>> +{
>>> +    return -ENOSYS;
>>> +}
>>>   static inline void kvm_s390_access_exception(S390CPU *cpu, uint16_t code,
>>>                                                uint64_t te_code)
>>>   {
>>> diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
>>> index 619684b..e2ae2b3 100644
>>> --- a/target-s390x/kvm.c
>>> +++ b/target-s390x/kvm.c
>>> @@ -123,6 +123,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
>>>
>>>   static int cap_sync_regs;
>>>   static int cap_async_pf;
>>> +static int cap_mem_op;
>>>
>>>   static void *legacy_s390_alloc(size_t size, uint64_t *align);
>>>
>>> @@ -247,6 +248,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
>>>   {
>>>       cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
>>>       cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);
>>> +    cap_mem_op = kvm_check_extension(s, KVM_CAP_S390_MEM_OP);
>>>
>>>       kvm_s390_enable_cmma(s);
>>>
>>> @@ -550,6 +552,39 @@ int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
>>>       return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
>>>   }
>>>
>>> +/**
>>> + * kvm_s390_mem_op:
>>> + * @addr:      the logical start address in guest memory
>>> + * @hostbuf:   buffer in host memory. NULL = do only checks w/o copying
>>> + * @len:       length that should be transfered
>>> + * @is_write:  true = write, false = read
>>> + * Returns:    0 on success, non-zero if an exception or error occured
>>> + *
>>> + * Use KVM ioctl to read/write from/to guest memory. An access exception
>>> + * is injected into the vCPU in case of translation errors.
>>> + */
>>> +int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
>>> +                    bool is_write)
>>> +{
>>> +    struct kvm_s390_mem_op mem_op = {
>>> +        .gaddr = addr,
>>> +        .flags = KVM_S390_MEMOP_F_INJECT_EXCEPTION,
>>> +        .size = len,
>>> +        .op = is_write ? KVM_S390_MEMOP_LOGICAL_WRITE
>>> +                       : KVM_S390_MEMOP_LOGICAL_READ,
>>> +        .buf = (uint64_t)hostbuf,
>>> +    };
>>> +
>>> +    if (!cap_mem_op) {
>>> +        return -ENOSYS;
>>> +    }
>>> +    if (!hostbuf) {
>>> +        mem_op.flags |= KVM_S390_MEMOP_F_CHECK_ONLY;
>>> +    }
>>> +
>>> +    return kvm_vcpu_ioctl(CPU(cpu), KVM_S390_MEM_OP, &mem_op);
>>> +}
>>> +
>>>   /*
>>>    * Legacy layout for s390:
>>>    * Older S390 KVM requires the topmost vma of the RAM to be
>>> diff --git a/target-s390x/mmu_helper.c b/target-s390x/mmu_helper.c
>>> index 9b88498..1e7412c 100644
>>> --- a/target-s390x/mmu_helper.c
>>> +++ b/target-s390x/mmu_helper.c
>>> @@ -450,6 +450,15 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, void *hostbuf,
>>>       target_ulong *pages;
>>>       int ret;
>>>
>>> +    if (kvm_enabled()) {
>>> +        ret = kvm_s390_mem_op(cpu, laddr, hostbuf, len, is_write);
>>> +        if (ret >= 0) {
>>> +            return ret;
>>> +        } else if (ret != -ENOSYS) {
>>> +            error_printf("kvm_s390_mem_op() failed: %s\n", strerror(-ret));
> 
> Won't this spill the logs like crazy when running new qemu on old kernels?

kvm_s390_mem_op will return -ENOSYS if cap_mem_op is not set.

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

* Re: [Qemu-devel] [PATCH 09/10] s390x/mmu: Use ioctl for reading and writing from/to guest memory
  2015-04-21 19:34       ` Christian Borntraeger
@ 2015-04-21 19:36         ` Alexander Graf
  2015-04-21 19:48           ` Christian Borntraeger
  0 siblings, 1 reply; 25+ messages in thread
From: Alexander Graf @ 2015-04-21 19:36 UTC (permalink / raw)
  To: Christian Borntraeger, Cornelia Huck, qemu-devel; +Cc: jfrei, Thomas Huth

On 04/21/2015 09:34 PM, Christian Borntraeger wrote:
> Am 21.04.2015 um 21:12 schrieb Alexander Graf:
>> On 04/20/2015 04:55 PM, Christian Borntraeger wrote:
>>> Am 09.04.2015 um 10:51 schrieb Cornelia Huck:
>>>> From: Thomas Huth <thuth@linux.vnet.ibm.com>
>>>>
>>>> Add code to make use of the new ioctl for reading from / writing to
>>>> virtual guest memory. By using the ioctl, the memory accesses are now
>>>> protected with the so-called ipte-lock in the kernel.
>>>>
>>>> Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
>>>> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
>>> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
>>>
>>>> ---
>>>>    target-s390x/cpu.h        |  7 +++++++
>>>>    target-s390x/kvm.c        | 35 +++++++++++++++++++++++++++++++++++
>>>>    target-s390x/mmu_helper.c |  9 +++++++++
>>>>    3 files changed, 51 insertions(+)
>>>>
>>>> diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
>>>> index 79bc80b..9c42743 100644
>>>> --- a/target-s390x/cpu.h
>>>> +++ b/target-s390x/cpu.h
>>>> @@ -401,6 +401,8 @@ void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq);
>>>>    void kvm_s390_floating_interrupt(struct kvm_s390_irq *irq);
>>>>    int kvm_s390_inject_flic(struct kvm_s390_irq *irq);
>>>>    void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code);
>>>> +int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
>>>> +                    bool is_write);
>>>>    int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_clock);
>>>>    int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_clock);
>>>>    #else
>>>> @@ -418,6 +420,11 @@ static inline int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
>>>>    {
>>>>        return -ENOSYS;
>>>>    }
>>>> +static inline int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf,
>>>> +                                  int len, bool is_write)
>>>> +{
>>>> +    return -ENOSYS;
>>>> +}
>>>>    static inline void kvm_s390_access_exception(S390CPU *cpu, uint16_t code,
>>>>                                                 uint64_t te_code)
>>>>    {
>>>> diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
>>>> index 619684b..e2ae2b3 100644
>>>> --- a/target-s390x/kvm.c
>>>> +++ b/target-s390x/kvm.c
>>>> @@ -123,6 +123,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
>>>>
>>>>    static int cap_sync_regs;
>>>>    static int cap_async_pf;
>>>> +static int cap_mem_op;
>>>>
>>>>    static void *legacy_s390_alloc(size_t size, uint64_t *align);
>>>>
>>>> @@ -247,6 +248,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
>>>>    {
>>>>        cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
>>>>        cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);
>>>> +    cap_mem_op = kvm_check_extension(s, KVM_CAP_S390_MEM_OP);
>>>>
>>>>        kvm_s390_enable_cmma(s);
>>>>
>>>> @@ -550,6 +552,39 @@ int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
>>>>        return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
>>>>    }
>>>>
>>>> +/**
>>>> + * kvm_s390_mem_op:
>>>> + * @addr:      the logical start address in guest memory
>>>> + * @hostbuf:   buffer in host memory. NULL = do only checks w/o copying
>>>> + * @len:       length that should be transfered
>>>> + * @is_write:  true = write, false = read
>>>> + * Returns:    0 on success, non-zero if an exception or error occured
>>>> + *
>>>> + * Use KVM ioctl to read/write from/to guest memory. An access exception
>>>> + * is injected into the vCPU in case of translation errors.
>>>> + */
>>>> +int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
>>>> +                    bool is_write)
>>>> +{
>>>> +    struct kvm_s390_mem_op mem_op = {
>>>> +        .gaddr = addr,
>>>> +        .flags = KVM_S390_MEMOP_F_INJECT_EXCEPTION,
>>>> +        .size = len,
>>>> +        .op = is_write ? KVM_S390_MEMOP_LOGICAL_WRITE
>>>> +                       : KVM_S390_MEMOP_LOGICAL_READ,
>>>> +        .buf = (uint64_t)hostbuf,
>>>> +    };
>>>> +
>>>> +    if (!cap_mem_op) {
>>>> +        return -ENOSYS;
>>>> +    }
>>>> +    if (!hostbuf) {
>>>> +        mem_op.flags |= KVM_S390_MEMOP_F_CHECK_ONLY;
>>>> +    }
>>>> +
>>>> +    return kvm_vcpu_ioctl(CPU(cpu), KVM_S390_MEM_OP, &mem_op);
>>>> +}
>>>> +
>>>>    /*
>>>>     * Legacy layout for s390:
>>>>     * Older S390 KVM requires the topmost vma of the RAM to be
>>>> diff --git a/target-s390x/mmu_helper.c b/target-s390x/mmu_helper.c
>>>> index 9b88498..1e7412c 100644
>>>> --- a/target-s390x/mmu_helper.c
>>>> +++ b/target-s390x/mmu_helper.c
>>>> @@ -450,6 +450,15 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, void *hostbuf,
>>>>        target_ulong *pages;
>>>>        int ret;
>>>>
>>>> +    if (kvm_enabled()) {
>>>> +        ret = kvm_s390_mem_op(cpu, laddr, hostbuf, len, is_write);
>>>> +        if (ret >= 0) {
>>>> +            return ret;
>>>> +        } else if (ret != -ENOSYS) {
>>>> +            error_printf("kvm_s390_mem_op() failed: %s\n", strerror(-ret));
>> Won't this spill the logs like crazy when running new qemu on old kernels?
> kvm_s390_mem_op will return -ENOSYS if cap_mem_op is not set.

Oh, I see the logic now. Can you think of any way to make it more 
obvious to a reader what's going on?


Alex

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

* Re: [Qemu-devel] [PATCH 09/10] s390x/mmu: Use ioctl for reading and writing from/to guest memory
  2015-04-21 19:36         ` Alexander Graf
@ 2015-04-21 19:48           ` Christian Borntraeger
  2015-04-22  8:37             ` Cornelia Huck
  0 siblings, 1 reply; 25+ messages in thread
From: Christian Borntraeger @ 2015-04-21 19:48 UTC (permalink / raw)
  To: Alexander Graf, Cornelia Huck, qemu-devel; +Cc: jfrei, Thomas Huth

Am 21.04.2015 um 21:36 schrieb Alexander Graf:
> On 04/21/2015 09:34 PM, Christian Borntraeger wrote:
>> Am 21.04.2015 um 21:12 schrieb Alexander Graf:
>>> On 04/20/2015 04:55 PM, Christian Borntraeger wrote:
>>>> Am 09.04.2015 um 10:51 schrieb Cornelia Huck:
>>>>> From: Thomas Huth <thuth@linux.vnet.ibm.com>
>>>>>
>>>>> Add code to make use of the new ioctl for reading from / writing to
>>>>> virtual guest memory. By using the ioctl, the memory accesses are now
>>>>> protected with the so-called ipte-lock in the kernel.
>>>>>
>>>>> Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
>>>>> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
>>>> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
>>>>
>>>>> ---
>>>>>    target-s390x/cpu.h        |  7 +++++++
>>>>>    target-s390x/kvm.c        | 35 +++++++++++++++++++++++++++++++++++
>>>>>    target-s390x/mmu_helper.c |  9 +++++++++
>>>>>    3 files changed, 51 insertions(+)
>>>>>
>>>>> diff --git a/target-s390x/cpu.h b/target-s390x/cpu.h
>>>>> index 79bc80b..9c42743 100644
>>>>> --- a/target-s390x/cpu.h
>>>>> +++ b/target-s390x/cpu.h
>>>>> @@ -401,6 +401,8 @@ void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq);
>>>>>    void kvm_s390_floating_interrupt(struct kvm_s390_irq *irq);
>>>>>    int kvm_s390_inject_flic(struct kvm_s390_irq *irq);
>>>>>    void kvm_s390_access_exception(S390CPU *cpu, uint16_t code, uint64_t te_code);
>>>>> +int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
>>>>> +                    bool is_write);
>>>>>    int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_clock);
>>>>>    int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_clock);
>>>>>    #else
>>>>> @@ -418,6 +420,11 @@ static inline int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
>>>>>    {
>>>>>        return -ENOSYS;
>>>>>    }
>>>>> +static inline int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf,
>>>>> +                                  int len, bool is_write)
>>>>> +{
>>>>> +    return -ENOSYS;
>>>>> +}
>>>>>    static inline void kvm_s390_access_exception(S390CPU *cpu, uint16_t code,
>>>>>                                                 uint64_t te_code)
>>>>>    {
>>>>> diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
>>>>> index 619684b..e2ae2b3 100644
>>>>> --- a/target-s390x/kvm.c
>>>>> +++ b/target-s390x/kvm.c
>>>>> @@ -123,6 +123,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
>>>>>
>>>>>    static int cap_sync_regs;
>>>>>    static int cap_async_pf;
>>>>> +static int cap_mem_op;
>>>>>
>>>>>    static void *legacy_s390_alloc(size_t size, uint64_t *align);
>>>>>
>>>>> @@ -247,6 +248,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
>>>>>    {
>>>>>        cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
>>>>>        cap_async_pf = kvm_check_extension(s, KVM_CAP_ASYNC_PF);
>>>>> +    cap_mem_op = kvm_check_extension(s, KVM_CAP_S390_MEM_OP);
>>>>>
>>>>>        kvm_s390_enable_cmma(s);
>>>>>
>>>>> @@ -550,6 +552,39 @@ int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod_low)
>>>>>        return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);
>>>>>    }
>>>>>
>>>>> +/**
>>>>> + * kvm_s390_mem_op:
>>>>> + * @addr:      the logical start address in guest memory
>>>>> + * @hostbuf:   buffer in host memory. NULL = do only checks w/o copying
>>>>> + * @len:       length that should be transfered
>>>>> + * @is_write:  true = write, false = read
>>>>> + * Returns:    0 on success, non-zero if an exception or error occured
>>>>> + *
>>>>> + * Use KVM ioctl to read/write from/to guest memory. An access exception
>>>>> + * is injected into the vCPU in case of translation errors.
>>>>> + */
>>>>> +int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
>>>>> +                    bool is_write)
>>>>> +{
>>>>> +    struct kvm_s390_mem_op mem_op = {
>>>>> +        .gaddr = addr,
>>>>> +        .flags = KVM_S390_MEMOP_F_INJECT_EXCEPTION,
>>>>> +        .size = len,
>>>>> +        .op = is_write ? KVM_S390_MEMOP_LOGICAL_WRITE
>>>>> +                       : KVM_S390_MEMOP_LOGICAL_READ,
>>>>> +        .buf = (uint64_t)hostbuf,
>>>>> +    };
>>>>> +
>>>>> +    if (!cap_mem_op) {
>>>>> +        return -ENOSYS;
>>>>> +    }
>>>>> +    if (!hostbuf) {
>>>>> +        mem_op.flags |= KVM_S390_MEMOP_F_CHECK_ONLY;
>>>>> +    }
>>>>> +
>>>>> +    return kvm_vcpu_ioctl(CPU(cpu), KVM_S390_MEM_OP, &mem_op);
>>>>> +}
>>>>> +
>>>>>    /*
>>>>>     * Legacy layout for s390:
>>>>>     * Older S390 KVM requires the topmost vma of the RAM to be
>>>>> diff --git a/target-s390x/mmu_helper.c b/target-s390x/mmu_helper.c
>>>>> index 9b88498..1e7412c 100644
>>>>> --- a/target-s390x/mmu_helper.c
>>>>> +++ b/target-s390x/mmu_helper.c
>>>>> @@ -450,6 +450,15 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, void *hostbuf,
>>>>>        target_ulong *pages;
>>>>>        int ret;
>>>>>
>>>>> +    if (kvm_enabled()) {
>>>>> +        ret = kvm_s390_mem_op(cpu, laddr, hostbuf, len, is_write);
>>>>> +        if (ret >= 0) {
>>>>> +            return ret;
>>>>> +        } else if (ret != -ENOSYS) {
>>>>> +            error_printf("kvm_s390_mem_op() failed: %s\n", strerror(-ret));
>>> Won't this spill the logs like crazy when running new qemu on old kernels?
>> kvm_s390_mem_op will return -ENOSYS if cap_mem_op is not set.
> 
> Oh, I see the logic now. Can you think of any way to make it more obvious to a reader what's going on?
> 
We could move the error_printf into kvm_s390_mem_op.
Well Conny has to do it as Thomas has left IBM.

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

* Re: [Qemu-devel] [PATCH 09/10] s390x/mmu: Use ioctl for reading and writing from/to guest memory
  2015-04-21 19:48           ` Christian Borntraeger
@ 2015-04-22  8:37             ` Cornelia Huck
  0 siblings, 0 replies; 25+ messages in thread
From: Cornelia Huck @ 2015-04-22  8:37 UTC (permalink / raw)
  To: Christian Borntraeger; +Cc: jfrei, Thomas Huth, Alexander Graf, qemu-devel

On Tue, 21 Apr 2015 21:48:02 +0200
Christian Borntraeger <borntraeger@de.ibm.com> wrote:

> Am 21.04.2015 um 21:36 schrieb Alexander Graf:
> > On 04/21/2015 09:34 PM, Christian Borntraeger wrote:
> >> Am 21.04.2015 um 21:12 schrieb Alexander Graf:
> >>> On 04/20/2015 04:55 PM, Christian Borntraeger wrote:
> >>>> Am 09.04.2015 um 10:51 schrieb Cornelia Huck:
> >>>>> From: Thomas Huth <thuth@linux.vnet.ibm.com>
> >>>>>
> >>>>> Add code to make use of the new ioctl for reading from / writing to
> >>>>> virtual guest memory. By using the ioctl, the memory accesses are now
> >>>>> protected with the so-called ipte-lock in the kernel.
> >>>>>
> >>>>> Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
> >>>>> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> >>>> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>

> >>>>> @@ -450,6 +450,15 @@ int s390_cpu_virt_mem_rw(S390CPU *cpu, vaddr laddr, void *hostbuf,
> >>>>>        target_ulong *pages;
> >>>>>        int ret;
> >>>>>
> >>>>> +    if (kvm_enabled()) {
> >>>>> +        ret = kvm_s390_mem_op(cpu, laddr, hostbuf, len, is_write);
> >>>>> +        if (ret >= 0) {
> >>>>> +            return ret;
> >>>>> +        } else if (ret != -ENOSYS) {
> >>>>> +            error_printf("kvm_s390_mem_op() failed: %s\n", strerror(-ret));
> >>> Won't this spill the logs like crazy when running new qemu on old kernels?
> >> kvm_s390_mem_op will return -ENOSYS if cap_mem_op is not set.
> > 
> > Oh, I see the logic now. Can you think of any way to make it more obvious to a reader what's going on?
> > 
> We could move the error_printf into kvm_s390_mem_op.
> Well Conny has to do it as Thomas has left IBM.

I can certainly do that, if that makes the code easier to follow.

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

* Re: [Qemu-devel] [PATCH 01/10] s390x/kvm: Remove message about "switch_amode" kernel parameter
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 01/10] s390x/kvm: Remove message about "switch_amode" kernel parameter Cornelia Huck
@ 2015-04-23 12:26   ` Christian Borntraeger
  2015-04-23 12:33     ` Cornelia Huck
  0 siblings, 1 reply; 25+ messages in thread
From: Christian Borntraeger @ 2015-04-23 12:26 UTC (permalink / raw)
  To: Cornelia Huck, qemu-devel; +Cc: jfrei, agraf, Thomas Huth

Am 09.04.2015 um 10:51 schrieb Cornelia Huck:
> From: Thomas Huth <thuth@linux.vnet.ibm.com>
> 
> The "switch_amode" parameter has been removed from the Linux kernel
> sources since version 3.7 - so QEMU should not advise this parameter
> nowadays anymore.
> 
> Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
> Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> ---
>  kvm-all.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/kvm-all.c b/kvm-all.c
> index dd44f8c..7c8537b 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -1542,11 +1542,6 @@ static int kvm_init(MachineState *ms)
>      if (ret < 0) {
>          fprintf(stderr, "ioctl(KVM_CREATE_VM) failed: %d %s\n", -ret,
>                  strerror(-ret));
> -
> -#ifdef TARGET_S390X
> -        fprintf(stderr, "Please add the 'switch_amode' kernel parameter to "
> -                        "your host kernel command line\n");
> -#endif
>          goto err;
>      }
> 

Can you drop this patch from your upcoming pull request?

See the discussion on http://marc.info/?l=kvm&m=142978728714865&w=2
We might want to change the error message instead of getting rid of it.

Christian

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

* Re: [Qemu-devel] [PATCH 01/10] s390x/kvm: Remove message about "switch_amode" kernel parameter
  2015-04-23 12:26   ` Christian Borntraeger
@ 2015-04-23 12:33     ` Cornelia Huck
  0 siblings, 0 replies; 25+ messages in thread
From: Cornelia Huck @ 2015-04-23 12:33 UTC (permalink / raw)
  To: Christian Borntraeger; +Cc: jfrei, Thomas Huth, qemu-devel, agraf

On Thu, 23 Apr 2015 14:26:44 +0200
Christian Borntraeger <borntraeger@de.ibm.com> wrote:

> Am 09.04.2015 um 10:51 schrieb Cornelia Huck:
> > From: Thomas Huth <thuth@linux.vnet.ibm.com>
> > 
> > The "switch_amode" parameter has been removed from the Linux kernel
> > sources since version 3.7 - so QEMU should not advise this parameter
> > nowadays anymore.
> > 
> > Signed-off-by: Thomas Huth <thuth@linux.vnet.ibm.com>
> > Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> > ---
> >  kvm-all.c | 5 -----
> >  1 file changed, 5 deletions(-)
> > 
> > diff --git a/kvm-all.c b/kvm-all.c
> > index dd44f8c..7c8537b 100644
> > --- a/kvm-all.c
> > +++ b/kvm-all.c
> > @@ -1542,11 +1542,6 @@ static int kvm_init(MachineState *ms)
> >      if (ret < 0) {
> >          fprintf(stderr, "ioctl(KVM_CREATE_VM) failed: %d %s\n", -ret,
> >                  strerror(-ret));
> > -
> > -#ifdef TARGET_S390X
> > -        fprintf(stderr, "Please add the 'switch_amode' kernel parameter to "
> > -                        "your host kernel command line\n");
> > -#endif
> >          goto err;
> >      }
> > 
> 
> Can you drop this patch from your upcoming pull request?
> 
> See the discussion on http://marc.info/?l=kvm&m=142978728714865&w=2
> We might want to change the error message instead of getting rid of it.

Can do, although I think what we want in the end is something different
from the current message anyway.

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

* Re: [Qemu-devel] [PATCH 07/10] linux-headers: update
  2015-04-09  8:51 ` [Qemu-devel] [PATCH 07/10] linux-headers: update Cornelia Huck
@ 2015-04-24  9:30   ` Paolo Bonzini
  2015-04-24 10:23     ` Cornelia Huck
  0 siblings, 1 reply; 25+ messages in thread
From: Paolo Bonzini @ 2015-04-24  9:30 UTC (permalink / raw)
  To: Cornelia Huck, qemu-devel; +Cc: borntraeger, jfrei, agraf



On 09/04/2015 10:51, Cornelia Huck wrote:
> This updates linux-headers against kvm/queue (commit
> c7f0cf16df59ac98b58af974c3947cac21402e29), with the exception of
> avoiding undoing 2106ba30105969262a7810417a57524d9a225b91
> ("uapi/virtio_scsi: allow overriding CDB/SENSE size").
> 
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> ---
>  linux-headers/asm-arm/kvm.h   |   3 +
>  linux-headers/asm-arm64/kvm.h |   3 +
>  linux-headers/asm-mips/kvm.h  | 164 ++++++++++++++++++++++++++----------------
>  linux-headers/asm-s390/kvm.h  |   4 ++
>  linux-headers/linux/kvm.h     |  65 ++++++++++++++++-
>  5 files changed, 175 insertions(+), 64 deletions(-)

Note that this commit was rebased, so you'll have to regenerate this
patch against Linus's tree.

Thanks,

Paolo

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

* Re: [Qemu-devel] [PATCH 07/10] linux-headers: update
  2015-04-24  9:30   ` Paolo Bonzini
@ 2015-04-24 10:23     ` Cornelia Huck
  0 siblings, 0 replies; 25+ messages in thread
From: Cornelia Huck @ 2015-04-24 10:23 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: borntraeger, jfrei, qemu-devel, agraf

On Fri, 24 Apr 2015 11:30:44 +0200
Paolo Bonzini <pbonzini@redhat.com> wrote:

> 
> 
> On 09/04/2015 10:51, Cornelia Huck wrote:
> > This updates linux-headers against kvm/queue (commit
> > c7f0cf16df59ac98b58af974c3947cac21402e29), with the exception of
> > avoiding undoing 2106ba30105969262a7810417a57524d9a225b91
> > ("uapi/virtio_scsi: allow overriding CDB/SENSE size").
> > 
> > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> > ---
> >  linux-headers/asm-arm/kvm.h   |   3 +
> >  linux-headers/asm-arm64/kvm.h |   3 +
> >  linux-headers/asm-mips/kvm.h  | 164 ++++++++++++++++++++++++++----------------
> >  linux-headers/asm-s390/kvm.h  |   4 ++
> >  linux-headers/linux/kvm.h     |  65 ++++++++++++++++-
> >  5 files changed, 175 insertions(+), 64 deletions(-)
> 
> Note that this commit was rebased, so you'll have to regenerate this
> patch against Linus's tree.

Yep, noted.

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

end of thread, other threads:[~2015-04-24 10:23 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-09  8:51 [Qemu-devel] [PATCH 00/10] first pile of s390x patches for 2.4 Cornelia Huck
2015-04-09  8:51 ` [Qemu-devel] [PATCH 01/10] s390x/kvm: Remove message about "switch_amode" kernel parameter Cornelia Huck
2015-04-23 12:26   ` Christian Borntraeger
2015-04-23 12:33     ` Cornelia Huck
2015-04-09  8:51 ` [Qemu-devel] [PATCH 02/10] virtio-ccw: sort into categories Cornelia Huck
2015-04-20 14:47   ` Christian Borntraeger
2015-04-09  8:51 ` [Qemu-devel] [PATCH 03/10] s390-virtio: " Cornelia Huck
2015-04-20 14:47   ` Christian Borntraeger
2015-04-09  8:51 ` [Qemu-devel] [PATCH 04/10] sclp: " Cornelia Huck
2015-04-20 14:48   ` Christian Borntraeger
2015-04-09  8:51 ` [Qemu-devel] [PATCH 05/10] s390x/ipl: " Cornelia Huck
2015-04-20 14:48   ` Christian Borntraeger
2015-04-09  8:51 ` [Qemu-devel] [PATCH 06/10] s390x/mmu: Use access type definitions instead of magic values Cornelia Huck
2015-04-09  8:51 ` [Qemu-devel] [PATCH 07/10] linux-headers: update Cornelia Huck
2015-04-24  9:30   ` Paolo Bonzini
2015-04-24 10:23     ` Cornelia Huck
2015-04-09  8:51 ` [Qemu-devel] [PATCH 08/10] s390x/kvm: Put vm name, extended name and UUID into STSI322 SYSIB Cornelia Huck
2015-04-09  8:51 ` [Qemu-devel] [PATCH 09/10] s390x/mmu: Use ioctl for reading and writing from/to guest memory Cornelia Huck
2015-04-20 14:55   ` Christian Borntraeger
2015-04-21 19:12     ` Alexander Graf
2015-04-21 19:34       ` Christian Borntraeger
2015-04-21 19:36         ` Alexander Graf
2015-04-21 19:48           ` Christian Borntraeger
2015-04-22  8:37             ` Cornelia Huck
2015-04-09  8:51 ` [Qemu-devel] [PATCH 10/10] s390x/kvm: Support access register mode for KVM_S390_MEM_OP ioctl Cornelia Huck

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.