All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC] [PATCH] kvm: arm: Introduce error code KVM_EINVARIANT
@ 2018-10-23 10:21 mjaggi
  2018-11-10 22:18   ` Manish Jaggi
  0 siblings, 1 reply; 13+ messages in thread
From: mjaggi @ 2018-10-23 10:21 UTC (permalink / raw)
  To: Jaggi, Manish, quintela, dgilbert, eric.auger, qemu-devel,
	peter.maydell, Nair, Jayachandran, Nowicki, Tomasz

From: Manish Jaggi <manish.jaggi@cavium.com>

This patch introduces an error code KVM_EINVARIANT which is returned
by KVM when userland tries to set an invariant register.

The need for this error code is in VM Migration for arm64.
ARM64 systems use mainly -machine virt -cpu host as parameter to qemu.
Migration requires both Source and destination machines to have same
physical cpu. There are cases where the overall architecture of CPU is
same but the next version of the chip with some bug fixes which have no
effect on qemu operation. In such cases invariant registers like MIDR
have a different value.
Currently Migration fails in such cases.

Rather than sending a EINVAL, a specifc error code will help
userland program the guest invariant register by querying the migrated
host machines invariant registers.

Qemu will have a parameter -hostinvariant along with checking of this
error code. So it can be safely assumed that the feature is opt-in

Corresponding Qemu patcset can be found at :
https://lists.gnu.org/archive/html/qemu-devel/2018-10/msg05048.html


Signed-off-by: Manish Jaggi <manish.jaggi@cavium.com>
---
 arch/arm64/kvm/sys_regs.c     | 9 ++++-----
 include/uapi/linux/kvm_para.h | 1 +
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index 22fbbdb..78ffc02 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -1111,7 +1111,7 @@ static int __set_id_reg(const struct sys_reg_desc *rd, void __user *uaddr,
 
 	/* This is what we mean by invariant: you can't change it. */
 	if (val != read_id_reg(rd, raz))
-		return -EINVAL;
+		return -KVM_EINVARIANT;
 
 	return 0;
 }
@@ -2254,9 +2254,8 @@ static int set_invariant_sys_reg(u64 id, void __user *uaddr)
 		return err;
 
 	/* This is what we mean by invariant: you can't change it. */
-	if (r->val != val)
-		return -EINVAL;
-
+	if (r->val != val)	
+		return -KVM_EINVARIANT;
 	return 0;
 }
 
@@ -2335,7 +2334,7 @@ static int demux_c15_set(u64 id, void __user *uaddr)
 
 		/* This is also invariant: you can't change it. */
 		if (newval != get_ccsidr(val))
-			return -EINVAL;
+			return -KVM_EINVARIANT;
 		return 0;
 	default:
 		return -ENOENT;
diff --git a/include/uapi/linux/kvm_para.h b/include/uapi/linux/kvm_para.h
index 6c0ce49..4358669 100644
--- a/include/uapi/linux/kvm_para.h
+++ b/include/uapi/linux/kvm_para.h
@@ -17,6 +17,7 @@
 #define KVM_E2BIG		E2BIG
 #define KVM_EPERM		EPERM
 #define KVM_EOPNOTSUPP		95
+#define KVM_EINVARIANT          96
 
 #define KVM_HC_VAPIC_POLL_IRQ		1
 #define KVM_HC_MMU_OP			2
-- 
1.8.3.1

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

end of thread, other threads:[~2018-11-12 10:09 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-23 10:21 [Qemu-devel] [RFC] [PATCH] kvm: arm: Introduce error code KVM_EINVARIANT mjaggi
2018-11-10 22:18 ` Manish Jaggi
2018-11-10 22:18   ` Manish Jaggi
2018-11-10 22:18   ` Manish Jaggi
2018-11-11 11:36   ` [Qemu-devel] " Marc Zyngier
2018-11-11 11:36     ` Marc Zyngier
2018-11-11 11:36     ` Marc Zyngier
2018-11-12 10:09     ` [Qemu-devel] " Andrew Jones
2018-11-12 10:09       ` Andrew Jones
2018-11-12 10:09       ` Andrew Jones
2018-11-12  9:06   ` Christoffer Dall
2018-11-12  9:06     ` Christoffer Dall
2018-11-12  9:06     ` Christoffer Dall

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.