From patchwork Wed Oct 2 11:33:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Mueller X-Patchwork-Id: 279700 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 9206A2C0077 for ; Wed, 2 Oct 2013 21:38:35 +1000 (EST) Received: from localhost ([::1]:35429 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRKlF-00076v-KT for incoming@patchwork.ozlabs.org; Wed, 02 Oct 2013 07:38:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40728) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRKgt-0000Yk-AI for qemu-devel@nongnu.org; Wed, 02 Oct 2013 07:34:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VRKgk-00026Z-2Y for qemu-devel@nongnu.org; Wed, 02 Oct 2013 07:34:03 -0400 Received: from e06smtp11.uk.ibm.com ([195.75.94.107]:59350) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRKgj-00025t-Qh for qemu-devel@nongnu.org; Wed, 02 Oct 2013 07:33:54 -0400 Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 2 Oct 2013 12:33:52 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 2 Oct 2013 12:33:50 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id A3BB2219005A for ; Wed, 2 Oct 2013 12:33:49 +0100 (BST) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r92BXbVq53346386 for ; Wed, 2 Oct 2013 11:33:37 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 r92BXmeQ022892 for ; Wed, 2 Oct 2013 05:33:49 -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 r92BXkeT022802; Wed, 2 Oct 2013 05:33:48 -0600 From: Michael Mueller To: qemu-devel@nongnu.org Date: Wed, 2 Oct 2013 13:33:35 +0200 Message-Id: <1380713622-22325-5-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-5024-0000-0000-00000763021E X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 195.75.94.107 Cc: Michael Mueller Subject: [Qemu-devel] [PATCH RFC 04/11] s390/qemu: cpu model cpu facilitiy support 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 defines s390 cpu facilities and their appearance/disappearance. The implemented functions allow to calculate cpu model specific facility sets. These sets are assiciated to the defiend cpu classes used to calculate the list of supported cpu models. Signed-off-by: Michael Mueller --- target-s390x/cpu-models.c | 126 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 125 insertions(+), 1 deletion(-) diff --git a/target-s390x/cpu-models.c b/target-s390x/cpu-models.c index e2e8019..b813f89 100644 --- a/target-s390x/cpu-models.c +++ b/target-s390x/cpu-models.c @@ -27,7 +27,7 @@ cc->class = cpu_class(_cpu_id); \ cc->ga = cpu_ga(_cpu_id); \ cc->generation = cpu_generation(_cpu_id); \ - cc->facilities = NULL; \ + cc->facilities = facilities(_cpu_id); \ cc->kvm_facilities = NULL; \ cc->is_active = true; \ cc->is_host = false; \ @@ -47,6 +47,130 @@ } \ type_init(glue(_cpu_id, _cpu_register_types)) +static unsigned int facility_availability[MAX_S390_FACILITY_BIT] = { + [0] = CPU_S390_2064_GA1, + [1] = CPU_S390_2064_GA1, + [2] = CPU_S390_2064_GA1, + [3] = CPU_S390_2084_GA1, + [4] = CPU_S390_2084_GA2, + [6] = CPU_S390_2084_GA3, + [7] = CPU_S390_2094_GA1, + [8] = CPU_S390_2097_GA1, + [9] = CPU_S390_2094_GA2, + [10] = CPU_S390_2097_GA1, + [11] = CPU_S390_2097_GA1, + [13] = CPU_S390_2817_GA2, + [14] = CPU_S390_2817_GA2, + [16] = CPU_S390_2064_GA2, /* GA1+ */ + [17] = CPU_S390_2084_GA1, + [18] = CPU_S390_2084_GA1, + [19] = CPU_S390_2084_GA1, + [20] = CPU_S390_2084_GA1, + [21] = CPU_S390_2094_GA1, + [22] = CPU_S390_2084_GA3, + [23] = CPU_S390_2094_GA1, + [24] = CPU_S390_2094_GA1, + [25] = CPU_S390_2094_GA1, + [26] = CPU_S390_2097_GA1, + [27] = CPU_S390_2094_GA2, + [28] = CPU_S390_2084_GA5, + [30] = CPU_S390_2094_GA1, + [31] = CPU_S390_2094_GA1, + [32] = CPU_S390_2094_GA2, + [33] = CPU_S390_2097_GA1, + [34] = CPU_S390_2097_GA1, + [35] = CPU_S390_2097_GA1, + [36] = CPU_S390_2817_GA1, + [37] = CPU_S390_2817_GA1, + [40] = CPU_S390_2097_GA3, + [41] = CPU_S390_2094_GA2, + [42] = CPU_S390_2094_GA2, + [43] = CPU_S390_2097_GA1, + [44] = CPU_S390_2094_GA3, + [45] = CPU_S390_2817_GA1, + [46] = CPU_S390_2817_GA1, + [47] = CPU_S390_2817_GA2, + [48] = CPU_S390_2827_GA1, + [49] = CPU_S390_2827_GA1, + [50] = CPU_S390_2827_GA1, + [51] = CPU_S390_2827_GA1, + [52] = CPU_S390_2827_GA1, + [65] = CPU_S390_2097_GA2, + [66] = CPU_S390_2817_GA2, + [67] = CPU_S390_2097_GA2, + [68] = CPU_S390_2097_GA2, + [73] = CPU_S390_2827_GA1, + [75] = CPU_S390_2817_GA1, + [76] = CPU_S390_2817_GA2, + [77] = CPU_S390_2817_GA2, + [78] = CPU_S390_2827_GA1, +}; + +static unsigned int facility_revocation[MAX_S390_FACILITY_BIT] = { + [65] = CPU_S390_2817_GA1, +}; + +/* set a specific bit in facility set */ +static void set_facility(unsigned int nr, void *facilities) +{ + unsigned char *ptr; + + if (nr >= MAX_S390_FACILITY_BIT) { + return; + } + ptr = (unsigned char *) facilities + (nr >> 3); + *ptr |= (0x80 >> (nr & 7)); +} + +/* clear a specific bit in facility set */ +static void clear_facility(unsigned int nr, void *facilities) +{ + unsigned char *ptr; + + if (nr >= MAX_S390_FACILITY_BIT) { + return; + } + ptr = (unsigned char *) facilities + (nr >> 3); + *ptr &= ~(0x80 >> (nr & 7)); +} + +/* test a specific bit in facility set to be set */ +static inline int test_facility(unsigned long nr, void *facilities) +{ + unsigned char *ptr; + + if (nr >= MAX_S390_FACILITY_BIT) + return 0; + ptr = (unsigned char *) facilities + (nr >> 3); + return (*ptr & (0x80 >> (nr & 7))) != 0; +} + +/* calculate the facility set for a specific cpu type */ +static unsigned long *facilities(unsigned int cpu_id) +{ + unsigned long *fac; + unsigned int i; + + fac = g_malloc0(MAX_S390_FACILITY_BYTE); + if (fac) { + for (i = 0; i < ARRAY_SIZE(facility_availability); i++) { + if (facility_availability[i]) { + if (cpu_order(facility_availability[i]) <= cpu_order(cpu_id)) { + set_facility(i, fac); + } + } + } + for (i = 0; i < ARRAY_SIZE(facility_revocation); i++) { + if (facility_revocation[i]) { + if (cpu_order(facility_revocation[i]) <= cpu_order(cpu_id)) { + clear_facility(i, fac); + } + } + } + } + return fac; +} + /* 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")