From patchwork Tue Jun 14 05:54:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 9175001 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 471746048C for ; Tue, 14 Jun 2016 05:55:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39D8828179 for ; Tue, 14 Jun 2016 05:55:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2ECB3282ED; Tue, 14 Jun 2016 05:55:38 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 0BC9228179 for ; Tue, 14 Jun 2016 05:55:36 +0000 (UTC) Received: from localhost ([::1]:32784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bChK2-0007hy-9g for patchwork-qemu-devel@patchwork.kernel.org; Tue, 14 Jun 2016 01:55:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bChJT-0007gs-IG for qemu-devel@nongnu.org; Tue, 14 Jun 2016 01:55:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bChJR-0004Oy-Do for qemu-devel@nongnu.org; Tue, 14 Jun 2016 01:54:58 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:60056) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bChJR-0004Of-1C; Tue, 14 Jun 2016 01:54:57 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3rTJkz6BJPz9t1B; Tue, 14 Jun 2016 15:54:51 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1465883691; bh=ik6ygEai5S5gmqa7ARa+TSccwIE/7QNXaDoAi8wmmxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FUIhgK0qfqG9/oK5dvp5hakxNNwYyn9XiDxAQIx4/WPGeFCEox6jFtamktxp4JwNY xgRhnVLwT3q8PH24qbice1XJAbsulftHeQ3UyNlciEn8MaNbXSyEXeSdiQHeYjc3Dq v37eszk1+4oH6iMKdFZjcVszh5T+1lv8kWoMQFDk= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 14 Jun 2016 15:54:45 +1000 Message-Id: <1465883690-8445-4-git-send-email-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465883690-8445-1-git-send-email-david@gibson.dropbear.id.au> References: <1465883690-8445-1-git-send-email-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 3/8] 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: Thomas Huth , David Gibson , qemu-ppc@nongnu.org, 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 From: Thomas Huth 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 Signed-off-by: David Gibson --- 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