From patchwork Wed Oct 2 11:33:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Mueller X-Patchwork-Id: 279693 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 D625D2C00B9 for ; Wed, 2 Oct 2013 21:34:49 +1000 (EST) Received: from localhost ([::1]:35400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRKhZ-0000ZZ-1d for incoming@patchwork.ozlabs.org; Wed, 02 Oct 2013 07:34:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRKgs-0000Yh-OP for qemu-devel@nongnu.org; Wed, 02 Oct 2013 07:34:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VRKgj-000262-Qu for qemu-devel@nongnu.org; Wed, 02 Oct 2013 07:34:02 -0400 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:54458) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRKgj-00025j-I7 for qemu-devel@nongnu.org; Wed, 02 Oct 2013 07:33:53 -0400 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 2 Oct 2013 12:33:51 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 2 Oct 2013 12:33:51 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 892F82190059 for ; Wed, 2 Oct 2013 12:33:50 +0100 (BST) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps4076.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r92BXc9N59637982 for ; Wed, 2 Oct 2013 11:33:38 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r92BXnSu022924 for ; Wed, 2 Oct 2013 05:33:50 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r92BXkeV022802; Wed, 2 Oct 2013 05:33:49 -0600 From: Michael Mueller To: qemu-devel@nongnu.org Date: Wed, 2 Oct 2013 13:33:37 +0200 Message-Id: <1380713622-22325-7-git-send-email-mimu@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1380713622-22325-1-git-send-email-mimu@linux.vnet.ibm.com> References: <1380713622-22325-1-git-send-email-mimu@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13100211-4966-0000-0000-00000711FB7D X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 195.75.94.106 Cc: Michael Mueller Subject: [Qemu-devel] [PATCH RFC 06/11] s390/qemu: cpu model KVM properties requests 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 This patch implements the functions s390_fetch_kvm_host_props() and s390_request_kvm_cpu_config(). They respectively retrieve or request the machine type, cpu facilities and KVM facility mask supported by the host. Both functions are based on the s390 configuration device interface. Signed-off-by: Michael Mueller --- target-s390x/cpu-models.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++ target-s390x/cpu-models.h | 16 ++++++++++++ 2 files changed, 81 insertions(+) diff --git a/target-s390x/cpu-models.c b/target-s390x/cpu-models.c index 4a4720a..4ce1546 100644 --- a/target-s390x/cpu-models.c +++ b/target-s390x/cpu-models.c @@ -234,6 +234,71 @@ static int set_s390_cpu_alias(const char *name, const char *model) return 0; } +/* return host specific properties */ +int s390_fetch_kvm_host_props(struct S390HostProps *prop) +{ + int ret; + + ret = get_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_TYPE, + &prop->vcpu.type); + if (ret) { + return ret; + } + ret = get_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_FACILITIES, + &prop->vcpu.facilities); + if (ret) { + return ret; + } + + ret = get_s390_config_attr(KVM_DEV_S390_CONFIG_KVM_FACILITY_MASK, + &prop->host.facility_mask); + if (ret) { + return ret; + } + + return 0; +} + +/* request cpu configuration defined in S390 cpu class */ +int s390_request_kvm_cpu_config(S390CPUClass *cc) +{ + int ret = 0; + + { + struct kvm_s390_attr_cpu_type cpu; + ret = set_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_TYPE, &cc->type); + if (ret) { + goto out; + } + ret = get_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_TYPE, &cpu.type); + if (ret) { + goto out; + } + if (cc->type != cpu.type) { + goto out; + } + } + { + struct kvm_s390_attr_cpu_facilities cpu; + int i; + ret = set_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_FACILITIES, cc->kvm_facilities); + if (ret) { + goto out; + } + ret = get_s390_config_attr(KVM_DEV_S390_CONFIG_CPU_FACILITIES, &cpu.facilities); + if (ret) { + goto out; + } + for (i = 0; i < sizeof(cpu.facilities) / sizeof(unsigned long); i++) { + if (cc->kvm_facilities[i] != cpu.facilities[i]) { + goto out; + } + } + } +out: + return ret; +} + /* define S390 CPU model classes */ S390_PROC_DEF("2064-ga1", CPU_S390_2064_GA1, "IBM zSeries 900 GA1") S390_PROC_DEF("2064-ga2", CPU_S390_2064_GA2, "IBM zSeries 900 GA2") diff --git a/target-s390x/cpu-models.h b/target-s390x/cpu-models.h index e188eca..0789a5e 100644 --- a/target-s390x/cpu-models.h +++ b/target-s390x/cpu-models.h @@ -34,6 +34,22 @@ typedef struct S390CPUAlias { } S390CPUAlias; extern GSList *s390_cpu_aliases; +/* + * host system properties used to trim s390 + * cpu class attributes during initial kvm setup + */ +struct S390HostProps { + struct { + unsigned long facility_mask[256]; + } host; + struct { + unsigned short type; + unsigned long facilities[256]; + } vcpu; +}; + +int s390_fetch_kvm_host_props(struct S390HostProps *prop); +int s390_request_kvm_cpu_config(S390CPUClass *cc); ObjectClass *s390_cpu_class_by_name(const char *name); /*