From patchwork Mon Apr 27 14:53:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Mueller X-Patchwork-Id: 465071 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 08CF8140082 for ; Tue, 28 Apr 2015 01:03:23 +1000 (AEST) Received: from localhost ([::1]:55594 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmkZ7-00006b-5V for incoming@patchwork.ozlabs.org; Mon, 27 Apr 2015 11:03:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmkQI-0007ZW-B3 for qemu-devel@nongnu.org; Mon, 27 Apr 2015 10:54:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmkQE-00017c-1O for qemu-devel@nongnu.org; Mon, 27 Apr 2015 10:54:14 -0400 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:50086) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmkQD-00017V-MK for qemu-devel@nongnu.org; Mon, 27 Apr 2015 10:54:09 -0400 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 27 Apr 2015 15:54:08 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 27 Apr 2015 15:54:07 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 80595219005C for ; Mon, 27 Apr 2015 15:53:49 +0100 (BST) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t3REs6QH51380330 for ; Mon, 27 Apr 2015 14:54:06 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 t3REs4iN025161 for ; Mon, 27 Apr 2015 08:54:05 -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 t3RErm9c024183; Mon, 27 Apr 2015 08:54:02 -0600 From: Michael Mueller To: qemu-devel@nongnu.org Date: Mon, 27 Apr 2015 16:53:27 +0200 Message-Id: <1430146411-34632-14-git-send-email-mimu@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1430146411-34632-1-git-send-email-mimu@linux.vnet.ibm.com> References: <1430146411-34632-1-git-send-email-mimu@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15042714-0029-0000-0000-000004607ABC X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.75.94.113 Cc: Eduardo Habkost , Gleb Natapov , Alexander Graf , Christian Borntraeger , Daniel Hansel , "Jason J. Herne" , Cornelia Huck , Paolo Bonzini , Richard Henderson , Andreas Faerber , Michael Mueller Subject: [Qemu-devel] [PATCH v6 13/17] target-s390x: Prepare accelerator during S390 CPU object realization 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 routine s390_cpu_model_init(). It is called by the realize function during instantiation of an CPU object. Its task is to initialize the current accelerator with the properties of the selected processor model. Signed-off-by: Michael Mueller Acked-by: Christian Borntraeger --- target-s390x/cpu-models.c | 30 ++++++++++++++++++++++++++++++ target-s390x/cpu-models.h | 4 ++++ target-s390x/cpu.c | 1 + 3 files changed, 35 insertions(+) diff --git a/target-s390x/cpu-models.c b/target-s390x/cpu-models.c index 3743f38..dfdfb7b 100644 --- a/target-s390x/cpu-models.c +++ b/target-s390x/cpu-models.c @@ -670,3 +670,33 @@ uint64_t *s390_current_fac_list_mask(void) return s390_fac_list_mask_by_machine(mc->name); } #endif + +/** + * s390_cpu_model_init: + * @cc: S390 CPU class + * + * This function intitializes the current accelerator with processor + * related properties. + * + * Since: 2.4 + */ +void s390_cpu_model_init(S390CPUClass *cc) +{ + S390ProcessorProps proc = { + .cpuid = cpuid(cc->proc), + .ibc = cc->proc.ibc, + }; + + /* none cpu model case */ + if (!proc.cpuid) { + return; + } + + bitmap_zero(proc.fac_list, FAC_LIST_ARCH_S390_SIZE_UINT1); + bitmap_copy(proc.fac_list, cc->fac_list[ACCEL_CURRENT], + FAC_LIST_CPU_S390_SIZE_UINT1); + + if (kvm_enabled()) { + kvm_s390_set_processor_props(&proc); + } +} diff --git a/target-s390x/cpu-models.h b/target-s390x/cpu-models.h index 00454d3..c24550b 100644 --- a/target-s390x/cpu-models.h +++ b/target-s390x/cpu-models.h @@ -45,6 +45,9 @@ #define type_cpuid(x) ((uint64_t)((x) & 0xffff) << 16) #define id_cpuid(x) ((uint64_t)((x) & 0xffffff) << 32) #define ver_cpuid(x) ((uint64_t)((x) & 0xff) << 56) +#define cpuid(x) (ver_cpuid(x.ver) | \ + id_cpuid(x.id) | \ + type_cpuid(x.type)) #define oldest_ibc(x) (((uint32_t)(x) >> 16) & 0xfff) #define newest_ibc(x) ((uint32_t)(x) & 0xfff) @@ -88,6 +91,7 @@ void s390_cpu_list_entry(gpointer data, gpointer user_data); bool s390_cpu_classes_initialized(void); uint64_t *s390_fac_list_mask_by_machine(const char *name); uint64_t *s390_current_fac_list_mask(void); +void s390_cpu_model_init(S390CPUClass *cc); #ifdef CONFIG_KVM int kvm_s390_get_processor_props(S390ProcessorProps *prop); diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c index cbab627..65dee3e 100644 --- a/target-s390x/cpu.c +++ b/target-s390x/cpu.c @@ -184,6 +184,7 @@ static void s390_cpu_realizefn(DeviceState *dev, Error **errp) CPUState *cs = CPU(dev); S390CPUClass *scc = S390_CPU_GET_CLASS(dev); + s390_cpu_model_init(scc); s390_cpu_gdb_init(cs); qemu_init_vcpu(cs); #if !defined(CONFIG_USER_ONLY)