From patchwork Wed Jul 22 08:32:19 2015
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pavel Fedin
X-Patchwork-Id: 498440
Return-Path:
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@bilbo.ozlabs.org
Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])
(using TLSv1 with cipher AES256-SHA (256/256 bits))
(No client certificate requested)
by ozlabs.org (Postfix) with ESMTPS id 63D751402BC
for ;
Wed, 22 Jul 2015 18:33:03 +1000 (AEST)
Received: from localhost ([::1]:35065 helo=lists.gnu.org)
by lists.gnu.org with esmtp (Exim 4.71) (envelope-from
)
id 1ZHpSX-0008R2-7R
for incoming@patchwork.ozlabs.org; Wed, 22 Jul 2015 04:33:01 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:59743)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from ) id 1ZHpS1-0007O6-O8
for qemu-devel@nongnu.org; Wed, 22 Jul 2015 04:32:31 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
(envelope-from ) id 1ZHpRz-0004HR-Ck
for qemu-devel@nongnu.org; Wed, 22 Jul 2015 04:32:29 -0400
Received: from mailout3.w1.samsung.com ([210.118.77.13]:58929)
by eggs.gnu.org with esmtp (Exim 4.71)
(envelope-from ) id 1ZHpRz-0004HL-4w
for qemu-devel@nongnu.org; Wed, 22 Jul 2015 04:32:27 -0400
Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244])
by mailout3.w1.samsung.com
(Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5
2014)) with ESMTP id <0NRV00K2HRQ2EQ30@mailout3.w1.samsung.com> for
qemu-devel@nongnu.org; Wed, 22 Jul 2015 09:32:26 +0100 (BST)
X-AuditID: cbfec7f4-f79c56d0000012ee-62-55af5519ea66
Received: from eusync1.samsung.com ( [203.254.199.211])
by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 6A.92.04846.9155FA55;
Wed, 22 Jul 2015 09:32:25 +0100 (BST)
Received: from localhost ([106.109.131.169])
by eusync1.samsung.com (Oracle Communications Messaging Server
7.0.5.31.0 64bit (built May 5 2014))
with ESMTPA id <0NRV00108RQ1ULB0@eusync1.samsung.com>; Wed,
22 Jul 2015 09:32:25 +0100 (BST)
From: Pavel Fedin
To: qemu-devel@nongnu.org
Date: Wed, 22 Jul 2015 11:32:19 +0300
Message-id:
<20f67ce7f15f2e5af3716e1dcb559fb198e4de35.1437553624.git.p.fedin@samsung.com>
X-Mailer: git-send-email 1.9.5.msysgit.0
In-reply-to:
References:
In-reply-to:
References:
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFlrHLMWRmVeSWpSXmKPExsVy+t/xy7qSoetDDd4s1bF48fofo8Wmz+dY
LOZvOcNqMefMAxaL4707WCzaPn9nt7j7+jOLA7vHv8P9TB47Z91l92g58pbV4861PWweT65t
ZgpgjeKySUnNySxLLdK3S+DK2NHXzVSwX7ni/c+NrA2ME6W7GDk5JARMJDbP/8MMYYtJXLi3
nq2LkYtDSGApo0TrvjvMEM43Rokjsz8zgVSxCahLnP76gQXEFhGQlPjddRqsiFlgIpPExtmt
bCAJYQEXid17poIVsQioSkxavhPM5hWIlug7/JIFYp2GxKIvc8DqOQXMJd5euMUIYgsJmEm8
m76UFZf4BEb+BYwMqxhFU0uTC4qT0nMN9YoTc4tL89L1kvNzNzFCQvHLDsbFx6wOMQpwMCrx
8E44ui5UiDWxrLgy9xCjBAezkgivMvf6UCHelMTKqtSi/Pii0pzU4kOM0hwsSuK8c3e9DxES
SE8sSc1OTS1ILYLJMnFwSjUwmvP8KljJGaD/82VR86VfCiLvF/0pOXW9lvt6+Ob0ScUav+9M
P31JtOR++xmzj5OaT17SfZCexmAwg1PeJuDx1FPLXnBUnTHjj9WdoMSxv2PXmuN3Z7YuerbQ
5qBMe+Kpzb/kV4T+LjG0yZj18lu9++536Xt3Pxc8elzf0d3VVP8Tf4TO3/emqUosxRmJhlrM
RcWJAJyJj9lBAgAA
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
recognized.
X-Received-From: 210.118.77.13
Cc: Peter Maydell ,
Eric Auger ,
Shlomo Pongratz ,
Shlomo Pongratz ,
Diana Craciun ,
Christoffer Dall
Subject: [Qemu-devel] [PATCH v6 4/6] Introduce irqchip type specification
for KVM
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
This patch introduces kernel_irqchip_type member in Machine class, which
it passed to kvm_arch_irqchip_create. It allows machine models to specify
correct GIC type during KVM capability verification. The variable is
defined as int in order to be architecture-agnostic for potential future
uses by other architectures.
Signed-off-by: Pavel Fedin
---
hw/arm/vexpress.c | 1 +
hw/arm/virt.c | 3 +++
include/hw/boards.h | 1 +
include/sysemu/kvm.h | 3 ++-
kvm-all.c | 2 +-
stubs/kvm.c | 2 +-
target-arm/kvm.c | 13 +++++++++++--
7 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index da21788..0675a00 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -556,6 +556,7 @@ static void vexpress_common_init(MachineState *machine)
const hwaddr *map = daughterboard->motherboard_map;
int i;
+ machine->kernel_irqchip_type = KVM_DEV_TYPE_ARM_VGIC_V2;
daughterboard->init(vms, machine->ram_size, machine->cpu_model, pic);
/*
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 4846892..2e7d858 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -945,6 +945,9 @@ static void virt_instance_init(Object *obj)
"Set on/off to enable/disable the ARM "
"Security Extensions (TrustZone)",
NULL);
+
+ /* Default GIC type is v2 */
+ vms->parent.kernel_irqchip_type = KVM_DEV_TYPE_ARM_VGIC_V2;
}
static void virt_class_init(ObjectClass *oc, void *data)
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 2aec9cb..37eb767 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -127,6 +127,7 @@ struct MachineState {
char *accel;
bool kernel_irqchip_allowed;
bool kernel_irqchip_required;
+ int kernel_irqchip_type;
int kvm_shadow_mem;
char *dtb;
char *dumpdtb;
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index 983e99e..8f4d485 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -434,6 +434,7 @@ void kvm_init_irq_routing(KVMState *s);
/**
* kvm_arch_irqchip_create:
* @KVMState: The KVMState pointer
+ * @type: irqchip type, architecture-specific
*
* Allow architectures to create an in-kernel irq chip themselves.
*
@@ -441,7 +442,7 @@ void kvm_init_irq_routing(KVMState *s);
* 0: irq chip was not created
* > 0: irq chip was created
*/
-int kvm_arch_irqchip_create(KVMState *s);
+int kvm_arch_irqchip_create(KVMState *s, int type);
/**
* kvm_set_one_reg - set a register value in KVM via KVM_SET_ONE_REG ioctl
diff --git a/kvm-all.c b/kvm-all.c
index 06e06f2..8df938d 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1395,7 +1395,7 @@ static void kvm_irqchip_create(MachineState *machine, KVMState *s)
/* First probe and see if there's a arch-specific hook to create the
* in-kernel irqchip for us */
- ret = kvm_arch_irqchip_create(s);
+ ret = kvm_arch_irqchip_create(s, machine->kernel_irqchip_type);
if (ret == 0) {
ret = kvm_vm_ioctl(s, KVM_CREATE_IRQCHIP);
}
diff --git a/stubs/kvm.c b/stubs/kvm.c
index e7c60b6..a8505ff 100644
--- a/stubs/kvm.c
+++ b/stubs/kvm.c
@@ -1,7 +1,7 @@
#include "qemu-common.h"
#include "sysemu/kvm.h"
-int kvm_arch_irqchip_create(KVMState *s)
+int kvm_arch_irqchip_create(KVMState *s, int type)
{
return 0;
}
diff --git a/target-arm/kvm.c b/target-arm/kvm.c
index b278542..180f75f 100644
--- a/target-arm/kvm.c
+++ b/target-arm/kvm.c
@@ -583,19 +583,28 @@ void kvm_arch_init_irq_routing(KVMState *s)
{
}
-int kvm_arch_irqchip_create(KVMState *s)
+int kvm_arch_irqchip_create(KVMState *s, int type)
{
int ret;
+ /* Failure here means forgotten initialization of
+ * machine->kernel_irqchip_type in model code
+ */
+ assert(type != 0);
+
/* If we can create the VGIC using the newer device control API, we
* let the device do this when it initializes itself, otherwise we
* fall back to the old API */
- ret = kvm_create_device(s, KVM_DEV_TYPE_ARM_VGIC_V2, true);
+ ret = kvm_create_device(s, type, true);
if (ret == 0) {
return 1;
}
+ /* Fallback will create VGIC v2 */
+ if (type != KVM_DEV_TYPE_ARM_VGIC_V2) {
+ return ret;
+ }
return 0;
}