From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHXok-0006d0-Ti for qemu-devel@nongnu.org; Thu, 05 Sep 2013 07:33:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VHXod-0000bs-In for qemu-devel@nongnu.org; Thu, 05 Sep 2013 07:33:42 -0400 Received: from cantor2.suse.de ([195.135.220.15]:38880 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHXod-0000bo-8y for qemu-devel@nongnu.org; Thu, 05 Sep 2013 07:33:35 -0400 Message-ID: <52286C0B.7080602@suse.de> Date: Thu, 05 Sep 2013 13:33:31 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1375366359-11553-1-git-send-email-jjherne@us.ibm.com> <1375366359-11553-3-git-send-email-jjherne@us.ibm.com> In-Reply-To: <1375366359-11553-3-git-send-email-jjherne@us.ibm.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/8] [PATCH RFC v3] s390-qemu: cpu hotplug - SCLP CPU Info List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Jason J. Herne" Cc: ehabkost@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, imammedo@redhat.com Am 01.08.2013 16:12, schrieb Jason J. Herne: > From: "Jason J. Herne" >=20 > Implement the CPU data in SCLP "Read SCP Info". And implement "Read CP= U Info" > SCLP command. This data will be used by the guest to get information ab= out hot > plugged cpus. >=20 > Signed-off-by: Jason J. Herne > --- > hw/s390x/sclp.c | 51 +++++++++++++++++++++++++++++++++++++++= ++++++++ > include/hw/s390x/sclp.h | 32 +++++++++++++++++++++++++++++ > 2 files changed, 83 insertions(+) >=20 > diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c > index cb53d7e..da8cf7a 100644 > --- a/hw/s390x/sclp.c > +++ b/hw/s390x/sclp.c > @@ -15,6 +15,7 @@ > #include "cpu.h" > #include "sysemu/kvm.h" > #include "exec/memory.h" > +#include "sysemu/sysemu.h" > =20 > #include "hw/s390x/sclp.h" > =20 > @@ -31,7 +32,26 @@ static inline S390SCLPDevice *get_event_facility(voi= d) > static void read_SCP_info(SCCB *sccb) > { > ReadInfo *read_info =3D (ReadInfo *) sccb; > + CPUState *cpu; > int shift =3D 0; > + int cpu_count =3D 0; > + int i =3D 0; > + > + for (cpu =3D first_cpu; cpu !=3D NULL; cpu =3D cpu->next_cpu) { > + cpu_count++; > + } > + > + /* CPU information */ > + read_info->entries_cpu =3D cpu_to_be16(cpu_count); > + read_info->offset_cpu =3D cpu_to_be16(offsetof(ReadInfo, entries))= ; > + read_info->highest_cpu =3D cpu_to_be16(max_cpus); > + > + for (i =3D 0; i < cpu_count; i++) { > + read_info->entries[i].address =3D i; > + read_info->entries[i].type =3D 0; > + } > + > + read_info->facilities =3D cpu_to_be64(SCLP_HAS_CPU_INFO); > =20 > while ((ram_size >> (20 + shift)) > 65535) { > shift++; > @@ -41,6 +61,34 @@ static void read_SCP_info(SCCB *sccb) > sccb->h.response_code =3D cpu_to_be16(SCLP_RC_NORMAL_READ_COMPLETI= ON); > } > =20 > +/* Provide information about the CPU */ > +static void sclp_read_cpu_info(SCCB *sccb) > +{ > + ReadCpuInfo *cpu_info =3D (ReadCpuInfo *) sccb; > + CPUState *cpu; > + int cpu_count =3D 0; > + int i =3D 0; > + > + for (cpu =3D first_cpu; cpu !=3D NULL; cpu =3D cpu->next_cpu) { This becomes CPU_FOREACH(cpu) { now. > + cpu_count++; > + } > + > + cpu_info->nr_configured =3D cpu_to_be16(cpu_count); > + cpu_info->offset_configured =3D cpu_to_be16(offsetof(ReadCpuInfo, = entries)); > + cpu_info->nr_standby =3D cpu_to_be16(0); > + > + /* The standby offset is 16-byte for each CPU */ > + cpu_info->offset_standby =3D cpu_to_be16(cpu_info->offset_configur= ed > + + cpu_info->nr_configured*sizeof(CpuEntry)); > + > + for (i =3D 0; i < cpu_count; i++) { > + cpu_info->entries[i].address =3D i; > + cpu_info->entries[i].type =3D 0; > + } > + > + sccb->h.response_code =3D cpu_to_be16(SCLP_RC_NORMAL_READ_COMPLETI= ON); > +} > + > static void sclp_execute(SCCB *sccb, uint64_t code) > { > S390SCLPDevice *sdev =3D get_event_facility(); > @@ -50,6 +98,9 @@ static void sclp_execute(SCCB *sccb, uint64_t code) > case SCLP_CMDW_READ_SCP_INFO_FORCED: > read_SCP_info(sccb); > break; > + case SCLP_CMDW_READ_CPU_INFO: > + sclp_read_cpu_info(sccb); > + break; > default: > sdev->sclp_command_handler(sdev->ef, sccb, code); > break; > diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h > index 174097d..89ae7d1 100644 > --- a/include/hw/s390x/sclp.h > +++ b/include/hw/s390x/sclp.h > @@ -79,12 +79,44 @@ typedef struct SCCBHeader { > =20 > #define SCCB_DATA_LEN (SCCB_SIZE - sizeof(SCCBHeader)) > =20 > +/* CPU information */ > +typedef struct CpuEntry { > + uint8_t address; > + uint8_t reserved0[13]; > + uint8_t type; > + uint8_t reserved1; > +} QEMU_PACKED CpuEntry; Feel free to use CPUEntry capitalization if this is not copied from a Linux struct of that name - your choice. Andreas > + > typedef struct ReadInfo { > SCCBHeader h; > uint16_t rnmax; > uint8_t rnsize; > + uint8_t _reserved1[16 - 11]; /* 11-15 */ > + uint16_t entries_cpu; /* 16-17 */ > + uint16_t offset_cpu; /* 18-19 */ > + uint8_t _reserved2[24 - 20]; /* 20-23 */ > + uint8_t loadparm[8]; /* 24-31 */ > + uint8_t _reserved3[48 - 32]; /* 32-47 */ > + uint64_t facilities; /* 48-55 */ > + uint8_t _reserved0[100 - 56]; > + uint32_t rnsize2; > + uint64_t rnmax2; > + uint8_t _reserved4[120-112]; /* 112-119 */ > + uint16_t highest_cpu; > + uint8_t _reserved5[128 - 122]; /* 122-127 */ > + struct CpuEntry entries[0]; > } QEMU_PACKED ReadInfo; > =20 > +typedef struct ReadCpuInfo { > + SCCBHeader h; > + uint16_t nr_configured; /* 8-9 */ > + uint16_t offset_configured; /* 10-11 */ > + uint16_t nr_standby; /* 12-13 */ > + uint16_t offset_standby; /* 14-15 */ > + uint8_t reserved0[24-16]; /* 16-23 */ > + struct CpuEntry entries[0]; > +} QEMU_PACKED ReadCpuInfo; > + > typedef struct SCCB { > SCCBHeader h; > char data[SCCB_DATA_LEN]; >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg