From patchwork Fri Apr 26 18:21:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 240036 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7C71F2C0119 for ; Sat, 27 Apr 2013 05:55:31 +1000 (EST) Received: from localhost ([::1]:59602 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVnUo-0006ls-Vt for incoming@patchwork.ozlabs.org; Fri, 26 Apr 2013 14:35:47 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55347) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVnHM-0003Im-SK for qemu-devel@nongnu.org; Fri, 26 Apr 2013 14:22:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVnHK-0004xE-Ul for qemu-devel@nongnu.org; Fri, 26 Apr 2013 14:21:52 -0400 Received: from cantor2.suse.de ([195.135.220.15]:38865 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVnHK-0004wf-Ok; Fri, 26 Apr 2013 14:21:50 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 2397D5E000204; Fri, 26 Apr 2013 20:21:50 +0200 (CEST) From: Alexander Graf To: qemu-ppc@nongnu.org Date: Fri, 26 Apr 2013 20:21:21 +0200 Message-Id: <1367000509-8833-3-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1367000509-8833-1-git-send-email-agraf@suse.de> References: <1367000509-8833-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: Blue Swirl , qemu-devel@nongnu.org, Aurelien Jarno , Stuart Yoder Subject: [Qemu-devel] [PATCH 02/30] PPC: e500: advertise 4.2 MPIC only if KVM supports EPR 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 From: Stuart Yoder Older KVM versions don't support EPR which breaks guests when we announce MPIC variants that support EPR. Catch that case and expose only MPIC version 2.0 which tells the guest that we don't support the EPR capability yet. Signed-off-by: Stuart Yoder [agraf: Add comment, route cap check through kvm_ppc.c] Signed-off-by: Alexander Graf --- hw/ppc/e500plat.c | 7 +++++++ target-ppc/kvm.c | 7 +++++++ target-ppc/kvm_ppc.h | 6 ++++++ 3 files changed, 20 insertions(+), 0 deletions(-) diff --git a/hw/ppc/e500plat.c b/hw/ppc/e500plat.c index 7292ce1..c852995 100644 --- a/hw/ppc/e500plat.c +++ b/hw/ppc/e500plat.c @@ -16,6 +16,7 @@ #include "sysemu/device_tree.h" #include "hw/pci/pci.h" #include "hw/ppc/openpic.h" +#include "kvm_ppc.h" static void e500plat_fixup_devtree(PPCE500Params *params, void *fdt) { @@ -48,6 +49,12 @@ static void e500plat_init(QEMUMachineInitArgs *args) .mpic_version = OPENPIC_MODEL_FSL_MPIC_42, }; + /* Older KVM versions don't support EPR which breaks guests when we announce + MPIC variants that support EPR. Revert to an older one for those */ + if (kvm_enabled() && !kvmppc_has_cap_epr()) { + params.mpic_version = OPENPIC_MODEL_FSL_MPIC_20; + } + ppce500_init(¶ms); } diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 5e9dddb..f2658bb 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -63,6 +63,7 @@ static int cap_ppc_rma; static int cap_spapr_tce; static int cap_hior; static int cap_one_reg; +static int cap_epr; /* XXX We have a race condition where we actually have a level triggered * interrupt, but the infrastructure can't expose that yet, so the guest @@ -95,6 +96,7 @@ int kvm_arch_init(KVMState *s) cap_spapr_tce = kvm_check_extension(s, KVM_CAP_SPAPR_TCE); cap_one_reg = kvm_check_extension(s, KVM_CAP_ONE_REG); cap_hior = kvm_check_extension(s, KVM_CAP_PPC_HIOR); + cap_epr = kvm_check_extension(s, KVM_CAP_PPC_EPR); if (!cap_interrupt_level) { fprintf(stderr, "KVM: Couldn't find level irq capability. Expect the " @@ -1530,6 +1532,11 @@ int kvmppc_fixup_cpu(PowerPCCPU *cpu) return 0; } +bool kvmppc_has_cap_epr(void) +{ + return cap_epr; +} + static int kvm_ppc_register_host_cpu_type(void) { TypeInfo type_info = { diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h index 6bcc5cc..600d632 100644 --- a/target-ppc/kvm_ppc.h +++ b/target-ppc/kvm_ppc.h @@ -33,6 +33,7 @@ int kvmppc_reset_htab(int shift_hint); uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift); #endif /* !CONFIG_USER_ONLY */ int kvmppc_fixup_cpu(PowerPCCPU *cpu); +bool kvmppc_has_cap_epr(void); #else @@ -129,6 +130,11 @@ static inline int kvmppc_fixup_cpu(PowerPCCPU *cpu) { return -1; } + +static inline bool kvmppc_has_cap_epr(void) +{ + return false; +} #endif #ifndef CONFIG_KVM