From patchwork Sun Apr 17 08:49:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 91537 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A69521007D5 for ; Sun, 17 Apr 2011 18:50:12 +1000 (EST) Received: from localhost ([::1]:56612 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QBNgH-0001yi-7y for incoming@patchwork.ozlabs.org; Sun, 17 Apr 2011 04:50:09 -0400 Received: from eggs.gnu.org ([140.186.70.92]:56336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QBNg9-0001yG-GQ for qemu-devel@nongnu.org; Sun, 17 Apr 2011 04:50:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QBNg8-0000iD-BQ for qemu-devel@nongnu.org; Sun, 17 Apr 2011 04:50:01 -0400 Received: from cantor.suse.de ([195.135.220.2]:39785 helo=mx1.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QBNg7-0000hw-Vw for qemu-devel@nongnu.org; Sun, 17 Apr 2011 04:50:00 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 6936A957DB for ; Sun, 17 Apr 2011 10:49:57 +0200 (CEST) From: Alexander Graf To: qemu-devel@nongnu.org Date: Sun, 17 Apr 2011 10:49:53 +0200 Message-Id: <1303030193-3732-1-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.2 Subject: [Qemu-devel] [PATCH] kvm: ppc: detect old headers 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 When compiling Qemu with older kernel headers, the PVR setting mechanism isn't available yet. Unfortunately, back then I didn't add a capability we could check against, so all we can do is add a configure test to see if we support PVR setting. For BookE, we don't care yet. While at it, also memset the sregs to zero, so we have sane state in case we add fields later. This fixes compilation errors with KVM enabled on older kernel headers (like 2.6.32). Signed-off-by: Alexander Graf --- configure | 18 ++++++++++++++++++ target-ppc/kvm.c | 24 +++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/configure b/configure index da2da04..7b90e1e 100755 --- a/configure +++ b/configure @@ -1772,6 +1772,21 @@ recent kvm-kmod from http://sourceforge.net/projects/kvm." fi ########################################## +# test for ppc kvm pvr setting + +if test "$kvm" = "yes" && test "$cpu" = "ppc" -o "$cpu" = "ppc64"; then + cat > $TMPC < + int main(void) { struct kvm_sregs s; s.pvr = 0; return 0; } +EOF + if compile_prog "$kvm_cflags" "" ; then + kvm_ppc_pvr=yes + else + kvm_ppc_pvr=no + fi +fi + +########################################## # test for vhost net if test "$vhost_net" != "no"; then @@ -3241,6 +3256,9 @@ case "$target_arch2" in if test $vhost_net = "yes" ; then echo "CONFIG_VHOST_NET=y" >> $config_target_mak fi + if test $kvm_ppc_pvr = "yes" ; then + echo "CONFIG_KVM_PPC_PVR=y" >> $config_target_mak + fi fi esac if test "$target_bigendian" = "yes" ; then diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 2cfb24b..93d91df 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -80,10 +80,28 @@ int kvm_arch_init(KVMState *s) int kvm_arch_init_vcpu(CPUState *cenv) { int ret = 0; - struct kvm_sregs sregs; - sregs.pvr = cenv->spr[SPR_PVR]; - ret = kvm_vcpu_ioctl(cenv, KVM_SET_SREGS, &sregs); + if ((cenv->mmu_model == POWERPC_MMU_BOOKE) || + (cenv->mmu_model == POWERPC_MMU_BOOKE_FSL)) { + /* What we're really trying to say is "if we're on BookE, we use + the native PVR for now". This is the only sane way to check + it though, so we potentially confuse users that they can run + BookE guests on BookS. Let's hope nobody dares enough :) */ + } else { +#ifdef CONFIG_KVM_PPC_PVR + struct kvm_sregs sregs; + + memset(&sregs, 0, sizeof(sregs)); + sregs.pvr = cenv->spr[SPR_PVR]; + ret = kvm_vcpu_ioctl(cenv, KVM_SET_SREGS, &sregs); +#else + ret = -ENOSYS; +#endif + + if (ret) { + fprintf(stderr, "kvm error: missing PVR setting capability\n"); + } + } idle_timer = qemu_new_timer_ns(vm_clock, kvm_kick_env, cenv);