From patchwork Fri Jul 24 09:55:46 2015
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Pavel Fedin
X-Patchwork-Id: 499643
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 BDA7B140A98
for ;
Fri, 24 Jul 2015 19:56:47 +1000 (AEST)
Received: from localhost ([::1]:44281 helo=lists.gnu.org)
by lists.gnu.org with esmtp (Exim 4.71) (envelope-from
)
id 1ZIZif-0007mf-Va
for incoming@patchwork.ozlabs.org; Fri, 24 Jul 2015 05:56:46 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:55053)
by lists.gnu.org with esmtp (Exim 4.71)
(envelope-from ) id 1ZIZi2-0006WL-E9
for qemu-devel@nongnu.org; Fri, 24 Jul 2015 05:56:07 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
(envelope-from ) id 1ZIZhx-0004vC-D7
for qemu-devel@nongnu.org; Fri, 24 Jul 2015 05:56:06 -0400
Received: from mailout2.w1.samsung.com ([210.118.77.12]:31242)
by eggs.gnu.org with esmtp (Exim 4.71)
(envelope-from ) id 1ZIZhx-0004uN-5T
for qemu-devel@nongnu.org; Fri, 24 Jul 2015 05:56:01 -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 <0NRZ0028LKX9R890@mailout2.w1.samsung.com> for
qemu-devel@nongnu.org; Fri, 24 Jul 2015 10:55:57 +0100 (BST)
X-AuditID: cbfec7f5-f794b6d000001495-65-55b20badff0c
Received: from eusync3.samsung.com ( [203.254.199.213])
by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 94.7B.05269.DAB02B55;
Fri, 24 Jul 2015 10:55:57 +0100 (BST)
Received: from fedinw7x64.rnd.samsung.ru ([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 <0NRZ007OMKX15F50@eusync3.samsung.com>; Fri,
24 Jul 2015 10:55:57 +0100 (BST)
From: Pavel Fedin
To: qemu-devel@nongnu.org
Date: Fri, 24 Jul 2015 12:55:46 +0300
Message-id:
<1d1b6e7107ccc15e3f3a0caf754279258673bfd0.1437731107.git.p.fedin@samsung.com>
X-Mailer: git-send-email 2.4.4
In-reply-to:
References:
In-reply-to:
References:
X-Brightmail-Tracker:
H4sIAAAAAAAAA+NgFlrCLMWRmVeSWpSXmKPExsVy+t/xq7pruTeFGhybpG7x4vU/Rov5W86w
Wsw584DF4njvDhaLts/f2S3uvv7M4sDmsXPWXXaPliNvWT3uXNvD5vHk2mamAJYoLpuU1JzM
stQifbsEroxbDxpYC5ZqVnTMWsrewDhBoYuRk0NCwESio7eZFcIWk7hwbz1bFyMXh5DAUkaJ
KY9OMkM4bUwS1xrPM4NUsQmoS5z++oEFxBYRkJT43XUarIhZ4BGjxLW2c2BFwgIuEkua5oCN
ZRFQldi/+TpYnFcgWuL8xgY2iHVyEleuTwezOQXMJR6c2As2VEjATGLx431MuMQnMPIvYGRY
xSiaWppcUJyUnmukV5yYW1yal66XnJ+7iRESdl93MC49ZnWIUYCDUYmH98CkjaFCrIllxZW5
hxglOJiVRHgZjgGFeFMSK6tSi/Lji0pzUosPMUpzsCiJ887c9T5ESCA9sSQ1OzW1ILUIJsvE
wSnVwOi0OaWmfletebbbnxkb7rXzy3IIx4d/vxn31ULTa/2FOhVppSrleV9sbzALrXV9eav0
roqMesm/06m+HS/vNF6ZWtI1PyJmVidb2bzoxn0LL7iZPRIO2y4T++aYRkyZenrLnn2fRQq6
Ijy9ZA5v1GjdOjF6r8kcqVcFDTvLe089KHnvNPvGdyWW4oxEQy3mouJEAJL6nYo3AgAA
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 v7 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
is passed to kvm_arch_irqchip_create. Machine models which can use vGIC
now use it in order to supply correct GIC type for 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-consts.h | 6 ++++++
target-arm/kvm.c | 13 +++++++++++--
8 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index da21788..865e823 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 = QEMU_GIC_TYPE_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..30d9ab8 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 = QEMU_GIC_TYPE_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-consts.h b/target-arm/kvm-consts.h
index 943bf89..0bc12b7 100644
--- a/target-arm/kvm-consts.h
+++ b/target-arm/kvm-consts.h
@@ -39,6 +39,12 @@ MISMATCH_CHECK(CP_REG_SIZE_U64, KVM_REG_SIZE_U64)
MISMATCH_CHECK(CP_REG_ARM, KVM_REG_ARM)
MISMATCH_CHECK(CP_REG_ARCH_MASK, KVM_REG_ARCH_MASK)
+#define QEMU_GIC_TYPE_V2 5
+#define QEMU_GIC_TYPE_V3 7
+
+MISMATCH_CHECK(QEMU_GIC_TYPE_V2, KVM_DEV_TYPE_ARM_VGIC_V2)
+MISMATCH_CHECK(QEMU_GIC_TYPE_V3, KVM_DEV_TYPE_ARM_VGIC_V3)
+
#define QEMU_PSCI_0_1_FN_BASE 0x95c1ba5e
#define QEMU_PSCI_0_1_FN(n) (QEMU_PSCI_0_1_FN_BASE + (n))
#define QEMU_PSCI_0_1_FN_CPU_SUSPEND QEMU_PSCI_0_1_FN(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;
}