From patchwork Mon Apr 13 13:56:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Mueller X-Patchwork-Id: 6209661 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E66C89F1C4 for ; Mon, 13 Apr 2015 14:04:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E7F7D2034E for ; Mon, 13 Apr 2015 14:04:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BF7932034B for ; Mon, 13 Apr 2015 14:04:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932343AbbDMODj (ORCPT ); Mon, 13 Apr 2015 10:03:39 -0400 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:50485 "EHLO e06smtp17.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754107AbbDMN5G (ORCPT ); Mon, 13 Apr 2015 09:57:06 -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, 13 Apr 2015 14:57:05 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 13 Apr 2015 14:57:01 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 7F2971B08078; Mon, 13 Apr 2015 14:57:34 +0100 (BST) Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t3DDv1NW6554010; Mon, 13 Apr 2015 13:57:01 GMT Received: from d06av05.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t3DDuxA2031593; Mon, 13 Apr 2015 07:57:00 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t3DDuwIH031505; Mon, 13 Apr 2015 07:56:59 -0600 From: Michael Mueller To: qemu-devel@nongnu.org, kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Eduardo Habkost , Gleb Natapov , Alexander Graf , Christian Borntraeger , "Jason J. Herne" , Cornelia Huck , Paolo Bonzini , Michael Mueller , Andreas Faerber , Richard Henderson , Daniel Hansel Subject: [PATCH v5 02/17] Add accelerator id and model name to CPUState Date: Mon, 13 Apr 2015 15:56:21 +0200 Message-Id: <1428933396-37887-3-git-send-email-mimu@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1428933396-37887-1-git-send-email-mimu@linux.vnet.ibm.com> References: <1428933396-37887-1-git-send-email-mimu@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15041313-0029-0000-0000-0000042AF8BF Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The patch defines ids per accelerator and adds the accel_id and the model_name to the CPUState. The accel_id is initialized by common code, the model name needs to be initialized by target specific code. Signed-off-by: Michael Mueller --- include/qom/cpu.h | 5 +++++ qapi-schema.json | 9 +++++++++ qom/cpu.c | 14 ++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/include/qom/cpu.h b/include/qom/cpu.h index 9dafb48..4ffc050 100644 --- a/include/qom/cpu.h +++ b/include/qom/cpu.h @@ -236,6 +236,8 @@ struct kvm_run; * @mem_io_pc: Host Program Counter at which the memory was accessed. * @mem_io_vaddr: Target virtual address at which the memory was accessed. * @kvm_fd: vCPU file descriptor for KVM. + * @accel_id: accelerator id of this CPU. + * @model_name: model name of this CPU * * State of one CPU core or thread. */ @@ -313,6 +315,9 @@ struct CPUState { (absolute value) offset as small as possible. This reduces code size, especially for hosts without large memory offsets. */ volatile sig_atomic_t tcg_exit_req; + + AccelId accel_id; + char *model_name; }; QTAILQ_HEAD(CPUTailQ, CPUState); diff --git a/qapi-schema.json b/qapi-schema.json index ac9594d..540e520 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -2515,6 +2515,15 @@ ## { 'command': 'query-machines', 'returns': ['MachineInfo'] } +# @AccelId +# +# Defines accelerator ids +# +# Since: 2.4 +## +{ 'enum': 'AccelId', + 'data': ['qtest', 'tcg', 'kvm', 'xen'] } + ## # @CpuDefinitionInfo: # diff --git a/qom/cpu.c b/qom/cpu.c index 108bfa2..457afc7 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -67,6 +67,20 @@ CPUState *cpu_generic_init(const char *typename, const char *cpu_model) goto out; } + if (tcg_enabled()) { + cpu->accel_id = ACCEL_ID_TCG; + } else if (kvm_enabled()) { + cpu->accel_id = ACCEL_ID_KVM; + } +#ifdef CONFIG_XEN + else if (xen_enabled()) { + cpu->accel_id = ACCEL_ID_XEN; + } +#endif + else { + cpu->accel_id = ACCEL_ID_QTEST; + } + object_property_set_bool(OBJECT(cpu), true, "realized", &err); out: