From patchwork Fri Jul 13 03:37:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rusty Russell X-Patchwork-Id: 170772 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 D743A2C0348 for ; Fri, 13 Jul 2012 13:39:40 +1000 (EST) Received: from localhost ([::1]:58054 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpWjC-0004gJ-Ih for incoming@patchwork.ozlabs.org; Thu, 12 Jul 2012 23:39:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpWj6-0004gD-Hr for qemu-devel@nongnu.org; Thu, 12 Jul 2012 23:39:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SpWj5-0006eh-FU for qemu-devel@nongnu.org; Thu, 12 Jul 2012 23:39:32 -0400 Received: from ozlabs.org ([203.10.76.45]:37826) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SpWj5-0006eA-48 for qemu-devel@nongnu.org; Thu, 12 Jul 2012 23:39:31 -0400 Received: by ozlabs.org (Postfix, from userid 1011) id 73FC52C02F2; Fri, 13 Jul 2012 13:39:26 +1000 (EST) From: Rusty Russell To: peter.maydell@linaro.org User-Agent: Notmuch/0.12 (http://notmuchmail.org) Emacs/23.3.1 (i686-pc-linux-gnu) Date: Fri, 13 Jul 2012 13:07:44 +0930 Message-ID: <878veoz5yv.fsf@rustcorp.com.au> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 203.10.76.45 Cc: kvmarm@lists.cs.columbia.edu, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] target-arm: kvm: use KVM_SET_SREGS to set target to Cortex A15 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 Recent kernels use this to set the cpu and features (currently, only the A15 is supported). Note that this causes the registers in the CPU to be initialized, so it's important that all CPUs are created first (they are, as it turns out). This code ignores errors, for backwards compatibility with older kernels. Signed-off-by: Rusty Russell diff --git a/linux-headers/asm-arm/kvm.h b/linux-headers/asm-arm/kvm.h index 38ff1d6..988890a 100644 --- a/linux-headers/asm-arm/kvm.h +++ b/linux-headers/asm-arm/kvm.h @@ -66,7 +66,13 @@ struct kvm_regs { }; +/* Supported Processor Types */ +#define KVM_ARM_TARGET_CORTEX_A15 (0xC0F) + struct kvm_sregs { + __u32 target; + __u32 num_features; + __u32 features[14]; }; struct kvm_fpu { diff --git a/target-arm/kvm.c b/target-arm/kvm.c index 29bb51f..67d005f 100644 --- a/target-arm/kvm.c +++ b/target-arm/kvm.c @@ -34,7 +34,13 @@ int kvm_arch_init(KVMState *s) int kvm_arch_init_vcpu(CPUARMState *env) { - return 0; + struct kvm_sregs sregs; + + sregs.target = KVM_ARM_TARGET_CORTEX_A15; + sregs.num_features = 0; + + /* Ignore failure for compatibility with old kvm versions. */ + return kvm_vcpu_ioctl(env, KVM_SET_SREGS, &sregs) ? 0 : 0; } int kvm_arch_put_registers(CPUARMState *env, int level)