Skip to contentSkip to conversation

GET/SET_ONE_REG and HIOR patches v2

PATCH In review Alexander Graf 4 participants 16 messages Jan 6, 2012 – Apr 16, 2012

Subsystems (4)
lore
Share & tools
lore
#10 lore raw

PATCH 2/3 KVM: PPC: Add support for explicit HIOR setting

In reply to Alexander Graf

Until now, we always set HIOR based on the PVR, but this is just wrong. Instead, we should be setting HIOR explicitly, so user space can decide what the initial HIOR value is - just like on real hardware.

We keep the old PVR based way around for backwards compatibility, but once user space uses the SET_ONE_REG based method, we drop the PVR logic.

---

v1 -> v2:

- rename KVM_ONE_REG to KVM_REG
- add size information to HIOR
- change HIOR number to 1, indicating that numbers are consecutive

---
 Documentation/virtual/kvm/api.txt     |    1 +
 arch/powerpc/include/asm/kvm.h        |    2 ++
 arch/powerpc/include/asm/kvm_book3s.h |    2 ++
 arch/powerpc/kvm/book3s_pr.c          |    6 ++++--
 arch/powerpc/kvm/powerpc.c            |   13 +++++++++++++
 include/linux/kvm.h                   |    1 +
 6 files changed, 23 insertions(+), 2 deletions(-)
Documentation/virtual/kvm/api.txt +1 -0
index 8494214..d73b8ea 100644
@@ -1546,6 +1546,7 @@ registers, find a list below:
 
   Arch  |       Register        | Width (bits)
         |                       |
+  PPC   | KVM_REG_PPC_HIOR      | 64
 
 4.66 KVM_GET_ONE_REG
 
arch/powerpc/include/asm/kvm.h +2 -0
index 25964ee..7e9e24d 100644
@@ -327,4 +327,6 @@ struct kvm_book3e_206_tlb_params {
 	__u32 reserved[8];
 };
 
+#define KVM_REG_PPC_HIOR	KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x1
+
 #endif /* __LINUX_KVM_POWERPC_H */
arch/powerpc/include/asm/kvm_book3s.h +2 -0
index 3c3edee..aa795cc 100644
@@ -90,6 +90,8 @@ struct kvmppc_vcpu_book3s {
 #endif
 	int context_id[SID_CONTEXTS];
 
+	bool hior_explicit;		/* HIOR is set by ioctl, not PVR */
+
 	struct hlist_head hpte_hash_pte[HPTEG_HASH_NUM_PTE];
 	struct hlist_head hpte_hash_pte_long[HPTEG_HASH_NUM_PTE_LONG];
 	struct hlist_head hpte_hash_vpte[HPTEG_HASH_NUM_VPTE];
arch/powerpc/kvm/book3s_pr.c +4 -2
index c193625..00efda6 100644
@@ -157,14 +157,16 @@ void kvmppc_set_pvr(struct kvm_vcpu *vcpu, u32 pvr)
 #ifdef CONFIG_PPC_BOOK3S_64
 	if ((pvr >= 0x330000) && (pvr < 0x70330000)) {
 		kvmppc_mmu_book3s_64_init(vcpu);
-		to_book3s(vcpu)->hior = 0xfff00000;
+		if (!to_book3s(vcpu)->hior_explicit)
+			to_book3s(vcpu)->hior = 0xfff00000;
 		to_book3s(vcpu)->msr_mask = 0xffffffffffffffffULL;
 		vcpu->arch.cpu_type = KVM_CPU_3S_64;
 	} else
 #endif
 	{
 		kvmppc_mmu_book3s_32_init(vcpu);
-		to_book3s(vcpu)->hior = 0;
+		if (!to_book3s(vcpu)->hior_explicit)
+			to_book3s(vcpu)->hior = 0;
 		to_book3s(vcpu)->msr_mask = 0xffffffffULL;
 		vcpu->arch.cpu_type = KVM_CPU_3S_32;
 	}
arch/powerpc/kvm/powerpc.c +13 -0
index 9c598b6..4223c6f 100644
@@ -209,6 +209,7 @@ int kvm_dev_ioctl_check_extension(long ext)
 	case KVM_CAP_PPC_BOOKE_SREGS:
 #else
 	case KVM_CAP_PPC_SEGSTATE:
+	case KVM_CAP_PPC_HIOR:
 	case KVM_CAP_PPC_PAPR:
 #endif
 	case KVM_CAP_PPC_UNSET_IRQ:
@@ -649,6 +650,11 @@ static int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu,
 	int r = -EINVAL;
 
 	switch (reg->id) {
+#ifdef CONFIG_PPC_BOOK3S
+	case KVM_REG_PPC_HIOR:
+		r = put_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr);
+		break;
+#endif
 	default:
 		break;
 	}
@@ -662,6 +668,13 @@ static int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu,
 	int r = -EINVAL;
 
 	switch (reg->id) {
+#ifdef CONFIG_PPC_BOOK3S
+	case KVM_ONE_REG_PPC_HIOR:
+		r = get_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr);
+		if (!r)
+			to_book3s(vcpu)->hior_explicit = true;
+		break;
+#endif
 	default:
 		break;
 	}
include/linux/kvm.h +1 -0
index 31fce98..125f1bc 100644
@@ -555,6 +555,7 @@ struct kvm_ppc_pvinfo {
 #define KVM_CAP_PPC_SMT 64
 #define KVM_CAP_PPC_RMA	65
 #define KVM_CAP_MAX_VCPUS 66       /* returns max vcpus per vm */
+#define KVM_CAP_PPC_HIOR 67
 #define KVM_CAP_PPC_PAPR 68
 #define KVM_CAP_SW_TLB 69
 #define KVM_CAP_ONE_REG 70
Signature · 1 line
1.6.0.2
#2 lore raw

Re: [PATCH 1/3] KVM: PPC: Add generic single register ioctls

In reply to Alexander Graf
Quoted 135 lines · Alexander Graf

Right now we transfer a static struct every time we want to get or set registers. Unfortunately, over time we realize that there are more of these than we thought of before and the extensibility and flexibility of transferring a full struct every time is limited.

So this is a new approach to the problem. With these new ioctls, we can get and set a single register that is identified by an ID. This allows for very precise and limited transmittal of data. When we later realize that it's a better idea to shove over multiple registers at once, we can reuse most of the infrastructure and simply implement a GET_MANY_REGS / SET_MANY_REGS interface.

The only downpoint I see to this one is that it needs to pad to 1024 bits (hardware is already on 512 bit registers, so I wanted to leave some room) which is slightly too much for transmitting only 64 bits. But if that's all the tradeoff we have to do for getting an extensible interface, I'd say go for it nevertheless.

---

v1 -> v2:

- rename KVM_ONE_REG to KVM_REG
- change semantics to include size in constant
and a user pointer to write/read to/from
- update documentation respectively
---

Documentation/virtual/kvm/api.txt |   40 +++++++++++++++++++++++++++++
arch/powerpc/kvm/powerpc.c        |   51 +++++++++++++++++++++++++++++++++++++
include/linux/kvm.h               |   35 +++++++++++++++++++++++++
3 files changed, 126 insertions(+), 0 deletions(-)
Documentation/virtual/kvm/api.txt +0 -0
index a4d7b4d..8494214 100644
@@ -1523,6 +1523,46 @@ following algorithm:

Some guests configure the LINT1 NMI input to cause a panic, aiding in debugging.

+4.65 KVM_SET_ONE_REG

Documentation/virtual/kvm/api.txt +39 -0
+
+Capability: KVM_CAP_ONE_REG
+Architectures: all
+Type: vcpu ioctl
+Parameters: struct kvm_one_reg (in)
+Returns: 0 on success, negative value on failure
+
+struct kvm_one_reg {
+       __u64 id;
+       __u64 addr;
+};
+
+Using this ioctl, a single vcpu register can be set to a specific value
+defined by user space with the passed in struct kvm_one_reg, where id
+refers to the register identifier as described below and addr is a pointer
+to a variable with the respective size. There can be architecture agnostic
+and architecture specific registers. Each have their own range of operation
+and their own constants and width. To keep track of the implemented
+registers, find a list below:
+
+  Arch  |       Register        | Width (bits)
+        |                       |
+
+4.66 KVM_GET_ONE_REG
+
+Capability: KVM_CAP_ONE_REG
+Architectures: all
+Type: vcpu ioctl
+Parameters: struct kvm_one_reg (in and out)
+Returns: 0 on success, negative value on failure
+
+This ioctl allows to receive the value of a single register implemented
+in a vcpu. The register to read is indicated by the "id" field of the
+kvm_one_reg struct passed in. On success, the register value can be found
+at the memory location pointed to by "addr".
+
+The list of registers accessible using this interface is identical to the
+list in 4.64.
+

5. The kvm_run structure

Application code obtains a pointer to the kvm_run structure by

arch/powerpc/kvm/powerpc.c +28 -0
index 76993eb..9c598b6 100644
@@ -214,6 +214,7 @@ int kvm_dev_ioctl_check_extension(long ext)
 	case KVM_CAP_PPC_UNSET_IRQ:
 	case KVM_CAP_PPC_IRQ_LEVEL:
 	case KVM_CAP_ENABLE_CAP:
+	case KVM_CAP_ONE_REG:
 		r = 1;
 		break;
 #ifndef CONFIG_KVM_BOOK3S_64_HV
@@ -642,6 +643,32 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
 	return r;
 }
 
+static int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu,
+				      struct kvm_one_reg *reg)
+{
+	int r = -EINVAL;
+
+	switch (reg->id) {
+	default:
+		break;
+	}
+
+	return r;
+}
+
+static int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu,
+				      struct kvm_one_reg *reg)
+{
+	int r = -EINVAL;
+
+	switch (reg->id) {
+	default:
+		break;
+	}
+
+	return r;
+}
+
 int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
                                    struct kvm_mp_state *mp_state)
 {
@@ -681,6 +708,30 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
 		break;
 	}
 
+	case KVM_GET_ONE_REG:

arch/powerpc/kvm/powerpc.c long kvm_arch_vcpu_ioctl(struct file *filp, · line 721

Quoted 10 lines
arch/powerpc/kvm/powerpc.c +10 -0
+	{
+		struct kvm_one_reg reg;
+		r = -EFAULT;
+		if (copy_from_user(&reg, argp, sizeof(reg)))
+			goto out;
+		r = kvm_vcpu_ioctl_get_one_reg(vcpu, &reg);
+		if (copy_to_user(argp, &reg, sizeof(reg))) {
+			r = -EFAULT;
+			goto out;
+		}

This is useless now - we already do the write to the user defined address. No need to write back the address and id fields :). Will send out v3 soon.

Alex

#0 lore raw

cover GET/SET_ONE_REG and HIOR patches v2

This is a revised version of the ONE_REG interface. The main difference to v1 is that we now encode the register size in the constant, making it very unambiguous what size it is. That way we can just take a pointer from user space to write it to.

Thanks a lot to Scott for reviewing the previous patches and pointing out some design issues before it actually lands upstream.

Alex

Alexander Graf (2):
KVM: PPC: Add generic single register ioctls
KVM: PPC: Add support for explicit HIOR setting

Paul Mackerras (1):
KVM: PPC: Move kvm_vcpu_ioctl_[gs]et_one_reg down to
platform-specific code

 Documentation/virtual/kvm/api.txt     |   41 +++++++++++++++++++++++++++++++++
 arch/powerpc/include/asm/kvm.h        |    2 +
 arch/powerpc/include/asm/kvm_book3s.h |    2 +
 arch/powerpc/include/asm/kvm_ppc.h    |    3 ++
 arch/powerpc/kvm/book3s_hv.c          |   36 +++++++++++++++++++++++++++++
 arch/powerpc/kvm/book3s_pr.c          |   38 +++++++++++++++++++++++++++++-
 arch/powerpc/kvm/booke.c              |   10 ++++++++
 arch/powerpc/kvm/powerpc.c            |   26 +++++++++++++++++++++
 include/linux/kvm.h                   |   36 +++++++++++++++++++++++++++++
 9 files changed, 192 insertions(+), 2 deletions(-)
#1 lore raw

PATCH 1/3 KVM: PPC: Add generic single register ioctls

Right now we transfer a static struct every time we want to get or set registers. Unfortunately, over time we realize that there are more of these than we thought of before and the extensibility and flexibility of transferring a full struct every time is limited.

So this is a new approach to the problem. With these new ioctls, we can get and set a single register that is identified by an ID. This allows for very precise and limited transmittal of data. When we later realize that it's a better idea to shove over multiple registers at once, we can reuse most of the infrastructure and simply implement a GET_MANY_REGS / SET_MANY_REGS interface.

The only downpoint I see to this one is that it needs to pad to 1024 bits (hardware is already on 512 bit registers, so I wanted to leave some room) which is slightly too much for transmitting only 64 bits. But if that's all the tradeoff we have to do for getting an extensible interface, I'd say go for it nevertheless.

---

v1 -> v2:

- rename KVM_ONE_REG to KVM_REG
- change semantics to include size in constant
and a user pointer to write/read to/from
- update documentation respectively

---
 Documentation/virtual/kvm/api.txt |   40 +++++++++++++++++++++++++++++
 arch/powerpc/kvm/powerpc.c        |   51 +++++++++++++++++++++++++++++++++++++
 include/linux/kvm.h               |   35 +++++++++++++++++++++++++
 3 files changed, 126 insertions(+), 0 deletions(-)
Documentation/virtual/kvm/api.txt +40 -0
index a4d7b4d..8494214 100644
@@ -1523,6 +1523,46 @@ following algorithm:
 Some guests configure the LINT1 NMI input to cause a panic, aiding in
 debugging.
 
+4.65 KVM_SET_ONE_REG
+
+Capability: KVM_CAP_ONE_REG
+Architectures: all
+Type: vcpu ioctl
+Parameters: struct kvm_one_reg (in)
+Returns: 0 on success, negative value on failure
+
+struct kvm_one_reg {
+       __u64 id;
+       __u64 addr;
+};
+
+Using this ioctl, a single vcpu register can be set to a specific value
+defined by user space with the passed in struct kvm_one_reg, where id
+refers to the register identifier as described below and addr is a pointer
+to a variable with the respective size. There can be architecture agnostic
+and architecture specific registers. Each have their own range of operation
+and their own constants and width. To keep track of the implemented
+registers, find a list below:
+
+  Arch  |       Register        | Width (bits)
+        |                       |
+
+4.66 KVM_GET_ONE_REG
+
+Capability: KVM_CAP_ONE_REG
+Architectures: all
+Type: vcpu ioctl
+Parameters: struct kvm_one_reg (in and out)
+Returns: 0 on success, negative value on failure
+
+This ioctl allows to receive the value of a single register implemented
+in a vcpu. The register to read is indicated by the "id" field of the
+kvm_one_reg struct passed in. On success, the register value can be found
+at the memory location pointed to by "addr".
+
+The list of registers accessible using this interface is identical to the
+list in 4.64.
+
 5. The kvm_run structure
 
 Application code obtains a pointer to the kvm_run structure by
arch/powerpc/kvm/powerpc.c +51 -0

69 lines not on this page · raw message

include/linux/kvm.h +35 -0
index 8d40db7..31fce98 100644
@@ -557,6 +557,7 @@ struct kvm_ppc_pvinfo {
 #define KVM_CAP_MAX_VCPUS 66       /* returns max vcpus per vm */
 #define KVM_CAP_PPC_PAPR 68
 #define KVM_CAP_SW_TLB 69
+#define KVM_CAP_ONE_REG 70
 #define KVM_CAP_S390_GMAP 71
 #define KVM_CAP_TSC_DEADLINE_TIMER 72
 
@@ -653,6 +654,37 @@ struct kvm_dirty_tlb {
 	__u32 num_dirty;
 };
 
+/* Available with KVM_CAP_ONE_REG */
+
+#define KVM_REG_ARCH_MASK	0xff00000000000000ULL
+#define KVM_REG_GENERIC		0x0000000000000000ULL
+
+/*
+ * Architecture specific registers are to be defined in arch headers and
+ * ORed with the arch identifier.
+ */
+#define KVM_REG_PPC		0x1000000000000000ULL
+#define KVM_REG_X86		0x2000000000000000ULL
+#define KVM_REG_IA64		0x3000000000000000ULL
+#define KVM_REG_ARM		0x4000000000000000ULL
+#define KVM_REG_S390		0x5000000000000000ULL
+
+#define KVM_REG_SIZE_SHIFT	52
+#define KVM_REG_SIZE_MASK	0x00f0000000000000ULL
+#define KVM_REG_SIZE_U8		0x0000000000000000ULL
+#define KVM_REG_SIZE_U16	0x0010000000000000ULL
+#define KVM_REG_SIZE_U32	0x0020000000000000ULL
+#define KVM_REG_SIZE_U64	0x0030000000000000ULL
+#define KVM_REG_SIZE_U128	0x0040000000000000ULL
+#define KVM_REG_SIZE_U256	0x0050000000000000ULL
+#define KVM_REG_SIZE_U512	0x0060000000000000ULL
+#define KVM_REG_SIZE_U1024	0x0070000000000000ULL
+
+struct kvm_one_reg {
+	__u64 id;
+	__u64 addr;
+};
+
 /*
  * ioctls for VM fds
  */
@@ -781,6 +813,9 @@ struct kvm_dirty_tlb {
 #define KVM_ALLOCATE_RMA	  _IOR(KVMIO,  0xa9, struct kvm_allocate_rma)
 /* Available with KVM_CAP_SW_TLB */
 #define KVM_DIRTY_TLB		  _IOW(KVMIO,  0xaa, struct kvm_dirty_tlb)
+/* Available with KVM_CAP_ONE_REG */
+#define KVM_GET_ONE_REG		  _IOWR(KVMIO, 0xab, struct kvm_one_reg)
+#define KVM_SET_ONE_REG		  _IOW(KVMIO,  0xac, struct kvm_one_reg)
 
 #define KVM_DEV_ASSIGN_ENABLE_IOMMU	(1 << 0)
 
Signature · 1 line
1.6.0.2
#15 lore raw

PATCH 3/3 KVM: PPC: Move kvm_vcpu_ioctl_[gs]et_one_reg down to platform-specific code

In reply to Alexander Graf

From: Paul Mackerras <[email protected]>

This moves the get/set_one_reg implementation down from powerpc.c into booke.c, book3s_pr.c and book3s_hv.c. This avoids #ifdefs in C code, but more importantly, it fixes a bug on Book3s HV where we were accessing beyond the end of the kvm_vcpu struct (via the to_book3s() macro) and corrupting memory, causing random crashes and file corruption.

On Book3s HV we only accept setting the HIOR to zero, since the guest runs in supervisor mode and its vectors are never offset from zero.

[agraf update to apply on top of changed ONE_REG patches]
---
 arch/powerpc/include/asm/kvm_ppc.h |    3 ++
 arch/powerpc/kvm/book3s_hv.c       |   36 ++++++++++++++++++++++++++++++++++
 arch/powerpc/kvm/book3s_pr.c       |   32 ++++++++++++++++++++++++++++++
 arch/powerpc/kvm/booke.c           |   10 +++++++++
 arch/powerpc/kvm/powerpc.c         |   38 ------------------------------------
 5 files changed, 81 insertions(+), 38 deletions(-)
arch/powerpc/include/asm/kvm_ppc.h +3 -0
index fb70414..a61b5b5 100644
@@ -176,6 +176,9 @@ int kvmppc_core_set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);
 void kvmppc_get_sregs_ivor(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);
 int kvmppc_set_sregs_ivor(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);
 
+int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg);
+int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg);
+
 void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 pid);
 
 #ifdef CONFIG_KVM_BOOK3S_64_HV
arch/powerpc/kvm/book3s_hv.c +36 -0
index fdc804c..3580db8 100644
@@ -398,6 +398,42 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
 	return 0;
 }
 
+int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
+{
+	int r = -EINVAL;
+
+	switch (reg->id) {
+	case KVM_REG_PPC_HIOR:
+		r = put_user(0, (u64 __user *)reg->addr);
+		break;
+	default:
+		break;
+	}
+
+	return r;
+}
+
+int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
+{
+	int r = -EINVAL;
+
+	switch (reg->id) {
+	case KVM_REG_PPC_HIOR:
+	{
+		u64 hior;
+		/* Only allow this to be set to zero */
+		r = get_user(hior, (u64 __user *)reg->addr);
+		if (!r && (hior != 0))
+			r = -EINVAL;
+		break;
+	}
+	default:
+		break;
+	}
+
+	return r;
+}
+
 int kvmppc_core_check_processor_compat(void)
 {
 	if (cpu_has_feature(CPU_FTR_HVMODE))
arch/powerpc/kvm/book3s_pr.c +32 -0
index 00efda6..ee222ec 100644
@@ -874,6 +874,38 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
 	return 0;
 }
 
+int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
+{
+	int r = -EINVAL;
+
+	switch (reg->id) {
+	case KVM_REG_PPC_HIOR:
+		r = put_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr);
+		break;
+	default:
+		break;
+	}
+
+	return r;
+}
+
+int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
+{
+	int r = -EINVAL;
+
+	switch (reg->id) {
+	case KVM_REG_PPC_HIOR:
+		r = get_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr);
+		if (!r)
+			to_book3s(vcpu)->hior_explicit = true;
+		break;
+	default:
+		break;
+	}
+
+	return r;
+}
+
 int kvmppc_core_check_processor_compat(void)
 {
 	return 0;
arch/powerpc/kvm/booke.c +10 -0
index 9e41f45..ee9e1ee 100644
@@ -887,6 +887,16 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
 	return kvmppc_core_set_sregs(vcpu, sregs);
 }
 
+int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
+{
+	return -EINVAL;
+}
+
+int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
+{
+	return -EINVAL;
+}
+
 int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
 {
 	return -ENOTSUPP;
arch/powerpc/kvm/powerpc.c +0 -38
index 4223c6f..64c738d 100644
@@ -644,44 +644,6 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
 	return r;
 }
 
-static int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu,
-				      struct kvm_one_reg *reg)
-{
-	int r = -EINVAL;
-
-	switch (reg->id) {
-#ifdef CONFIG_PPC_BOOK3S
-	case KVM_REG_PPC_HIOR:
-		r = put_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr);
-		break;
-#endif
-	default:
-		break;
-	}
-
-	return r;
-}
-
-static int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu,
-				      struct kvm_one_reg *reg)
-{
-	int r = -EINVAL;
-
-	switch (reg->id) {
-#ifdef CONFIG_PPC_BOOK3S
-	case KVM_ONE_REG_PPC_HIOR:
-		r = get_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr);
-		if (!r)
-			to_book3s(vcpu)->hior_explicit = true;
-		break;
-#endif
-	default:
-		break;
-	}
-
-	return r;
-}
-
 int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
                                     struct kvm_mp_state *mp_state)
 {
Signature · 1 line
1.6.0.2
#3 lore raw

PATCH 1/1 KVM: PPC: Add generic single register ioctls

In reply to Alexander Graf

Right now we transfer a static struct every time we want to get or set registers. Unfortunately, over time we realize that there are more of these than we thought of before and the extensibility and flexibility of transferring a full struct every time is limited.

So this is a new approach to the problem. With these new ioctls, we can get and set a single register that is identified by an ID. This allows for very precise and limited transmittal of data. When we later realize that it's a better idea to shove over multiple registers at once, we can reuse most of the infrastructure and simply implement a GET_MANY_REGS / SET_MANY_REGS interface.

The only downpoint I see to this one is that it needs to pad to 1024 bits (hardware is already on 512 bit registers, so I wanted to leave some room) which is slightly too much for transmitting only 64 bits. But if that's all the tradeoff we have to do for getting an extensible interface, I'd say go for it nevertheless.

---

v1 -> v2:

- rename KVM_ONE_REG to KVM_REG
- change semantics to include size in constant
and a user pointer to write/read to/from
- update documentation respectively

v2 -> v3:

- make GET_ONE_REG ioctl write-only

Documentation/virtual/kvm/api.txt +40 -0
index a4d7b4d..8494214 100644
@@ -1523,6 +1523,46 @@ following algorithm:
 Some guests configure the LINT1 NMI input to cause a panic, aiding in
 debugging.
 
+4.65 KVM_SET_ONE_REG
+
+Capability: KVM_CAP_ONE_REG
+Architectures: all
+Type: vcpu ioctl
+Parameters: struct kvm_one_reg (in)
+Returns: 0 on success, negative value on failure
+
+struct kvm_one_reg {
+       __u64 id;
+       __u64 addr;
+};
+
+Using this ioctl, a single vcpu register can be set to a specific value
+defined by user space with the passed in struct kvm_one_reg, where id
+refers to the register identifier as described below and addr is a pointer
+to a variable with the respective size. There can be architecture agnostic
+and architecture specific registers. Each have their own range of operation
+and their own constants and width. To keep track of the implemented
+registers, find a list below:
+
+  Arch  |       Register        | Width (bits)
+        |                       |
+
+4.66 KVM_GET_ONE_REG
+
+Capability: KVM_CAP_ONE_REG
+Architectures: all
+Type: vcpu ioctl
+Parameters: struct kvm_one_reg (in and out)
+Returns: 0 on success, negative value on failure
+
+This ioctl allows to receive the value of a single register implemented
+in a vcpu. The register to read is indicated by the "id" field of the
+kvm_one_reg struct passed in. On success, the register value can be found
+at the memory location pointed to by "addr".
+
+The list of registers accessible using this interface is identical to the
+list in 4.64.
+
 5. The kvm_run structure
 
 Application code obtains a pointer to the kvm_run structure by
arch/powerpc/kvm/powerpc.c +41 -0

59 lines not on this page · raw message

include/linux/kvm.h +35 -0
index 8d40db7..4b63ec1 100644
@@ -557,6 +557,7 @@ struct kvm_ppc_pvinfo {
 #define KVM_CAP_MAX_VCPUS 66       /* returns max vcpus per vm */
 #define KVM_CAP_PPC_PAPR 68
 #define KVM_CAP_SW_TLB 69
+#define KVM_CAP_ONE_REG 70
 #define KVM_CAP_S390_GMAP 71
 #define KVM_CAP_TSC_DEADLINE_TIMER 72
 
@@ -653,6 +654,37 @@ struct kvm_dirty_tlb {
 	__u32 num_dirty;
 };
 
+/* Available with KVM_CAP_ONE_REG */
+
+#define KVM_REG_ARCH_MASK	0xff00000000000000ULL
+#define KVM_REG_GENERIC		0x0000000000000000ULL
+
+/*
+ * Architecture specific registers are to be defined in arch headers and
+ * ORed with the arch identifier.
+ */
+#define KVM_REG_PPC		0x1000000000000000ULL
+#define KVM_REG_X86		0x2000000000000000ULL
+#define KVM_REG_IA64		0x3000000000000000ULL
+#define KVM_REG_ARM		0x4000000000000000ULL
+#define KVM_REG_S390		0x5000000000000000ULL
+
+#define KVM_REG_SIZE_SHIFT	52
+#define KVM_REG_SIZE_MASK	0x00f0000000000000ULL
+#define KVM_REG_SIZE_U8		0x0000000000000000ULL
+#define KVM_REG_SIZE_U16	0x0010000000000000ULL
+#define KVM_REG_SIZE_U32	0x0020000000000000ULL
+#define KVM_REG_SIZE_U64	0x0030000000000000ULL
+#define KVM_REG_SIZE_U128	0x0040000000000000ULL
+#define KVM_REG_SIZE_U256	0x0050000000000000ULL
+#define KVM_REG_SIZE_U512	0x0060000000000000ULL
+#define KVM_REG_SIZE_U1024	0x0070000000000000ULL
+
+struct kvm_one_reg {
+	__u64 id;
+	__u64 addr;
+};
+
 /*
  * ioctls for VM fds
  */
@@ -781,6 +813,9 @@ struct kvm_dirty_tlb {
 #define KVM_ALLOCATE_RMA	  _IOR(KVMIO,  0xa9, struct kvm_allocate_rma)
 /* Available with KVM_CAP_SW_TLB */
 #define KVM_DIRTY_TLB		  _IOW(KVMIO,  0xaa, struct kvm_dirty_tlb)
+/* Available with KVM_CAP_ONE_REG */
+#define KVM_GET_ONE_REG		  _IOW(KVMIO,  0xab, struct kvm_one_reg)
+#define KVM_SET_ONE_REG		  _IOW(KVMIO,  0xac, struct kvm_one_reg)
 
 #define KVM_DEV_ASSIGN_ENABLE_IOMMU	(1 << 0)
 
#11 lore raw

Re: [PATCH 2/3] KVM: PPC: Add support for explicit HIOR setting

In reply to Alexander Graf

arch/powerpc/include/asm/kvm.h struct kvm_book3e_206_tlb_params { · line 330

Quoted 9 lines · Alexander Graf
arch/powerpc/include/asm/kvm.h +1 -0
index 25964ee..7e9e24d 100644
@@ -327,4 +327,6 @@ struct kvm_book3e_206_tlb_params {
 	__u32 reserved[8];
 };
 
+#define KVM_REG_PPC_HIOR	KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x1

Parentheses around macro definition

-Scott

#4 lore raw

Re: [PATCH] KVM: PPC: Add generic single register ioctls

In reply to Alexander Graf
Quoted 12 lines · Alexander Graf

Right now we transfer a static struct every time we want to get or set registers. Unfortunately, over time we realize that there are more of these than we thought of before and the extensibility and flexibility of transferring a full struct every time is limited.

So this is a new approach to the problem. With these new ioctls, we can get and set a single register that is identified by an ID. This allows for very precise and limited transmittal of data. When we later realize that it's a better idea to shove over multiple registers at once, we can reuse most of the infrastructure and simply implement a GET_MANY_REGS / SET_MANY_REGS interface.

Quoted 5 lines

The only downpoint I see to this one is that it needs to pad to 1024 bits (hardware is already on 512 bit registers, so I wanted to leave some room) which is slightly too much for transmitting only 64 bits. But if that's all the tradeoff we have to do for getting an extensible interface, I'd say go for it nevertheless.

The comment about padding is no longer relevant.

Quoted 10 lines
include/linux/kvm.h +10 -0
+/*
+ * Architecture specific registers are to be defined in arch headers and
+ * ORed with the arch identifier.
+ */
+#define KVM_REG_PPC		0x1000000000000000ULL
+#define KVM_REG_X86		0x2000000000000000ULL
+#define KVM_REG_IA64		0x3000000000000000ULL
+#define KVM_REG_ARM		0x4000000000000000ULL
+#define KVM_REG_S390		0x5000000000000000ULL
+

include/linux/kvm.h struct kvm_dirty_tlb { · line 681

Quoted 10 lines
include/linux/kvm.h +10 -0
+#define KVM_REG_SIZE_SHIFT	52
+#define KVM_REG_SIZE_MASK	0x00f0000000000000ULL
+#define KVM_REG_SIZE_U8		0x0000000000000000ULL
+#define KVM_REG_SIZE_U16	0x0010000000000000ULL
+#define KVM_REG_SIZE_U32	0x0020000000000000ULL
+#define KVM_REG_SIZE_U64	0x0030000000000000ULL
+#define KVM_REG_SIZE_U128	0x0040000000000000ULL
+#define KVM_REG_SIZE_U256	0x0050000000000000ULL
+#define KVM_REG_SIZE_U512	0x0060000000000000ULL
+#define KVM_REG_SIZE_U1024	0x0070000000000000ULL

Why not just encode directly as number of bytes?

-Scott

#5 lore raw

Re: [PATCH] KVM: PPC: Add generic single register ioctls

Quoted 35 lines · Scott Wood
Quoted 12 lines · Alexander Graf

Right now we transfer a static struct every time we want to get or set registers. Unfortunately, over time we realize that there are more of these than we thought of before and the extensibility and flexibility of transferring a full struct every time is limited.

So this is a new approach to the problem. With these new ioctls, we can get and set a single register that is identified by an ID. This allows for very precise and limited transmittal of data. When we later realize that it's a better idea to shove over multiple registers at once, we can reuse most of the infrastructure and simply implement a GET_MANY_REGS / SET_MANY_REGS interface.

Quoted 5 lines

The only downpoint I see to this one is that it needs to pad to 1024 bits (hardware is already on 512 bit registers, so I wanted to leave some room) which is slightly too much for transmitting only 64 bits. But if that's all the tradeoff we have to do for getting an extensible interface, I'd say go for it nevertheless.

The comment about padding is no longer relevant.

Quoted 14 lines
include/linux/kvm.h +14 -0
+/*
+ * Architecture specific registers are to be defined in arch headers and
+ * ORed with the arch identifier.
+ */
+#define KVM_REG_PPC        0x1000000000000000ULL
+#define KVM_REG_X86        0x2000000000000000ULL
+#define KVM_REG_IA64        0x3000000000000000ULL
+#define KVM_REG_ARM        0x4000000000000000ULL
+#define KVM_REG_S390        0x5000000000000000ULL
+
+#define KVM_REG_SIZE_SHIFT    52
+#define KVM_REG_SIZE_MASK    0x00f0000000000000ULL
+#define KVM_REG_SIZE_U8        0x0000000000000000ULL
+#define KVM_REG_SIZE_U16    0x0010000000000000ULL
Quoted 8 lines

include/linux/kvm.h struct kvm_dirty_tlb { · line 681

Quoted 6 lines
include/linux/kvm.h +6 -0
+#define KVM_REG_SIZE_U32    0x0020000000000000ULL
+#define KVM_REG_SIZE_U64    0x0030000000000000ULL
+#define KVM_REG_SIZE_U128    0x0040000000000000ULL
+#define KVM_REG_SIZE_U256    0x0050000000000000ULL
+#define KVM_REG_SIZE_U512    0x0060000000000000ULL
+#define KVM_REG_SIZE_U1024    0x0070000000000000ULL

Why not just encode directly as number of bytes?

Because this is 1 << n bytes :)

Alex

Quoted 3 lines

-Scott

#6 lore raw

Re: [PATCH] KVM: PPC: Add generic single register ioctls

Quoted 29 lines · Alexander Graf
Quoted 16 lines · Scott Wood
Quoted 14 lines · Alexander Graf
include/linux/kvm.h +14 -0
+/*
+ * Architecture specific registers are to be defined in arch headers and
+ * ORed with the arch identifier.
+ */
+#define KVM_REG_PPC        0x1000000000000000ULL
+#define KVM_REG_X86        0x2000000000000000ULL
+#define KVM_REG_IA64        0x3000000000000000ULL
+#define KVM_REG_ARM        0x4000000000000000ULL
+#define KVM_REG_S390        0x5000000000000000ULL
+
+#define KVM_REG_SIZE_SHIFT    52
+#define KVM_REG_SIZE_MASK    0x00f0000000000000ULL
+#define KVM_REG_SIZE_U8        0x0000000000000000ULL
+#define KVM_REG_SIZE_U16    0x0010000000000000ULL
Quoted 8 lines

include/linux/kvm.h struct kvm_dirty_tlb { · line 681

Quoted 6 lines
include/linux/kvm.h +6 -0
+#define KVM_REG_SIZE_U32    0x0020000000000000ULL
+#define KVM_REG_SIZE_U64    0x0030000000000000ULL
+#define KVM_REG_SIZE_U128    0x0040000000000000ULL
+#define KVM_REG_SIZE_U256    0x0050000000000000ULL
+#define KVM_REG_SIZE_U512    0x0060000000000000ULL
+#define KVM_REG_SIZE_U1024    0x0070000000000000ULL

Why not just encode directly as number of bytes?

Quoted 1 line

Because this is 1 << n bytes :)

Some registers may not be a power-of-2 number of bytes (e.g. x86 segment descriptors), and we've got plenty of space to spare in the id.

It's probably not worth another respin, though -- we can just document right/left justification in the event that we have such a register.

-Scott

#7 lore raw

Re: [PATCH] KVM: PPC: Add generic single register ioctls

Am 09.01.2012 um 20:07 schrieb Scott Wood <[email protected]>:

Quoted 30 lines · Alexander Graf
Quoted 29 lines · Scott Wood
Quoted 25 lines · Alexander Graf
Quoted 11 lines
include/linux/kvm.h +10 -0
+/*
+ * Architecture specific registers are to be defined in arch headers and
+ * ORed with the arch identifier.
+ */
+#define KVM_REG_PPC        0x1000000000000000ULL
+#define KVM_REG_X86        0x2000000000000000ULL
+#define KVM_REG_IA64        0x3000000000000000ULL
+#define KVM_REG_ARM        0x4000000000000000ULL
+#define KVM_REG_S390        0x5000000000000000ULL
+

include/linux/kvm.h struct kvm_dirty_tlb { · line 681

Quoted 10 lines
include/linux/kvm.h +10 -0
+#define KVM_REG_SIZE_SHIFT    52
+#define KVM_REG_SIZE_MASK    0x00f0000000000000ULL
+#define KVM_REG_SIZE_U8        0x0000000000000000ULL
+#define KVM_REG_SIZE_U16    0x0010000000000000ULL
+#define KVM_REG_SIZE_U32    0x0020000000000000ULL
+#define KVM_REG_SIZE_U64    0x0030000000000000ULL
+#define KVM_REG_SIZE_U128    0x0040000000000000ULL
+#define KVM_REG_SIZE_U256    0x0050000000000000ULL
+#define KVM_REG_SIZE_U512    0x0060000000000000ULL
+#define KVM_REG_SIZE_U1024    0x0070000000000000ULL

Why not just encode directly as number of bytes?

Quoted 4 lines
Quoted 1 line

Because this is 1 << n bytes :)

Some registers may not be a power-of-2 number of bytes (e.g. x86 segment descriptors), and we've got plenty of space to spare in the id.

If they're not a power of 2, we can still bmp it to the next power of 2 size, no?

Alex

Quoted 6 lines

It's probably not worth another respin, though -- we can just document right/left justification in the event that we have such a register.

-Scott

#8 lore raw

Re: [PATCH] KVM: PPC: Add generic single register ioctls

Quoted 34 lines · Alexander Graf

Am 09.01.2012 um 20:07 schrieb Scott Wood <[email protected]>:

Quoted 30 lines · Alexander Graf
Quoted 29 lines · Scott Wood
Quoted 25 lines · Alexander Graf
Quoted 11 lines
include/linux/kvm.h +10 -0
+/*
+ * Architecture specific registers are to be defined in arch headers and
+ * ORed with the arch identifier.
+ */
+#define KVM_REG_PPC        0x1000000000000000ULL
+#define KVM_REG_X86        0x2000000000000000ULL
+#define KVM_REG_IA64        0x3000000000000000ULL
+#define KVM_REG_ARM        0x4000000000000000ULL
+#define KVM_REG_S390        0x5000000000000000ULL
+

include/linux/kvm.h struct kvm_dirty_tlb { · line 681

Quoted 10 lines
include/linux/kvm.h +10 -0
+#define KVM_REG_SIZE_SHIFT    52
+#define KVM_REG_SIZE_MASK    0x00f0000000000000ULL
+#define KVM_REG_SIZE_U8        0x0000000000000000ULL
+#define KVM_REG_SIZE_U16    0x0010000000000000ULL
+#define KVM_REG_SIZE_U32    0x0020000000000000ULL
+#define KVM_REG_SIZE_U64    0x0030000000000000ULL
+#define KVM_REG_SIZE_U128    0x0040000000000000ULL
+#define KVM_REG_SIZE_U256    0x0050000000000000ULL
+#define KVM_REG_SIZE_U512    0x0060000000000000ULL
+#define KVM_REG_SIZE_U1024    0x0070000000000000ULL

Why not just encode directly as number of bytes?

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Because this is 1 << n bytes :)

Some registers may not be a power-of-2 number of bytes (e.g. x86 segment descriptors), and we've got plenty of space to spare in the id.

If they're not a power of 2, we can still bmp it to the next power of 2 size, no?

Yes, that's what I meant by it not being a huge deal and documenting whether the padding is on the right or the left. Just seems a little more awkward than necessary, given that we have room to encode it as a plain linear size.

-Scott

#9 lore raw

Re: [PATCH] KVM: PPC: Add generic single register ioctls

Am 09.01.2012 um 21:12 schrieb Scott Wood <[email protected]>:

Quoted 40 lines · Alexander Graf
Quoted 39 lines

Am 09.01.2012 um 20:07 schrieb Scott Wood <[email protected]>:

Quoted 34 lines · Alexander Graf
Quoted 29 lines · Scott Wood
Quoted 17 lines · Alexander Graf
Quoted 15 lines
include/linux/kvm.h +14 -0
+/*
+ * Architecture specific registers are to be defined in arch headers and
+ * ORed with the arch identifier.
+ */
+#define KVM_REG_PPC        0x1000000000000000ULL
+#define KVM_REG_X86        0x2000000000000000ULL
+#define KVM_REG_IA64        0x3000000000000000ULL
+#define KVM_REG_ARM        0x4000000000000000ULL
+#define KVM_REG_S390        0x5000000000000000ULL
+
+#define KVM_REG_SIZE_SHIFT    52
+#define KVM_REG_SIZE_MASK    0x00f0000000000000ULL
+#define KVM_REG_SIZE_U8        0x0000000000000000ULL
+#define KVM_REG_SIZE_U16    0x0010000000000000ULL
Quoted 8 lines

include/linux/kvm.h struct kvm_dirty_tlb { · line 681

Quoted 6 lines
include/linux/kvm.h +6 -0
+#define KVM_REG_SIZE_U32    0x0020000000000000ULL
+#define KVM_REG_SIZE_U64    0x0030000000000000ULL
+#define KVM_REG_SIZE_U128    0x0040000000000000ULL
+#define KVM_REG_SIZE_U256    0x0050000000000000ULL
+#define KVM_REG_SIZE_U512    0x0060000000000000ULL
+#define KVM_REG_SIZE_U1024    0x0070000000000000ULL

Why not just encode directly as number of bytes?

Quoted 1 line

Because this is 1 << n bytes :)

Some registers may not be a power-of-2 number of bytes (e.g. x86 segment descriptors), and we've got plenty of space to spare in the id.

Quoted 6 lines
Quoted 1 line

If they're not a power of 2, we can still bmp it to the next power of 2 size, no?

Yes, that's what I meant by it not being a huge deal and documenting whether the padding is on the right or the left. Just seems a little more awkward than necessary, given that we have room to encode it as a plain linear size.

Well I thought it makes things easier, since variable types are usually in a power of 2 :). But I'm certainly not attached to it.

Alex

Quoted 3 lines

-Scott

#12 lore raw

Re: [PATCH 2/3] KVM: PPC: Add support for explicit HIOR setting

In reply to Alexander Graf

arch/powerpc/kvm/powerpc.c static int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, · line 673

Quoted 7 lines · Alexander Graf
arch/powerpc/kvm/powerpc.c +3 -0
@@ -662,6 +668,13 @@ static int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu,
 	int r = -EINVAL;
 
 	switch (reg->id) {
+#ifdef CONFIG_PPC_BOOK3S
+	case KVM_ONE_REG_PPC_HIOR:
+		r = get_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr);

That doesn't build on ppc32, get_user cannot handle 64 bit values. You need to use __get_user64 instead.

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#13 lore raw

Re: [PATCH 2/3] KVM: PPC: Add support for explicit HIOR setting

Quoted 5 lines · Andreas Schwab
Quoted 3 lines · Alexander Graf
(quoted diff) +0 -0
@@ -662,6 +668,13 @@ static int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu,
 	int r = -EINVAL;
 
Quoted 7 lines

Review static int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, · line 673

Quoted 4 lines
(quoted diff) +3 -0
 	switch (reg->id) {
+#ifdef CONFIG_PPC_BOOK3S
+	case KVM_ONE_REG_PPC_HIOR:
+		r = get_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr);

That doesn't build on ppc32, get_user cannot handle 64 bit values. You need to use __get_user64 instead.

Yeah :(. I already have this patch in my tree to fix that:

commit 3c82a50bb07455b2f0663ebc12fffdb647f737d2

Author: Alexander Graf <[email protected]>
Date:   Tue Mar 13 19:59:39 2012 +0100

KVM: PPC: Book3S: Compile fix for ppc32 in HIOR

On PPC32 we can not use get_user/put_user for 64bit wide variables, as there is no single instruction that could load or store variables that big.

So instead, we have to use copy_from/to_user which works everywhere.

arch/powerpc/kvm/book3s_pr.c +4 -4
index 1717ac8..e2be5ad 100644
@@ -881,8 +881,8 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
 
        switch (reg->id) {
        case KVM_REG_PPC_HIOR:
-               r = put_user(to_book3s(vcpu)->hior,
-                            (u64 __user *)(long)reg->addr);
+               r = copy_to_user((u64 __user *)(long)reg->addr,
+                               &to_book3s(vcpu)->hior, sizeof(u64));
                break;
        default:
                break;
@@ -897,8 +897,8 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
 
        switch (reg->id) {
        case KVM_REG_PPC_HIOR:
-               r = get_user(to_book3s(vcpu)->hior,
-                            (u64 __user *)(long)reg->addr);
+               r = copy_from_user(&to_book3s(vcpu)->hior,
+                                  (u64 __user *)(long)reg->addr, sizeof(u64));
                if (!r)
                        to_book3s(vcpu)->hior_explicit = true;
                break;
#14 lore raw

Re: [PATCH 2/3] KVM: PPC: Add support for explicit HIOR setting

Quoted 2 lines · Alexander Graf

Yeah :(. I already have this patch in my tree to fix that:

...

arch/powerpc/kvm/book3s_pr.c int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) · line 885

Quoted 5 lines

case KVM_REG_PPC_HIOR:

arch/powerpc/kvm/book3s_pr.c +2 -2
-               r = put_user(to_book3s(vcpu)->hior,
-                            (u64 __user *)(long)reg->addr);
+               r = copy_to_user((u64 __user *)(long)reg->addr,
+                               &to_book3s(vcpu)->hior, sizeof(u64));

I folded this in with your other patch that touches these lines and sent it to Avi, and it is in Linus' tree as b8e6f8ae51.

Paul.