From patchwork Tue Jun 7 15:39:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 9161707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DCFF660572 for ; Tue, 7 Jun 2016 15:48:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEF4224151 for ; Tue, 7 Jun 2016 15:48:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C39BB27248; Tue, 7 Jun 2016 15:48:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6D43724151 for ; Tue, 7 Jun 2016 15:48:44 +0000 (UTC) Received: from localhost ([::1]:51104 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAJFD-0000Ne-Nn for patchwork-qemu-devel@patchwork.kernel.org; Tue, 07 Jun 2016 11:48:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAJ6e-0001fO-6V for qemu-devel@nongnu.org; Tue, 07 Jun 2016 11:39:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAJ6b-0002e7-Sy for qemu-devel@nongnu.org; Tue, 07 Jun 2016 11:39:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33766) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAJ6b-0002e1-NR; Tue, 07 Jun 2016 11:39:49 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 471F763141; Tue, 7 Jun 2016 15:39:49 +0000 (UTC) Received: from thh440s.fritz.box (vpn1-4-220.ams2.redhat.com [10.36.4.220]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u57FdfGS021203; Tue, 7 Jun 2016 11:39:47 -0400 From: Thomas Huth To: qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Date: Tue, 7 Jun 2016 17:39:38 +0200 Message-Id: <1465313980-31281-4-git-send-email-thuth@redhat.com> In-Reply-To: <1465313980-31281-1-git-send-email-thuth@redhat.com> References: <1465313980-31281-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 07 Jun 2016 15:39:49 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/5] ppc: Provide function to get CPU class of the host CPU X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy , agraf@suse.de, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When running with KVM, we might be interested in some details of the host CPU class, too, so provide a function to get the corresponding CPU class. Signed-off-by: Thomas Huth Reviewed-by: Michael Roth --- target-ppc/kvm.c | 19 ++++++++++++++----- target-ppc/kvm_ppc.h | 7 +++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 24d6032..6c15361 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -2329,6 +2329,19 @@ static PowerPCCPUClass *ppc_cpu_get_family_class(PowerPCCPUClass *pcc) return POWERPC_CPU_CLASS(oc); } +PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void) +{ + uint32_t host_pvr = mfpvr(); + PowerPCCPUClass *pvr_pcc; + + pvr_pcc = ppc_cpu_class_by_pvr(host_pvr); + if (pvr_pcc == NULL) { + pvr_pcc = ppc_cpu_class_by_pvr_mask(host_pvr); + } + + return pvr_pcc; +} + static int kvm_ppc_register_host_cpu_type(void) { TypeInfo type_info = { @@ -2336,14 +2349,10 @@ static int kvm_ppc_register_host_cpu_type(void) .instance_init = kvmppc_host_cpu_initfn, .class_init = kvmppc_host_cpu_class_init, }; - uint32_t host_pvr = mfpvr(); PowerPCCPUClass *pvr_pcc; DeviceClass *dc; - pvr_pcc = ppc_cpu_class_by_pvr(host_pvr); - if (pvr_pcc == NULL) { - pvr_pcc = ppc_cpu_class_by_pvr_mask(host_pvr); - } + pvr_pcc = kvm_ppc_get_host_cpu_class(); if (pvr_pcc == NULL) { return -1; } diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h index 3b2090e..20bfb59 100644 --- a/target-ppc/kvm_ppc.h +++ b/target-ppc/kvm_ppc.h @@ -56,6 +56,7 @@ void kvmppc_hash64_write_pte(CPUPPCState *env, target_ulong pte_index, bool kvmppc_has_cap_fixup_hcalls(void); int kvmppc_enable_hwrng(void); int kvmppc_put_books_sregs(PowerPCCPU *cpu); +PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void); #else @@ -252,6 +253,12 @@ static inline int kvmppc_put_books_sregs(PowerPCCPU *cpu) { abort(); } + +static inline PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void) +{ + return NULL; +} + #endif #ifndef CONFIG_KVM