All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH V5 0/8] PSCI v0.2 support for KVM ARM/ARM64
@ 2014-05-12 12:37 Pranavkumar Sawargaonkar
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 1/8] update-linux-headers.sh: Add psci.h to linux header sync-up script Pranavkumar Sawargaonkar
                   ` (8 more replies)
  0 siblings, 9 replies; 18+ messages in thread
From: Pranavkumar Sawargaonkar @ 2014-05-12 12:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, patches, robherring2, kvmarm, christoffer.dall,
	Pranavkumar Sawargaonkar

This patchset adds the QEMU side changes for providing PSCI v0.2 to VM.

ChangeLog:

V5:
- Updated "scripts/update-linux-headers.sh" to include linux/psci.h
- Synced linux headers using update-linux-headers.sh with linux-next tree
- Added per cpu field for kvm init features.
- Set psci-0.2 compatible string in generated dtb sucn that it works for 
  guest kernel not having psci 0.2 support.
- Added QEMU_KVM_CAP_ARM_PSCI_0_2 define in target-arm/kvm-consts.h

V4:
- Rebase this patch against v11 patchset for in-kernel PSCI v0.2 emulation
 (http://www.spinics.net/lists/kvm-arm/msg09182.html)
- Used PSCI 0.2 DT bindings for linux kernel.
  (http://www.spinics.net/lists/arm-kernel/msg326044.html).

V3:
 - Rebase this patchset against v8 patchset for in-kernel PSCI v0.2 emulation
   (http://www.spinics.net/lists/kvm-arm/msg08780.html)
 - Added common kvm_arm_vcpu_init() function for kvm arm and kvm arm64

V2:
 - Rebase this patchset against v6 patchset for in-kernel PSCI v0.2 emulation
   (http://www.spinics.net/lists/arm-kernel/msg319037.html)
 - Handle KVM_EXIT_SYSTEM_EVENT in kvm-all.c:kvm_cpu_exec()
 - Drop change in kvm_arm_get_host_cpu_features()
 - Improve comments and description of kvm_arch_reset_vcpu() implementation

V1:
 - Initial RFC patchset

Pranavkumar Sawargaonkar (8):
  update-linux-headers.sh: Add psci.h to linux header sync-up script
  linux-headers: Update KVM headers from linux-next tag next-20140508
  kvm: Handle exit reason KVM_EXIT_SYSTEM_EVENT
  target-arm/kvm-const.h: Add QEMU_KVM_CAP_ARM_PSCI_0_2 define
  target-arm: Common kvm_arm_vcpu_init() for KVM ARM and KVM ARM64
  target-arm: Enable KVM_ARM_VCPU_PSCI_0_2 feature when possible
  target-arm: Implement kvm_arch_reset_vcpu() for KVM ARM64
  hw/arm/virt: Use PSCI v0.2 compatible when kernel supports it

 hw/arm/virt.c                   |    8 +++-
 kvm-all.c                       |   16 +++++++
 linux-headers/asm-arm/kvm.h     |   10 +++--
 linux-headers/asm-arm64/kvm.h   |   10 +++--
 linux-headers/asm-s390/kvm.h    |   28 ++++++++++++
 linux-headers/linux/kvm.h       |   14 +++++-
 linux-headers/linux/psci.h      |   90 +++++++++++++++++++++++++++++++++++++++
 scripts/update-linux-headers.sh |    2 +-
 target-arm/cpu-qom.h            |    3 ++
 target-arm/kvm-consts.h         |    5 +++
 target-arm/kvm.c                |   16 +++++++
 target-arm/kvm32.c              |   21 ++++-----
 target-arm/kvm64.c              |   31 +++++++++-----
 target-arm/kvm_arm.h            |   13 ++++++
 14 files changed, 236 insertions(+), 31 deletions(-)
 create mode 100644 linux-headers/linux/psci.h

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Qemu-devel] [RFC PATCH V5 1/8] update-linux-headers.sh: Add psci.h to linux header sync-up script
  2014-05-12 12:37 [Qemu-devel] [RFC PATCH V5 0/8] PSCI v0.2 support for KVM ARM/ARM64 Pranavkumar Sawargaonkar
@ 2014-05-12 12:37 ` Pranavkumar Sawargaonkar
  2014-05-14 15:16   ` Peter Maydell
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 2/8] linux-headers: Update KVM headers from linux-next tag next-20140508 Pranavkumar Sawargaonkar
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 18+ messages in thread
From: Pranavkumar Sawargaonkar @ 2014-05-12 12:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, Anup Patel, patches, robherring2, kvmarm,
	christoffer.dall, Pranavkumar Sawargaonkar

We will be using linux/psci.h for KVM ARM/ARM64 hence add it to
linux header sync-up script.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
---
 scripts/update-linux-headers.sh |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh
index 120a694..eec3f40 100755
--- a/scripts/update-linux-headers.sh
+++ b/scripts/update-linux-headers.sh
@@ -61,7 +61,7 @@ done
 
 rm -rf "$output/linux-headers/linux"
 mkdir -p "$output/linux-headers/linux"
-for header in kvm.h kvm_para.h vfio.h vhost.h virtio_config.h virtio_ring.h; do
+for header in kvm.h kvm_para.h vfio.h vhost.h virtio_config.h virtio_ring.h psci.h; do
     cp "$tmpdir/include/linux/$header" "$output/linux-headers/linux"
 done
 rm -rf "$output/linux-headers/asm-generic"
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [RFC PATCH V5 2/8] linux-headers: Update KVM headers from linux-next tag next-20140508
  2014-05-12 12:37 [Qemu-devel] [RFC PATCH V5 0/8] PSCI v0.2 support for KVM ARM/ARM64 Pranavkumar Sawargaonkar
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 1/8] update-linux-headers.sh: Add psci.h to linux header sync-up script Pranavkumar Sawargaonkar
@ 2014-05-12 12:37 ` Pranavkumar Sawargaonkar
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 3/8] kvm: Handle exit reason KVM_EXIT_SYSTEM_EVENT Pranavkumar Sawargaonkar
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 18+ messages in thread
From: Pranavkumar Sawargaonkar @ 2014-05-12 12:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, Anup Patel, patches, robherring2, kvmarm,
	christoffer.dall, Pranavkumar Sawargaonkar

Syncup KVM related linux headers from linux-next tree using
scripts/update-linux-headers.sh.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
---
 linux-headers/asm-arm/kvm.h   |   10 +++--
 linux-headers/asm-arm64/kvm.h |   10 +++--
 linux-headers/asm-s390/kvm.h  |   28 +++++++++++++
 linux-headers/linux/kvm.h     |   14 ++++++-
 linux-headers/linux/psci.h    |   90 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 143 insertions(+), 9 deletions(-)
 create mode 100644 linux-headers/linux/psci.h

diff --git a/linux-headers/asm-arm/kvm.h b/linux-headers/asm-arm/kvm.h
index ef0c878..e6ebdd3 100644
--- a/linux-headers/asm-arm/kvm.h
+++ b/linux-headers/asm-arm/kvm.h
@@ -20,6 +20,7 @@
 #define __ARM_KVM_H__
 
 #include <linux/types.h>
+#include <linux/psci.h>
 #include <asm/ptrace.h>
 
 #define __KVM_HAVE_GUEST_DEBUG
@@ -83,6 +84,7 @@ struct kvm_regs {
 #define KVM_VGIC_V2_CPU_SIZE		0x2000
 
 #define KVM_ARM_VCPU_POWER_OFF		0 /* CPU is started in OFF state */
+#define KVM_ARM_VCPU_PSCI_0_2		1 /* CPU uses PSCI v0.2 */
 
 struct kvm_vcpu_init {
 	__u32 target;
@@ -201,9 +203,9 @@ struct kvm_arch_memory_slot {
 #define KVM_PSCI_FN_CPU_ON		KVM_PSCI_FN(2)
 #define KVM_PSCI_FN_MIGRATE		KVM_PSCI_FN(3)
 
-#define KVM_PSCI_RET_SUCCESS		0
-#define KVM_PSCI_RET_NI			((unsigned long)-1)
-#define KVM_PSCI_RET_INVAL		((unsigned long)-2)
-#define KVM_PSCI_RET_DENIED		((unsigned long)-3)
+#define KVM_PSCI_RET_SUCCESS		PSCI_RET_SUCCESS
+#define KVM_PSCI_RET_NI			PSCI_RET_NOT_SUPPORTED
+#define KVM_PSCI_RET_INVAL		PSCI_RET_INVALID_PARAMS
+#define KVM_PSCI_RET_DENIED		PSCI_RET_DENIED
 
 #endif /* __ARM_KVM_H__ */
diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h
index eaf54a3..e6471da 100644
--- a/linux-headers/asm-arm64/kvm.h
+++ b/linux-headers/asm-arm64/kvm.h
@@ -31,6 +31,7 @@
 #define KVM_NR_SPSR	5
 
 #ifndef __ASSEMBLY__
+#include <linux/psci.h>
 #include <asm/types.h>
 #include <asm/ptrace.h>
 
@@ -77,6 +78,7 @@ struct kvm_regs {
 
 #define KVM_ARM_VCPU_POWER_OFF		0 /* CPU is started in OFF state */
 #define KVM_ARM_VCPU_EL1_32BIT		1 /* CPU running a 32bit VM */
+#define KVM_ARM_VCPU_PSCI_0_2		2 /* CPU uses PSCI v0.2 */
 
 struct kvm_vcpu_init {
 	__u32 target;
@@ -186,10 +188,10 @@ struct kvm_arch_memory_slot {
 #define KVM_PSCI_FN_CPU_ON		KVM_PSCI_FN(2)
 #define KVM_PSCI_FN_MIGRATE		KVM_PSCI_FN(3)
 
-#define KVM_PSCI_RET_SUCCESS		0
-#define KVM_PSCI_RET_NI			((unsigned long)-1)
-#define KVM_PSCI_RET_INVAL		((unsigned long)-2)
-#define KVM_PSCI_RET_DENIED		((unsigned long)-3)
+#define KVM_PSCI_RET_SUCCESS		PSCI_RET_SUCCESS
+#define KVM_PSCI_RET_NI			PSCI_RET_NOT_SUPPORTED
+#define KVM_PSCI_RET_INVAL		PSCI_RET_INVALID_PARAMS
+#define KVM_PSCI_RET_DENIED		PSCI_RET_DENIED
 
 #endif
 
diff --git a/linux-headers/asm-s390/kvm.h b/linux-headers/asm-s390/kvm.h
index c003c6a..98bedf3 100644
--- a/linux-headers/asm-s390/kvm.h
+++ b/linux-headers/asm-s390/kvm.h
@@ -15,6 +15,7 @@
 #include <linux/types.h>
 
 #define __KVM_S390
+#define __KVM_HAVE_GUEST_DEBUG
 
 /* Device control API: s390-specific devices */
 #define KVM_DEV_FLIC_GET_ALL_IRQS	1
@@ -54,6 +55,13 @@ struct kvm_s390_io_adapter_req {
 	__u64 addr;
 };
 
+/* kvm attr_group  on vm fd */
+#define KVM_S390_VM_MEM_CTRL		0
+
+/* kvm attributes for mem_ctrl */
+#define KVM_S390_VM_MEM_ENABLE_CMMA	0
+#define KVM_S390_VM_MEM_CLR_CMMA	1
+
 /* for KVM_GET_REGS and KVM_SET_REGS */
 struct kvm_regs {
 	/* general purpose regs for s390 */
@@ -72,11 +80,31 @@ struct kvm_fpu {
 	__u64 fprs[16];
 };
 
+#define KVM_GUESTDBG_USE_HW_BP		0x00010000
+
+#define KVM_HW_BP			1
+#define KVM_HW_WP_WRITE			2
+#define KVM_SINGLESTEP			4
+
 struct kvm_debug_exit_arch {
+	__u64 addr;
+	__u8 type;
+	__u8 pad[7]; /* Should be set to 0 */
+};
+
+struct kvm_hw_breakpoint {
+	__u64 addr;
+	__u64 phys_addr;
+	__u64 len;
+	__u8 type;
+	__u8 pad[7]; /* Should be set to 0 */
 };
 
 /* for KVM_SET_GUEST_DEBUG */
 struct kvm_guest_debug_arch {
+	__u32 nr_hw_bp;
+	__u32 pad; /* Should be set to 0 */
+	struct kvm_hw_breakpoint *hw_bp;
 };
 
 #define KVM_SYNC_PREFIX (1UL << 0)
diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index b278ab3..6a9a0fc 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -171,6 +171,7 @@ struct kvm_pit_config {
 #define KVM_EXIT_WATCHDOG         21
 #define KVM_EXIT_S390_TSCH        22
 #define KVM_EXIT_EPR              23
+#define KVM_EXIT_SYSTEM_EVENT     24
 
 /* For KVM_EXIT_INTERNAL_ERROR */
 /* Emulate instruction failed. */
@@ -301,6 +302,13 @@ struct kvm_run {
 		struct {
 			__u32 epr;
 		} epr;
+		/* KVM_EXIT_SYSTEM_EVENT */
+		struct {
+#define KVM_SYSTEM_EVENT_SHUTDOWN       1
+#define KVM_SYSTEM_EVENT_RESET          2
+			__u32 type;
+			__u64 flags;
+		} system_event;
 		/* Fix the size of the union. */
 		char padding[256];
 	};
@@ -515,6 +523,7 @@ enum {
 	kvm_ioeventfd_flag_nr_pio,
 	kvm_ioeventfd_flag_nr_deassign,
 	kvm_ioeventfd_flag_nr_virtio_ccw_notify,
+	kvm_ioeventfd_flag_nr_fast_mmio,
 	kvm_ioeventfd_flag_nr_max,
 };
 
@@ -529,7 +538,7 @@ enum {
 struct kvm_ioeventfd {
 	__u64 datamatch;
 	__u64 addr;        /* legal pio/mmio address */
-	__u32 len;         /* 1, 2, 4, or 8 bytes    */
+	__u32 len;         /* 1, 2, 4, or 8 bytes; or 0 to ignore length */
 	__s32 fd;
 	__u32 flags;
 	__u8  pad[36];
@@ -743,6 +752,9 @@ struct kvm_ppc_smmu_info {
 #define KVM_CAP_IOAPIC_POLARITY_IGNORED 97
 #define KVM_CAP_ENABLE_CAP_VM 98
 #define KVM_CAP_S390_IRQCHIP 99
+#define KVM_CAP_IOEVENTFD_NO_LENGTH 100
+#define KVM_CAP_VM_ATTRIBUTES 101
+#define KVM_CAP_ARM_PSCI_0_2 102
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
diff --git a/linux-headers/linux/psci.h b/linux-headers/linux/psci.h
new file mode 100644
index 0000000..5a76763
--- /dev/null
+++ b/linux-headers/linux/psci.h
@@ -0,0 +1,90 @@
+/*
+ * ARM Power State and Coordination Interface (PSCI) header
+ *
+ * This header holds common PSCI defines and macros shared
+ * by: ARM kernel, ARM64 kernel, KVM ARM/ARM64 and user space.
+ *
+ * Copyright (C) 2014 Linaro Ltd.
+ * Author: Anup Patel <anup.patel@linaro.org>
+ */
+
+#ifndef _LINUX_PSCI_H
+#define _LINUX_PSCI_H
+
+/*
+ * PSCI v0.1 interface
+ *
+ * The PSCI v0.1 function numbers are implementation defined.
+ *
+ * Only PSCI return values such as: SUCCESS, NOT_SUPPORTED,
+ * INVALID_PARAMS, and DENIED defined below are applicable
+ * to PSCI v0.1.
+ */
+
+/* PSCI v0.2 interface */
+#define PSCI_0_2_FN_BASE			0x84000000
+#define PSCI_0_2_FN(n)				(PSCI_0_2_FN_BASE + (n))
+#define PSCI_0_2_64BIT				0x40000000
+#define PSCI_0_2_FN64_BASE			\
+					(PSCI_0_2_FN_BASE + PSCI_0_2_64BIT)
+#define PSCI_0_2_FN64(n)			(PSCI_0_2_FN64_BASE + (n))
+
+#define PSCI_0_2_FN_PSCI_VERSION		PSCI_0_2_FN(0)
+#define PSCI_0_2_FN_CPU_SUSPEND			PSCI_0_2_FN(1)
+#define PSCI_0_2_FN_CPU_OFF			PSCI_0_2_FN(2)
+#define PSCI_0_2_FN_CPU_ON			PSCI_0_2_FN(3)
+#define PSCI_0_2_FN_AFFINITY_INFO		PSCI_0_2_FN(4)
+#define PSCI_0_2_FN_MIGRATE			PSCI_0_2_FN(5)
+#define PSCI_0_2_FN_MIGRATE_INFO_TYPE		PSCI_0_2_FN(6)
+#define PSCI_0_2_FN_MIGRATE_INFO_UP_CPU		PSCI_0_2_FN(7)
+#define PSCI_0_2_FN_SYSTEM_OFF			PSCI_0_2_FN(8)
+#define PSCI_0_2_FN_SYSTEM_RESET		PSCI_0_2_FN(9)
+
+#define PSCI_0_2_FN64_CPU_SUSPEND		PSCI_0_2_FN64(1)
+#define PSCI_0_2_FN64_CPU_ON			PSCI_0_2_FN64(3)
+#define PSCI_0_2_FN64_AFFINITY_INFO		PSCI_0_2_FN64(4)
+#define PSCI_0_2_FN64_MIGRATE			PSCI_0_2_FN64(5)
+#define PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU	PSCI_0_2_FN64(7)
+
+/* PSCI v0.2 power state encoding for CPU_SUSPEND function */
+#define PSCI_0_2_POWER_STATE_ID_MASK		0xffff
+#define PSCI_0_2_POWER_STATE_ID_SHIFT		0
+#define PSCI_0_2_POWER_STATE_TYPE_SHIFT		16
+#define PSCI_0_2_POWER_STATE_TYPE_MASK		\
+				(0x1 << PSCI_0_2_POWER_STATE_TYPE_SHIFT)
+#define PSCI_0_2_POWER_STATE_AFFL_SHIFT		24
+#define PSCI_0_2_POWER_STATE_AFFL_MASK		\
+				(0x3 << PSCI_0_2_POWER_STATE_AFFL_SHIFT)
+
+/* PSCI v0.2 affinity level state returned by AFFINITY_INFO */
+#define PSCI_0_2_AFFINITY_LEVEL_ON		0
+#define PSCI_0_2_AFFINITY_LEVEL_OFF		1
+#define PSCI_0_2_AFFINITY_LEVEL_ON_PENDING	2
+
+/* PSCI v0.2 multicore support in Trusted OS returned by MIGRATE_INFO_TYPE */
+#define PSCI_0_2_TOS_UP_MIGRATE			0
+#define PSCI_0_2_TOS_UP_NO_MIGRATE		1
+#define PSCI_0_2_TOS_MP				2
+
+/* PSCI version decoding (independent of PSCI version) */
+#define PSCI_VERSION_MAJOR_SHIFT		16
+#define PSCI_VERSION_MINOR_MASK			\
+		((1U << PSCI_VERSION_MAJOR_SHIFT) - 1)
+#define PSCI_VERSION_MAJOR_MASK			~PSCI_VERSION_MINOR_MASK
+#define PSCI_VERSION_MAJOR(ver)			\
+		(((ver) & PSCI_VERSION_MAJOR_MASK) >> PSCI_VERSION_MAJOR_SHIFT)
+#define PSCI_VERSION_MINOR(ver)			\
+		((ver) & PSCI_VERSION_MINOR_MASK)
+
+/* PSCI return values (inclusive of all PSCI versions) */
+#define PSCI_RET_SUCCESS			0
+#define PSCI_RET_NOT_SUPPORTED			-1
+#define PSCI_RET_INVALID_PARAMS			-2
+#define PSCI_RET_DENIED				-3
+#define PSCI_RET_ALREADY_ON			-4
+#define PSCI_RET_ON_PENDING			-5
+#define PSCI_RET_INTERNAL_FAILURE		-6
+#define PSCI_RET_NOT_PRESENT			-7
+#define PSCI_RET_DISABLED			-8
+
+#endif /* _LINUX_PSCI_H */
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [RFC PATCH V5 3/8] kvm: Handle exit reason KVM_EXIT_SYSTEM_EVENT
  2014-05-12 12:37 [Qemu-devel] [RFC PATCH V5 0/8] PSCI v0.2 support for KVM ARM/ARM64 Pranavkumar Sawargaonkar
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 1/8] update-linux-headers.sh: Add psci.h to linux header sync-up script Pranavkumar Sawargaonkar
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 2/8] linux-headers: Update KVM headers from linux-next tag next-20140508 Pranavkumar Sawargaonkar
@ 2014-05-12 12:37 ` Pranavkumar Sawargaonkar
  2014-05-14 15:17   ` Peter Maydell
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 4/8] target-arm/kvm-const.h: Add QEMU_KVM_CAP_ARM_PSCI_0_2 define Pranavkumar Sawargaonkar
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 18+ messages in thread
From: Pranavkumar Sawargaonkar @ 2014-05-12 12:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, Anup Patel, patches, robherring2, kvmarm,
	christoffer.dall, Pranavkumar Sawargaonkar

In-kernel PSCI v0.2 emulation of KVM ARM/ARM64 forwards SYSTEM_OFF
and SYSTEM_RESET function calls to QEMU using KVM_EXIT_SYSTEM_EVENT
exit reason.

This patch updates kvm_cpu_exec() to handle KVM_SYSTEM_EVENT_SHUTDOWN
and KVM_SYSTEM_EVENT_RESET system-level events from QEMU-side.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
---
 kvm-all.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/kvm-all.c b/kvm-all.c
index 5cb7f26..d038b46 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1724,6 +1724,22 @@ int kvm_cpu_exec(CPUState *cpu)
         case KVM_EXIT_INTERNAL_ERROR:
             ret = kvm_handle_internal_error(cpu, run);
             break;
+        case KVM_EXIT_SYSTEM_EVENT:
+            switch (run->system_event.type) {
+            case KVM_SYSTEM_EVENT_SHUTDOWN:
+                qemu_system_shutdown_request();
+                ret = EXCP_INTERRUPT;
+                break;
+            case KVM_SYSTEM_EVENT_RESET:
+                qemu_system_reset_request();
+                ret = EXCP_INTERRUPT;
+                break;
+            default:
+                DPRINTF("kvm_arch_handle_exit\n");
+                ret = kvm_arch_handle_exit(cpu, run);
+                break;
+            }
+            break;
         default:
             DPRINTF("kvm_arch_handle_exit\n");
             ret = kvm_arch_handle_exit(cpu, run);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [RFC PATCH V5 4/8] target-arm/kvm-const.h: Add QEMU_KVM_CAP_ARM_PSCI_0_2 define
  2014-05-12 12:37 [Qemu-devel] [RFC PATCH V5 0/8] PSCI v0.2 support for KVM ARM/ARM64 Pranavkumar Sawargaonkar
                   ` (2 preceding siblings ...)
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 3/8] kvm: Handle exit reason KVM_EXIT_SYSTEM_EVENT Pranavkumar Sawargaonkar
@ 2014-05-12 12:37 ` Pranavkumar Sawargaonkar
  2014-05-14 16:42   ` Peter Maydell
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 5/8] target-arm: Common kvm_arm_vcpu_init() for KVM ARM and KVM ARM64 Pranavkumar Sawargaonkar
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 18+ messages in thread
From: Pranavkumar Sawargaonkar @ 2014-05-12 12:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, Anup Patel, patches, robherring2, kvmarm,
	christoffer.dall, Pranavkumar Sawargaonkar

We require to check whether PSCI v0.2 capability is available or
not in hw/arm/virt.c such that it compiles for both KVM and TCG QEMU.

This patch adds PSCI v0.2 capability #define in target-arm/kvm-const.h
so that it is available for both KVM and TCG QEMU.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
---
 target-arm/kvm-consts.h |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/target-arm/kvm-consts.h b/target-arm/kvm-consts.h
index 6009a33..b5f9a20 100644
--- a/target-arm/kvm-consts.h
+++ b/target-arm/kvm-consts.h
@@ -110,6 +110,11 @@ MISMATCH_CHECK(CP_REG_ARM64_SYSREG_OP2_MASK, KVM_REG_ARM64_SYSREG_OP2_MASK)
 MISMATCH_CHECK(CP_REG_ARM64_SYSREG_OP2_SHIFT, KVM_REG_ARM64_SYSREG_OP2_SHIFT)
 #endif
 
+/* KVM ARM/ARM64 specific capabilities */
+#define QEMU_KVM_CAP_ARM_PSCI_0_2 102
+
+MISMATCH_CHECK(QEMU_KVM_CAP_ARM_PSCI_0_2, KVM_CAP_ARM_PSCI_0_2)
+
 #undef MISMATCH_CHECK
 
 #endif
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [RFC PATCH V5 5/8] target-arm: Common kvm_arm_vcpu_init() for KVM ARM and KVM ARM64
  2014-05-12 12:37 [Qemu-devel] [RFC PATCH V5 0/8] PSCI v0.2 support for KVM ARM/ARM64 Pranavkumar Sawargaonkar
                   ` (3 preceding siblings ...)
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 4/8] target-arm/kvm-const.h: Add QEMU_KVM_CAP_ARM_PSCI_0_2 define Pranavkumar Sawargaonkar
@ 2014-05-12 12:37 ` Pranavkumar Sawargaonkar
  2014-05-14 15:30   ` Peter Maydell
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 6/8] target-arm: Enable KVM_ARM_VCPU_PSCI_0_2 feature when possible Pranavkumar Sawargaonkar
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 18+ messages in thread
From: Pranavkumar Sawargaonkar @ 2014-05-12 12:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, Anup Patel, patches, robherring2, kvmarm,
	christoffer.dall, Pranavkumar Sawargaonkar

Introduce a common kvm_arm_vcpu_init() for doing KVM_ARM_VCPU_INIT
ioctl in KVM ARM and KVM ARM64. This also helps us factor-out few
common code lines from kvm_arch_init_vcpu() for KVM ARM/ARM64.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
---
 target-arm/cpu-qom.h |    3 +++
 target-arm/kvm.c     |   16 ++++++++++++++++
 target-arm/kvm32.c   |   18 ++++++++----------
 target-arm/kvm64.c   |   24 ++++++++++++++----------
 target-arm/kvm_arm.h |   13 +++++++++++++
 5 files changed, 54 insertions(+), 20 deletions(-)

diff --git a/target-arm/cpu-qom.h b/target-arm/cpu-qom.h
index edc7f26..2bd7df8 100644
--- a/target-arm/cpu-qom.h
+++ b/target-arm/cpu-qom.h
@@ -102,6 +102,9 @@ typedef struct ARMCPU {
      */
     uint32_t kvm_target;
 
+    /* KVM init features for this CPU */
+    uint32_t kvm_init_features[7];
+
     /* The instance init functions for implementation-specific subclasses
      * set these fields to specify the implementation-dependent values of
      * various constant registers and reset values of non-constant
diff --git a/target-arm/kvm.c b/target-arm/kvm.c
index 39202d7..74c90a7 100644
--- a/target-arm/kvm.c
+++ b/target-arm/kvm.c
@@ -27,6 +27,22 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
     KVM_CAP_LAST_INFO
 };
 
+int kvm_arm_vcpu_init(CPUState *cs)
+{
+    ARMCPU *cpu = ARM_CPU(cs);
+    struct kvm_vcpu_init init;
+
+    if (cpu->kvm_target == QEMU_KVM_ARM_TARGET_NONE) {
+        fprintf(stderr, "KVM is not supported for this guest CPU type\n");
+        return -EINVAL;
+    }
+
+    init.target = cpu->kvm_target;
+    memcpy(init.features, cpu->kvm_init_features, sizeof(init.features));
+
+    return kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_INIT, &init);
+}
+
 bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try,
                                       int *fdarray,
                                       struct kvm_vcpu_init *init)
diff --git a/target-arm/kvm32.c b/target-arm/kvm32.c
index a690d99..cc9cdfa 100644
--- a/target-arm/kvm32.c
+++ b/target-arm/kvm32.c
@@ -166,7 +166,6 @@ static int compare_u64(const void *a, const void *b)
 
 int kvm_arch_init_vcpu(CPUState *cs)
 {
-    struct kvm_vcpu_init init;
     int i, ret, arraylen;
     uint64_t v;
     struct kvm_one_reg r;
@@ -174,20 +173,19 @@ int kvm_arch_init_vcpu(CPUState *cs)
     struct kvm_reg_list *rlp;
     ARMCPU *cpu = ARM_CPU(cs);
 
-    if (cpu->kvm_target == QEMU_KVM_ARM_TARGET_NONE) {
-        fprintf(stderr, "KVM is not supported for this guest CPU type\n");
-        return -EINVAL;
-    }
-
-    init.target = cpu->kvm_target;
-    memset(init.features, 0, sizeof(init.features));
+    /* Determine init features for this CPU */
+    memset(cpu->kvm_init_features, 0, sizeof(cpu->kvm_init_features));
+    cpu->kvm_init_features[0] = 0;
     if (cpu->start_powered_off) {
-        init.features[0] = 1 << KVM_ARM_VCPU_POWER_OFF;
+        cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_POWER_OFF;
     }
-    ret = kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_INIT, &init);
+
+    /* Do KVM_ARM_VCPU_INIT ioctl */
+    ret = kvm_arm_vcpu_init(cs);
     if (ret) {
         return ret;
     }
+
     /* Query the kernel to make sure it supports 32 VFP
      * registers: QEMU's "cortex-a15" CPU is always a
      * VFP-D32 core. The simplest way to do this is just
diff --git a/target-arm/kvm64.c b/target-arm/kvm64.c
index e115879..528536f 100644
--- a/target-arm/kvm64.c
+++ b/target-arm/kvm64.c
@@ -77,26 +77,30 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUClass *ahcc)
 
 int kvm_arch_init_vcpu(CPUState *cs)
 {
-    ARMCPU *cpu = ARM_CPU(cs);
-    struct kvm_vcpu_init init;
     int ret;
+    ARMCPU *cpu = ARM_CPU(cs);
 
-    if (cpu->kvm_target == QEMU_KVM_ARM_TARGET_NONE ||
-        !arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
-        fprintf(stderr, "KVM is not supported for this guest CPU type\n");
+    if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
+        fprintf(stderr, "KVM only support Aarch64 CPU type\n");
         return -EINVAL;
     }
 
-    init.target = cpu->kvm_target;
-    memset(init.features, 0, sizeof(init.features));
+    /* Determine init features for this CPU */
+    memset(cpu->kvm_init_features, 0, sizeof(cpu->kvm_init_features));
+    cpu->kvm_init_features[0] = 0;
     if (cpu->start_powered_off) {
-        init.features[0] = 1 << KVM_ARM_VCPU_POWER_OFF;
+        cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_POWER_OFF;
+    }
+
+    /* Do KVM_ARM_VCPU_INIT ioctl */
+    ret = kvm_arm_vcpu_init(cs);
+    if (ret) {
+        return ret;
     }
-    ret = kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_INIT, &init);
 
     /* TODO : support for save/restore/reset of system regs via tuple list */
 
-    return ret;
+    return 0;
 }
 
 #define AARCH64_CORE_REG(x)   (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \
diff --git a/target-arm/kvm_arm.h b/target-arm/kvm_arm.h
index 137c567..31e845f 100644
--- a/target-arm/kvm_arm.h
+++ b/target-arm/kvm_arm.h
@@ -15,6 +15,19 @@
 #include "exec/memory.h"
 
 /**
+ * kvm_arm_vcpu_init:
+ * @cs: CPUState
+ *
+ * KVM ARM and KVM ARM64 need to use KVM_ARM_VCPU_INIT ioctl for
+ * init/re-init/reset the VCPU with given feature flags.
+ * This is a common function for doing KVM_ARM_VCPU_INIT ioctl
+ * independent of KVM ARM or KVM ARM64.
+ *
+ * Returns: 0 if success else < 0 error code
+ */
+int kvm_arm_vcpu_init(CPUState *cs);
+
+/**
  * kvm_arm_register_device:
  * @mr: memory region for this device
  * @devid: the KVM device ID
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [RFC PATCH V5 6/8] target-arm: Enable KVM_ARM_VCPU_PSCI_0_2 feature when possible
  2014-05-12 12:37 [Qemu-devel] [RFC PATCH V5 0/8] PSCI v0.2 support for KVM ARM/ARM64 Pranavkumar Sawargaonkar
                   ` (4 preceding siblings ...)
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 5/8] target-arm: Common kvm_arm_vcpu_init() for KVM ARM and KVM ARM64 Pranavkumar Sawargaonkar
@ 2014-05-12 12:37 ` Pranavkumar Sawargaonkar
  2014-05-14 16:46   ` Peter Maydell
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 7/8] target-arm: Implement kvm_arch_reset_vcpu() for KVM ARM64 Pranavkumar Sawargaonkar
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 18+ messages in thread
From: Pranavkumar Sawargaonkar @ 2014-05-12 12:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, Anup Patel, patches, robherring2, kvmarm,
	christoffer.dall, Pranavkumar Sawargaonkar

Latest linux kernel supports in-kernel emulation of PSCI v0.2 but
to enable it we need to select KVM_ARM_VCPU_PSCI_0_2 feature using
KVM_ARM_VCPU_INIT ioctl.

Also, we can use KVM_ARM_VCPU_PSCI_0_2 feature for VCPU only when
linux kernel has KVM_CAP_ARM_PSCI_0_2 capability.

This patch updates kvm_arch_init_vcpu() to enable KVM_ARM_VCPU_PSCI_0_2
feature for VCPU when KVM ARM/ARM64 has KVM_CAP_ARM_PSCI_0_2 capability.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
---
 target-arm/kvm32.c |    3 +++
 target-arm/kvm64.c |    3 +++
 2 files changed, 6 insertions(+)

diff --git a/target-arm/kvm32.c b/target-arm/kvm32.c
index cc9cdfa..afc248b 100644
--- a/target-arm/kvm32.c
+++ b/target-arm/kvm32.c
@@ -179,6 +179,9 @@ int kvm_arch_init_vcpu(CPUState *cs)
     if (cpu->start_powered_off) {
         cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_POWER_OFF;
     }
+    if (kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PSCI_0_2)) {
+        cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_PSCI_0_2;
+    }
 
     /* Do KVM_ARM_VCPU_INIT ioctl */
     ret = kvm_arm_vcpu_init(cs);
diff --git a/target-arm/kvm64.c b/target-arm/kvm64.c
index 528536f..917d256 100644
--- a/target-arm/kvm64.c
+++ b/target-arm/kvm64.c
@@ -91,6 +91,9 @@ int kvm_arch_init_vcpu(CPUState *cs)
     if (cpu->start_powered_off) {
         cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_POWER_OFF;
     }
+    if (kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PSCI_0_2)) {
+        cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_PSCI_0_2;
+    }
 
     /* Do KVM_ARM_VCPU_INIT ioctl */
     ret = kvm_arm_vcpu_init(cs);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [RFC PATCH V5 7/8] target-arm: Implement kvm_arch_reset_vcpu() for KVM ARM64
  2014-05-12 12:37 [Qemu-devel] [RFC PATCH V5 0/8] PSCI v0.2 support for KVM ARM/ARM64 Pranavkumar Sawargaonkar
                   ` (5 preceding siblings ...)
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 6/8] target-arm: Enable KVM_ARM_VCPU_PSCI_0_2 feature when possible Pranavkumar Sawargaonkar
@ 2014-05-12 12:37 ` Pranavkumar Sawargaonkar
  2014-05-14 15:42   ` Peter Maydell
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 8/8] hw/arm/virt: Use PSCI v0.2 compatible when kernel supports it Pranavkumar Sawargaonkar
  2014-05-14 16:50 ` [Qemu-devel] [RFC PATCH V5 0/8] PSCI v0.2 support for KVM ARM/ARM64 Peter Maydell
  8 siblings, 1 reply; 18+ messages in thread
From: Pranavkumar Sawargaonkar @ 2014-05-12 12:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, Anup Patel, patches, robherring2, kvmarm,
	christoffer.dall, Pranavkumar Sawargaonkar

To implement kvm_arch_reset_vcpu(), we simply re-init the VCPU
using kvm_arm_vcpu_init() so that all registers of VCPU are set
to their reset values by in-kernel KVM code.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
---
 target-arm/kvm64.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/target-arm/kvm64.c b/target-arm/kvm64.c
index 917d256..6e988f3 100644
--- a/target-arm/kvm64.c
+++ b/target-arm/kvm64.c
@@ -269,4 +269,8 @@ int kvm_arch_get_registers(CPUState *cs)
 
 void kvm_arch_reset_vcpu(CPUState *cs)
 {
+    /* Re-init VCPU so that all registers are set to
+     * their respective reset values.
+     */
+    kvm_arm_vcpu_init(cs);
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Qemu-devel] [RFC PATCH V5 8/8] hw/arm/virt: Use PSCI v0.2 compatible when kernel supports it
  2014-05-12 12:37 [Qemu-devel] [RFC PATCH V5 0/8] PSCI v0.2 support for KVM ARM/ARM64 Pranavkumar Sawargaonkar
                   ` (6 preceding siblings ...)
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 7/8] target-arm: Implement kvm_arch_reset_vcpu() for KVM ARM64 Pranavkumar Sawargaonkar
@ 2014-05-12 12:37 ` Pranavkumar Sawargaonkar
  2014-05-14 16:41   ` Peter Maydell
  2014-05-14 16:50 ` [Qemu-devel] [RFC PATCH V5 0/8] PSCI v0.2 support for KVM ARM/ARM64 Peter Maydell
  8 siblings, 1 reply; 18+ messages in thread
From: Pranavkumar Sawargaonkar @ 2014-05-12 12:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, Anup Patel, patches, robherring2, kvmarm,
	christoffer.dall, Pranavkumar Sawargaonkar

If we have in-kernel emulation of PSCI v0.2 for KVM ARM/ARM64 then
we enable PSCI v0.2 for each VCPU at the time of VCPU init hence we
need to provide PSCI v0.2 compatible string via generated DTB.

This patch updates generated DTB to have PSCI v0.2 compatible string
when we have in-kernel emulation PSCI v0.2 for KVM ARM/ARM64.

Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
---
 hw/arm/virt.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index ea4f02d..64ee630 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -183,7 +183,13 @@ static void create_fdt(VirtBoardInfo *vbi)
     /* No PSCI for TCG yet */
     if (kvm_enabled()) {
         qemu_fdt_add_subnode(fdt, "/psci");
-        qemu_fdt_setprop_string(fdt, "/psci", "compatible", "arm,psci");
+        if (kvm_check_extension(kvm_state, QEMU_KVM_CAP_ARM_PSCI_0_2)) {
+            qemu_fdt_setprop(fdt, "/psci", "compatible",
+                             "arm,psci-0.2\0arm,psci",
+                             strlen("arm,psci-0.2") + strlen("arm,psci") + 2);
+        } else {
+            qemu_fdt_setprop_string(fdt, "/psci", "compatible", "arm,psci");
+        }
         qemu_fdt_setprop_string(fdt, "/psci", "method", "hvc");
         qemu_fdt_setprop_cell(fdt, "/psci", "cpu_suspend",
                                   PSCI_FN_CPU_SUSPEND);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] [RFC PATCH V5 1/8] update-linux-headers.sh: Add psci.h to linux header sync-up script
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 1/8] update-linux-headers.sh: Add psci.h to linux header sync-up script Pranavkumar Sawargaonkar
@ 2014-05-14 15:16   ` Peter Maydell
  0 siblings, 0 replies; 18+ messages in thread
From: Peter Maydell @ 2014-05-14 15:16 UTC (permalink / raw)
  To: Pranavkumar Sawargaonkar
  Cc: Anup Patel, patches, QEMU Developers, Rob Herring, kvmarm,
	Christoffer Dall

On 12 May 2014 13:37, Pranavkumar Sawargaonkar <pranavkumar@linaro.org> wrote:
> We will be using linux/psci.h for KVM ARM/ARM64 hence add it to
> linux header sync-up script.
>
> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
> Signed-off-by: Anup Patel <anup.patel@linaro.org>
> ---
>  scripts/update-linux-headers.sh |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh
> index 120a694..eec3f40 100755
> --- a/scripts/update-linux-headers.sh
> +++ b/scripts/update-linux-headers.sh
> @@ -61,7 +61,7 @@ done
>
>  rm -rf "$output/linux-headers/linux"
>  mkdir -p "$output/linux-headers/linux"
> -for header in kvm.h kvm_para.h vfio.h vhost.h virtio_config.h virtio_ring.h; do
> +for header in kvm.h kvm_para.h vfio.h vhost.h virtio_config.h virtio_ring.h psci.h; do

A couple of nits:
 * would be nice to keep the list of .h files in alphabetical order
 * this line is now longer than 80 characters so needs breaking

Otherwise looks good.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] [RFC PATCH V5 3/8] kvm: Handle exit reason KVM_EXIT_SYSTEM_EVENT
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 3/8] kvm: Handle exit reason KVM_EXIT_SYSTEM_EVENT Pranavkumar Sawargaonkar
@ 2014-05-14 15:17   ` Peter Maydell
  0 siblings, 0 replies; 18+ messages in thread
From: Peter Maydell @ 2014-05-14 15:17 UTC (permalink / raw)
  To: Pranavkumar Sawargaonkar
  Cc: Anup Patel, patches, QEMU Developers, Rob Herring, kvmarm,
	Christoffer Dall

On 12 May 2014 13:37, Pranavkumar Sawargaonkar <pranavkumar@linaro.org> wrote:
> In-kernel PSCI v0.2 emulation of KVM ARM/ARM64 forwards SYSTEM_OFF
> and SYSTEM_RESET function calls to QEMU using KVM_EXIT_SYSTEM_EVENT
> exit reason.
>
> This patch updates kvm_cpu_exec() to handle KVM_SYSTEM_EVENT_SHUTDOWN
> and KVM_SYSTEM_EVENT_RESET system-level events from QEMU-side.
>
> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
> Signed-off-by: Anup Patel <anup.patel@linaro.org>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] [RFC PATCH V5 5/8] target-arm: Common kvm_arm_vcpu_init() for KVM ARM and KVM ARM64
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 5/8] target-arm: Common kvm_arm_vcpu_init() for KVM ARM and KVM ARM64 Pranavkumar Sawargaonkar
@ 2014-05-14 15:30   ` Peter Maydell
  0 siblings, 0 replies; 18+ messages in thread
From: Peter Maydell @ 2014-05-14 15:30 UTC (permalink / raw)
  To: Pranavkumar Sawargaonkar
  Cc: Anup Patel, patches, QEMU Developers, Rob Herring, kvmarm,
	Christoffer Dall

On 12 May 2014 13:37, Pranavkumar Sawargaonkar <pranavkumar@linaro.org> wrote:
> Introduce a common kvm_arm_vcpu_init() for doing KVM_ARM_VCPU_INIT
> ioctl in KVM ARM and KVM ARM64. This also helps us factor-out few
> common code lines from kvm_arch_init_vcpu() for KVM ARM/ARM64.

Mostly OK, some minor tweaks below.

> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
> Signed-off-by: Anup Patel <anup.patel@linaro.org>
> ---
>  target-arm/cpu-qom.h |    3 +++
>  target-arm/kvm.c     |   16 ++++++++++++++++
>  target-arm/kvm32.c   |   18 ++++++++----------
>  target-arm/kvm64.c   |   24 ++++++++++++++----------
>  target-arm/kvm_arm.h |   13 +++++++++++++
>  5 files changed, 54 insertions(+), 20 deletions(-)
>
> diff --git a/target-arm/cpu-qom.h b/target-arm/cpu-qom.h
> index edc7f26..2bd7df8 100644
> --- a/target-arm/cpu-qom.h
> +++ b/target-arm/cpu-qom.h
> @@ -102,6 +102,9 @@ typedef struct ARMCPU {
>       */
>      uint32_t kvm_target;
>
> +    /* KVM init features for this CPU */
> +    uint32_t kvm_init_features[7];
> +
>      /* The instance init functions for implementation-specific subclasses
>       * set these fields to specify the implementation-dependent values of
>       * various constant registers and reset values of non-constant
> diff --git a/target-arm/kvm.c b/target-arm/kvm.c
> index 39202d7..74c90a7 100644
> --- a/target-arm/kvm.c
> +++ b/target-arm/kvm.c
> @@ -27,6 +27,22 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
>      KVM_CAP_LAST_INFO
>  };
>
> +int kvm_arm_vcpu_init(CPUState *cs)
> +{
> +    ARMCPU *cpu = ARM_CPU(cs);
> +    struct kvm_vcpu_init init;
> +
> +    if (cpu->kvm_target == QEMU_KVM_ARM_TARGET_NONE) {
> +        fprintf(stderr, "KVM is not supported for this guest CPU type\n");
> +        return -EINVAL;
> +    }

This check should stay in kvm_arch_init_vcpu(), not be moved to here.

> +
> +    init.target = cpu->kvm_target;
> +    memcpy(init.features, cpu->kvm_init_features, sizeof(init.features));
> +
> +    return kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_INIT, &init);
> +}
> +
>  bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try,
>                                        int *fdarray,
>                                        struct kvm_vcpu_init *init)
> diff --git a/target-arm/kvm32.c b/target-arm/kvm32.c
> index a690d99..cc9cdfa 100644
> --- a/target-arm/kvm32.c
> +++ b/target-arm/kvm32.c
> @@ -166,7 +166,6 @@ static int compare_u64(const void *a, const void *b)
>
>  int kvm_arch_init_vcpu(CPUState *cs)
>  {
> -    struct kvm_vcpu_init init;
>      int i, ret, arraylen;
>      uint64_t v;
>      struct kvm_one_reg r;
> @@ -174,20 +173,19 @@ int kvm_arch_init_vcpu(CPUState *cs)
>      struct kvm_reg_list *rlp;
>      ARMCPU *cpu = ARM_CPU(cs);
>
> -    if (cpu->kvm_target == QEMU_KVM_ARM_TARGET_NONE) {
> -        fprintf(stderr, "KVM is not supported for this guest CPU type\n");
> -        return -EINVAL;
> -    }
> -
> -    init.target = cpu->kvm_target;
> -    memset(init.features, 0, sizeof(init.features));
> +    /* Determine init features for this CPU */
> +    memset(cpu->kvm_init_features, 0, sizeof(cpu->kvm_init_features));
> +    cpu->kvm_init_features[0] = 0;

This = 0 line is just repeating work the memset() just did.

>      if (cpu->start_powered_off) {
> -        init.features[0] = 1 << KVM_ARM_VCPU_POWER_OFF;
> +        cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_POWER_OFF;
>      }
> -    ret = kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_INIT, &init);
> +
> +    /* Do KVM_ARM_VCPU_INIT ioctl */
> +    ret = kvm_arm_vcpu_init(cs);
>      if (ret) {
>          return ret;
>      }
> +
>      /* Query the kernel to make sure it supports 32 VFP
>       * registers: QEMU's "cortex-a15" CPU is always a
>       * VFP-D32 core. The simplest way to do this is just
> diff --git a/target-arm/kvm64.c b/target-arm/kvm64.c
> index e115879..528536f 100644
> --- a/target-arm/kvm64.c
> +++ b/target-arm/kvm64.c
> @@ -77,26 +77,30 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUClass *ahcc)
>
>  int kvm_arch_init_vcpu(CPUState *cs)
>  {
> -    ARMCPU *cpu = ARM_CPU(cs);
> -    struct kvm_vcpu_init init;
>      int ret;
> +    ARMCPU *cpu = ARM_CPU(cs);
>
> -    if (cpu->kvm_target == QEMU_KVM_ARM_TARGET_NONE ||
> -        !arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
> -        fprintf(stderr, "KVM is not supported for this guest CPU type\n");
> +    if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
> +        fprintf(stderr, "KVM only support Aarch64 CPU type\n");

Again, you don't need to change this guard/error.

>          return -EINVAL;
>      }
>
> -    init.target = cpu->kvm_target;
> -    memset(init.features, 0, sizeof(init.features));
> +    /* Determine init features for this CPU */
> +    memset(cpu->kvm_init_features, 0, sizeof(cpu->kvm_init_features));
> +    cpu->kvm_init_features[0] = 0;

Unnecessary.

>      if (cpu->start_powered_off) {
> -        init.features[0] = 1 << KVM_ARM_VCPU_POWER_OFF;
> +        cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_POWER_OFF;
> +    }
> +
> +    /* Do KVM_ARM_VCPU_INIT ioctl */
> +    ret = kvm_arm_vcpu_init(cs);
> +    if (ret) {
> +        return ret;
>      }
> -    ret = kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_INIT, &init);
>
>      /* TODO : support for save/restore/reset of system regs via tuple list */
>
> -    return ret;
> +    return 0;
>  }
>
>  #define AARCH64_CORE_REG(x)   (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \
> diff --git a/target-arm/kvm_arm.h b/target-arm/kvm_arm.h
> index 137c567..31e845f 100644
> --- a/target-arm/kvm_arm.h
> +++ b/target-arm/kvm_arm.h
> @@ -15,6 +15,19 @@
>  #include "exec/memory.h"
>
>  /**
> + * kvm_arm_vcpu_init:
> + * @cs: CPUState
> + *
> + * KVM ARM and KVM ARM64 need to use KVM_ARM_VCPU_INIT ioctl for
> + * init/re-init/reset the VCPU with given feature flags.
> + * This is a common function for doing KVM_ARM_VCPU_INIT ioctl
> + * independent of KVM ARM or KVM ARM64.

I think it would be more informative if this read:
 * Initialize (or reinitialize) the VCPU by invoking the
 * KVM_ARM_VCPU_INIT ioctl with the CPU type and feature
 * bitmask specified in the CPUState.

> + *
> + * Returns: 0 if success else < 0 error code
> + */
> +int kvm_arm_vcpu_init(CPUState *cs);
> +
> +/**
>   * kvm_arm_register_device:
>   * @mr: memory region for this device
>   * @devid: the KVM device ID
> --
> 1.7.9.5
>

thanks
-- PMM

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] [RFC PATCH V5 7/8] target-arm: Implement kvm_arch_reset_vcpu() for KVM ARM64
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 7/8] target-arm: Implement kvm_arch_reset_vcpu() for KVM ARM64 Pranavkumar Sawargaonkar
@ 2014-05-14 15:42   ` Peter Maydell
  2014-05-15 15:12     ` Diana Craciun
  0 siblings, 1 reply; 18+ messages in thread
From: Peter Maydell @ 2014-05-14 15:42 UTC (permalink / raw)
  To: Pranavkumar Sawargaonkar
  Cc: Anup Patel, patches, QEMU Developers, Rob Herring, kvmarm,
	Christoffer Dall

On 12 May 2014 13:37, Pranavkumar Sawargaonkar <pranavkumar@linaro.org> wrote:
> To implement kvm_arch_reset_vcpu(), we simply re-init the VCPU
> using kvm_arm_vcpu_init() so that all registers of VCPU are set
> to their reset values by in-kernel KVM code.
>
> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
> Signed-off-by: Anup Patel <anup.patel@linaro.org>
> ---
>  target-arm/kvm64.c |    4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/target-arm/kvm64.c b/target-arm/kvm64.c
> index 917d256..6e988f3 100644
> --- a/target-arm/kvm64.c
> +++ b/target-arm/kvm64.c
> @@ -269,4 +269,8 @@ int kvm_arch_get_registers(CPUState *cs)
>
>  void kvm_arch_reset_vcpu(CPUState *cs)
>  {
> +    /* Re-init VCPU so that all registers are set to
> +     * their respective reset values.
> +     */
> +    kvm_arm_vcpu_init(cs);
>  }

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

There is a cleanup we can make which makes this the
common reset function for both 32 and 64 bit, but let's
not tangle that up with this patchseries.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] [RFC PATCH V5 8/8] hw/arm/virt: Use PSCI v0.2 compatible when kernel supports it
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 8/8] hw/arm/virt: Use PSCI v0.2 compatible when kernel supports it Pranavkumar Sawargaonkar
@ 2014-05-14 16:41   ` Peter Maydell
  0 siblings, 0 replies; 18+ messages in thread
From: Peter Maydell @ 2014-05-14 16:41 UTC (permalink / raw)
  To: Pranavkumar Sawargaonkar
  Cc: Anup Patel, patches, QEMU Developers, Rob Herring, kvmarm,
	Christoffer Dall

On 12 May 2014 13:37, Pranavkumar Sawargaonkar <pranavkumar@linaro.org> wrote:
> If we have in-kernel emulation of PSCI v0.2 for KVM ARM/ARM64 then
> we enable PSCI v0.2 for each VCPU at the time of VCPU init hence we
> need to provide PSCI v0.2 compatible string via generated DTB.
>
> This patch updates generated DTB to have PSCI v0.2 compatible string
> when we have in-kernel emulation PSCI v0.2 for KVM ARM/ARM64.
>
> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
> Signed-off-by: Anup Patel <anup.patel@linaro.org>
> ---
>  hw/arm/virt.c |    8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index ea4f02d..64ee630 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -183,7 +183,13 @@ static void create_fdt(VirtBoardInfo *vbi)
>      /* No PSCI for TCG yet */
>      if (kvm_enabled()) {
>          qemu_fdt_add_subnode(fdt, "/psci");
> -        qemu_fdt_setprop_string(fdt, "/psci", "compatible", "arm,psci");
> +        if (kvm_check_extension(kvm_state, QEMU_KVM_CAP_ARM_PSCI_0_2)) {
> +            qemu_fdt_setprop(fdt, "/psci", "compatible",
> +                             "arm,psci-0.2\0arm,psci",
> +                             strlen("arm,psci-0.2") + strlen("arm,psci") + 2);
> +        } else {
> +            qemu_fdt_setprop_string(fdt, "/psci", "compatible", "arm,psci");
> +        }
>          qemu_fdt_setprop_string(fdt, "/psci", "method", "hvc");
>          qemu_fdt_setprop_cell(fdt, "/psci", "cpu_suspend",
>                                    PSCI_FN_CPU_SUSPEND);

I don't think we should be directly calling kvm_check_extension()
here to decide whether to emit a PSCI 0.1 or 0.2 DT node.
When Rob's TCG PSCI implementation lands then that would need
to be special cased, and if we wanted to let the user restrict
us to PSCI 0.1 (on the command line, for migration compat)
that would end up forcing changes here.

Instead I think the struct ARMCPU should have an
   int psci_version;
which has the CPU's PSCI version. Then you can set that
to 0.1 or 0.2 in the KVM init code where you're already
probing for the KVM capability, and the TCG init can set
it to always 0.2.

(Use the obvious encoding of PSCI version numbers to integers,
as per the psci.h PSCI_VERSION_* macros.)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] [RFC PATCH V5 4/8] target-arm/kvm-const.h: Add QEMU_KVM_CAP_ARM_PSCI_0_2 define
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 4/8] target-arm/kvm-const.h: Add QEMU_KVM_CAP_ARM_PSCI_0_2 define Pranavkumar Sawargaonkar
@ 2014-05-14 16:42   ` Peter Maydell
  0 siblings, 0 replies; 18+ messages in thread
From: Peter Maydell @ 2014-05-14 16:42 UTC (permalink / raw)
  To: Pranavkumar Sawargaonkar
  Cc: Anup Patel, patches, QEMU Developers, Rob Herring, kvmarm,
	Christoffer Dall

On 12 May 2014 13:37, Pranavkumar Sawargaonkar <pranavkumar@linaro.org> wrote:
> We require to check whether PSCI v0.2 capability is available or
> not in hw/arm/virt.c such that it compiles for both KVM and TCG QEMU.
>
> This patch adds PSCI v0.2 capability #define in target-arm/kvm-const.h
> so that it is available for both KVM and TCG QEMU.
>
> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
> Signed-off-by: Anup Patel <anup.patel@linaro.org>
> ---
>  target-arm/kvm-consts.h |    5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/target-arm/kvm-consts.h b/target-arm/kvm-consts.h
> index 6009a33..b5f9a20 100644
> --- a/target-arm/kvm-consts.h
> +++ b/target-arm/kvm-consts.h
> @@ -110,6 +110,11 @@ MISMATCH_CHECK(CP_REG_ARM64_SYSREG_OP2_MASK, KVM_REG_ARM64_SYSREG_OP2_MASK)
>  MISMATCH_CHECK(CP_REG_ARM64_SYSREG_OP2_SHIFT, KVM_REG_ARM64_SYSREG_OP2_SHIFT)
>  #endif
>
> +/* KVM ARM/ARM64 specific capabilities */
> +#define QEMU_KVM_CAP_ARM_PSCI_0_2 102
> +
> +MISMATCH_CHECK(QEMU_KVM_CAP_ARM_PSCI_0_2, KVM_CAP_ARM_PSCI_0_2)
> +
>  #undef MISMATCH_CHECK
>
>  #endif
> --
> 1.7.9.5

If you follow my suggestion for how to determine which PSCI
DT node to emit in my review comments on patch 8, you'll find
that this patch is now unnecessary.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] [RFC PATCH V5 6/8] target-arm: Enable KVM_ARM_VCPU_PSCI_0_2 feature when possible
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 6/8] target-arm: Enable KVM_ARM_VCPU_PSCI_0_2 feature when possible Pranavkumar Sawargaonkar
@ 2014-05-14 16:46   ` Peter Maydell
  0 siblings, 0 replies; 18+ messages in thread
From: Peter Maydell @ 2014-05-14 16:46 UTC (permalink / raw)
  To: Pranavkumar Sawargaonkar
  Cc: Anup Patel, patches, QEMU Developers, Rob Herring, Paolo Bonzini,
	kvmarm, Christoffer Dall

On 12 May 2014 13:37, Pranavkumar Sawargaonkar <pranavkumar@linaro.org> wrote:
> Latest linux kernel supports in-kernel emulation of PSCI v0.2 but
> to enable it we need to select KVM_ARM_VCPU_PSCI_0_2 feature using
> KVM_ARM_VCPU_INIT ioctl.
>
> Also, we can use KVM_ARM_VCPU_PSCI_0_2 feature for VCPU only when
> linux kernel has KVM_CAP_ARM_PSCI_0_2 capability.
>
> This patch updates kvm_arch_init_vcpu() to enable KVM_ARM_VCPU_PSCI_0_2
> feature for VCPU when KVM ARM/ARM64 has KVM_CAP_ARM_PSCI_0_2 capability.

I was dubious in previous versions of this patchset about
whether we could reasonably just set the CPU feature if the
kernel reports the extension. However after a discussion on
#qemu with Paolo I'm now happier that it's OK.

The effect is that we will (silently) break migration between
hosts where one end supports PSCI 0.2 and the other does not.
However it's not unreasonable at this point in time to just
say that migration requires matching kernel versions.

At a later date we might want to introduce support for CPU
feature enable/disable subflags, at which point a command line
switch would allow running a QEMU with PSCI 0.1 even on a 0.2
supporting host kernel, to allow for back-compatible migration.
(Or it might turn out that by that point PSCI-0.1-only kernels
are a distant memory...)

> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
> Signed-off-by: Anup Patel <anup.patel@linaro.org>
> ---
>  target-arm/kvm32.c |    3 +++
>  target-arm/kvm64.c |    3 +++
>  2 files changed, 6 insertions(+)
>
> diff --git a/target-arm/kvm32.c b/target-arm/kvm32.c
> index cc9cdfa..afc248b 100644
> --- a/target-arm/kvm32.c
> +++ b/target-arm/kvm32.c
> @@ -179,6 +179,9 @@ int kvm_arch_init_vcpu(CPUState *cs)
>      if (cpu->start_powered_off) {
>          cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_POWER_OFF;
>      }
> +    if (kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PSCI_0_2)) {
> +        cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_PSCI_0_2;
> +    }
>
>      /* Do KVM_ARM_VCPU_INIT ioctl */
>      ret = kvm_arm_vcpu_init(cs);
> diff --git a/target-arm/kvm64.c b/target-arm/kvm64.c
> index 528536f..917d256 100644
> --- a/target-arm/kvm64.c
> +++ b/target-arm/kvm64.c
> @@ -91,6 +91,9 @@ int kvm_arch_init_vcpu(CPUState *cs)
>      if (cpu->start_powered_off) {
>          cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_POWER_OFF;
>      }
> +    if (kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PSCI_0_2)) {
> +        cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_PSCI_0_2;
> +    }
>
>      /* Do KVM_ARM_VCPU_INIT ioctl */
>      ret = kvm_arm_vcpu_init(cs);
> --
> 1.7.9.5

See also my review comments on patch 8: this patch is the place
to add the psci_version field to the ARMCPU struct, and set it
appropriately based on the KVM capabilities the kernel reports.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] [RFC PATCH V5 0/8] PSCI v0.2 support for KVM ARM/ARM64
  2014-05-12 12:37 [Qemu-devel] [RFC PATCH V5 0/8] PSCI v0.2 support for KVM ARM/ARM64 Pranavkumar Sawargaonkar
                   ` (7 preceding siblings ...)
  2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 8/8] hw/arm/virt: Use PSCI v0.2 compatible when kernel supports it Pranavkumar Sawargaonkar
@ 2014-05-14 16:50 ` Peter Maydell
  8 siblings, 0 replies; 18+ messages in thread
From: Peter Maydell @ 2014-05-14 16:50 UTC (permalink / raw)
  To: Pranavkumar Sawargaonkar
  Cc: patches, Rob Herring, QEMU Developers, Christoffer Dall, kvmarm

On 12 May 2014 13:37, Pranavkumar Sawargaonkar <pranavkumar@linaro.org> wrote:
> This patchset adds the QEMU side changes for providing PSCI v0.2 to VM.
>
> ChangeLog:
>
> V5:
> - Updated "scripts/update-linux-headers.sh" to include linux/psci.h
> - Synced linux headers using update-linux-headers.sh with linux-next tree
> - Added per cpu field for kvm init features.
> - Set psci-0.2 compatible string in generated dtb sucn that it works for
>   guest kernel not having psci 0.2 support.
> - Added QEMU_KVM_CAP_ARM_PSCI_0_2 define in target-arm/kvm-consts.h

OK, I think we're nearly there with this set. I've made review
comments (or added my reviewed-by tag) for this set, and they're
all relatively minor changes. Then the only other thing we're waiting
for is for the kernel header changes to hit at least the kvm-next
tree...

thanks
-- PMM

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [Qemu-devel] [RFC PATCH V5 7/8] target-arm: Implement kvm_arch_reset_vcpu() for KVM ARM64
  2014-05-14 15:42   ` Peter Maydell
@ 2014-05-15 15:12     ` Diana Craciun
  0 siblings, 0 replies; 18+ messages in thread
From: Diana Craciun @ 2014-05-15 15:12 UTC (permalink / raw)
  To: Peter Maydell; +Cc: kvmarm, patches, QEMU Developers, Pranavkumar Sawargaonkar

On 05/14/2014 06:42 PM, Peter Maydell wrote:
> On 12 May 2014 13:37, Pranavkumar Sawargaonkar <pranavkumar@linaro.org> wrote:
>> To implement kvm_arch_reset_vcpu(), we simply re-init the VCPU
>> using kvm_arm_vcpu_init() so that all registers of VCPU are set
>> to their reset values by in-kernel KVM code.
>>
>> Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
>> Signed-off-by: Anup Patel <anup.patel@linaro.org>
>> ---
>>   target-arm/kvm64.c |    4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/target-arm/kvm64.c b/target-arm/kvm64.c
>> index 917d256..6e988f3 100644
>> --- a/target-arm/kvm64.c
>> +++ b/target-arm/kvm64.c
>> @@ -269,4 +269,8 @@ int kvm_arch_get_registers(CPUState *cs)
>>
>>   void kvm_arch_reset_vcpu(CPUState *cs)
>>   {
>> +    /* Re-init VCPU so that all registers are set to
>> +     * their respective reset values.
>> +     */
>> +    kvm_arm_vcpu_init(cs);
>>   }
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>
> There is a cleanup we can make which makes this the
> common reset function for both 32 and 64 bit, but let's
> not tangle that up with this patchseries.

It is not just cleanup, on 32 bit the reset is not working properly as 
it is currently implemented. The reason is that the secondary cores fail 
to boot because the "cpu->arch.pause" (to mark the VCPU as paused) is 
not set in KVM because the KVM_ARM_VCPU_INIT ioctl is not called on reset.

I can make the changes to re-initialize the VCPU also for 32 bit once 
these patches are final.

Diana

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2014-05-15 15:12 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-12 12:37 [Qemu-devel] [RFC PATCH V5 0/8] PSCI v0.2 support for KVM ARM/ARM64 Pranavkumar Sawargaonkar
2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 1/8] update-linux-headers.sh: Add psci.h to linux header sync-up script Pranavkumar Sawargaonkar
2014-05-14 15:16   ` Peter Maydell
2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 2/8] linux-headers: Update KVM headers from linux-next tag next-20140508 Pranavkumar Sawargaonkar
2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 3/8] kvm: Handle exit reason KVM_EXIT_SYSTEM_EVENT Pranavkumar Sawargaonkar
2014-05-14 15:17   ` Peter Maydell
2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 4/8] target-arm/kvm-const.h: Add QEMU_KVM_CAP_ARM_PSCI_0_2 define Pranavkumar Sawargaonkar
2014-05-14 16:42   ` Peter Maydell
2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 5/8] target-arm: Common kvm_arm_vcpu_init() for KVM ARM and KVM ARM64 Pranavkumar Sawargaonkar
2014-05-14 15:30   ` Peter Maydell
2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 6/8] target-arm: Enable KVM_ARM_VCPU_PSCI_0_2 feature when possible Pranavkumar Sawargaonkar
2014-05-14 16:46   ` Peter Maydell
2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 7/8] target-arm: Implement kvm_arch_reset_vcpu() for KVM ARM64 Pranavkumar Sawargaonkar
2014-05-14 15:42   ` Peter Maydell
2014-05-15 15:12     ` Diana Craciun
2014-05-12 12:37 ` [Qemu-devel] [RFC PATCH V5 8/8] hw/arm/virt: Use PSCI v0.2 compatible when kernel supports it Pranavkumar Sawargaonkar
2014-05-14 16:41   ` Peter Maydell
2014-05-14 16:50 ` [Qemu-devel] [RFC PATCH V5 0/8] PSCI v0.2 support for KVM ARM/ARM64 Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.