All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2
@ 2008-12-16 15:45 Jes Sorensen
  2008-12-17  1:41 ` Zhang, Xiantao
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Jes Sorensen @ 2008-12-16 15:45 UTC (permalink / raw)
  To: kvm-ia64

[-- Attachment #1: Type: text/plain, Size: 641 bytes --]

Avi Kivity wrote:
> This makes several tons of sense, but breaks backwards compatibility.  
> If I understand correctly, get/set was never used so this shouldn't matter?
> 
> I suggest reserving some space at the end of kvm_regs in case further 
> state needs to be added.
> 
> Please add a KVM_CAP_ entry to advertise the fixup.  This way userspace 
> can determine that it's compiling or running on an old kernel and error 
> out gracefully.

Hi Avi,

Here's an update version of this patch, which leaves some space for
future extensions in struct kvm_regs. The KVM_CAP is unnecessary as
GET/SET_REGS never worked on ia64.

Cheers,
Jes




[-- Attachment #2: 6000-kvm-ia64-get-regs-locking.patch --]
[-- Type: text/plain, Size: 3471 bytes --]

Fix kvm_arch_vcpu_ioctl_[gs]et_regs() to do something meaningful on
ia64. Old versions could never have worked since they required
pointers to be set in the ioctl payload which were never being set by
the ioctl handler for get_regs.

In addition reserve extra space for future extensions.

The change of layout of struct kvm_regs doesn't require adding a new
CAP since get/set regs never worked on ia64 until now. 

This version doesn't support copying the KVM kernel stack in/out of
the kernel. This should be implemented in a seperate ioctl call if
ever needed.

Signed-off-by: Jes Sorensen <jes@sgi.com>

---
 arch/ia64/include/asm/kvm.h |    6 ++++--
 arch/ia64/kvm/kvm-ia64.c    |   40 ++++++++++------------------------------
 2 files changed, 14 insertions(+), 32 deletions(-)

Index: linux-2.6.git/arch/ia64/include/asm/kvm.h
===================================================================
--- linux-2.6.git.orig/arch/ia64/include/asm/kvm.h
+++ linux-2.6.git/arch/ia64/include/asm/kvm.h
@@ -199,8 +199,6 @@
 };
 
 struct kvm_regs {
-	char *saved_guest;
-	char *saved_stack;
 	struct saved_vpd vpd;
 	/*Arch-regs*/
 	int mp_state;
@@ -233,6 +231,10 @@
 	unsigned long fp_psr;       /*used for lazy float register */
 	unsigned long saved_gp;
 	/*for phycial  emulation */
+
+	unsigned long reserved[64];	/* for future use */
+
+	union context saved_guest;
 };
 
 struct kvm_sregs {
Index: linux-2.6.git/arch/ia64/kvm/kvm-ia64.c
===================================================================
--- linux-2.6.git.orig/arch/ia64/kvm/kvm-ia64.c
+++ linux-2.6.git/arch/ia64/kvm/kvm-ia64.c
@@ -867,9 +867,8 @@
 
 int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
 {
-	int i;
 	struct vpd *vpd = to_host(vcpu->kvm, vcpu->arch.vpd);
-	int r;
+	int i;
 
 	vcpu_load(vcpu);
 
@@ -886,18 +885,7 @@
 
 	vpd->vpr = regs->vpd.vpr;
 
-	r = -EFAULT;
-	r = copy_from_user(&vcpu->arch.guest, regs->saved_guest,
-						sizeof(union context));
-	if (r)
-		goto out;
-	r = copy_from_user(vcpu + 1, regs->saved_stack +
-			sizeof(struct kvm_vcpu),
-			KVM_STK_OFFSET - sizeof(struct kvm_vcpu));
-	if (r)
-		goto out;
-	vcpu->arch.exit_data =
-		((struct kvm_vcpu *)(regs->saved_stack))->arch.exit_data;
+	memcpy(&vcpu->arch.guest, &regs->saved_guest, sizeof(union context));
 
 	RESTORE_REGS(mp_state);
 	RESTORE_REGS(vmm_rr);
@@ -931,9 +919,8 @@
 	set_bit(KVM_REQ_RESUME, &vcpu->requests);
 
 	vcpu_put(vcpu);
-	r = 0;
-out:
-	return r;
+
+	return 0;
 }
 
 long kvm_arch_vm_ioctl(struct file *filp,
@@ -1418,9 +1405,9 @@
 
 int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
 {
-	int i;
-	int r;
 	struct vpd *vpd = to_host(vcpu->kvm, vcpu->arch.vpd);
+	int i;
+
 	vcpu_load(vcpu);
 
 	for (i = 0; i < 16; i++) {
@@ -1435,14 +1422,8 @@
 	regs->vpd.vpsr = vpd->vpsr;
 	regs->vpd.vpr = vpd->vpr;
 
-	r = -EFAULT;
-	r = copy_to_user(regs->saved_guest, &vcpu->arch.guest,
-					sizeof(union context));
-	if (r)
-		goto out;
-	r = copy_to_user(regs->saved_stack, (void *)vcpu, KVM_STK_OFFSET);
-	if (r)
-		goto out;
+	memcpy(&regs->saved_guest, &vcpu->arch.guest, sizeof(union context));
+
 	SAVE_REGS(mp_state);
 	SAVE_REGS(vmm_rr);
 	memcpy(regs->itrs, vcpu->arch.itrs, sizeof(struct thash_data) * NITRS);
@@ -1470,10 +1451,9 @@
 	SAVE_REGS(metaphysical_saved_rr4);
 	SAVE_REGS(fp_psr);
 	SAVE_REGS(saved_gp);
+
 	vcpu_put(vcpu);
-	r = 0;
-out:
-	return r;
+	return 0;
 }
 
 void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)

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

* RE: [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2
  2008-12-16 15:45 [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2 Jes Sorensen
@ 2008-12-17  1:41 ` Zhang, Xiantao
  2008-12-17  1:41 ` Zhang, Xiantao
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Zhang, Xiantao @ 2008-12-17  1:41 UTC (permalink / raw)
  To: kvm-ia64

Jes Sorensen wrote:
> Avi Kivity wrote:
>> This makes several tons of sense, but breaks backwards compatibility.
>> If I understand correctly, get/set was never used so this shouldn't
>> matter? 
>> 
>> I suggest reserving some space at the end of kvm_regs in case
>> further state needs to be added. 
>> 
>> Please add a KVM_CAP_ entry to advertise the fixup.  This way
>> userspace can determine that it's compiling or running on an old
>> kernel and error out gracefully.
> 
> Hi Avi,
> 
> Here's an update version of this patch, which leaves some space for
> future extensions in struct kvm_regs. The KVM_CAP is unnecessary as
> GET/SET_REGS never worked on ia64.

Avi,
    Please help to queue it for 2.6.28 merge. We will push changes in userland for live migration , and 2.6.29 should be ready for live migration. 
Xiantao

Acked-by : Xiantao Zhang <xiantao.zhang@intel.com>


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

* RE: [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2
  2008-12-16 15:45 [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2 Jes Sorensen
  2008-12-17  1:41 ` Zhang, Xiantao
@ 2008-12-17  1:41 ` Zhang, Xiantao
  2008-12-17 10:32 ` Avi Kivity
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Zhang, Xiantao @ 2008-12-17  1:41 UTC (permalink / raw)
  To: kvm-ia64

Jes Sorensen wrote:
> Avi Kivity wrote:
>> This makes several tons of sense, but breaks backwards compatibility.
>> If I understand correctly, get/set was never used so this shouldn't
>> matter? 
>> 
>> I suggest reserving some space at the end of kvm_regs in case
>> further state needs to be added. 
>> 
>> Please add a KVM_CAP_ entry to advertise the fixup.  This way
>> userspace can determine that it's compiling or running on an old
>> kernel and error out gracefully.
> 
> Hi Avi,
> 
> Here's an update version of this patch, which leaves some space for
> future extensions in struct kvm_regs. The KVM_CAP is unnecessary as
> GET/SET_REGS never worked on ia64.

Thanks, Jes! 
Xiantao

Acked-by : Xiantao Zhang <xiantao.zhang@intel.com>


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

* Re: [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2
  2008-12-16 15:45 [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2 Jes Sorensen
  2008-12-17  1:41 ` Zhang, Xiantao
  2008-12-17  1:41 ` Zhang, Xiantao
@ 2008-12-17 10:32 ` Avi Kivity
  2008-12-17 10:32 ` Avi Kivity
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Avi Kivity @ 2008-12-17 10:32 UTC (permalink / raw)
  To: kvm-ia64

Jes Sorensen wrote:
>
> Here's an update version of this patch, which leaves some space for
> future extensions in struct kvm_regs. The KVM_CAP is unnecessary as
> GET/SET_REGS never worked on ia64.
>

Applied, thanks.  I moved the reserved bits to the end to be more 
traditional.

-- 
error compiling committee.c: too many arguments to function


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

* Re: [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2
  2008-12-16 15:45 [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2 Jes Sorensen
                   ` (2 preceding siblings ...)
  2008-12-17 10:32 ` Avi Kivity
@ 2008-12-17 10:32 ` Avi Kivity
  2008-12-18  9:13 ` Jes Sorensen
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Avi Kivity @ 2008-12-17 10:32 UTC (permalink / raw)
  To: kvm-ia64

Zhang, Xiantao wrote:
>     Please help to queue it for 2.6.28 merge. We will push changes in userland for live migration , and 2.6.29 should be ready for live migration. 
> Xiantao
>
>   

Since it doesn't fix a regression, I'll queue it for 2.6.29.

-- 
error compiling committee.c: too many arguments to function


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

* Re: [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2
  2008-12-16 15:45 [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2 Jes Sorensen
                   ` (3 preceding siblings ...)
  2008-12-17 10:32 ` Avi Kivity
@ 2008-12-18  9:13 ` Jes Sorensen
  2008-12-18 10:11 ` Avi Kivity
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jes Sorensen @ 2008-12-18  9:13 UTC (permalink / raw)
  To: kvm-ia64

Avi Kivity wrote:
> Jes Sorensen wrote:
>>
>> Here's an update version of this patch, which leaves some space for
>> future extensions in struct kvm_regs. The KVM_CAP is unnecessary as
>> GET/SET_REGS never worked on ia64.
>>
> 
> Applied, thanks.  I moved the reserved bits to the end to be more 
> traditional.

Hi Avi,

Please don't do that, then they'll end up after a 16KB struct, I put
them where they were deliberately.

Cheers,
Jes

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

* Re: [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2
  2008-12-16 15:45 [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2 Jes Sorensen
                   ` (4 preceding siblings ...)
  2008-12-18  9:13 ` Jes Sorensen
@ 2008-12-18 10:11 ` Avi Kivity
  2008-12-18 10:26 ` Jes Sorensen
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Avi Kivity @ 2008-12-18 10:11 UTC (permalink / raw)
  To: kvm-ia64

Jes Sorensen wrote:
>
> Please don't do that, then they'll end up after a 16KB struct, I put
> them where they were deliberately.
>

Why does it matter?  I don't see any performance issue, we copy 
everything anyway, and this is not a high usage interface.

-- 
error compiling committee.c: too many arguments to function


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

* Re: [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2
  2008-12-16 15:45 [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2 Jes Sorensen
                   ` (5 preceding siblings ...)
  2008-12-18 10:11 ` Avi Kivity
@ 2008-12-18 10:26 ` Jes Sorensen
  2008-12-18 11:19 ` Avi Kivity
  2008-12-18 11:21 ` Jes Sorensen
  8 siblings, 0 replies; 10+ messages in thread
From: Jes Sorensen @ 2008-12-18 10:26 UTC (permalink / raw)
  To: kvm-ia64

Avi Kivity wrote:
> Jes Sorensen wrote:
>>
>> Please don't do that, then they'll end up after a 16KB struct, I put
>> them where they were deliberately.
> Why does it matter?  I don't see any performance issue, we copy 
> everything anyway, and this is not a high usage interface.

Well it just makes the generated code uglier.

Jes




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

* Re: [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2
  2008-12-16 15:45 [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2 Jes Sorensen
                   ` (6 preceding siblings ...)
  2008-12-18 10:26 ` Jes Sorensen
@ 2008-12-18 11:19 ` Avi Kivity
  2008-12-18 11:21 ` Jes Sorensen
  8 siblings, 0 replies; 10+ messages in thread
From: Avi Kivity @ 2008-12-18 11:19 UTC (permalink / raw)
  To: kvm-ia64

Jes Sorensen wrote:
> Avi Kivity wrote:
>> Jes Sorensen wrote:
>>>
>>> Please don't do that, then they'll end up after a 16KB struct, I put
>>> them where they were deliberately.
>> Why does it matter?  I don't see any performance issue, we copy 
>> everything anyway, and this is not a high usage interface.
>
> Well it just makes the generated code uglier.
>

Who cares?

-- 
error compiling committee.c: too many arguments to function


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

* Re: [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2
  2008-12-16 15:45 [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2 Jes Sorensen
                   ` (7 preceding siblings ...)
  2008-12-18 11:19 ` Avi Kivity
@ 2008-12-18 11:21 ` Jes Sorensen
  8 siblings, 0 replies; 10+ messages in thread
From: Jes Sorensen @ 2008-12-18 11:21 UTC (permalink / raw)
  To: kvm-ia64

Avi Kivity wrote:
> Jes Sorensen wrote:
>>>> Please don't do that, then they'll end up after a 16KB struct, I put
>>>> them where they were deliberately.
>>> Why does it matter?  I don't see any performance issue, we copy 
>>> everything anyway, and this is not a high usage interface.
>>
>> Well it just makes the generated code uglier.
> 
> Who cares?

Me :-)

Anyway, ignore it, just leave it as it is.

Cheers,
Jes

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

end of thread, other threads:[~2008-12-18 11:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-16 15:45 [patch] fix kvm_arch_vcpu_ioctl_[gs]et_regs() - v2 Jes Sorensen
2008-12-17  1:41 ` Zhang, Xiantao
2008-12-17  1:41 ` Zhang, Xiantao
2008-12-17 10:32 ` Avi Kivity
2008-12-17 10:32 ` Avi Kivity
2008-12-18  9:13 ` Jes Sorensen
2008-12-18 10:11 ` Avi Kivity
2008-12-18 10:26 ` Jes Sorensen
2008-12-18 11:19 ` Avi Kivity
2008-12-18 11:21 ` Jes Sorensen

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.