Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/borntraeger/tags/kvm-s390-20140…
Browse files Browse the repository at this point in the history
…901' into staging

s390x/kvm: Several updates/fixes/features

1. s390x/kvm: avoid synchronize_rcu's in kernel
----------------------------------------------
The first patches change s390x/kvm code to issue VCPU specific ioctls
from the VCPU thread. This will avoid unnecessary synchronize_rcu in
the kernel, which caused a noticably slowdown with many guest CPUs.
It speeds up all start/restart/reset operations involving cpus
drastically.

2. s390-ccw.img: block size and DASD format support
---------------------------------------------------
The second part changes the s390-ccw bios to IPL (boot)  more disk
formats than before. Furthermore a small fix is made to the console
output of the bios.

3. s390: Support for Hotplug of Standby Memory
----------------------------------------------
The third part adds support in s390 for a pool of standby memory,
which can be set online/offline by the guest (ie, via chmem).
The standby pool of memory is allocated as the difference between
the initial memory setting and the maxmem setting.
As part of this work, additional results are provided for the
Read SCP Information SCLP, and new implentation is added for the
Read Storage Element Information, Attach Storage Element,
Assign Storage and Unassign Storage SCLPs, which enables the s390
guest to manipulate the standby memory pool.

This patchset is based on work originally done by Jeng-Fang (Nick)
Wang.

Sample qemu command snippet:

qemu -machine s390-ccw-virtio  -m 1024M,maxmem=2048M,slots=32 -enable-kvm

This will allocate 1024M of active memory, and another 1024M
of standby memory.  Example output from s390-tools lsmem:
=============================================================================
0x0000000000000000-0x000000000fffffff        256  online   no         0-127
0x0000000010000000-0x000000001fffffff        256  online   yes        128-255
0x0000000020000000-0x000000003fffffff        512  online   no         256-511
0x0000000040000000-0x000000007fffffff       1024  offline  -          512-1023

Memory device size  : 2 MB
Memory block size   : 256 MB
Total online memory : 1024 MB
Total offline memory: 1024 MB

The guest can dynamically enable part or all of the standby pool
via the s390-tools chmem, for example:

chmem -e 512M

And can attempt to dynamically disable:

chmem -d 512M

4. s390x/gdb: various fixes
---------------------------
* Patch 1 fixes a bug where the cc was changed accidentally.
* Patch 2 adds the gdb feature XML files for s390x
* Patch 3 Define acr and fpr registers as coprocessor registers. This allows us
   to reuse the feature XML files.
* Patch 4 whitespace fixes

# gpg: Signature made Mon 01 Sep 2014 12:53:39 BST using RSA key ID B5A61C7C
# gpg: Can't check signature: public key not found

* remotes/borntraeger/tags/kvm-s390-20140901:
  s390x/gdb: coding style fixes
  s390x/gdb: generate target.xml and handle fp/ac as coprocessors
  s390x/gdb: add the feature xml files for s390x
  s390x/gdb: don't touch the cc if tcg is not enabled
  sclp-s390: Add memory hotplug SCLPs
  s390-virtio: Apply same memory boundaries as virtio-ccw
  virtio-ccw: Include standby memory when calculating storage increment
  sclp-s390: Add device to manage s390 memory hotplug
  pc-bios/s390-ccw.img binary update
  pc-bios/s390-ccw: Do proper console setup
  pc-bios/s390-ccw: IPL from DASD with format variations
  pc-bios/s390-ccw Really big EAV ECKD DASD handling
  pc-bios/s390-ccw Improve ECKD informational message
  pc-bios/s390-ccw: handle more ECKD DASD block sizes
  pc-bios/s390-ccw: support all virtio block size
  s390x/kvm: execute the first cpu reset on the vcpu thread
  s390x/kvm: execute "system reset" cpu resets on the vcpu thread
  s390x/kvm: execute sigp orders on the target vcpu thread
  s390x/kvm: run guest triggered resets on the target vcpu thread

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Sep 1, 2014
2 parents 988f463 + 218829d commit 5cd1475
Show file tree
Hide file tree
Showing 20 changed files with 692 additions and 173 deletions.
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -5093,6 +5093,7 @@ case "$target_name" in
echo "TARGET_ABI32=y" >> $config_target_mak
;;
s390x)
gdb_xml_files="s390x-core64.xml s390-acr.xml s390-fpr.xml"
;;
unicore32)
;;
Expand Down
26 changes: 26 additions & 0 deletions gdb-xml/s390-acr.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<!-- Copyright (C) 2010-2014 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. -->

<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.s390.acr">
<reg name="acr0" bitsize="32" type="uint32" group="access"/>
<reg name="acr1" bitsize="32" type="uint32" group="access"/>
<reg name="acr2" bitsize="32" type="uint32" group="access"/>
<reg name="acr3" bitsize="32" type="uint32" group="access"/>
<reg name="acr4" bitsize="32" type="uint32" group="access"/>
<reg name="acr5" bitsize="32" type="uint32" group="access"/>
<reg name="acr6" bitsize="32" type="uint32" group="access"/>
<reg name="acr7" bitsize="32" type="uint32" group="access"/>
<reg name="acr8" bitsize="32" type="uint32" group="access"/>
<reg name="acr9" bitsize="32" type="uint32" group="access"/>
<reg name="acr10" bitsize="32" type="uint32" group="access"/>
<reg name="acr11" bitsize="32" type="uint32" group="access"/>
<reg name="acr12" bitsize="32" type="uint32" group="access"/>
<reg name="acr13" bitsize="32" type="uint32" group="access"/>
<reg name="acr14" bitsize="32" type="uint32" group="access"/>
<reg name="acr15" bitsize="32" type="uint32" group="access"/>
</feature>
27 changes: 27 additions & 0 deletions gdb-xml/s390-fpr.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<!-- Copyright (C) 2010-2014 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. -->

<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.s390.fpr">
<reg name="fpc" bitsize="32" type="uint32" group="float"/>
<reg name="f0" bitsize="64" type="ieee_double" group="float"/>
<reg name="f1" bitsize="64" type="ieee_double" group="float"/>
<reg name="f2" bitsize="64" type="ieee_double" group="float"/>
<reg name="f3" bitsize="64" type="ieee_double" group="float"/>
<reg name="f4" bitsize="64" type="ieee_double" group="float"/>
<reg name="f5" bitsize="64" type="ieee_double" group="float"/>
<reg name="f6" bitsize="64" type="ieee_double" group="float"/>
<reg name="f7" bitsize="64" type="ieee_double" group="float"/>
<reg name="f8" bitsize="64" type="ieee_double" group="float"/>
<reg name="f9" bitsize="64" type="ieee_double" group="float"/>
<reg name="f10" bitsize="64" type="ieee_double" group="float"/>
<reg name="f11" bitsize="64" type="ieee_double" group="float"/>
<reg name="f12" bitsize="64" type="ieee_double" group="float"/>
<reg name="f13" bitsize="64" type="ieee_double" group="float"/>
<reg name="f14" bitsize="64" type="ieee_double" group="float"/>
<reg name="f15" bitsize="64" type="ieee_double" group="float"/>
</feature>
28 changes: 28 additions & 0 deletions gdb-xml/s390x-core64.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0"?>
<!-- Copyright (C) 2010-2014 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. -->

<!DOCTYPE feature SYSTEM "gdb-target.dtd">
<feature name="org.gnu.gdb.s390.core">
<reg name="pswm" bitsize="64" type="uint64" group="psw"/>
<reg name="pswa" bitsize="64" type="uint64" group="psw"/>
<reg name="r0" bitsize="64" type="uint64" group="general"/>
<reg name="r1" bitsize="64" type="uint64" group="general"/>
<reg name="r2" bitsize="64" type="uint64" group="general"/>
<reg name="r3" bitsize="64" type="uint64" group="general"/>
<reg name="r4" bitsize="64" type="uint64" group="general"/>
<reg name="r5" bitsize="64" type="uint64" group="general"/>
<reg name="r6" bitsize="64" type="uint64" group="general"/>
<reg name="r7" bitsize="64" type="uint64" group="general"/>
<reg name="r8" bitsize="64" type="uint64" group="general"/>
<reg name="r9" bitsize="64" type="uint64" group="general"/>
<reg name="r10" bitsize="64" type="uint64" group="general"/>
<reg name="r11" bitsize="64" type="uint64" group="general"/>
<reg name="r12" bitsize="64" type="uint64" group="general"/>
<reg name="r13" bitsize="64" type="uint64" group="general"/>
<reg name="r14" bitsize="64" type="uint64" group="general"/>
<reg name="r15" bitsize="64" type="uint64" group="general"/>
</feature>
46 changes: 38 additions & 8 deletions hw/s390x/s390-virtio-ccw.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "ioinst.h"
#include "css.h"
#include "virtio-ccw.h"
#include "qemu/config-file.h"

#define TYPE_S390_CCW_MACHINE "s390-ccw-machine"

Expand Down Expand Up @@ -86,17 +87,35 @@ static void ccw_init(MachineState *machine)
ram_addr_t my_ram_size = machine->ram_size;
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
int shift = 0;
sclpMemoryHotplugDev *mhd = init_sclp_memory_hotplug_dev();
uint8_t *storage_keys;
int ret;
VirtualCssBus *css_bus;

/* s390x ram size detection needs a 16bit multiplier + an increment. So
guests > 64GB can be specified in 2MB steps etc. */
while ((my_ram_size >> (20 + shift)) > 65535) {
shift++;
QemuOpts *opts = qemu_opts_find(qemu_find_opts("memory"), NULL);
ram_addr_t pad_size = 0;
ram_addr_t maxmem = qemu_opt_get_size(opts, "maxmem", my_ram_size);
ram_addr_t standby_mem_size = maxmem - my_ram_size;

/* The storage increment size is a multiple of 1M and is a power of 2.
* The number of storage increments must be MAX_STORAGE_INCREMENTS or fewer.
* The variable 'mhd->increment_size' is an exponent of 2 that can be
* used to calculate the size (in bytes) of an increment. */
mhd->increment_size = 20;
while ((my_ram_size >> mhd->increment_size) > MAX_STORAGE_INCREMENTS) {
mhd->increment_size++;
}
while ((standby_mem_size >> mhd->increment_size) > MAX_STORAGE_INCREMENTS) {
mhd->increment_size++;
}
my_ram_size = my_ram_size >> (20 + shift) << (20 + shift);

/* The core and standby memory areas need to be aligned with
* the increment size. In effect, this can cause the
* user-specified memory size to be rounded down to align
* with the nearest increment boundary. */
standby_mem_size = standby_mem_size >> mhd->increment_size
<< mhd->increment_size;
my_ram_size = my_ram_size >> mhd->increment_size
<< mhd->increment_size;

/* let's propagate the changed ram size into the global variable. */
ram_size = my_ram_size;
Expand All @@ -111,11 +130,22 @@ static void ccw_init(MachineState *machine)
/* register hypercalls */
virtio_ccw_register_hcalls();

/* allocate RAM */
/* allocate RAM for core */
memory_region_init_ram(ram, NULL, "s390.ram", my_ram_size);
vmstate_register_ram_global(ram);
memory_region_add_subregion(sysmem, 0, ram);

/* If the size of ram is not on a MEM_SECTION_SIZE boundary,
calculate the pad size necessary to force this boundary. */
if (standby_mem_size) {
if (my_ram_size % MEM_SECTION_SIZE) {
pad_size = MEM_SECTION_SIZE - my_ram_size % MEM_SECTION_SIZE;
}
my_ram_size += standby_mem_size + pad_size;
mhd->pad_size = pad_size;
mhd->standby_mem_size = standby_mem_size;
}

/* allocate storage keys */
storage_keys = g_malloc0(my_ram_size / TARGET_PAGE_SIZE);

Expand Down
15 changes: 9 additions & 6 deletions hw/s390x/s390-virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,21 @@ static void s390_init(MachineState *machine)
ram_addr_t my_ram_size = machine->ram_size;
MemoryRegion *sysmem = get_system_memory();
MemoryRegion *ram = g_new(MemoryRegion, 1);
int shift = 0;
int increment_size = 20;
uint8_t *storage_keys;
void *virtio_region;
hwaddr virtio_region_len;
hwaddr virtio_region_start;

/* s390x ram size detection needs a 16bit multiplier + an increment. So
guests > 64GB can be specified in 2MB steps etc. */
while ((my_ram_size >> (20 + shift)) > 65535) {
shift++;
/*
* The storage increment size is a multiple of 1M and is a power of 2.
* The number of storage increments must be MAX_STORAGE_INCREMENTS or
* fewer.
*/
while ((my_ram_size >> increment_size) > MAX_STORAGE_INCREMENTS) {
increment_size++;
}
my_ram_size = my_ram_size >> (20 + shift) << (20 + shift);
my_ram_size = my_ram_size >> increment_size << increment_size;

/* let's propagate the changed ram size into the global variable. */
ram_size = my_ram_size;
Expand Down
Loading

0 comments on commit 5cd1475

Please sign in to comment.