From patchwork Fri Jun 7 17:28:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason J. Herne" X-Patchwork-Id: 249771 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6D1B12C007A for ; Sat, 8 Jun 2013 03:30:22 +1000 (EST) Received: from localhost ([::1]:47801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ul0UW-00015K-Ge for incoming@patchwork.ozlabs.org; Fri, 07 Jun 2013 13:30:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ul0SZ-00071j-Fo for qemu-devel@nongnu.org; Fri, 07 Jun 2013 13:28:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ul0SU-00083a-SC for qemu-devel@nongnu.org; Fri, 07 Jun 2013 13:28:19 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:35679) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ul0SU-00083S-N8 for qemu-devel@nongnu.org; Fri, 07 Jun 2013 13:28:14 -0400 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 7 Jun 2013 13:28:14 -0400 Received: from d01dlp01.pok.ibm.com (9.56.250.166) by e9.ny.us.ibm.com (192.168.1.109) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 7 Jun 2013 13:28:11 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 40EE138C8054 for ; Fri, 7 Jun 2013 13:28:10 -0400 (EDT) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r57HS98i164480 for ; Fri, 7 Jun 2013 13:28:09 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r57HS8HV018340 for ; Fri, 7 Jun 2013 14:28:08 -0300 Received: from jason-ThinkPad-W500.endicott.ibm.com (jason-thinkpad-w500.endicott.ibm.com [9.60.75.211] (may be forged)) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r57HS7Jd018232; Fri, 7 Jun 2013 14:28:08 -0300 From: "Jason J. Herne" To: agraf@suse.de, borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, imammedo@redhat.com, qemu-devel@nongnu.org, ehabkost@redhat.com Date: Fri, 7 Jun 2013 13:28:01 -0400 Message-Id: <1370626087-840-3-git-send-email-jjherne@us.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1370626087-840-1-git-send-email-jjherne@us.ibm.com> References: <1370626087-840-1-git-send-email-jjherne@us.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13060717-7182-0000-0000-00000733C893 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 32.97.182.139 Cc: "Jason J. Herne" Subject: [Qemu-devel] [PATCH 2/8] [PATCH RFC v2] s390-qemu: cpu hotplug - SCLP CPU Info X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Jason J. Herne" Implement the CPU data in SCLP "Read SCP Info". And implement "Read CPU Info" SCLP command. This data will be used by the guest to get information about hot plugged cpus. Signed-off-by: Jason J. Herne --- hw/s390x/sclp.c | 38 ++++++++++++++++++++++++++++++++++++++ include/hw/s390x/sclp.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index cb53d7e..20b718f 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" #include "hw/s390x/sclp.h" @@ -32,6 +33,19 @@ static void read_SCP_info(SCCB *sccb) { ReadInfo *read_info = (ReadInfo *) sccb; int shift = 0; + int i = 0; + + /* CPU information */ + read_info->entries_cpu = cpu_to_be16(smp_cpus); + read_info->offset_cpu = cpu_to_be16(offsetof(ReadInfo, entries)); + read_info->highest_cpu = cpu_to_be16(max_cpus); + + for (i = 0; i < smp_cpus; i++) { + read_info->entries[i].address = i; + read_info->entries[i].type = 0; + } + + read_info->facilities = cpu_to_be64(SCLP_HAS_CPU_INFO); while ((ram_size >> (20 + shift)) > 65535) { shift++; @@ -41,6 +55,27 @@ static void read_SCP_info(SCCB *sccb) sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_READ_COMPLETION); } +static void sclp_read_cpu_info(SCCB *sccb) +{ + ReadCpuInfo *cpu_info = (ReadCpuInfo *) sccb; + int i = 0; + + cpu_info->nr_configured = cpu_to_be16(smp_cpus); + 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)); + + for (i = 0; i < smp_cpus; i++) { + cpu_info->entries[i].address = i; + cpu_info->entries[i].type = 0; + } + + sccb->h.response_code = cpu_to_be16(SCLP_RC_NORMAL_READ_COMPLETION); +} + static void sclp_execute(SCCB *sccb, uint64_t code) { S390SCLPDevice *sdev = get_event_facility(); @@ -50,6 +85,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..6783d40 100644 --- a/include/hw/s390x/sclp.h +++ b/include/hw/s390x/sclp.h @@ -79,12 +79,42 @@ typedef struct SCCBHeader { #define SCCB_DATA_LEN (SCCB_SIZE - sizeof(SCCBHeader)) +/* CPU information */ +typedef struct CpuEntry { + uint8_t address; + uint8_t reserved0[13]; + uint8_t type; + uint8_t reserved1; +} QEMU_PACKED CpuEntry; + 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[48 - 20]; /* 20-47 */ + uint64_t facilities; /* 48-55 */ + uint8_t _reserved3[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; +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];