2012-10-29 03:13:22 +01:00
|
|
|
/*
|
|
|
|
* SCLP Support
|
|
|
|
*
|
|
|
|
* Copyright IBM, Corp. 2012
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Christian Borntraeger <borntraeger@de.ibm.com>
|
|
|
|
* Heinz Graalfs <graalfs@linux.vnet.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or (at your
|
|
|
|
* option) any later version. See the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-01-26 19:17:00 +01:00
|
|
|
#include "qemu/osdep.h"
|
include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef. Since then, we've moved to include qemu/osdep.h
everywhere. Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h. That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h. Include qapi/error.h in .c files that need it and don't
get it now. Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly. Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third. Unfortunately, the number depending on
qapi-types.h shrinks only a little. More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-14 09:01:28 +01:00
|
|
|
#include "qapi/error.h"
|
2012-10-29 03:13:22 +01:00
|
|
|
#include "cpu.h"
|
2014-01-20 20:51:49 +01:00
|
|
|
#include "sysemu/sysemu.h"
|
2015-05-29 13:14:50 +02:00
|
|
|
#include "hw/boards.h"
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/s390x/sclp.h"
|
2013-12-18 10:10:49 +01:00
|
|
|
#include "hw/s390x/event-facility.h"
|
2015-01-09 09:04:38 +01:00
|
|
|
#include "hw/s390x/s390-pci-bus.h"
|
2016-03-29 16:34:37 +02:00
|
|
|
#include "hw/s390x/ipl.h"
|
2012-10-29 03:13:22 +01:00
|
|
|
|
2015-05-27 10:04:56 +02:00
|
|
|
static inline SCLPDevice *get_sclp_device(void)
|
|
|
|
{
|
2016-08-10 12:14:19 +02:00
|
|
|
static SCLPDevice *sclp;
|
|
|
|
|
|
|
|
if (!sclp) {
|
|
|
|
sclp = SCLP(object_resolve_path_type("", TYPE_SCLP, NULL));
|
|
|
|
}
|
|
|
|
return sclp;
|
2015-05-27 10:04:56 +02:00
|
|
|
}
|
|
|
|
|
2017-09-13 15:24:16 +02:00
|
|
|
static void prepare_cpu_entries(SCLPDevice *sclp, CPUEntry *entry, int *count)
|
2016-09-05 10:52:27 +02:00
|
|
|
{
|
2017-09-13 15:24:16 +02:00
|
|
|
MachineState *ms = MACHINE(qdev_get_machine());
|
2016-09-05 10:52:29 +02:00
|
|
|
uint8_t features[SCCB_CPU_FEATURE_LEN] = { 0 };
|
2016-09-05 10:52:27 +02:00
|
|
|
int i;
|
|
|
|
|
2016-09-05 10:52:29 +02:00
|
|
|
s390_get_feat_block(S390_FEAT_TYPE_SCLP_CPU, features);
|
2017-09-13 15:24:16 +02:00
|
|
|
for (i = 0, *count = 0; i < ms->possible_cpus->len; i++) {
|
|
|
|
if (!ms->possible_cpus->cpus[i].cpu) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
entry[*count].address = ms->possible_cpus->cpus[i].arch_id;
|
|
|
|
entry[*count].type = 0;
|
|
|
|
memcpy(entry[*count].features, features, sizeof(features));
|
|
|
|
(*count)++;
|
2016-09-05 10:52:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-29 03:13:22 +01:00
|
|
|
/* Provide information about the configuration, CPUs and storage */
|
2015-05-27 10:04:56 +02:00
|
|
|
static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb)
|
2012-10-29 03:13:22 +01:00
|
|
|
{
|
|
|
|
ReadInfo *read_info = (ReadInfo *) sccb;
|
2015-05-29 13:14:50 +02:00
|
|
|
MachineState *machine = MACHINE(qdev_get_machine());
|
2017-09-13 15:24:16 +02:00
|
|
|
int cpu_count;
|
2014-08-28 17:25:35 +02:00
|
|
|
int rnsize, rnmax;
|
2016-03-29 16:34:37 +02:00
|
|
|
IplParameterBlock *ipib = s390_ipl_get_iplb();
|
2014-01-20 20:51:49 +01:00
|
|
|
|
|
|
|
/* CPU information */
|
2017-09-13 15:24:16 +02:00
|
|
|
prepare_cpu_entries(sclp, read_info->entries, &cpu_count);
|
2014-01-20 20:51:49 +01:00
|
|
|
read_info->entries_cpu = cpu_to_be16(cpu_count);
|
|
|
|
read_info->offset_cpu = cpu_to_be16(offsetof(ReadInfo, entries));
|
2017-12-19 09:28:07 +01:00
|
|
|
read_info->highest_cpu = cpu_to_be16(max_cpus - 1);
|
2014-01-20 20:51:49 +01:00
|
|
|
|
2016-09-05 10:52:30 +02:00
|
|
|
read_info->ibc_val = cpu_to_be32(s390_get_ibc_val());
|
|
|
|
|
2016-09-05 10:52:29 +02:00
|
|
|
/* Configuration Characteristic (Extension) */
|
|
|
|
s390_get_feat_block(S390_FEAT_TYPE_SCLP_CONF_CHAR,
|
|
|
|
read_info->conf_char);
|
|
|
|
s390_get_feat_block(S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT,
|
|
|
|
read_info->conf_char_ext);
|
|
|
|
|
2015-01-09 09:04:38 +01:00
|
|
|
read_info->facilities = cpu_to_be64(SCLP_HAS_CPU_INFO |
|
2017-07-06 17:13:14 +02:00
|
|
|
SCLP_HAS_IOA_RECONFIG);
|
2012-10-29 03:13:22 +01:00
|
|
|
|
2016-09-05 10:52:31 +02:00
|
|
|
read_info->mha_pow = s390_get_mha_pow();
|
2016-09-05 10:52:32 +02:00
|
|
|
read_info->hmfai = cpu_to_be32(s390_get_hmfai());
|
2014-08-28 17:25:35 +02:00
|
|
|
|
2015-06-01 13:03:23 +02:00
|
|
|
rnsize = 1 << (sclp->increment_size - 20);
|
2014-08-28 17:25:35 +02:00
|
|
|
if (rnsize <= 128) {
|
|
|
|
read_info->rnsize = rnsize;
|
|
|
|
} else {
|
|
|
|
read_info->rnsize = 0;
|
|
|
|
read_info->rnsize2 = cpu_to_be32(rnsize);
|
|
|
|
}
|
|
|
|
|
s390x/sclp: remove memory hotplug support
From an architecture point of view, nothing can be mapped into the address
space on s390x. All there is is memory. Therefore there is also not really
an interface to communicate such information to the guest. All we can do is
specify the maximum ram address and guests can probe in that range if
memory is available and usable (TPROT).
Also memory hotplug is strange. The guest can decide at some point in
time to add / remove memory in some range. While the hypervisor can deny
to online an increment, all increments have to be predefined and there is
no way of telling the guest about a newly "hotplugged" increment. So if we
specify right now e.g.
-m 2G,slots=2,maxmem=20G
An ordinary fedora guest will happily online (hotplug) all memory,
resulting in a guest consuming 20G. So it really behaves rather like
-m 22G
There is no way to hotplug memory from the outside like on other
architectures. This is of course bad for upper management layers.
As the guest can create/delete memory regions while it is running, of
course migration support is not available and tricky to implement.
With virtualization, it is different. We might want to map something
into guest address space (e.g. fake DAX devices) and not detect it
automatically as memory. So we really want to use the maxmem and slots
parameter just like on all other architectures. Such devices will have
to expose the applicable memory range themselves. To finally be able to
provide memory hotplug to guests, we will need a new paravirtualized
interface to do that (e.g. something into the direction of virtio-mem).
This implies, that maxmem cannot be used for s390x memory hotplug
anymore and has to go. This simplifies the code quite a bit.
As migration support is not working, this change cannot really break
migration as guests without slots and maxmem don't see the SCLP
features. Also, the ram size calculation does not change.
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20180219174231.10874-1-david@redhat.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
[CH: tweaked patch description, as discussed on list]
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
2018-02-19 18:42:31 +01:00
|
|
|
/* we don't support standby memory, maxram_size is never exposed */
|
|
|
|
rnmax = machine->ram_size >> sclp->increment_size;
|
2014-08-28 17:25:35 +02:00
|
|
|
if (rnmax < 0x10000) {
|
|
|
|
read_info->rnmax = cpu_to_be16(rnmax);
|
|
|
|
} else {
|
|
|
|
read_info->rnmax = cpu_to_be16(0);
|
|
|
|
read_info->rnmax2 = cpu_to_be64(rnmax);
|
|
|
|
}
|
|
|
|
|
2016-03-29 16:34:37 +02:00
|
|
|
if (ipib && ipib->flags & DIAG308_FLAGS_LP_VALID) {
|
|
|
|
memcpy(&read_info->loadparm, &ipib->loadparm,
|
|
|
|
sizeof(read_info->loadparm));
|
|
|
|
} else {
|
|
|
|
s390_ipl_set_loadparm(read_info->loadparm);
|
|
|
|
}
|
|
|
|
|
2014-08-28 17:25:35 +02:00
|
|
|
sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_READ_COMPLETION);
|
|
|
|
}
|
|
|
|
|
2014-01-20 20:51:49 +01:00
|
|
|
/* Provide information about the CPU */
|
2015-05-27 10:04:56 +02:00
|
|
|
static void sclp_read_cpu_info(SCLPDevice *sclp, SCCB *sccb)
|
2014-01-20 20:51:49 +01:00
|
|
|
{
|
|
|
|
ReadCpuInfo *cpu_info = (ReadCpuInfo *) sccb;
|
2017-09-13 15:24:16 +02:00
|
|
|
int cpu_count;
|
2014-01-20 20:51:49 +01:00
|
|
|
|
2017-09-13 15:24:16 +02:00
|
|
|
prepare_cpu_entries(sclp, cpu_info->entries, &cpu_count);
|
2014-01-20 20:51:49 +01:00
|
|
|
cpu_info->nr_configured = cpu_to_be16(cpu_count);
|
|
|
|
cpu_info->offset_configured = cpu_to_be16(offsetof(ReadCpuInfo, entries));
|
|
|
|
cpu_info->nr_standby = cpu_to_be16(0);
|
|
|
|
|
|
|
|
/* The standby offset is 16-byte for each CPU */
|
|
|
|
cpu_info->offset_standby = cpu_to_be16(cpu_info->offset_configured
|
|
|
|
+ cpu_info->nr_configured*sizeof(CPUEntry));
|
|
|
|
|
|
|
|
|
|
|
|
sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_READ_COMPLETION);
|
|
|
|
}
|
|
|
|
|
2017-07-06 17:13:14 +02:00
|
|
|
static void sclp_configure_io_adapter(SCLPDevice *sclp, SCCB *sccb,
|
|
|
|
bool configure)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (be16_to_cpu(sccb->h.length) < 16) {
|
|
|
|
rc = SCLP_RC_INSUFFICIENT_SCCB_LENGTH;
|
|
|
|
goto out_err;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (((IoaCfgSccb *)sccb)->atype) {
|
|
|
|
case SCLP_RECONFIG_PCI_ATYPE:
|
|
|
|
if (s390_has_feat(S390_FEAT_ZPCI)) {
|
|
|
|
if (configure) {
|
|
|
|
s390_pci_sclp_configure(sccb);
|
|
|
|
} else {
|
|
|
|
s390_pci_sclp_deconfigure(sccb);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* fallthrough */
|
|
|
|
default:
|
|
|
|
rc = SCLP_RC_ADAPTER_TYPE_NOT_RECOGNIZED;
|
|
|
|
}
|
|
|
|
|
|
|
|
out_err:
|
|
|
|
sccb->h.response_code = cpu_to_be16(rc);
|
|
|
|
}
|
|
|
|
|
2015-05-27 10:04:56 +02:00
|
|
|
static void sclp_execute(SCLPDevice *sclp, SCCB *sccb, uint32_t code)
|
2012-10-29 03:13:22 +01:00
|
|
|
{
|
2015-05-27 10:04:56 +02:00
|
|
|
SCLPDeviceClass *sclp_c = SCLP_GET_CLASS(sclp);
|
|
|
|
SCLPEventFacility *ef = sclp->event_facility;
|
2013-12-18 10:10:49 +01:00
|
|
|
SCLPEventFacilityClass *efc = EVENT_FACILITY_GET_CLASS(ef);
|
2012-10-29 03:13:23 +01:00
|
|
|
|
2014-01-20 20:51:48 +01:00
|
|
|
switch (code & SCLP_CMD_CODE_MASK) {
|
2012-10-29 03:13:22 +01:00
|
|
|
case SCLP_CMDW_READ_SCP_INFO:
|
|
|
|
case SCLP_CMDW_READ_SCP_INFO_FORCED:
|
2015-05-27 10:04:56 +02:00
|
|
|
sclp_c->read_SCP_info(sclp, sccb);
|
2012-10-29 03:13:22 +01:00
|
|
|
break;
|
2014-01-20 20:51:49 +01:00
|
|
|
case SCLP_CMDW_READ_CPU_INFO:
|
2015-05-27 10:04:56 +02:00
|
|
|
sclp_c->read_cpu_info(sclp, sccb);
|
2014-01-20 20:51:49 +01:00
|
|
|
break;
|
2017-07-06 17:13:14 +02:00
|
|
|
case SCLP_CMDW_CONFIGURE_IOA:
|
|
|
|
sclp_configure_io_adapter(sclp, sccb, true);
|
2015-01-09 09:04:38 +01:00
|
|
|
break;
|
2017-07-06 17:13:14 +02:00
|
|
|
case SCLP_CMDW_DECONFIGURE_IOA:
|
|
|
|
sclp_configure_io_adapter(sclp, sccb, false);
|
2015-01-09 09:04:38 +01:00
|
|
|
break;
|
2012-10-29 03:13:22 +01:00
|
|
|
default:
|
2013-12-18 10:10:49 +01:00
|
|
|
efc->command_handler(ef, sccb, code);
|
2012-10-29 03:13:22 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-13 12:55:55 +01:00
|
|
|
int sclp_service_call(CPUS390XState *env, uint64_t sccb, uint32_t code)
|
2012-10-29 03:13:22 +01:00
|
|
|
{
|
2015-05-27 10:04:56 +02:00
|
|
|
SCLPDevice *sclp = get_sclp_device();
|
|
|
|
SCLPDeviceClass *sclp_c = SCLP_GET_CLASS(sclp);
|
2012-10-29 03:13:22 +01:00
|
|
|
int r = 0;
|
|
|
|
SCCB work_sccb;
|
|
|
|
|
|
|
|
hwaddr sccb_len = sizeof(SCCB);
|
|
|
|
|
|
|
|
/* first some basic checks on program checks */
|
2014-01-13 12:55:55 +01:00
|
|
|
if (env->psw.mask & PSW_MASK_PSTATE) {
|
|
|
|
r = -PGM_PRIVILEGED;
|
|
|
|
goto out;
|
|
|
|
}
|
2012-10-29 03:13:22 +01:00
|
|
|
if (cpu_physical_memory_is_io(sccb)) {
|
|
|
|
r = -PGM_ADDRESSING;
|
|
|
|
goto out;
|
|
|
|
}
|
2014-01-13 12:55:55 +01:00
|
|
|
if ((sccb & ~0x1fffUL) == 0 || (sccb & ~0x1fffUL) == env->psa
|
|
|
|
|| (sccb & ~0x7ffffff8UL) != 0) {
|
2012-10-29 03:13:22 +01:00
|
|
|
r = -PGM_SPECIFICATION;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* we want to work on a private copy of the sccb, to prevent guests
|
|
|
|
* from playing dirty tricks by modifying the memory content after
|
|
|
|
* the host has checked the values
|
|
|
|
*/
|
|
|
|
cpu_physical_memory_read(sccb, &work_sccb, sccb_len);
|
|
|
|
|
|
|
|
/* Valid sccb sizes */
|
|
|
|
if (be16_to_cpu(work_sccb.h.length) < sizeof(SCCBHeader) ||
|
|
|
|
be16_to_cpu(work_sccb.h.length) > SCCB_SIZE) {
|
|
|
|
r = -PGM_SPECIFICATION;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2016-06-15 18:14:33 +02:00
|
|
|
sclp_c->execute(sclp, &work_sccb, code);
|
2012-10-29 03:13:22 +01:00
|
|
|
|
|
|
|
cpu_physical_memory_write(sccb, &work_sccb,
|
|
|
|
be16_to_cpu(work_sccb.h.length));
|
|
|
|
|
2015-05-13 15:06:44 +02:00
|
|
|
sclp_c->service_interrupt(sclp, sccb);
|
2012-10-29 03:13:22 +01:00
|
|
|
|
|
|
|
out:
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2015-05-13 15:06:44 +02:00
|
|
|
static void service_interrupt(SCLPDevice *sclp, uint32_t sccb)
|
2012-10-29 03:13:22 +01:00
|
|
|
{
|
2015-05-13 15:06:44 +02:00
|
|
|
SCLPEventFacility *ef = sclp->event_facility;
|
2013-12-18 10:10:49 +01:00
|
|
|
SCLPEventFacilityClass *efc = EVENT_FACILITY_GET_CLASS(ef);
|
|
|
|
|
2012-10-29 03:13:23 +01:00
|
|
|
uint32_t param = sccb & ~3;
|
|
|
|
|
|
|
|
/* Indicate whether an event is still pending */
|
2013-12-18 10:10:49 +01:00
|
|
|
param |= efc->event_pending(ef) ? 1 : 0;
|
2012-10-29 03:13:23 +01:00
|
|
|
|
|
|
|
if (!param) {
|
|
|
|
/* No need to send an interrupt, there's nothing to be notified about */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
s390_sclp_extint(param);
|
2012-10-29 03:13:22 +01:00
|
|
|
}
|
|
|
|
|
2015-05-13 15:06:44 +02:00
|
|
|
void sclp_service_interrupt(uint32_t sccb)
|
|
|
|
{
|
|
|
|
SCLPDevice *sclp = get_sclp_device();
|
|
|
|
SCLPDeviceClass *sclp_c = SCLP_GET_CLASS(sclp);
|
|
|
|
|
|
|
|
sclp_c->service_interrupt(sclp, sccb);
|
|
|
|
}
|
|
|
|
|
2012-10-29 03:13:22 +01:00
|
|
|
/* qemu object creation and initialization functions */
|
|
|
|
|
2012-10-29 03:13:23 +01:00
|
|
|
void s390_sclp_init(void)
|
|
|
|
{
|
2015-05-27 09:49:43 +02:00
|
|
|
Object *new = object_new(TYPE_SCLP);
|
2012-10-29 03:13:23 +01:00
|
|
|
|
2015-05-27 09:49:43 +02:00
|
|
|
object_property_add_child(qdev_get_machine(), TYPE_SCLP, new,
|
|
|
|
NULL);
|
|
|
|
object_unref(OBJECT(new));
|
|
|
|
qdev_init_nofail(DEVICE(new));
|
2012-10-29 03:13:23 +01:00
|
|
|
}
|
2014-08-28 17:25:32 +02:00
|
|
|
|
2015-05-27 09:49:43 +02:00
|
|
|
static void sclp_realize(DeviceState *dev, Error **errp)
|
|
|
|
{
|
2015-05-29 13:53:08 +02:00
|
|
|
MachineState *machine = MACHINE(qdev_get_machine());
|
2015-05-27 09:49:43 +02:00
|
|
|
SCLPDevice *sclp = SCLP(dev);
|
2015-12-18 16:35:25 +01:00
|
|
|
Error *err = NULL;
|
2015-05-29 13:53:08 +02:00
|
|
|
uint64_t hw_limit;
|
|
|
|
int ret;
|
2015-05-27 09:49:43 +02:00
|
|
|
|
|
|
|
object_property_set_bool(OBJECT(sclp->event_facility), true, "realized",
|
2015-12-18 16:35:25 +01:00
|
|
|
&err);
|
|
|
|
if (err) {
|
2015-12-18 16:35:26 +01:00
|
|
|
goto out;
|
2015-05-27 09:49:43 +02:00
|
|
|
}
|
2015-11-23 13:03:08 +01:00
|
|
|
/*
|
|
|
|
* qdev_device_add searches the sysbus for TYPE_SCLP_EVENTS_BUS. As long
|
|
|
|
* as we can't find a fitting bus via the qom tree, we have to add the
|
|
|
|
* event facility to the sysbus, so e.g. a sclp console can be created.
|
|
|
|
*/
|
|
|
|
qdev_set_parent_bus(DEVICE(sclp->event_facility), sysbus_get_default());
|
2015-05-29 13:53:08 +02:00
|
|
|
|
|
|
|
ret = s390_set_memory_limit(machine->maxram_size, &hw_limit);
|
|
|
|
if (ret == -E2BIG) {
|
2017-04-13 18:14:39 +02:00
|
|
|
error_setg(&err, "host supports a maximum of %" PRIu64 " GB",
|
2015-05-29 13:53:08 +02:00
|
|
|
hw_limit >> 30);
|
|
|
|
} else if (ret) {
|
2017-04-13 18:14:39 +02:00
|
|
|
error_setg(&err, "setting the guest size failed");
|
2015-05-29 13:53:08 +02:00
|
|
|
}
|
2015-12-18 16:35:26 +01:00
|
|
|
|
|
|
|
out:
|
2015-12-18 16:35:25 +01:00
|
|
|
error_propagate(errp, err);
|
2015-05-27 09:49:43 +02:00
|
|
|
}
|
|
|
|
|
2015-05-29 13:53:08 +02:00
|
|
|
static void sclp_memory_init(SCLPDevice *sclp)
|
|
|
|
{
|
|
|
|
MachineState *machine = MACHINE(qdev_get_machine());
|
|
|
|
ram_addr_t initial_mem = machine->ram_size;
|
|
|
|
int increment_size = 20;
|
|
|
|
|
|
|
|
/* 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 'increment_size' is an exponent of 2 that can be
|
|
|
|
* used to calculate the size (in bytes) of an increment. */
|
|
|
|
while ((initial_mem >> increment_size) > MAX_STORAGE_INCREMENTS) {
|
|
|
|
increment_size++;
|
|
|
|
}
|
2015-06-01 13:03:23 +02:00
|
|
|
sclp->increment_size = increment_size;
|
2015-05-29 13:53:08 +02:00
|
|
|
|
s390x/sclp: remove memory hotplug support
From an architecture point of view, nothing can be mapped into the address
space on s390x. All there is is memory. Therefore there is also not really
an interface to communicate such information to the guest. All we can do is
specify the maximum ram address and guests can probe in that range if
memory is available and usable (TPROT).
Also memory hotplug is strange. The guest can decide at some point in
time to add / remove memory in some range. While the hypervisor can deny
to online an increment, all increments have to be predefined and there is
no way of telling the guest about a newly "hotplugged" increment. So if we
specify right now e.g.
-m 2G,slots=2,maxmem=20G
An ordinary fedora guest will happily online (hotplug) all memory,
resulting in a guest consuming 20G. So it really behaves rather like
-m 22G
There is no way to hotplug memory from the outside like on other
architectures. This is of course bad for upper management layers.
As the guest can create/delete memory regions while it is running, of
course migration support is not available and tricky to implement.
With virtualization, it is different. We might want to map something
into guest address space (e.g. fake DAX devices) and not detect it
automatically as memory. So we really want to use the maxmem and slots
parameter just like on all other architectures. Such devices will have
to expose the applicable memory range themselves. To finally be able to
provide memory hotplug to guests, we will need a new paravirtualized
interface to do that (e.g. something into the direction of virtio-mem).
This implies, that maxmem cannot be used for s390x memory hotplug
anymore and has to go. This simplifies the code quite a bit.
As migration support is not working, this change cannot really break
migration as guests without slots and maxmem don't see the SCLP
features. Also, the ram size calculation does not change.
Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20180219174231.10874-1-david@redhat.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Acked-by: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
[CH: tweaked patch description, as discussed on list]
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
2018-02-19 18:42:31 +01:00
|
|
|
/* The core memory area needs 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. */
|
2015-05-29 13:53:08 +02:00
|
|
|
initial_mem = initial_mem >> increment_size << increment_size;
|
|
|
|
|
|
|
|
machine->ram_size = initial_mem;
|
|
|
|
/* let's propagate the changed ram size into the global variable. */
|
|
|
|
ram_size = initial_mem;
|
|
|
|
}
|
|
|
|
|
2015-05-27 09:49:43 +02:00
|
|
|
static void sclp_init(Object *obj)
|
|
|
|
{
|
|
|
|
SCLPDevice *sclp = SCLP(obj);
|
|
|
|
Object *new;
|
|
|
|
|
|
|
|
new = object_new(TYPE_SCLP_EVENT_FACILITY);
|
|
|
|
object_property_add_child(obj, TYPE_SCLP_EVENT_FACILITY, new, NULL);
|
|
|
|
object_unref(new);
|
|
|
|
sclp->event_facility = EVENT_FACILITY(new);
|
2015-05-29 13:53:08 +02:00
|
|
|
|
|
|
|
sclp_memory_init(sclp);
|
2015-05-27 09:49:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sclp_class_init(ObjectClass *oc, void *data)
|
|
|
|
{
|
2015-05-27 10:04:56 +02:00
|
|
|
SCLPDeviceClass *sc = SCLP_CLASS(oc);
|
2015-05-27 09:49:43 +02:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
|
|
|
|
|
|
|
dc->desc = "SCLP (Service-Call Logical Processor)";
|
|
|
|
dc->realize = sclp_realize;
|
|
|
|
dc->hotpluggable = false;
|
|
|
|
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
|
2017-10-04 15:53:19 +02:00
|
|
|
/*
|
|
|
|
* Reason: Creates TYPE_SCLP_EVENT_FACILITY in sclp_init
|
|
|
|
* which is a non-pluggable sysbus device
|
|
|
|
*/
|
|
|
|
dc->user_creatable = false;
|
2015-05-27 10:04:56 +02:00
|
|
|
|
|
|
|
sc->read_SCP_info = read_SCP_info;
|
|
|
|
sc->read_cpu_info = sclp_read_cpu_info;
|
|
|
|
sc->execute = sclp_execute;
|
2015-05-13 15:06:44 +02:00
|
|
|
sc->service_interrupt = service_interrupt;
|
2015-05-27 09:49:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static TypeInfo sclp_info = {
|
|
|
|
.name = TYPE_SCLP,
|
|
|
|
.parent = TYPE_DEVICE,
|
|
|
|
.instance_init = sclp_init,
|
|
|
|
.instance_size = sizeof(SCLPDevice),
|
|
|
|
.class_init = sclp_class_init,
|
|
|
|
.class_size = sizeof(SCLPDeviceClass),
|
|
|
|
};
|
|
|
|
|
2014-08-28 17:25:32 +02:00
|
|
|
static void register_types(void)
|
|
|
|
{
|
2015-05-27 09:49:43 +02:00
|
|
|
type_register_static(&sclp_info);
|
2014-08-28 17:25:32 +02:00
|
|
|
}
|
|
|
|
type_init(register_types);
|