From patchwork Fri Jul 3 09:14:22 2015
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pavel Fedin
X-Patchwork-Id: 490952
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 46C2E140778
for ;
Fri, 3 Jul 2015 19:15:11 +1000 (AEST)
Received: from localhost ([::1]:39956 helo=lists.gnu.org)
by lists.gnu.org with esmtp (Exim 4.71) (envelope-from
)
id 1ZAx3t-0007Ke-5k
for incoming@patchwork.ozlabs.org; Fri, 03 Jul 2015 05:15:09 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:36063)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from ) id 1ZAx3L-0006Sp-MK
for qemu-devel@nongnu.org; Fri, 03 Jul 2015 05:14:37 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
(envelope-from ) id 1ZAx3G-0002DH-Ov
for qemu-devel@nongnu.org; Fri, 03 Jul 2015 05:14:35 -0400
Received: from mailout2.w1.samsung.com ([210.118.77.12]:56009)
by eggs.gnu.org with esmtp (Exim 4.71)
(envelope-from ) id 1ZAx3G-0002Ct-Jq
for qemu-devel@nongnu.org; Fri, 03 Jul 2015 05:14:30 -0400
Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245])
by mailout2.w1.samsung.com
(Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5
2014)) with ESMTP id <0NQW0086HN054Z00@mailout2.w1.samsung.com> for
qemu-devel@nongnu.org; Fri, 03 Jul 2015 10:14:29 +0100 (BST)
X-AuditID: cbfec7f5-f794b6d000001495-63-55965275f104
Received: from eusync3.samsung.com ( [203.254.199.213])
by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id F5.2C.05269.57256955;
Fri, 3 Jul 2015 10:14:29 +0100 (BST)
Received: from localhost ([106.109.131.169])
by eusync3.samsung.com (Oracle Communications Messaging Server
7.0.5.31.0 64bit (built May 5 2014))
with ESMTPA id <0NQW00L5VN04T150@eusync3.samsung.com>; Fri,
03 Jul 2015 10:14:29 +0100 (BST)
From: Pavel Fedin
To: qemu-devel@nongnu.org
Date: Fri, 03 Jul 2015 12:14:22 +0300
Message-id:
<4b761fbe1ac681e45fbc03db271a88fb5c125600.1435914499.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+NgFmplluLIzCtJLcpLzFFi42I5/e/4Vd3SoGmhBlcf81vMOfOAxeJ47w4W
ByaPO9f2sHk8ubaZKYApissmJTUnsyy1SN8ugSvjzINjjAX/tSveHVvA1sDYo9TFyMkhIWAi
8fNZOxuELSZx4d56IJuLQ0hgKaNE468ORgjnG6PErNaVrCBVbALqEqe/fmABsUUEJCV+d51m
BiliFnjEKHGt7RwzSEJYwEXi3vT5YEUsAqoS/TNnAI3l4OAViJb4PccfYpuGxKIvc8A2cwqY
S6z8epIJxBYSMJO4fGQlTvEJjPwLGBlWMYqmliYXFCel5xrpFSfmFpfmpesl5+duYoQEztcd
jEuPWR1iFOBgVOLhvXB6aqgQa2JZcWXuIUYJDmYlEd6X/tNChXhTEiurUovy44tKc1KLDzFK
c7AoifPO3PU+REggPbEkNTs1tSC1CCbLxMEp1cA4f7NlWAifFA/396mHuFuOFLY+5r4porrw
aN09l3m6nEoXd86bmPK/nimA+YWYds1nsc39TT91FydbmdlmX5pg56Av9spb46u9hlVTzy+h
sAOSOW+O+G+3fzDz19PIRTtNjWK8WFpj+By6HtxoyZ3qrnrrcW9m/DfZFA8P8Y6zex4eLvJa
8leJpTgj0VCLuag4EQAQjJxdGAIAAA==
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
recognized.
X-Received-From: 210.118.77.12
Cc: Peter Maydell ,
Shlomo Pongratz ,
Shlomo Pongratz ,
Christoffer Dall ,
Eric Auger
Subject: [Qemu-devel] [PATCH v2 3/5] 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.
Just in case, the default value is set for absolutely all board models
which include GIC in some form. I am not sure whether all these models can
use KVM acceleration, but it definitely would not hurt.
Signed-off-by: Pavel Fedin
---
hw/arm/exynos4_boards.c | 1 +
hw/arm/realview.c | 1 +
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 | 8 ++++++--
9 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/hw/arm/exynos4_boards.c b/hw/arm/exynos4_boards.c
index d644db1..d4136bc 100644
--- a/hw/arm/exynos4_boards.c
+++ b/hw/arm/exynos4_boards.c
@@ -104,6 +104,7 @@ static Exynos4210State *exynos4_boards_init_common(MachineState *machine,
exynos4_machines[board_type].max_cpus);
}
+ machine->kernel_irqchip_type = KVM_DEV_TYPE_ARM_VGIC_V2;
exynos4_board_binfo.ram_size = exynos4_board_ram_size[board_type];
exynos4_board_binfo.board_id = exynos4_board_id[board_type];
exynos4_board_binfo.smp_bootreg_addr =
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index ef2788d..f670d9f 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -74,6 +74,7 @@ static void realview_init(MachineState *machine,
ram_addr_t ram_size = machine->ram_size;
hwaddr periphbase = 0;
+ machine->kernel_irqchip_type = KVM_DEV_TYPE_ARM_VGIC_V2;
switch (board_type) {
case BOARD_EB:
break;
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 6379901..6e42cf2 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -126,6 +126,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 f459fbd..b9009c8 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -426,6 +426,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.
*
@@ -433,7 +434,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 53e01d4..7710ffe 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1350,7 +1350,7 @@ static int 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) {
return ret;
} else if (ret == 0) {
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 548bfd7..fa1073f 100644
--- a/target-arm/kvm.c
+++ b/target-arm/kvm.c
@@ -579,7 +579,7 @@ 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;
@@ -587,11 +587,15 @@ int kvm_arch_irqchip_create(KVMState *s)
* 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;
}