Skip to contentSkip to conversation

s390 patch queue 2012-10-29

GIT PULL New Alexander Graf 2 participants 9 messages Oct 29, 2012 – Oct 30, 2012

lore
Share & tools
lore
#1 lore raw

PATCH 1/7 s390x: fix -initrd in virtio machine

In reply to Alexander Graf

When using -initrd in the virtio machine, we need to indicate the initrd start and size inside the kernel image. These parameters need to be stored in native endianness.

---
 hw/s390-virtio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/s390-virtio.c +2 -2
index 85bd13e..52fad37 100644
@@ -285,8 +285,8 @@ static void s390_init(QEMUMachineInitArgs *args)
         }
 
         /* we have to overwrite values in the kernel image, which are "rom" */
-        memcpy(rom_ptr(INITRD_PARM_START), &initrd_offset, 8);
-        memcpy(rom_ptr(INITRD_PARM_SIZE), &initrd_size, 8);
+        stq_p(rom_ptr(INITRD_PARM_START), initrd_offset);
+        stq_p(rom_ptr(INITRD_PARM_SIZE), initrd_size);
     }
 
     if (rom_ptr(KERN_PARM_AREA)) {
Signature · 1 line
1.6.0.2
#0 lore raw

Hi Blue / Aurelien,

This is my current patch queue for s390. Please pull.

Alex

The following changes since commit b308c82cbda44e138ef990af64d44a5613c16092:
Avi Kivity (1):
pci: avoid destroying bridge address space windows in a transaction

are available in the git repository at:

git://repo.or.cz/qemu/agraf.git s390-for-upstream

Alexander Graf (1):

      s390x: fix -initrd in virtio machine

Christian Borntraeger (1):
s390: use sync regs for register transfer

Heinz Graalfs (5):
s390/kvm_stat: correct sys_perf_event_open syscall number
s390: sclp base support
s390: sclp event support
s390: sclp signal quiesce support
s390: sclp ascii console support

 hw/s390-virtio.c           |    6 +-
 hw/s390x/Makefile.objs     |    3 +
 hw/s390x/event-facility.c  |  398 ++++++++++++++++++++++++++++++++++++++++++++
 hw/s390x/event-facility.h  |   96 +++++++++++
 hw/s390x/sclp.c            |  163 ++++++++++++++++++
 hw/s390x/sclp.h            |  118 +++++++++++++
 hw/s390x/sclpconsole.c     |  306 ++++++++++++++++++++++++++++++++++
 hw/s390x/sclpquiesce.c     |  123 ++++++++++++++
 scripts/kvm/kvm_stat       |   11 +-
 target-s390x/cpu.h         |   13 +--
 target-s390x/kvm.c         |  117 ++++++++++---
 target-s390x/misc_helper.c |   45 +-----
 12 files changed, 1315 insertions(+), 84 deletions(-)
 create mode 100644 hw/s390x/event-facility.c
 create mode 100644 hw/s390x/event-facility.h
 create mode 100644 hw/s390x/sclp.c
 create mode 100644 hw/s390x/sclp.h
 create mode 100644 hw/s390x/sclpconsole.c
 create mode 100644 hw/s390x/sclpquiesce.c
#2 lore raw

PATCH 2/7 s390/kvm_stat: correct sys_perf_event_open syscall number

From: Heinz Graalfs <[email protected]>

Correct sys_perf_event_open syscall number for s390 architecture
- the hardcoded syscall number 298 is for x86 but should be different for other architectures.
In case we figure out via /proc/cpuinfo that we are running on s390 the appropriate syscall number is used from map syscall_numbers; other architectures can extend this.

---
 scripts/kvm/kvm_stat |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
scripts/kvm/kvm_stat +9 -2
index e8d68f0..762544b 100755
@@ -170,6 +170,12 @@ vendor_exit_reasons = {
     'IBM/S390': s390_exit_reasons,
 }
 
+syscall_numbers = {
+    'IBM/S390': 331,
+}
+
+sc_perf_evt_open = 298
+
 exit_reasons = None
 
 for line in file('/proc/cpuinfo').readlines():
@@ -177,7 +183,8 @@ for line in file('/proc/cpuinfo').readlines():
         for flag in line.split():
             if flag in vendor_exit_reasons:
                 exit_reasons = vendor_exit_reasons[flag]
-
+            if flag in syscall_numbers:
+                sc_perf_evt_open = syscall_numbers[flag]
 filters = {
     'kvm_exit': ('exit_reason', exit_reasons)
 }
@@ -206,7 +213,7 @@ class perf_event_attr(ctypes.Structure):
                 ('bp_len', ctypes.c_uint64),
                 ]
 def _perf_event_open(attr, pid, cpu, group_fd, flags):
-    return syscall(298, ctypes.pointer(attr), ctypes.c_int(pid),
+    return syscall(sc_perf_evt_open, ctypes.pointer(attr), ctypes.c_int(pid),
                    ctypes.c_int(cpu), ctypes.c_int(group_fd),
                    ctypes.c_long(flags))
 
Signature · 1 line
1.6.0.2
#3 lore raw

PATCH 3/7 s390: use sync regs for register transfer

In reply to Alexander Graf

From: Christian Borntraeger <[email protected]>

Newer kernels provide the guest registers in kvm_run. Lets use those if available (i.e. the capability is set). This avoids ioctls on cpu_synchronize_state making intercepts faster.

In addition, we have now the prefix register, the access registers the control registers up to date. This helps in certain cases, e.g. for resolving kernel module addresses with gdb on a guest.

On return, we update the registers according to the level statement, i.e. we put all registers for KVM_PUT_FULL_STATE and _RESET_STATE.

---
 target-s390x/kvm.c |  112 ++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 92 insertions(+), 20 deletions(-)
target-s390x/kvm.c +92 -20
index 07edf93..e19a44d 100644
@@ -67,8 +67,11 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
     KVM_CAP_LAST_INFO
 };
 
+static int cap_sync_regs;
+
 int kvm_arch_init(KVMState *s)
 {
+    cap_sync_regs = kvm_check_extension(s, KVM_CAP_SYNC_REGS);
     return 0;
 }
 
@@ -90,47 +93,116 @@ void kvm_arch_reset_vcpu(CPUS390XState *env)
 
 int kvm_arch_put_registers(CPUS390XState *env, int level)
 {
+    struct kvm_sregs sregs;
     struct kvm_regs regs;
     int ret;
     int i;
 
-    ret = kvm_vcpu_ioctl(env, KVM_GET_REGS, &regs);
-    if (ret < 0) {
-        return ret;
-    }
+    /* always save the PSW  and the GPRS*/
+    env->kvm_run->psw_addr = env->psw.addr;
+    env->kvm_run->psw_mask = env->psw.mask;
 
-    for (i = 0; i < 16; i++) {
-        regs.gprs[i] = env->regs[i];
+    if (cap_sync_regs && env->kvm_run->kvm_valid_regs & KVM_SYNC_GPRS) {
+        for (i = 0; i < 16; i++) {
+            env->kvm_run->s.regs.gprs[i] = env->regs[i];
+            env->kvm_run->kvm_dirty_regs |= KVM_SYNC_GPRS;
+        }
+    } else {
+        for (i = 0; i < 16; i++) {
+            regs.gprs[i] = env->regs[i];
+        }
+        ret = kvm_vcpu_ioctl(env, KVM_SET_REGS, &regs);
+        if (ret < 0) {
+            return ret;
+        }
     }
 
-    ret = kvm_vcpu_ioctl(env, KVM_SET_REGS, &regs);
-    if (ret < 0) {
-        return ret;
+    /* Do we need to save more than that? */
+    if (level == KVM_PUT_RUNTIME_STATE) {
+        return 0;
     }
 
-    env->kvm_run->psw_addr = env->psw.addr;
-    env->kvm_run->psw_mask = env->psw.mask;
+    if (cap_sync_regs &&
+        env->kvm_run->kvm_valid_regs & KVM_SYNC_ACRS &&
+        env->kvm_run->kvm_valid_regs & KVM_SYNC_CRS) {
+        for (i = 0; i < 16; i++) {
+            env->kvm_run->s.regs.acrs[i] = env->aregs[i];
+            env->kvm_run->s.regs.crs[i] = env->cregs[i];
+        }
+        env->kvm_run->kvm_dirty_regs |= KVM_SYNC_ACRS;
+        env->kvm_run->kvm_dirty_regs |= KVM_SYNC_CRS;
+    } else {
+        for (i = 0; i < 16; i++) {
+            sregs.acrs[i] = env->aregs[i];
+            sregs.crs[i] = env->cregs[i];
+        }
+        ret = kvm_vcpu_ioctl(env, KVM_SET_SREGS, &sregs);
+        if (ret < 0) {
+            return ret;
+        }
+    }
 
-    return ret;
+    /* Finally the prefix */
+    if (cap_sync_regs && env->kvm_run->kvm_valid_regs & KVM_SYNC_PREFIX) {
+        env->kvm_run->s.regs.prefix = env->psa;
+        env->kvm_run->kvm_dirty_regs |= KVM_SYNC_PREFIX;
+    } else {
+        /* prefix is only supported via sync regs */
+    }
+    return 0;
 }
 
 int kvm_arch_get_registers(CPUS390XState *env)
 {
-    int ret;
+    struct kvm_sregs sregs;
     struct kvm_regs regs;
+    int ret;
     int i;
 
-    ret = kvm_vcpu_ioctl(env, KVM_GET_REGS, &regs);
-    if (ret < 0) {
-        return ret;
+    /* get the PSW */
+    env->psw.addr = env->kvm_run->psw_addr;
+    env->psw.mask = env->kvm_run->psw_mask;
+
+    /* the GPRS */
+    if (cap_sync_regs && env->kvm_run->kvm_valid_regs & KVM_SYNC_GPRS) {
+        for (i = 0; i < 16; i++) {
+            env->regs[i] = env->kvm_run->s.regs.gprs[i];
+        }
+    } else {
+        ret = kvm_vcpu_ioctl(env, KVM_GET_REGS, &regs);
+        if (ret < 0) {
+            return ret;
+        }
+         for (i = 0; i < 16; i++) {
+            env->regs[i] = regs.gprs[i];
+        }
     }
 
-    for (i = 0; i < 16; i++) {
-        env->regs[i] = regs.gprs[i];
+    /* The ACRS and CRS */
+    if (cap_sync_regs &&
+        env->kvm_run->kvm_valid_regs & KVM_SYNC_ACRS &&
+        env->kvm_run->kvm_valid_regs & KVM_SYNC_CRS) {
+        for (i = 0; i < 16; i++) {
+            env->aregs[i] = env->kvm_run->s.regs.acrs[i];
+            env->cregs[i] = env->kvm_run->s.regs.crs[i];
+        }
+    } else {
+        ret = kvm_vcpu_ioctl(env, KVM_GET_SREGS, &sregs);
+        if (ret < 0) {
+            return ret;
+        }
+         for (i = 0; i < 16; i++) {
+            env->aregs[i] = sregs.acrs[i];
+            env->cregs[i] = sregs.crs[i];
+        }
     }
 
-    env->psw.addr = env->kvm_run->psw_addr;
-    env->psw.mask = env->kvm_run->psw_mask;
+    /* Finally the prefix */
+    if (cap_sync_regs && env->kvm_run->kvm_valid_regs & KVM_SYNC_PREFIX) {
+        env->psa = env->kvm_run->s.regs.prefix;
+    } else {
+        /* no prefix without sync regs */
+    }
 
     return 0;
 }
Signature · 1 line
1.6.0.2
#4 lore raw

PATCH 4/7 s390: sclp base support

In reply to Alexander Graf

From: Heinz Graalfs <[email protected]>

This adds a more generic infrastructure for handling Service-Call requests on s390. Currently we only support a small subset of Read SCP Info directly in target-s390x. This patch provides the base infrastructure for supporting more commands and moves Read SCP Info.
In the future we could add additional commands for hotplug, call home and event handling.

---
 hw/s390x/Makefile.objs     |    1 +
 hw/s390x/sclp.c            |  118 ++++++++++++++++++++++++++++++++++++++++++++
 hw/s390x/sclp.h            |   76 ++++++++++++++++++++++++++++
 target-s390x/cpu.h         |   13 +-----
 target-s390x/kvm.c         |    5 +--
 target-s390x/misc_helper.c |   45 +----------------
 6 files changed, 198 insertions(+), 60 deletions(-)
 create mode 100644 hw/s390x/sclp.c
 create mode 100644 hw/s390x/sclp.h
hw/s390x/Makefile.objs +1 -0
index dcdcac8..1c14b96 100644
@@ -1,3 +1,4 @@
 obj-y = s390-virtio-bus.o s390-virtio.o
 
 obj-y := $(addprefix ../,$(obj-y))
+obj-y += sclp.o
hw/s390x/sclp.c new file +118 -0

118 lines not on this page · raw message

hw/s390x/sclp.h new file +76 -0

76 lines not on this page · raw message

target-s390x/cpu.h +1 -12
index 9997765..5be6e83 100644
@@ -596,17 +596,6 @@ static inline const char *cc_name(int cc_op)
     return cc_names[cc_op];
 }
 
-/* SCLP PV interface defines */
-#define SCLP_CMDW_READ_SCP_INFO         0x00020001
-#define SCLP_CMDW_READ_SCP_INFO_FORCED  0x00120001
-
-#define SCP_LENGTH                      0x00
-#define SCP_FUNCTION_CODE               0x02
-#define SCP_CONTROL_MASK                0x03
-#define SCP_RESPONSE_CODE               0x06
-#define SCP_MEM_CODE                    0x08
-#define SCP_INCREMENT                   0x0a
-
 typedef struct LowCore
 {
     /* prefix area: defined by architecture */
@@ -955,7 +944,7 @@ static inline void ebcdic_put(uint8_t *p, const char *ascii, int len)
 void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr);
 int mmu_translate(CPUS390XState *env, target_ulong vaddr, int rw, uint64_t asc,
                   target_ulong *raddr, int *flags);
-int sclp_service_call(CPUS390XState *env, uint32_t sccb, uint64_t code);
+int sclp_service_call(uint32_t sccb, uint64_t code);
 uint32_t calc_cc(CPUS390XState *env, uint32_t cc_op, uint64_t src, uint64_t dst,
                  uint64_t vr);
 
target-s390x/kvm.c +1 -4
index e19a44d..a66ac43 100644
@@ -60,9 +60,6 @@
 #define SIGP_STORE_STATUS_ADDR          0x0e
 #define SIGP_SET_ARCH                   0x12
 
-#define SCLP_CMDW_READ_SCP_INFO         0x00020001
-#define SCLP_CMDW_READ_SCP_INFO_FORCED  0x00120001
-
 const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
     KVM_CAP_LAST_INFO
 };
@@ -344,7 +341,7 @@ static int kvm_sclp_service_call(CPUS390XState *env, struct kvm_run *run,
     sccb = env->regs[ipbh0 & 0xf];
     code = env->regs[(ipbh0 & 0xf0) >> 4];
 
-    r = sclp_service_call(env, sccb, code);
+    r = sclp_service_call(sccb, code);
     if (r < 0) {
         enter_pgmcheck(env, -r);
     }
target-s390x/misc_helper.c +1 -44

56 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#6 lore raw

PATCH 6/7 s390: sclp signal quiesce support

In reply to Alexander Graf

From: Heinz Graalfs <[email protected]>

This implements the sclp signal quiesce event via the SCLP Event Facility.
This allows to gracefully shutdown a guest by using system_powerdown notifiers. It creates a service interrupt that will trigger a Read Event Data command from the guest. This code will then add an event that is interpreted by linux guests as ctrl-alt-del.

---
 hw/s390x/Makefile.objs    |    1 +
 hw/s390x/event-facility.c |    7 +++
 hw/s390x/sclpquiesce.c    |  123 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 131 insertions(+), 0 deletions(-)
 create mode 100644 hw/s390x/sclpquiesce.c
hw/s390x/Makefile.objs +1 -0
index b32fc52..ed4e61a 100644
@@ -3,3 +3,4 @@ obj-y = s390-virtio-bus.o s390-virtio.o
 obj-y := $(addprefix ../,$(obj-y))
 obj-y += sclp.o
 obj-y += event-facility.o
+obj-y += sclpquiesce.o
hw/s390x/event-facility.c +7 -0
index 1108e2d..9367660 100644
@@ -315,6 +315,7 @@ static void command_handler(SCLPEventFacility *ef, SCCB *sccb, uint64_t code)
 static int init_event_facility(S390SCLPDevice *sdev)
 {
     SCLPEventFacility *event_facility;
+    DeviceState *quiesce;
 
     event_facility = g_malloc0(sizeof(SCLPEventFacility));
     sdev->ef = event_facility;
@@ -327,6 +328,12 @@ static int init_event_facility(S390SCLPDevice *sdev)
     event_facility->sbus.qbus.allow_hotplug = 0;
     event_facility->qdev = (DeviceState *) sdev;
 
+    quiesce = qdev_create(&event_facility->sbus.qbus, "sclpquiesce");
+    if (!quiesce) {
+        return -1;
+    }
+    qdev_init_nofail(quiesce);
+
     return 0;
 }
 
hw/s390x/sclpquiesce.c new file +123 -0

123 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#7 lore raw

PATCH 7/7 s390: sclp ascii console support

In reply to Alexander Graf

From: Heinz Graalfs <[email protected]>

This code adds console support by implementing SCLP's ASCII Console Data event. This is the same console as LPARs ASCII console or z/VMs sysascii.

The console can be specified manually with something like
-chardev stdio,id=charconsole0 -device sclpconsole,chardev=charconsole0,id=console0

Newer kernels will autodetect that console and prefer that over virtio console.

When data is received from the character layer it creates a service interrupt to trigger a Read Event Data command from the guest that will pick up the received character byte-stream.
When characters are echo'ed by the linux guest a Write Event Data occurs which is forwarded by the Event Facility to the console that supports a corresponding mask value.
Console resizing is not supported.
The character layer byte-stream is buffered using a fixed size iov buffer.

---
 hw/s390x/Makefile.objs |    2 +-
 hw/s390x/sclpconsole.c |  306 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 307 insertions(+), 1 deletions(-)
 create mode 100644 hw/s390x/sclpconsole.c
hw/s390x/Makefile.objs +1 -1
index ed4e61a..096dfcd 100644
@@ -3,4 +3,4 @@ obj-y = s390-virtio-bus.o s390-virtio.o
 obj-y := $(addprefix ../,$(obj-y))
 obj-y += sclp.o
 obj-y += event-facility.o
-obj-y += sclpquiesce.o
+obj-y += sclpquiesce.o sclpconsole.o
hw/s390x/sclpconsole.c new file +306 -0

306 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#5 lore raw

PATCH 5/7 s390: sclp event support

In reply to Alexander Graf

From: Heinz Graalfs <[email protected]>

Several SCLP features are considered to be events. Those events don't provide SCLP commands on their own, instead they are all based on Read Event Data, Write Event Data, Write Event Mask and the service interrupt. Follow-on patches will provide SCLP's Signal Quiesce (via system_powerdown) and the ASCII console.
Further down the road the sclp line mode console and configuration change events (e.g. cpu hotplug) can be implemented.

---
 hw/s390-virtio.c          |    2 +
 hw/s390x/Makefile.objs    |    1 +
 hw/s390x/event-facility.c |  391 +++++++++++++++++++++++++++++++++++++++++++++
 hw/s390x/event-facility.h |   96 +++++++++++
 hw/s390x/sclp.c           |   49 ++++++-
 hw/s390x/sclp.h           |   42 +++++
 6 files changed, 579 insertions(+), 2 deletions(-)
 create mode 100644 hw/s390x/event-facility.c
 create mode 100644 hw/s390x/event-facility.h
hw/s390-virtio.c +2 -0
index 52fad37..685cb54 100644
@@ -32,6 +32,7 @@
 #include "exec-memory.h"
 
 #include "hw/s390-virtio-bus.h"
+#include "hw/s390x/sclp.h"
 
 //#define DEBUG_S390
 
@@ -184,6 +185,7 @@ static void s390_init(QEMUMachineInitArgs *args)
 
     /* get a BUS */
     s390_bus = s390_virtio_bus_init(&my_ram_size);
+    s390_sclp_init();
 
     /* allocate RAM */
     memory_region_init_ram(ram, "s390.ram", my_ram_size);
hw/s390x/Makefile.objs +1 -0
index 1c14b96..b32fc52 100644
@@ -2,3 +2,4 @@ obj-y = s390-virtio-bus.o s390-virtio.o
 
 obj-y := $(addprefix ../,$(obj-y))
 obj-y += sclp.o
+obj-y += event-facility.o
hw/s390x/event-facility.c new file +391 -0

391 lines not on this page · raw message

hw/s390x/event-facility.h new file +96 -0

96 lines not on this page · raw message

hw/s390x/sclp.c +47 -2

77 lines not on this page · raw message

hw/s390x/sclp.h +42 -0

71 lines not on this page · raw message

Signature · 1 line
1.6.0.2
#8 lore raw
In reply to Alexander Graf
Quoted 39 lines · Alexander Graf

Hi Blue / Aurelien,

This is my current patch queue for s390. Please pull.

Alex

The following changes since commit b308c82cbda44e138ef990af64d44a5613c16092:
Avi Kivity (1):
pci: avoid destroying bridge address space windows in a transaction

are available in the git repository at:

git://repo.or.cz/qemu/agraf.git s390-for-upstream

Alexander Graf (1):

      s390x: fix -initrd in virtio machine

Christian Borntraeger (1):
s390: use sync regs for register transfer

Heinz Graalfs (5):
s390/kvm_stat: correct sys_perf_event_open syscall number
s390: sclp base support
s390: sclp event support
s390: sclp signal quiesce support
s390: sclp ascii console support

 hw/s390-virtio.c           |    6 +-
 hw/s390x/Makefile.objs     |    3 +
 hw/s390x/event-facility.c  |  398 ++++++++++++++++++++++++++++++++++++++++++++
 hw/s390x/event-facility.h  |   96 +++++++++++
 hw/s390x/sclp.c            |  163 ++++++++++++++++++
 hw/s390x/sclp.h            |  118 +++++++++++++
 hw/s390x/sclpconsole.c     |  306 ++++++++++++++++++++++++++++++++++
 hw/s390x/sclpquiesce.c     |  123 ++++++++++++++
 scripts/kvm/kvm_stat       |   11 +-
 target-s390x/cpu.h         |   13 +--
 target-s390x/kvm.c         |  117 ++++++++++---
Quoted 9 lines
 target-s390x/misc_helper.c |   45 +-----
 12 files changed, 1315 insertions(+), 84 deletions(-)
 create mode 100644 hw/s390x/event-facility.c
 create mode 100644 hw/s390x/event-facility.h
 create mode 100644 hw/s390x/sclp.c
 create mode 100644 hw/s390x/sclp.h
 create mode 100644 hw/s390x/sclpconsole.c
 create mode 100644 hw/s390x/sclpquiesce.c

Thanks, pulled.

Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net